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_HEAD/Zend - zend_ptr_stack.h
Test: PHP Code Coverage
Date: 2009-11-23 Instrumented lines: 32
Code covered: 81.2 % Executed lines: 26
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: Andi Gutmans <andi@zend.com>                                |
      16                 :    |          Zeev Suraski <zeev@zend.com>                                |
      17                 :    +----------------------------------------------------------------------+
      18                 : */
      19                 : 
      20                 : /* $Id: zend_ptr_stack.h 281711 2009-06-05 11:21:16Z lbarnaud $ */
      21                 : 
      22                 : #ifndef ZEND_PTR_STACK_H
      23                 : #define ZEND_PTR_STACK_H
      24                 : 
      25                 : typedef struct _zend_ptr_stack {
      26                 :         int top, max;
      27                 :         void **elements;
      28                 :         void **top_element;
      29                 :         zend_bool persistent;
      30                 : } zend_ptr_stack;
      31                 : 
      32                 : 
      33                 : #define PTR_STACK_BLOCK_SIZE 64
      34                 : 
      35                 : BEGIN_EXTERN_C()
      36                 : ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack);
      37                 : ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent);
      38                 : ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...);
      39                 : ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...);
      40                 : ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack);
      41                 : ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *));
      42                 : ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), zend_bool free_elements);
      43                 : ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack);
      44                 : END_EXTERN_C()
      45                 : 
      46                 : #define ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count)           \
      47                 :         if (stack->top+count > stack->max) {                                   \
      48                 :                 /* we need to allocate more memory */                           \
      49                 :                 stack->max *= 2;                                                                     \
      50                 :                 stack->max += count;                                                         \
      51                 :                 stack->elements = (void **) perealloc(stack->elements, (sizeof(void *) * (stack->max)), stack->persistent); \
      52                 :                 stack->top_element = stack->elements+stack->top;       \
      53                 :         }
      54                 : 
      55                 : /*      Not doing this with a macro because of the loop unrolling in the element assignment.
      56                 :         Just using a macro for 3 in the body for readability sake. */
      57                 : static inline void zend_ptr_stack_3_push(zend_ptr_stack *stack, void *a, void *b, void *c)
      58        35644289 : {
      59                 : #define ZEND_PTR_STACK_NUM_ARGS 3
      60                 : 
      61        35644289 :         ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, ZEND_PTR_STACK_NUM_ARGS)
      62                 : 
      63        35644289 :         stack->top += ZEND_PTR_STACK_NUM_ARGS;
      64        35644289 :         *(stack->top_element++) = a;
      65        35644289 :         *(stack->top_element++) = b;
      66        35644289 :         *(stack->top_element++) = c;
      67                 : 
      68                 : #undef ZEND_PTR_STACK_NUM_ARGS
      69        35644289 : }
      70                 : 
      71                 : static inline void zend_ptr_stack_2_push(zend_ptr_stack *stack, void *a, void *b)
      72               0 : {
      73                 : #define ZEND_PTR_STACK_NUM_ARGS 2
      74                 : 
      75               0 :         ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, ZEND_PTR_STACK_NUM_ARGS)
      76                 : 
      77               0 :         stack->top += ZEND_PTR_STACK_NUM_ARGS;
      78               0 :         *(stack->top_element++) = a;
      79               0 :         *(stack->top_element++) = b;
      80                 : 
      81                 : #undef ZEND_PTR_STACK_NUM_ARGS
      82               0 : }
      83                 : 
      84                 : static inline void zend_ptr_stack_3_pop(zend_ptr_stack *stack, void **a, void **b, void **c)
      85        35644152 : {
      86        35644152 :         *a = *(--stack->top_element);
      87        35644152 :         *b = *(--stack->top_element);
      88        35644152 :         *c = *(--stack->top_element);
      89        35644152 :         stack->top -= 3;
      90        35644152 : }
      91                 : 
      92                 : static inline void zend_ptr_stack_2_pop(zend_ptr_stack *stack, void **a, void **b)
      93              19 : {
      94              19 :         *a = *(--stack->top_element);
      95              19 :         *b = *(--stack->top_element);
      96              19 :         stack->top -= 2;
      97              19 : }
      98                 : 
      99                 : static inline void zend_ptr_stack_push(zend_ptr_stack *stack, void *ptr)
     100              86 : {
     101              86 :         ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, 1)
     102                 : 
     103              86 :         stack->top++;
     104              86 :         *(stack->top_element++) = ptr;
     105              86 : }
     106                 : 
     107                 : static inline void *zend_ptr_stack_pop(zend_ptr_stack *stack)
     108              67 : {
     109              67 :         stack->top--;
     110              67 :         return *(--stack->top_element);
     111                 : }
     112                 : 
     113                 : #endif /* ZEND_PTR_STACK_H */
     114                 : 
     115                 : /*
     116                 :  * Local variables:
     117                 :  * tab-width: 4
     118                 :  * c-basic-offset: 4
     119                 :  * indent-tabs-mode: t
     120                 :  * End:
     121                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Mon, 23 Nov 2009 17:39:27 +0000 (36 hours ago)

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