]> granicus.if.org Git - php/commitdiff
Generalize some common thread-safety stuff
authorZeev Suraski <zeev@php.net>
Sat, 1 Apr 2000 14:15:20 +0000 (14:15 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 1 Apr 2000 14:15:20 +0000 (14:15 +0000)
Zend/zend_API.h

index 5a9e744df29411537a0c3ff9fde3fbc13d50dd6b..2e44c2acbe6e3666d48a14e61c2b950d0530eac5 100644 (file)
 #define ZEND_GINIT_FUNCTION(module)      int ZEND_GINIT(module)(GINIT_FUNC_ARGS)
 #define ZEND_GSHUTDOWN_FUNCTION(module)  int ZEND_GSHUTDOWN(module)(void)
 
+
+#define ZEND_BEGIN_MODULE_GLOBALS(module_name)         \
+       typedef struct _zend_##module_name##_globals {
+#define ZEND_END_MODULE_GLOBALS(module_name)           \
+       } zend_##module_name##_globals;
+
+#ifdef ZTS
+
+#define ZEND_DECLARE_MODULE_GLOBALS(module_name)                                                       \
+       static ts_rsrc_id module_name##_globals_id;
+#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)      \
+       module_name##_globals_id = ts_allocate_id(sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
+
+#else
+
+#define ZEND_DECLARE_MODULE_GLOBALS(module_name)                                                       \
+       static zend_##module_name##_globals module_name##_globals;
+#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)      \
+       globals_ctor(&module_name##_globals);
+
+#endif
+
+
+
 #define INIT_CLASS_ENTRY(class_container, class_name, functions)       \
        {                                                                                                                               \
                class_container.name = strdup(class_name);                                      \