Skip to content

Commit 340e2ea

Browse files
committed
Export php_gd_libgdimageptr_from_zval_p()
Some extension may need to retrieve the `gdImagePtr` from an `GdImage` object; thus, we export the respective function. To not being forced to include gd.h in php_gd.h, we use the opaque `struct gdImageStruct *` as return type. We also rename php_gd2.dll to php_gd.dll, since there's not really much point in giving the DLL a version number, since there is no php_gd.dll for years (if there ever has been). Renaming, on the other hand, matches the name on other systems (gd.so), and allows to actually use `ADD_EXTENSION_DEP()`.
1 parent d5a0370 commit 340e2ea

File tree

7 files changed

+15
-8
lines changed

7 files changed

+15
-8
lines changed

UPGRADING

+3
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,9 @@ PHP 8.0 UPGRADE NOTES
888888
shell now consistently execute `%comspec% /s /c "$commandline"`, which has
889889
the same effect as executing `$commandline` (without additional quotes).
890890

891+
- GD:
892+
. php_gd2.dll has been renamed to php_gd.dll.
893+
891894
- php-test-pack:
892895
. The test runner has been renamed from run-test.php to run-tests.php, to
893896
match its name in php-src.

ext/gd/config.w32

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (PHP_GD != "no") {
3333
CHECK_LIB("User32.lib", "gd", PHP_GD);
3434
CHECK_LIB("Gdi32.lib", "gd", PHP_GD);
3535

36-
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd", "php_gd2.dll");
36+
EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd");
3737
ADD_SOURCES("ext/gd/libgd", "gd2copypal.c gd.c \
3838
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
3939
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
@@ -43,6 +43,7 @@ if (PHP_GD != "no") {
4343
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
4444
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
4545
ADD_FLAG("CFLAGS_GD", " \
46+
/D PHP_GD_EXPORTS=1 \
4647
/D HAVE_GD_DYNAMIC_CTX_EX=1 \
4748
/D HAVE_GD_BUNDLED=1 \
4849
/D HAVE_GD_GD2 \

ext/gd/gd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static zend_always_inline php_gd_image_object* php_gd_exgdimage_from_zobj_p(zend
178178
* Converts an extension GdImage instance contained within a zval into the gdImagePtr
179179
* for use with library APIs
180180
*/
181-
static zend_always_inline gdImagePtr php_gd_libgdimageptr_from_zval_p(zval* zp)
181+
PHP_GD_API gdImagePtr php_gd_libgdimageptr_from_zval_p(zval* zp)
182182
{
183183
return php_gd_exgdimage_from_zobj_p(Z_OBJ_P(zp))->image;
184184
}

ext/gd/php_gd.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
#define PHP_IMG_TGA 128
5252

5353
#ifdef PHP_WIN32
54-
# define PHP_GD_API __declspec(dllexport)
54+
# ifdef PHP_GD_EXPORTS
55+
# define PHP_GD_API __declspec(dllexport)
56+
# else
57+
# define PHP_GD_API __declspec(dllimport)
58+
# endif
5559
#elif defined(__GNUC__) && __GNUC__ >= 4
5660
# define PHP_GD_API __attribute__ ((visibility("default")))
5761
#else
@@ -77,6 +81,8 @@ PHP_MINIT_FUNCTION(gd);
7781
PHP_MSHUTDOWN_FUNCTION(gd);
7882
PHP_RSHUTDOWN_FUNCTION(gd);
7983

84+
PHP_GD_API struct gdImageStruct *php_gd_libgdimageptr_from_zval_p(zval* zp);
85+
8086
#else
8187

8288
#define phpext_gd_ptr NULL

php.ini-development

+1-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ default_socket_timeout = 60
901901
;extension=ffi
902902
;extension=ftp
903903
;extension=fileinfo
904-
;extension=gd2
904+
;extension=gd
905905
;extension=gettext
906906
;extension=gmp
907907
;extension=intl

php.ini-production

+1-1
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ default_socket_timeout = 60
903903
;extension=ffi
904904
;extension=ftp
905905
;extension=fileinfo
906-
;extension=gd2
906+
;extension=gd
907907
;extension=gettext
908908
;extension=gmp
909909
;extension=intl

win32/build/confutils.js

-3
Original file line numberDiff line numberDiff line change
@@ -2026,9 +2026,6 @@ function generate_tmp_php_ini()
20262026
var directive = (extensions_enabled[i][2] ? 'zend_extension' : 'extension');
20272027

20282028
var ext_name = extensions_enabled[i][0];
2029-
if ("gd" == ext_name) {
2030-
ext_name = "gd2";
2031-
}
20322029

20332030
if (!is_on_exclude_list_for_test_ini(ext_list, ext_name)) {
20342031
INI.WriteLine(directive + "=php_" + ext_name + ".dll");

0 commit comments

Comments
 (0)