FAQ
I am going to commit the same patch into PHP_5_2 on this week.

Dmitry.
-----Original Message-----
From: Dmitry Stogov
Sent: Tuesday, June 13, 2006 5:12 PM
To: zend-engine-cvs@lists.php.net
Subject: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c
zend_API.h zend_modules.h php-src NEWS


dmitry Tue Jun 13 13:11:43 2006 UTC

Modified files:
/php-src NEWS
/ZendEngine2 zend_API.c zend_API.h zend_modules.h
Log:
Added automatic module globals management.


http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2118&r2=1.211
9&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2118 php-src/NEWS:1.2119
--- php-src/NEWS:1.2118 Tue Jun 6 20:08:58 2006
+++ php-src/NEWS Tue Jun 13 13:11:42 2006
@@ -33,6 +33,7 @@
. Added curl_setopt_array() which allows setting of
multiple cURL options.
. Added CURLINFO_HEADER_OUT constant to facilitate request
retrieval.

+- Added automatic module globals management. (Dmitry)
- Added "jump label" operator (limited "goto"). (Dmitry, Sara)
- Added E_STRICT to E_ALL. (Dmitry)
- Added gmp_nextprime() function. (Tony, patch by ants dot
aasma at gmail dot com)
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_API.c?r1=1.370
&r2=1.371&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.370 ZendEngine2/zend_API.c:1.371
--- ZendEngine2/zend_API.c:1.370 Wed Jun 7 09:20:02 2006
+++ ZendEngine2/zend_API.c Tue Jun 13 13:11:42 2006
@@ -18,7 +18,7 @@

+-------------------------------------------------------------
---------+
*/

-/* $Id: zend_API.c,v 1.370 2006/06/07 09:20:02 helly Exp $ */
+/* $Id: zend_API.c,v 1.371 2006/06/13 13:11:42 dmitry Exp $ */

#include "zend.h"
#include "zend_execute.h"
@@ -1873,6 +1873,17 @@
}
}

+ /* Initialize module globals */
+ if (module->globals_size) {
+#ifdef ZTS
+ ts_allocate_id(module->globals_id_ptr,
module->globals_size,
+(ts_allocate_ctor) module->globals_ctor, (ts_allocate_dtor)
module->globals_dtor); #else
+ if (module->globals_ctor) {
+
module->globals_ctor(module->globals_ptr TSRMLS_CC);
+ }
+#endif
+ }
+
if (module->module_startup_func) {
EG(current_module) = module;
if (module->module_startup_func(module->type,
module->module_number TSRMLS_CC)==FAILURE) { @@ -2323,6
+2334,19 @@ #endif
module->module_shutdown_func(module->type,
module->module_number TSRMLS_CC);
}
+
+
+ /* Deinitilaise module globals */
+ if (module->globals_size) {
+#ifdef ZTS
+ ts_free_id(*module->globals_id_ptr);
+#else
+ if (module->globals_dtor) {
+
module->globals_dtor(module->globals_ptr TSRMLS_CC);
+ }
+#endif
+ }
+
module->module_started=0;
if (module->functions) {
zend_unregister_functions(module->functions,
-1, NULL TSRMLS_CC);
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_API.h?r1=1.246
&r2=1.247&diff_format=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.246 ZendEngine2/zend_API.h:1.247
--- ZendEngine2/zend_API.h:1.246 Sat May 27 19:40:06 2006
+++ ZendEngine2/zend_API.h Tue Jun 13 13:11:42 2006
@@ -18,7 +18,7 @@

+-------------------------------------------------------------
---------+
*/

-/* $Id: zend_API.h,v 1.246 2006/05/27 19:40:06 helly Exp $ */
+/* $Id: zend_API.h,v 1.247 2006/06/13 13:11:42 dmitry Exp $ */

#ifndef ZEND_API_H
#define ZEND_API_H
@@ -79,6 +79,8 @@
#define ZEND_MODULE_DEACTIVATE_N(module) zm_deactivate_##module
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)
zm_post_zend_deactivate_##module
#define ZEND_MODULE_INFO_N(module) zm_info_##module
+#define ZEND_MODULE_GLOBALS_CTOR_N(module) zm_globals_ctor_##module
+#define ZEND_MODULE_GLOBALS_DTOR_N(module) zm_globals_dtor_##module

/* Declaration macros */
#define ZEND_MODULE_STARTUP_D(module) int
ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS)
@@ -87,6 +89,8 @@
#define ZEND_MODULE_DEACTIVATE_D(module) int
ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS)
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) int
ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void)
#define ZEND_MODULE_INFO_D(module) void
ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
+#define ZEND_MODULE_GLOBALS_CTOR_D(module) void
+ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals
+*module##_globals TSRMLS_DC) #define
ZEND_MODULE_GLOBALS_DTOR_D(module)
+void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals
+*module##_globals TSRMLS_DC)

#define ZEND_GET_MODULE(name) \
BEGIN_EXTERN_C()\
@@ -1034,12 +1038,16 @@
#define ZEND_RINIT ZEND_MODULE_ACTIVATE_N
#define ZEND_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
#define ZEND_MINFO ZEND_MODULE_INFO_N
+#define ZEND_GINIT(module) ((void (*)(void*
TSRMLS_DC))(ZEND_MODULE_GLOBALS_CTOR_N(module)))
+#define ZEND_GSHUTDOWN(module) ((void (*)(void*
TSRMLS_DC))(ZEND_MODULE_GLOBALS_DTOR_N(module)))

#define ZEND_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
#define ZEND_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
#define ZEND_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
#define ZEND_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
#define ZEND_MINFO_FUNCTION ZEND_MODULE_INFO_D
+#define ZEND_GINIT_FUNCTION
ZEND_MODULE_GLOBALS_CTOR_D
+#define ZEND_GSHUTDOWN_FUNCTION
ZEND_MODULE_GLOBALS_DTOR_D

END_EXTERN_C()

http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_modules.h?r1=1
.72&r2=1.73&diff_format=u
Index: ZendEngine2/zend_modules.h
diff -u ZendEngine2/zend_modules.h:1.72
ZendEngine2/zend_modules.h:1.73
--- ZendEngine2/zend_modules.h:1.72 Thu Apr 6 21:16:28 2006
+++ ZendEngine2/zend_modules.h Tue Jun 13 13:11:42 2006
@@ -17,7 +17,7 @@

+-------------------------------------------------------------
---------+
*/

-/* $Id: zend_modules.h,v 1.72 2006/04/06 21:16:28 andrei Exp $ */
+/* $Id: zend_modules.h,v 1.73 2006/06/13 13:11:42 dmitry Exp $ */

#ifndef MODULES_H
#define MODULES_H
@@ -39,7 +39,7 @@
extern struct _zend_arg_info fifth_arg_force_ref[6];
extern struct _zend_arg_info all_args_by_ref[1];

-#define ZEND_MODULE_API_NO 20050922
+#define ZEND_MODULE_API_NO 20060613
#ifdef ZTS
#define USING_ZTS 1
#else
@@ -52,10 +52,18 @@
#define ZE2_STANDARD_MODULE_HEADER \
STANDARD_MODULE_HEADER_EX, ini_entries, NULL

-#define STANDARD_MODULE_PROPERTIES_EX 0, 0, 0, NULL, 0
+#define STANDARD_MODULE_PROPERTIES_EX 0, 0, NULL, 0
+
+#define NO_MODULE_GLOBASLS 0, NULL, NULL, NULL
+
+#ifdef ZTS
+# define ZEND_MODULE_GLOBALS(module_name)
+sizeof(zend_##module_name##_globals),
&module_name##_globals_id #else #
+define ZEND_MODULE_GLOBALS(module_name)
+sizeof(zend_##module_name##_globals), &module_name##_globals #endif

#define STANDARD_MODULE_PROPERTIES \
- NULL, STANDARD_MODULE_PROPERTIES_EX
+ NO_MODULE_GLOBASLS, NULL, STANDARD_MODULE_PROPERTIES_EX

#define NO_VERSION_YET NULL

@@ -81,8 +89,15 @@
int (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS);
void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS);
char *version;
+ size_t globals_size;
+#ifdef ZTS
+ ts_rsrc_id* globals_id_ptr;
+#else
+ void* globals_ptr;
+#endif
+ void (*globals_ctor)(void *global TSRMLS_DC);
+ void (*globals_dtor)(void *global TSRMLS_DC);
int (*post_deactivate_func)(void);
- int globals_id;
int module_started;
unsigned char type;
void *handle;

--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJun 13, '06 at 1:27p
activeJun 13, '06 at 1:27p
posts1
users1
websitephp.net

1 user in discussion

Dmitry Stogov: 1 post

People

Translate

site design / logo © 2022 Grokbase