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

LCOV - code coverage report
Current view: top level - Zend - zend_ts_hash.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 0 165 0.0 %
Date: 2014-09-27 Functions: 0 34 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2014 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$ */
      20             : 
      21             : #include "zend.h"
      22             : #include "zend_ts_hash.h"
      23             : 
      24             : /* ts management functions */
      25           0 : static void begin_read(TsHashTable *ht)
      26             : {
      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           0 : static void end_read(TsHashTable *ht)
      37             : {
      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           0 : static void begin_write(TsHashTable *ht)
      48             : {
      49             : #ifdef ZTS
      50             :         tsrm_mutex_lock(ht->mx_writer);
      51             : #endif
      52           0 : }
      53             : 
      54           0 : static void end_write(TsHashTable *ht)
      55             : {
      56             : #ifdef ZTS
      57             :         tsrm_mutex_unlock(ht->mx_writer);
      58             : #endif
      59           0 : }
      60             : 
      61             : /* delegates */
      62           0 : ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
      63             : {
      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 :         _zend_hash_init(TS_HASH(ht), nSize, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC);
      70           0 : }
      71             : 
      72           0 : ZEND_API void _zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC)
      73             : {
      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 :         _zend_hash_init_ex(TS_HASH(ht), nSize, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_RELAY_CC);
      80           0 : }
      81             : 
      82           0 : ZEND_API void zend_ts_hash_destroy(TsHashTable *ht)
      83             : {
      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           0 : ZEND_API void zend_ts_hash_clean(TsHashTable *ht)
      95             : {
      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           0 : ZEND_API zval *_zend_ts_hash_add_or_update(TsHashTable *ht, zend_string *key, zval *pData, int flag ZEND_FILE_LINE_DC)
     103             : {
     104             :         zval *retval;
     105             : 
     106           0 :         begin_write(ht);
     107           0 :         retval = _zend_hash_add_or_update(TS_HASH(ht), key, pData, flag ZEND_FILE_LINE_RELAY_CC);
     108           0 :         end_write(ht);
     109             : 
     110           0 :         return retval;
     111             : }
     112             : 
     113           0 : ZEND_API zval *_zend_ts_hash_index_add_or_update(TsHashTable *ht, zend_ulong h, zval *pData, int flag ZEND_FILE_LINE_DC)
     114             : {
     115             :         zval *retval;
     116             : 
     117           0 :         begin_write(ht);
     118           0 :         retval = _zend_hash_index_add_or_update(TS_HASH(ht), h, pData, flag ZEND_FILE_LINE_RELAY_CC);
     119           0 :         end_write(ht);
     120             : 
     121           0 :         return retval;
     122             : }
     123             : 
     124           0 : ZEND_API zval *zend_ts_hash_add_empty_element(TsHashTable *ht, zend_string *key)
     125             : {
     126             :         zval *retval;
     127             : 
     128           0 :         begin_write(ht);
     129           0 :         retval = zend_hash_add_empty_element(TS_HASH(ht), key);
     130           0 :         end_write(ht);
     131             : 
     132           0 :         return retval;
     133             : }
     134             : 
     135           0 : ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht)
     136             : {
     137           0 :         begin_write(ht);
     138           0 :         zend_hash_graceful_destroy(TS_HASH(ht));
     139           0 :         end_write(ht);
     140             : 
     141             : #ifdef ZTS
     142             :         tsrm_mutex_free(ht->mx_reader);
     143             :         tsrm_mutex_free(ht->mx_reader);
     144             : #endif
     145           0 : }
     146             : 
     147           0 : ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC)
     148             : {
     149           0 :         begin_write(ht);
     150           0 :         zend_hash_apply(TS_HASH(ht), apply_func TSRMLS_CC);
     151           0 :         end_write(ht);
     152           0 : }
     153             : 
     154           0 : ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC)
     155             : {
     156           0 :         begin_write(ht);
     157           0 :         zend_hash_apply_with_argument(TS_HASH(ht), apply_func, argument TSRMLS_CC);
     158           0 :         end_write(ht);
     159           0 : }
     160             : 
     161           0 : ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int num_args, ...)
     162             : {
     163             :         va_list args;
     164             : 
     165           0 :         va_start(args, num_args);
     166           0 :         begin_write(ht);
     167           0 :         zend_hash_apply_with_arguments(TS_HASH(ht) TSRMLS_CC, apply_func, num_args, args);
     168           0 :         end_write(ht);
     169           0 :         va_end(args);
     170           0 : }
     171             : 
     172           0 : ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC)
     173             : {
     174           0 :         begin_write(ht);
     175           0 :         zend_hash_reverse_apply(TS_HASH(ht), apply_func TSRMLS_CC);
     176           0 :         end_write(ht);
     177           0 : }
     178             : 
     179           0 : ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key)
     180             : {
     181             :         int retval;
     182             : 
     183           0 :         begin_write(ht);
     184           0 :         retval = zend_hash_del(TS_HASH(ht), key);
     185           0 :         end_write(ht);
     186             : 
     187           0 :         return retval;
     188             : }
     189             : 
     190           0 : ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h)
     191             : {
     192             :         int retval;
     193             : 
     194           0 :         begin_write(ht);
     195           0 :         retval = zend_hash_index_del(TS_HASH(ht), h);
     196           0 :         end_write(ht);
     197             : 
     198           0 :         return retval;
     199             : }
     200             : 
     201           0 : ZEND_API zval *zend_ts_hash_find(TsHashTable *ht, zend_string *key)
     202             : {
     203             :         zval *retval;
     204             : 
     205           0 :         begin_read(ht);
     206           0 :         retval = zend_hash_find(TS_HASH(ht), key);
     207           0 :         end_read(ht);
     208             : 
     209           0 :         return retval;
     210             : }
     211             : 
     212           0 : ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, zend_ulong h)
     213             : {
     214             :         zval *retval;
     215             : 
     216           0 :         begin_read(ht);
     217           0 :         retval = zend_hash_index_find(TS_HASH(ht), h);
     218           0 :         end_read(ht);
     219             : 
     220           0 :         return retval;
     221             : }
     222             : 
     223           0 : ZEND_API int zend_ts_hash_exists(TsHashTable *ht, zend_string *key)
     224             : {
     225             :         int retval;
     226             : 
     227           0 :         begin_read(ht);
     228           0 :         retval = zend_hash_exists(TS_HASH(ht), key);
     229           0 :         end_read(ht);
     230             : 
     231           0 :         return retval;
     232             : }
     233             : 
     234           0 : ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, zend_ulong h)
     235             : {
     236             :         int retval;
     237             : 
     238           0 :         begin_read(ht);
     239           0 :         retval = zend_hash_index_exists(TS_HASH(ht), h);
     240           0 :         end_read(ht);
     241             : 
     242           0 :         return retval;
     243             : }
     244             : 
     245           0 : ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor)
     246             : {
     247           0 :         begin_read(source);
     248           0 :         begin_write(target);
     249           0 :         zend_hash_copy(TS_HASH(target), TS_HASH(source), pCopyConstructor);
     250           0 :         end_write(target);
     251           0 :         end_read(source);
     252           0 : }
     253             : 
     254           0 : ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor)
     255             : {
     256           0 :         begin_read(source);
     257           0 :         zend_hash_copy(target, TS_HASH(source), pCopyConstructor);
     258           0 :         end_read(source);
     259           0 : }
     260             : 
     261           0 : ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, int overwrite)
     262             : {
     263           0 :         begin_read(source);
     264           0 :         begin_write(target);
     265           0 :         zend_hash_merge(TS_HASH(target), TS_HASH(source), pCopyConstructor, overwrite);
     266           0 :         end_write(target);
     267           0 :         end_read(source);
     268           0 : }
     269             : 
     270           0 : ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam)
     271             : {
     272           0 :         begin_read(source);
     273           0 :         begin_write(target);
     274           0 :         zend_hash_merge_ex(TS_HASH(target), TS_HASH(source), pCopyConstructor, pMergeSource, pParam);
     275           0 :         end_write(target);
     276           0 :         end_read(source);
     277           0 : }
     278             : 
     279           0 : ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC)
     280             : {
     281             :         int retval;
     282             : 
     283           0 :         begin_write(ht);
     284           0 :         retval = zend_hash_sort(TS_HASH(ht), sort_func, compare_func, renumber TSRMLS_CC);
     285           0 :         end_write(ht);
     286             : 
     287           0 :         return retval;
     288             : }
     289             : 
     290           0 : ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC)
     291             : {
     292             :         int retval;
     293             : 
     294           0 :         begin_read(ht1);
     295           0 :         begin_read(ht2);
     296           0 :         retval = zend_hash_compare(TS_HASH(ht1), TS_HASH(ht2), compar, ordered TSRMLS_CC);
     297           0 :         end_read(ht2);
     298           0 :         end_read(ht1);
     299             : 
     300           0 :         return retval;
     301             : }
     302             : 
     303           0 : ZEND_API zval *zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag TSRMLS_DC)
     304             : {
     305             :         zval *retval;
     306             : 
     307           0 :         begin_read(ht);
     308           0 :         retval = zend_hash_minmax(TS_HASH(ht), compar, flag TSRMLS_CC);
     309           0 :         end_read(ht);
     310             : 
     311           0 :         return retval;
     312             : }
     313             : 
     314           0 : ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht)
     315             : {
     316             :         int retval;
     317             : 
     318           0 :         begin_read(ht);
     319           0 :         retval = zend_hash_num_elements(TS_HASH(ht));
     320           0 :         end_read(ht);
     321             : 
     322           0 :         return retval;
     323             : }
     324             : 
     325           0 : ZEND_API int zend_ts_hash_rehash(TsHashTable *ht)
     326             : {
     327             :         int retval;
     328             : 
     329           0 :         begin_write(ht);
     330           0 :         retval = zend_hash_rehash(TS_HASH(ht));
     331           0 :         end_write(ht);
     332             : 
     333           0 :         return retval;
     334             : }
     335             : 
     336           0 : ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, int len)
     337             : {
     338             :         zval *retval;
     339             : 
     340           0 :         begin_read(ht);
     341           0 :         retval = zend_hash_str_find(TS_HASH(ht), key, len);
     342           0 :         end_read(ht);
     343             : 
     344           0 :         return retval;
     345             : }
     346             : 
     347           0 : ZEND_API zval *_zend_ts_hash_str_update(TsHashTable *ht, const char *key, int len, zval *pData ZEND_FILE_LINE_DC)
     348             : {
     349             :         zval *retval;
     350             : 
     351           0 :         begin_write(ht);
     352           0 :         retval = zend_hash_str_update(TS_HASH(ht), key, len, pData);
     353           0 :         end_write(ht);
     354             : 
     355           0 :         return retval;
     356             : }
     357             : 
     358           0 : ZEND_API zval *_zend_ts_hash_str_add(TsHashTable *ht, const char *key, int len, zval *pData ZEND_FILE_LINE_DC)
     359             : {
     360             :         zval *retval;
     361             : 
     362           0 :         begin_write(ht);
     363           0 :         retval = zend_hash_str_add(TS_HASH(ht), key, len, pData);
     364           0 :         end_write(ht);
     365             : 
     366           0 :         return retval;
     367             : }
     368             : 
     369             : /*
     370             :  * Local variables:
     371             :  * tab-width: 4
     372             :  * c-basic-offset: 4
     373             :  * indent-tabs-mode: t
     374             :  * End:
     375             :  */

Generated by: LCOV version 1.10

Generated at Sat, 27 Sep 2014 16:43:05 +0000 (3 days ago)

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