From 037e8d58f6d9f4bb8cb433757d1fb425ae522a26 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 10 Jul 2020 19:16:09 +0200 Subject: [PATCH 1/3] 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. --- ext/gd/gd.c | 2 +- ext/gd/php_gd.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 7d415137bd3e..1efb917ded39 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -178,7 +178,7 @@ static zend_always_inline php_gd_image_object* php_gd_exgdimage_from_zobj_p(zend * Converts an extension GdImage instance contained within a zval into the gdImagePtr * for use with library APIs */ -static zend_always_inline gdImagePtr php_gd_libgdimageptr_from_zval_p(zval* zp) +inline gdImagePtr php_gd_libgdimageptr_from_zval_p(zval* zp) { return php_gd_exgdimage_from_zobj_p(Z_OBJ_P(zp))->image; } diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h index ffb6f60b755d..a3899f696501 100644 --- a/ext/gd/php_gd.h +++ b/ext/gd/php_gd.h @@ -77,6 +77,8 @@ PHP_MINIT_FUNCTION(gd); PHP_MSHUTDOWN_FUNCTION(gd); PHP_RSHUTDOWN_FUNCTION(gd); +PHP_GD_API struct gdImageStruct *php_gd_libgdimageptr_from_zval_p(zval* zp); + #else #define phpext_gd_ptr NULL From 6103edb2d916d8229b16497af06857e0607296b4 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 11 Jul 2020 14:58:52 +0200 Subject: [PATCH 2/3] Allow to import the function from other DLLs --- ext/gd/config.w32 | 1 + ext/gd/gd.c | 2 +- ext/gd/php_gd.h | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 index 8fe44def2b4f..6a5333b9d77c 100644 --- a/ext/gd/config.w32 +++ b/ext/gd/config.w32 @@ -43,6 +43,7 @@ if (PHP_GD != "no") { gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd"); AC_DEFINE('HAVE_LIBGD', 1, 'GD support'); ADD_FLAG("CFLAGS_GD", " \ +/D PHP_GD_EXPORTS=1 \ /D HAVE_GD_DYNAMIC_CTX_EX=1 \ /D HAVE_GD_BUNDLED=1 \ /D HAVE_GD_GD2 \ diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 1efb917ded39..156f1b541fea 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -178,7 +178,7 @@ static zend_always_inline php_gd_image_object* php_gd_exgdimage_from_zobj_p(zend * Converts an extension GdImage instance contained within a zval into the gdImagePtr * for use with library APIs */ -inline gdImagePtr php_gd_libgdimageptr_from_zval_p(zval* zp) +PHP_GD_API gdImagePtr php_gd_libgdimageptr_from_zval_p(zval* zp) { return php_gd_exgdimage_from_zobj_p(Z_OBJ_P(zp))->image; } diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h index a3899f696501..387346727621 100644 --- a/ext/gd/php_gd.h +++ b/ext/gd/php_gd.h @@ -51,7 +51,11 @@ #define PHP_IMG_TGA 128 #ifdef PHP_WIN32 -# define PHP_GD_API __declspec(dllexport) +# ifdef PHP_GD_EXPORTS +# define PHP_GD_API __declspec(dllexport) +# else +# define PHP_GD_API __declspec(dllimport) +# endif #elif defined(__GNUC__) && __GNUC__ >= 4 # define PHP_GD_API __attribute__ ((visibility("default"))) #else From dbd00e448982ec8b37e2686a402179a99b0a2c90 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 11 Jul 2020 15:41:15 +0200 Subject: [PATCH 3/3] Rename php_gd2.dll to php_gd.dll 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 hand, matches the name on other systems (gd.so), and allows to actually use `ADD_EXTENSION_DEP()`. --- ext/gd/config.w32 | 2 +- php.ini-development | 2 +- php.ini-production | 2 +- win32/build/confutils.js | 3 --- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 index 6a5333b9d77c..541d5f51e0e2 100644 --- a/ext/gd/config.w32 +++ b/ext/gd/config.w32 @@ -33,7 +33,7 @@ if (PHP_GD != "no") { CHECK_LIB("User32.lib", "gd", PHP_GD); CHECK_LIB("Gdi32.lib", "gd", PHP_GD); - EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd", "php_gd2.dll"); + EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd"); ADD_SOURCES("ext/gd/libgd", "gd2copypal.c gd.c \ gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \ 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 \ diff --git a/php.ini-development b/php.ini-development index 4acfa89a197c..5471728ce0bf 100644 --- a/php.ini-development +++ b/php.ini-development @@ -901,7 +901,7 @@ default_socket_timeout = 60 ;extension=ffi ;extension=ftp ;extension=fileinfo -;extension=gd2 +;extension=gd ;extension=gettext ;extension=gmp ;extension=intl diff --git a/php.ini-production b/php.ini-production index 2fdcdc0e5d3d..08fc7557384b 100644 --- a/php.ini-production +++ b/php.ini-production @@ -903,7 +903,7 @@ default_socket_timeout = 60 ;extension=ffi ;extension=ftp ;extension=fileinfo -;extension=gd2 +;extension=gd ;extension=gettext ;extension=gmp ;extension=intl diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 2f2c01e47dc4..e71757748fda 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2026,9 +2026,6 @@ function generate_tmp_php_ini() var directive = (extensions_enabled[i][2] ? 'zend_extension' : 'extension'); var ext_name = extensions_enabled[i][0]; - if ("gd" == ext_name) { - ext_name = "gd2"; - } if (!is_on_exclude_list_for_test_ini(ext_list, ext_name)) { INI.WriteLine(directive + "=php_" + ext_name + ".dll");