MUTEX_T cwd_mutex;
#endif
-ZEND_DECLARE_MODULE_GLOBALS(cwd);
+#ifdef ZTS
+static ts_rsrc_id cwd_globals_id;
+#else
+static virtual_cwd_globals cwd_globals;
+#endif
cwd_state main_cwd_state; /* True global */
return (1);
}
-static void cwd_globals_ctor(zend_cwd_globals *cwd_globals)
+static void cwd_globals_ctor(virtual_cwd_globals *cwd_globals)
{
CWD_STATE_COPY(&cwd_globals->cwd, &main_cwd_state);
}
-static void cwd_globals_dtor(zend_cwd_globals *cwd_globals)
+static void cwd_globals_dtor(virtual_cwd_globals *cwd_globals)
{
CWD_STATE_FREE(&cwd_globals->cwd);
}
main_cwd_state.cwd = strdup(cwd);
main_cwd_state.cwd_length = strlen(cwd);
- ZEND_INIT_MODULE_GLOBALS(cwd, cwd_globals_ctor, cwd_globals_dtor);
+#ifdef ZTS
+ cwd_globals_id = ts_allocate_id(sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor);
+#else
+ cwd_globals_ctor(&cwd_globals);
+#endif
+
#if defined(ZEND_WIN32) && defined(ZTS)
cwd_mutex = tsrm_mutex_alloc();
#endif
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path);
-ZEND_BEGIN_MODULE_GLOBALS(cwd)
+typedef struct _virtual_cwd_globals {
cwd_state cwd;
-ZEND_END_MODULE_GLOBALS(cwd)
+} virtual_cwd_globals;
#ifdef ZTS
-# define CWDLS_D zend_cwd_globals *cwd_globals
+# define CWDLS_D virtual_cwd_globals *cwd_globals
# define CWDLS_DC , CWDLS_D
# define CWDLS_C cwd_globals
# define CWDLS_CC , CWDLS_C
# define CWDG(v) (cwd_globals->v)
-# define CWDLS_FETCH() zend_cwd_globals *cwd_globals = ts_resource(cwd_globals_id)
+# define CWDLS_FETCH() virtual_cwd_globals *cwd_globals = ts_resource(cwd_globals_id)
#else
# define CWDLS_D void
# define CWDLS_DC