From 54c73d1ccb93e334ec0694536a6294a0814e237c Mon Sep 17 00:00:00 2001 From: Harald Radi Date: Thu, 30 Jan 2003 03:15:52 +0000 Subject: [PATCH] fix non-zts build for wez --- Zend/zend_ts_hash.c | 19 ++++++++++++++++--- Zend/zend_ts_hash.h | 7 ++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index 4bf7527aa7..78bb324aec 100644 --- a/Zend/zend_ts_hash.c +++ b/Zend/zend_ts_hash.c @@ -16,60 +16,73 @@ +----------------------------------------------------------------------+ */ -#ifdef ZTS #include "zend_ts_hash.h" /* ts management functions */ static void begin_read(TsHashTable *ht) { +#ifdef ZTS tsrm_mutex_lock(ht->mx_reader); if ((++(ht->reader)) == 1) { tsrm_mutex_lock(ht->mx_writer); } tsrm_mutex_unlock(ht->mx_reader); +#endif } static void end_read(TsHashTable *ht) { +#ifdef ZTS tsrm_mutex_lock(ht->mx_reader); if ((--(ht->reader)) == 0) { tsrm_mutex_unlock(ht->mx_writer); } tsrm_mutex_unlock(ht->mx_reader); +#endif } static void begin_write(TsHashTable *ht) { +#ifdef ZTS tsrm_mutex_lock(ht->mx_writer); +#endif } static void end_write(TsHashTable *ht) { +#ifdef ZTS tsrm_mutex_unlock(ht->mx_writer); +#endif } /* delegates */ ZEND_API int zend_ts_hash_init(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent) { +#ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; +#endif return zend_hash_init(TS_HASH(ht), nSize, pHashFunction, pDestructor, persistent); } ZEND_API int zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection) { +#ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; +#endif return zend_hash_init_ex(TS_HASH(ht), nSize, pHashFunction, pDestructor, persistent, bApplyProtection); } ZEND_API void zend_ts_hash_destroy(TsHashTable *ht) { +#ifdef ZTS tsrm_mutex_free(ht->mx_reader); tsrm_mutex_free(ht->mx_writer); +#endif zend_hash_destroy(TS_HASH(ht)); } @@ -125,8 +138,10 @@ ZEND_API int zend_ts_hash_add_empty_element(TsHashTable *ht, char *arKey, uint n ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) { +#ifdef ZTS tsrm_mutex_free(ht->mx_reader); tsrm_mutex_free(ht->mx_reader); +#endif zend_hash_graceful_destroy(TS_HASH(ht)); } @@ -338,5 +353,3 @@ void zend_ts_hash_display(TsHashTable *ht) end_read(ht); } #endif - -#endif /* ZTS */ diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index 2b1b3fc801..39b71ddadb 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -19,15 +19,15 @@ #ifndef ZEND_TS_HASH_H #define ZEND_TS_HASH_H -#ifdef ZTS - #include "zend.h" typedef struct _zend_ts_hashtable { HashTable hash; zend_uint reader; +#ifdef ZTS MUTEX_T mx_reader; MUTEX_T mx_writer; +#endif } TsHashTable; BEGIN_EXTERN_C() @@ -115,7 +115,4 @@ END_EXTERN_C() #define ZEND_TS_INIT_SYMTABLE_EX(ht, n, persistent) \ zend_ts_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent) - -#endif /* ZTS */ - #endif /* ZEND_HASH_H */ -- 2.40.0