File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / zend_ts_hash.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:36 2012 UTC (12 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_17p0, HEAD
php 5.4.3+patches

    1: /*
    2:    +----------------------------------------------------------------------+
    3:    | Zend Engine                                                          |
    4:    +----------------------------------------------------------------------+
    5:    | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
    6:    +----------------------------------------------------------------------+
    7:    | This source file is subject to version 2.00 of the Zend license,     |
    8:    | that is bundled with this package in the file LICENSE, and is        | 
    9:    | available through the world-wide-web at the following url:           |
   10:    | http://www.zend.com/license/2_00.txt.                                |
   11:    | If you did not receive a copy of the Zend license and are unable to  |
   12:    | obtain it through the world-wide-web, please send a note to          |
   13:    | license@zend.com so we can mail you a copy immediately.              |
   14:    +----------------------------------------------------------------------+
   15:    | Authors: Harald Radi <harald.radi@nme.at>                            |
   16:    +----------------------------------------------------------------------+
   17: */
   18: 
   19: /* $Id: zend_ts_hash.h,v 1.1.1.2 2012/05/29 12:34:36 misho Exp $ */
   20: 
   21: #ifndef ZEND_TS_HASH_H
   22: #define ZEND_TS_HASH_H
   23: 
   24: #include "zend.h"
   25: 
   26: typedef struct _zend_ts_hashtable {
   27: 	HashTable hash;
   28: 	zend_uint reader;
   29: #ifdef ZTS
   30: 	MUTEX_T mx_reader;
   31: 	MUTEX_T mx_writer;
   32: #endif
   33: } TsHashTable;
   34: 
   35: BEGIN_EXTERN_C()
   36: 
   37: #define TS_HASH(table) (&(table->hash))
   38: 
   39: /* startup/shutdown */
   40: ZEND_API int _zend_ts_hash_init(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC);
   41: 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 ZEND_FILE_LINE_DC);
   42: ZEND_API void zend_ts_hash_destroy(TsHashTable *ht);
   43: ZEND_API void zend_ts_hash_clean(TsHashTable *ht);
   44: 
   45: #define zend_ts_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)	\
   46: 	_zend_ts_hash_init(ht, nSize, pHashFunction, pDestructor, persistent ZEND_FILE_LINE_CC)
   47: #define zend_ts_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection)	\
   48: 	_zend_ts_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_CC)
   49: 
   50: 
   51: /* additions/updates/changes */
   52: ZEND_API int _zend_ts_hash_add_or_update(TsHashTable *ht, char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
   53: #define zend_ts_hash_update(ht, arKey, nKeyLength, pData, nDataSize, pDest) \
   54: 		_zend_ts_hash_add_or_update(ht, arKey, nKeyLength, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
   55: #define zend_ts_hash_add(ht, arKey, nKeyLength, pData, nDataSize, pDest) \
   56: 		_zend_ts_hash_add_or_update(ht, arKey, nKeyLength, pData, nDataSize, pDest, HASH_ADD ZEND_FILE_LINE_CC)
   57: 
   58: ZEND_API int _zend_ts_hash_quick_add_or_update(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
   59: #define zend_ts_hash_quick_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest) \
   60: 		_zend_ts_hash_quick_add_or_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
   61: #define zend_ts_hash_quick_add(ht, arKey, nKeyLength, h, pData, nDataSize, pDest) \
   62: 		_zend_ts_hash_quick_add_or_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest, HASH_ADD ZEND_FILE_LINE_CC)
   63: 
   64: ZEND_API int _zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
   65: #define zend_ts_hash_index_update(ht, h, pData, nDataSize, pDest) \
   66: 		_zend_ts_hash_index_update_or_next_insert(ht, h, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
   67: #define zend_ts_hash_next_index_insert(ht, pData, nDataSize, pDest) \
   68: 		_zend_ts_hash_index_update_or_next_insert(ht, 0, pData, nDataSize, pDest, HASH_NEXT_INSERT ZEND_FILE_LINE_CC)
   69: 
   70: ZEND_API int zend_ts_hash_add_empty_element(TsHashTable *ht, char *arKey, uint nKeyLength);
   71: 
   72: ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht);
   73: ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC);
   74: ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void * TSRMLS_DC);
   75: ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int, ...);
   76: 
   77: ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC);
   78: 
   79: 
   80: /* Deletes */
   81: ZEND_API int zend_ts_hash_del_key_or_index(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, int flag);
   82: #define zend_ts_hash_del(ht, arKey, nKeyLength) \
   83: 		zend_ts_hash_del_key_or_index(ht, arKey, nKeyLength, 0, HASH_DEL_KEY)
   84: #define zend_ts_hash_index_del(ht, h) \
   85: 		zend_ts_hash_del_key_or_index(ht, NULL, 0, h, HASH_DEL_INDEX)
   86: 
   87: ZEND_API ulong zend_ts_get_hash_value(TsHashTable *ht, char *arKey, uint nKeyLength);
   88: 
   89: /* Data retreival */
   90: ZEND_API int zend_ts_hash_find(TsHashTable *ht, char *arKey, uint nKeyLength, void **pData);
   91: ZEND_API int zend_ts_hash_quick_find(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, void **pData);
   92: ZEND_API int zend_ts_hash_index_find(TsHashTable *ht, ulong h, void **pData);
   93: 
   94: /* Misc */
   95: ZEND_API int zend_ts_hash_exists(TsHashTable *ht, char *arKey, uint nKeyLength);
   96: ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, ulong h);
   97: 
   98: /* Copying, merging and sorting */
   99: ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size);
  100: ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size);
  101: ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, int overwrite);
  102: ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, uint size, merge_checker_func_t pMergeSource, void *pParam);
  103: ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC);
  104: ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC);
  105: ZEND_API int zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag, void **pData TSRMLS_DC);
  106: 
  107: ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht);
  108: 
  109: ZEND_API int zend_ts_hash_rehash(TsHashTable *ht);
  110: 
  111: ZEND_API ulong zend_ts_hash_func(char *arKey, uint nKeyLength);
  112: 
  113: #if ZEND_DEBUG
  114: /* debug */
  115: void zend_ts_hash_display_pListTail(TsHashTable *ht);
  116: void zend_ts_hash_display(TsHashTable *ht);
  117: #endif
  118: 
  119: END_EXTERN_C()
  120: 
  121: #define ZEND_TS_INIT_SYMTABLE(ht)								\
  122: 	ZEND_TS_INIT_SYMTABLE_EX(ht, 2, 0)
  123: 
  124: #define ZEND_TS_INIT_SYMTABLE_EX(ht, n, persistent)			\
  125: 	zend_ts_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
  126: 
  127: #endif							/* ZEND_HASH_H */
  128: 
  129: /*
  130:  * Local variables:
  131:  * tab-width: 4
  132:  * c-basic-offset: 4
  133:  * indent-tabs-mode: t
  134:  * End:
  135:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>