svn: /pecl/newt/trunk/ newt.c php_newt.h

From: Date: Sun, 13 Oct 2013 17:13:01 +0000
Subject: svn: /pecl/newt/trunk/ newt.c php_newt.h
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-19874@lists.php.net to get a copy of this message
remi Sun, 13 Oct 2013 17:13:01 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=331801 Log: switch to new globals management, fix segfault in ZTS shutdown Changed paths: U pecl/newt/trunk/newt.c U pecl/newt/trunk/php_newt.h Modified: pecl/newt/trunk/newt.c =================================================================== --- pecl/newt/trunk/newt.c 2013-10-13 16:10:23 UTC (rev 331800) +++ pecl/newt/trunk/newt.c 2013-10-13 17:13:01 UTC (rev 331801) @@ -249,6 +249,13 @@ }; /* }}} */ +ZEND_DECLARE_MODULE_GLOBALS (newt) +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) +/* This "if" allows PECL builds from this file to be portable to older PHP releases */ +static PHP_GINIT_FUNCTION(newt); +static PHP_GSHUTDOWN_FUNCTION(newt); +#endif + /* {{{ newt_module_entry */ zend_module_entry newt_module_entry = { @@ -261,19 +268,33 @@ NULL, PHP_MINFO(newt), PHP_NEWT_VERSION, +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) + /* This check allows PECL builds from this file to be portable to older PHP releases */ + PHP_MODULE_GLOBALS(newt), + PHP_GINIT(newt), + PHP_GSHUTDOWN(newt), + NULL, + STANDARD_MODULE_PROPERTIES_EX +#else STANDARD_MODULE_PROPERTIES +#endif }; /* }}} */ -ZEND_DECLARE_MODULE_GLOBALS (newt) - #ifdef COMPILE_DL_NEWT ZEND_GET_MODULE(newt) #endif -/* {{{ php_newt_init_globals +/* {{{ PHP_GINIT_FUNCTION + * + * Zerofill globals during module init */ +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) +/* This check allows PECL builds from this file to be portable to older PHP releases */ +static PHP_GINIT_FUNCTION(newt) +#else static void php_newt_init_globals (zend_newt_globals *newt_globals TSRMLS_DC) +#endif { newt_globals->newt_has_inited = 0; @@ -282,9 +303,16 @@ } /* }}} */ -/* {{{ php_newt_destroy_globals +/* {{{ PHP_GSHUTDOWN_FUNCTION + * + * Called for thread shutdown in ZTS, after module shutdown for non-ZTS */ +/* This check allows PECL builds from this file to be portable to older PHP releases */ +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) +static PHP_GSHUTDOWN_FUNCTION(newt) +#else static void php_newt_destroy_globals(zend_newt_globals *newt_globals TSRMLS_DC) +#endif { if (newt_globals->newt_has_inited) { newtFinished(); @@ -295,6 +323,7 @@ } /* }}} */ + /* {{{ php_newt_free_cb */ void php_newt_free_cb (php_newt_cb **cb_ptr) @@ -397,7 +426,12 @@ le_newt_comp = zend_register_list_destructors_ex(NULL, NULL, le_newt_comp_name, module_number); le_newt_grid = zend_register_list_destructors_ex(NULL, NULL, le_newt_grid_name, module_number); +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) + /* This check allows PECL builds from this file to be portable to older PHP releases */ + /* this is handled by new globals management code */ +#else ZEND_INIT_MODULE_GLOBALS (newt, php_newt_init_globals, php_newt_destroy_globals); +#endif /* Colorsets */ REGISTER_NEWT_CONSTANT(NEWT_COLORSET_ROOT); @@ -548,9 +582,12 @@ */ PHP_MSHUTDOWN_FUNCTION(newt) { +/* Work around PHP_GSHUTDOWN_FUNCTION not being called in older versions of PHP */ +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2) || (PHP_MAJOR_VERSION < 5) #ifndef ZTS php_newt_destroy_globals (&newt_globals TSRMLS_CC); #endif +#endif return SUCCESS; } Modified: pecl/newt/trunk/php_newt.h =================================================================== --- pecl/newt/trunk/php_newt.h 2013-10-13 16:10:23 UTC (rev 331800) +++ pecl/newt/trunk/php_newt.h 2013-10-13 17:13:01 UTC (rev 331801) @@ -232,8 +232,6 @@ static void newt_suspend_callback_wrapper (void *cb_key); static void newt_help_callback_wrapper (newtComponent form, char *help); -static void php_newt_init_globals (zend_newt_globals *newt_globals TSRMLS_DC); -static void php_newt_destroy_globals(zend_newt_globals *newt_globals TSRMLS_DC); void php_newt_free_cb (php_newt_cb **cb_ptr); int php_newt_fetch_resource (zval *rsrc, void *data, int le_type);

« previous php.pecl.cvs (#19874) next »