From: Christoph M. Becker Date: Sat, 11 Jul 2020 13:41:15 +0000 (+0200) Subject: Export php_gd_libgdimageptr_from_zval_p() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=340e2ead7719266bd54ec16f1740d5b862cf11f8;p=php 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()`. --- diff --git a/UPGRADING b/UPGRADING index 63a30d4ab4..e45cb23fbf 100644 --- a/UPGRADING +++ b/UPGRADING @@ -888,6 +888,9 @@ PHP 8.0 UPGRADE NOTES shell now consistently execute `%comspec% /s /c "$commandline"`, which has the same effect as executing `$commandline` (without additional quotes). +- GD: + . php_gd2.dll has been renamed to php_gd.dll. + - php-test-pack: . The test runner has been renamed from run-test.php to run-tests.php, to match its name in php-src. diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 index 8fe44def2b..541d5f51e0 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 \ @@ -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 5996579e3f..eb35655f33 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) +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 ffb6f60b75..3873467276 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 @@ -77,6 +81,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 diff --git a/php.ini-development b/php.ini-development index 4acfa89a19..5471728ce0 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 2fdcdc0e5d..08fc755738 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 2f2c01e47d..e71757748f 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");