Re: zend module patch
| From: | Zeev Suraski | Date: | Wed, 10 Oct 2001 13:52:07 +0000 |
| Subject: | Re: zend module patch | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-67688@lists.php.net to get a copy of this message | ||
The patch looks good. I suggest adding sizeof(zend_module_entry) to be the first element in this structure, so that in the future, we can offer downwards compatibility in the future.
Zeev
At 02:29 10-10-01, Stig S. Bakken wrote:
Stig Sæther Bakken wrote: Hi, A while ago, we discussed being able to give more intelligent error messages when loading extensions compiled with different configurations/API versions. Attached is a patch that changes the zend_module_entry type so the configuration appears first. This way PHP can give more sensible error messages like "I need thread-safe extensions" or "sorry, this extension was built in debug mode". The patch also adds a "version" field to the struct, along with a zend_get_module_version Zend API function and an optional parameter to phpversion() for getting the version of a loaded extension. The downside is that moving zend_module_entry's configuration fields first can't be done in a backwards-compatible way. This patch breaks every extension out there (except ext/standard, which is updated), but it does buy us better BC possibilities in the future. Comments, opinions? - Stig Now where did that attachment go? Sigh, here it is inlined: Index: ext/standard/basic_functions.c =================================================================== RCS file: /repository/php4/ext/standard/basic_functions.c,v retrieving revision 1.404 diff -u -b -B -r1.404 basic_functions.c--- ext/standard/basic_functions.c 5 Oct 2001 23:56:19 -0000 1.404 +++ ext/standard/basic_functions.c 10 Oct 2001 00:02:08 -0000@@ -830,6 +830,7 @@ zend_module_entry basic_functions_module = {+ STANDARD_MODULE_HEADER, "standard", /* extension name */ basic_functions, /* function list */ PHP_MINIT(basic), /* process startup */@@ -837,6 +838,7 @@PHP_RINIT(basic), /* request startup */ PHP_RSHUTDOWN(basic), /* request shutdown */ PHP_MINFO(basic), /* extension info */ + PHP_VERSION, /* extension version */ STANDARD_MODULE_PROPERTIES}; Index: ext/standard/info.c =================================================================== RCS file: /repository/php4/ext/standard/info.c,v retrieving revision 1.158 diff -u -b -B -r1.158 info.c--- ext/standard/info.c 6 Oct 2001 20:13:37 -0000 1.158+++ ext/standard/info.c 10 Oct 2001 00:02:09 -0000 @@ -473,15 +473,26 @@ /* }}} */ -/* {{{ proto string phpversion(void) +/* {{{ proto string phpversion([string extension])Return the current PHP version */PHP_FUNCTION(phpversion) {- if (ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } + zval **arg; + int argc = ZEND_NUM_ARGS();+ if (argc == 0) { RETURN_STRING(PHP_VERSION, 1); + } else if (argc == 1 && zend_get_parameters_ex(1, &arg) == SUCCESS) { + char *version; + convert_to_string_ex(arg); + version = zend_get_module_version(Z_STRVAL_PP(arg)); + if (version == NULL) { + RETURN_FALSE; + } + RETURN_STRING(version, 1); + } else { + WRONG_PARAM_COUNT; + }} /* }}} */ Index: Zend/zend_API.c =================================================================== RCS file: /repository/Zend/zend_API.c,v retrieving revision 1.100 diff -u -b -B -r1.100 zend_API.c--- Zend/zend_API.c 2001/08/24 03:18:44 1.100 +++ Zend/zend_API.c 2001/10/10 00:02:15@@ -1385,3 +1385,14 @@return retval;} + +ZEND_API char *zend_get_module_version(char *module_name) +{+ zend_module_entry *module;++ if (zend_hash_find(&module_registry, module_name, strlen(module_name)+ 1,+ (void**)&module) == FAILURE) { + return NULL; + } + return module->version;+} Index: Zend/zend_API.h =================================================================== RCS file: /repository/Zend/zend_API.h,v retrieving revision 1.107 diff -u -b -B -r1.107 zend_API.h--- Zend/zend_API.h 2001/08/12 14:50:14 1.107 +++ Zend/zend_API.h 2001/10/10 00:02:16@@ -137,6 +137,7 @@ ZEND_API void zend_wrong_param_count(TSRMLS_D); ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name); +ZEND_API char *zend_get_module_version(char *module_name); #define getThis() (this_ptr) Index: Zend/zend_modules.h =================================================================== RCS file: /repository/Zend/zend_modules.h,v retrieving revision 1.40 diff -u -b -B -r1.40 zend_modules.h--- Zend/zend_modules.h 2001/09/01 12:57:50 1.40+++ Zend/zend_modules.h 2001/10/10 00:02:16 @@ -43,8 +43,10 @@ #define USING_ZTS 0 #endif -#define STANDARD_MODULE_PROPERTIES_EX 0, 0, 0, NULL, 0, ZEND_DEBUG, USING_ZTS, ZEND_MODULE_API_NO +#define STANDARD_MODULE_HEADER ZEND_MODULE_API_NO, ZEND_DEBUG, USING_ZTS +#define STANDARD_MODULE_PROPERTIES_EX 0, 0, 0, NULL, 0 + #define STANDARD_MODULE_PROPERTIES \NULL, NULL, STANDARD_MODULE_PROPERTIES_EX@@ -54,6 +56,9 @@ typedef struct _zend_module_entry zend_module_entry; struct _zend_module_entry {+ unsigned int zend_api; + unsigned char zend_debug; + unsigned char zts; char *name; zend_function_entry *functions; int (*module_startup_func)(INIT_FUNC_ARGS);@@ -61,6 +66,7 @@int (*request_startup_func)(INIT_FUNC_ARGS); int (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS); + char *version; int (*global_startup_func)(void); int (*global_shutdown_func)(void); int globals_id;@@ -68,9 +74,6 @@unsigned char type; void *handle; int module_number; - unsigned char zend_debug; - unsigned char zts; - unsigned int zend_api;}; -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net