cvs: php4 /ext/pcre php_pcre.c php_pcre.h
| From: | Andrei Zmievski | Date: | Mon, 30 Jul 2001 15:41:11 +0000 |
| Subject: | cvs: php4 /ext/pcre php_pcre.c php_pcre.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6414@lists.php.net to get a copy of this message | ||
andrei Mon Jul 30 11:41:11 2001 EDT
Modified files:
/php4/ext/pcre php_pcre.c php_pcre.h
Log:
Updated to match TSRM changes.
Index: php4/ext/pcre/php_pcre.c
diff -u php4/ext/pcre/php_pcre.c:1.106 php4/ext/pcre/php_pcre.c:1.107
--- php4/ext/pcre/php_pcre.c:1.106 Mon Jul 30 04:24:32 2001
+++ php4/ext/pcre/php_pcre.c Mon Jul 30 11:41:11 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.c,v 1.106 2001/07/30 08:24:32 zeev Exp $ */
+/* $Id: php_pcre.c,v 1.107 2001/07/30 15:41:11 andrei Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -40,11 +40,8 @@
#define PREG_REPLACE_EVAL (1<<0)
-#ifdef ZTS
-int pcre_globals_id;
-#else
-php_pcre_globals pcre_globals;
-#endif
+
+ZEND_DECLARE_MODULE_GLOBALS(pcre)
static void *php_pcre_malloc(size_t size)
@@ -69,16 +66,15 @@
}
-#ifdef ZTS
-static void php_pcre_init_globals(php_pcre_globals *pcre_globals TSRMLS_DC)
+static void php_pcre_init_globals(zend_pcre_globals *pcre_globals TSRMLS_DC)
{
- zend_hash_init(&PCRE_G(pcre_cache), 0, NULL, php_free_pcre_cache, 1);
+ zend_hash_init(&pcre_globals->pcre_cache, 0, NULL, php_free_pcre_cache, 1);
}
-
-static void php_pcre_shutdown_globals(php_pcre_globals *pcre_globals TSRMLS_DC)
+#ifdef ZTS
+static void php_pcre_shutdown_globals(zend_pcre_globals *pcre_globals TSRMLS_DC)
{
- zend_hash_destroy(&PCRE_G(pcre_cache));
+ zend_hash_destroy(&pcre_globals->pcre_cache);
}
#endif
@@ -96,15 +92,7 @@
/* {{{ PHP_MINIT_FUNCTION(pcre) */
static PHP_MINIT_FUNCTION(pcre)
{
-#ifdef ZTS
- ts_allocate_id(
- &pcre_globals_id,
- sizeof(php_pcre_globals),
- (ts_allocate_ctor) php_pcre_init_globals,
- (ts_allocate_dtor) php_pcre_shutdown_globals);
-#else
- zend_hash_init(&PCRE_G(pcre_cache), 0, NULL, php_free_pcre_cache, 1);
-#endif
+ ZEND_INIT_MODULE_GLOBALS(pcre, php_pcre_init_globals, php_pcre_shutdown_globals);
REGISTER_LONG_CONSTANT("PREG_PATTERN_ORDER", PREG_PATTERN_ORDER, CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PREG_SET_ORDER", PREG_SET_ORDER, CONST_CS | CONST_PERSISTENT);
@@ -117,11 +105,6 @@
/* {{{ PHP_MSHUTDOWN_FUNCTION(pcre) */
static PHP_MSHUTDOWN_FUNCTION(pcre)
{
-#ifndef ZTS
- zend_hash_destroy(&PCRE_G(pcre_cache));
-#else
- ts_free_id(pcre_globals_id);
-#endif
return SUCCESS;
}
/* }}} */
@@ -158,7 +141,7 @@
#endif
pcre_cache_entry *pce;
pcre_cache_entry new_entry;
- PCRE_LS_FETCH();
+ TSRMLS_FETCH();
/* Try to lookup the cached regex entry, and if successful, just pass
back the compiled pattern, otherwise go on and compile it. */
Index: php4/ext/pcre/php_pcre.h
diff -u php4/ext/pcre/php_pcre.h:1.26 php4/ext/pcre/php_pcre.h:1.27
--- php4/ext/pcre/php_pcre.h:1.26 Tue Mar 13 00:24:03 2001
+++ php4/ext/pcre/php_pcre.h Mon Jul 30 11:41:11 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.h,v 1.26 2001/03/13 05:24:03 andrei Exp $ */
+/* $Id: php_pcre.h,v 1.27 2001/07/30 15:41:11 andrei Exp $ */
#ifndef PHP_PCRE_H
#define PHP_PCRE_H
@@ -54,25 +54,14 @@
#endif
} pcre_cache_entry;
-typedef struct {
+ZEND_BEGIN_MODULE_GLOBALS(pcre)
HashTable pcre_cache;
-} php_pcre_globals;
+ZEND_END_MODULE_GLOBALS(pcre)
#ifdef ZTS
-# define PCRE_LS_D php_pcre_globals *pcre_globals
-# define PCRE_LS_DC , PCRE_LS_D
-# define PCRE_LS_C pcre_globals
-# define PCRE_LS_CC , PCRE_LS_C
-# define PCRE_G(v) (pcre_globals->v)
-# define PCRE_LS_FETCH() php_pcre_globals *pcre_globals = ts_resource(pcre_globals_id);
+# define PCRE_G(v) TSRMG(pcre_globals_id, zend_pcre_globals *, v)
#else
-# define PCRE_LS_D
-# define PCRE_LS_DC
-# define PCRE_LS_C
-# define PCRE_LS_CC
# define PCRE_G(v) (pcre_globals.v)
-# define PCRE_LS_FETCH()
-extern ZEND_API php_pcre_globals pcre_globals;
#endif
#else