PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - var/php_gcov/PHP_5_3/Zend - zend_ts_hash.c
Test: PHP Code Coverage
Date: 2009-11-21 Instrumented lines: 158
Code covered: 0.0 % Executed lines: 0
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | Zend Engine                                                          |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1998-2009 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.c 273192 2009-01-09 19:16:55Z tony2001 $ */
      20                 : 
      21                 : #include "zend.h"
      22                 : #include "zend_ts_hash.h"
      23                 : 
      24                 : /* ts management functions */
      25                 : static void begin_read(TsHashTable *ht)
      26               0 : {
      27                 : #ifdef ZTS
      28                 :         tsrm_mutex_lock(ht->mx_reader);
      29                 :         if ((++(ht->reader)) == 1) {
      30                 :                 tsrm_mutex_lock(ht->mx_writer);
      31                 :         }
      32                 :         tsrm_mutex_unlock(ht->mx_reader);
      33                 : #endif
      34               0 : }
      35                 : 
      36                 : static void end_read(TsHashTable *ht)
      37               0 : {
      38                 : #ifdef ZTS
      39                 :         tsrm_mutex_lock(ht->mx_reader);
      40                 :         if ((--(ht->reader)) == 0) {
      41                 :                 tsrm_mutex_unlock(ht->mx_writer);
      42                 :         }
      43                 :         tsrm_mutex_unlock(ht->mx_reader);
      44                 : #endif
      45               0 : }
      46                 : 
      47                 : static void begin_write(TsHashTable *ht)
      48               0 : {
      49                 : #ifdef ZTS
      50                 :         tsrm_mutex_lock(ht->mx_writer);
      51                 : #endif
      52               0 : }
      53                 : 
      54                 : static void end_write(TsHashTable *ht)
      55               0 : {
      56                 : #ifdef ZTS
      57                 :         tsrm_mutex_unlock(ht->mx_writer);
      58                 : #endif
      59               0 : }
      60                 : 
      61                 : /* delegates */
      62                 : 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)
      63               0 : {
      64                 : #ifdef ZTS
      65                 :         ht->mx_reader = tsrm_mutex_alloc();
      66                 :         ht->mx_writer = tsrm_mutex_alloc();
      67                 :         ht->reader = 0;
      68                 : #endif
      69               0 :         return _zend_hash_init(TS_HASH(ht), nSize, pHashFunction, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC);
      70                 : }
      71                 : 
      72                 : 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)
      73               0 : {
      74                 : #ifdef ZTS
      75                 :         ht->mx_reader = tsrm_mutex_alloc();
      76                 :         ht->mx_writer = tsrm_mutex_alloc();
      77                 :         ht->reader = 0;
      78                 : #endif
      79               0 :         return _zend_hash_init_ex(TS_HASH(ht), nSize, pHashFunction, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_RELAY_CC);
      80                 : }
      81                 : 
      82                 : ZEND_API void zend_ts_hash_destroy(TsHashTable *ht)
      83               0 : {
      84               0 :         begin_write(ht);
      85               0 :         zend_hash_destroy(TS_HASH(ht));
      86               0 :         end_write(ht);
      87                 : 
      88                 : #ifdef ZTS
      89                 :         tsrm_mutex_free(ht->mx_reader);
      90                 :         tsrm_mutex_free(ht->mx_writer);
      91                 : #endif
      92               0 : }
      93                 : 
      94                 : ZEND_API void zend_ts_hash_clean(TsHashTable *ht)
      95               0 : {
      96               0 :         ht->reader = 0;
      97               0 :         begin_write(ht);
      98               0 :         zend_hash_clean(TS_HASH(ht));
      99               0 :         end_write(ht);
     100               0 : }
     101                 : 
     102                 : 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)
     103               0 : {
     104                 :         int retval;
     105                 : 
     106               0 :         begin_write(ht);
     107               0 :         retval = _zend_hash_add_or_update(TS_HASH(ht), arKey, nKeyLength, pData, nDataSize, pDest, flag ZEND_FILE_LINE_RELAY_CC);
     108               0 :         end_write(ht);
     109                 : 
     110               0 :         return retval;
     111                 : }
     112                 : 
     113                 : 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)
     114               0 : {
     115                 :         int retval;
     116                 : 
     117               0 :         begin_write(ht);
     118               0 :         retval = _zend_hash_quick_add_or_update(TS_HASH(ht), arKey, nKeyLength, h, pData, nDataSize, pDest, flag ZEND_FILE_LINE_RELAY_CC);
     119               0 :         end_write(ht);
     120                 : 
     121               0 :         return retval;
     122                 : }
     123                 : 
     124                 : 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)
     125               0 : {
     126                 :         int retval;
     127                 : 
     128               0 :         begin_write(ht);
     129               0 :         retval = _zend_hash_index_update_or_next_insert(TS_HASH(ht), h, pData, nDataSize, pDest, flag ZEND_FILE_LINE_RELAY_CC);
     130               0 :         end_write(ht);
     131                 : 
     132               0 :         return retval;
     133                 : }
     134                 : 
     135                 : ZEND_API int zend_ts_hash_add_empty_element(TsHashTable *ht, char *arKey, uint nKeyLength)
     136               0 : {
     137                 :         int retval;
     138                 : 
     139               0 :         begin_write(ht);
     140               0 :         retval = zend_hash_add_empty_element(TS_HASH(ht), arKey, nKeyLength);
     141               0 :         end_write(ht);
     142                 : 
     143               0 :         return retval;
     144                 : }
     145                 : 
     146                 : ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht)
     147               0 : {
     148               0 :         begin_write(ht);
     149               0 :         zend_hash_graceful_destroy(TS_HASH(ht));
     150               0 :         end_write(ht);
     151                 : 
     152                 : #ifdef ZTS
     153                 :         tsrm_mutex_free(ht->mx_reader);
     154                 :         tsrm_mutex_free(ht->mx_reader);
     155                 : #endif
     156               0 : }
     157                 : 
     158                 : ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC)
     159               0 : {
     160               0 :         begin_write(ht);
     161               0 :         zend_hash_apply(TS_HASH(ht), apply_func TSRMLS_CC);
     162               0 :         end_write(ht);
     163               0 : }
     164                 : 
     165                 : ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC)
     166               0 : {
     167               0 :         begin_write(ht);
     168               0 :         zend_hash_apply_with_argument(TS_HASH(ht), apply_func, argument TSRMLS_CC);
     169               0 :         end_write(ht);
     170               0 : }
     171                 : 
     172                 : ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int num_args, ...)
     173               0 : {
     174                 :         va_list args;
     175                 : 
     176               0 :         va_start(args, num_args);
     177               0 :         begin_write(ht);
     178               0 :         zend_hash_apply_with_arguments(TS_HASH(ht) TSRMLS_CC, apply_func, num_args, args);
     179               0 :         end_write(ht);
     180               0 :         va_end(args);
     181               0 : }
     182                 : 
     183                 : ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC)
     184               0 : {
     185               0 :         begin_write(ht);
     186               0 :         zend_hash_reverse_apply(TS_HASH(ht), apply_func TSRMLS_CC);
     187               0 :         end_write(ht);
     188               0 : }
     189                 : 
     190                 : ZEND_API int zend_ts_hash_del_key_or_index(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, int flag)
     191               0 : {
     192                 :         int retval;
     193                 : 
     194               0 :         begin_write(ht);
     195               0 :         retval = zend_hash_del_key_or_index(TS_HASH(ht), arKey, nKeyLength, h, flag);
     196               0 :         end_write(ht);
     197                 : 
     198               0 :         return retval;
     199                 : }
     200                 : 
     201                 : ZEND_API ulong zend_ts_get_hash_value(TsHashTable *ht, char *arKey, uint nKeyLength)
     202               0 : {
     203                 :         ulong retval;
     204                 : 
     205               0 :         begin_read(ht);
     206               0 :         retval = zend_get_hash_value(arKey, nKeyLength);
     207               0 :         end_read(ht);
     208                 : 
     209               0 :         return retval;
     210                 : }
     211                 : 
     212                 : ZEND_API int zend_ts_hash_find(TsHashTable *ht, char *arKey, uint nKeyLength, void **pData)
     213               0 : {
     214                 :         int retval;
     215                 : 
     216               0 :         begin_read(ht);
     217               0 :         retval = zend_hash_find(TS_HASH(ht), arKey, nKeyLength, pData);
     218               0 :         end_read(ht);
     219                 : 
     220               0 :         return retval;
     221                 : }
     222                 : 
     223                 : ZEND_API int zend_ts_hash_quick_find(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, void **pData)
     224               0 : {
     225                 :         int retval;
     226                 : 
     227               0 :         begin_read(ht);
     228               0 :         retval = zend_hash_quick_find(TS_HASH(ht), arKey, nKeyLength, h, pData);
     229               0 :         end_read(ht);
     230                 : 
     231               0 :         return retval;
     232                 : }
     233                 : 
     234                 : ZEND_API int zend_ts_hash_index_find(TsHashTable *ht, ulong h, void **pData)
     235               0 : {
     236                 :         int retval;
     237                 : 
     238               0 :         begin_read(ht);
     239               0 :         retval = zend_hash_index_find(TS_HASH(ht), h, pData);
     240               0 :         end_read(ht);
     241                 : 
     242               0 :         return retval;
     243                 : }
     244                 : 
     245                 : ZEND_API int zend_ts_hash_exists(TsHashTable *ht, char *arKey, uint nKeyLength)
     246               0 : {
     247                 :         int retval;
     248                 : 
     249               0 :         begin_read(ht);
     250               0 :         retval = zend_hash_exists(TS_HASH(ht), arKey, nKeyLength);
     251               0 :         end_read(ht);
     252                 : 
     253               0 :         return retval;
     254                 : }
     255                 : 
     256                 : ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, ulong h)
     257               0 : {
     258                 :         int retval;
     259                 : 
     260               0 :         begin_read(ht);
     261               0 :         retval = zend_hash_index_exists(TS_HASH(ht), h);
     262               0 :         end_read(ht);
     263                 : 
     264               0 :         return retval;
     265                 : }
     266                 : 
     267                 : ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size)
     268               0 : {
     269               0 :         begin_read(source);
     270               0 :         begin_write(target);
     271               0 :         zend_hash_copy(TS_HASH(target), TS_HASH(source), pCopyConstructor, tmp, size);
     272               0 :         end_write(target);
     273               0 :         end_read(source);
     274               0 : }
     275                 : 
     276                 : ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size)
     277               0 : {
     278               0 :         begin_read(source);
     279               0 :         zend_hash_copy(target, TS_HASH(source), pCopyConstructor, tmp, size);
     280               0 :         end_read(source);
     281               0 : }
     282                 : 
     283                 : ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, int overwrite)
     284               0 : {
     285               0 :         begin_read(source);
     286               0 :         begin_write(target);
     287               0 :         zend_hash_merge(TS_HASH(target), TS_HASH(source), pCopyConstructor, tmp, size, overwrite);
     288               0 :         end_write(target);
     289               0 :         end_read(source);
     290               0 : }
     291                 : 
     292                 : 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)
     293               0 : {
     294               0 :         begin_read(source);
     295               0 :         begin_write(target);
     296               0 :         zend_hash_merge_ex(TS_HASH(target), TS_HASH(source), pCopyConstructor, size, pMergeSource, pParam);
     297               0 :         end_write(target);
     298               0 :         end_read(source);
     299               0 : }
     300                 : 
     301                 : ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC)
     302               0 : {
     303                 :         int retval;
     304                 : 
     305               0 :         begin_write(ht);
     306               0 :         retval = zend_hash_sort(TS_HASH(ht), sort_func, compare_func, renumber TSRMLS_CC);
     307               0 :         end_write(ht);
     308                 : 
     309               0 :         return retval;
     310                 : }
     311                 : 
     312                 : ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC)
     313               0 : {
     314                 :         int retval;
     315                 : 
     316               0 :         begin_read(ht1);
     317               0 :         begin_read(ht2);
     318               0 :         retval = zend_hash_compare(TS_HASH(ht1), TS_HASH(ht2), compar, ordered TSRMLS_CC);
     319               0 :         end_read(ht2);
     320               0 :         end_read(ht1);
     321                 : 
     322               0 :         return retval;
     323                 : }
     324                 : 
     325                 : ZEND_API int zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag, void **pData TSRMLS_DC)
     326               0 : {
     327                 :         int retval;
     328                 : 
     329               0 :         begin_read(ht);
     330               0 :         retval = zend_hash_minmax(TS_HASH(ht), compar, flag, pData TSRMLS_CC);
     331               0 :         end_read(ht);
     332                 : 
     333               0 :         return retval;
     334                 : }
     335                 : 
     336                 : ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht)
     337               0 : {
     338                 :         int retval;
     339                 : 
     340               0 :         begin_read(ht);
     341               0 :         retval = zend_hash_num_elements(TS_HASH(ht));
     342               0 :         end_read(ht);
     343                 : 
     344               0 :         return retval;
     345                 : }
     346                 : 
     347                 : ZEND_API int zend_ts_hash_rehash(TsHashTable *ht)
     348               0 : {
     349                 :         int retval;
     350                 : 
     351               0 :         begin_write(ht);
     352               0 :         retval = zend_hash_rehash(TS_HASH(ht));
     353               0 :         end_write(ht);
     354                 : 
     355               0 :         return retval;
     356                 : }
     357                 : 
     358                 : #if ZEND_DEBUG
     359                 : void zend_ts_hash_display_pListTail(TsHashTable *ht)
     360                 : {
     361                 :         begin_read(ht);
     362                 :         zend_hash_display_pListTail(TS_HASH(ht));
     363                 :         end_read(ht);
     364                 : }
     365                 : 
     366                 : void zend_ts_hash_display(TsHashTable *ht)
     367                 : {
     368                 :         begin_read(ht);
     369                 :         zend_hash_display(TS_HASH(ht));
     370                 :         end_read(ht);
     371                 : }
     372                 : #endif
     373                 : 
     374                 : /*
     375                 :  * Local variables:
     376                 :  * tab-width: 4
     377                 :  * c-basic-offset: 4
     378                 :  * indent-tabs-mode: t
     379                 :  * End:
     380                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Sat, 21 Nov 2009 12:26:53 +0000 (3 days ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.