LTP GCOV extension - code coverage report
Current view: directory - main - php_ticks.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 23
Code covered: 26.1 % Executed lines: 6
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 5                                                        |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1997-2007 The PHP Group                                |
       6                 :    +----------------------------------------------------------------------+
       7                 :    | This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt                                  |
      11                 :    | If you did not receive a copy of the PHP license and are unable to   |
      12                 :    | obtain it through the world-wide-web, please send a note to          |
      13                 :    | license@php.net so we can mail you a copy immediately.               |
      14                 :    +----------------------------------------------------------------------+
      15                 :    | Author: Stig Bakken <ssb@php.net>                                    |
      16                 :    +----------------------------------------------------------------------+
      17                 : */
      18                 : 
      19                 : /* $Id: php_ticks.c,v 1.20.2.1.2.1 2007/01/01 09:36:11 sebastian Exp $ */
      20                 : 
      21                 : #include "php.h"
      22                 : #include "php_ticks.h"
      23                 : 
      24                 : int php_startup_ticks(TSRMLS_D)
      25             220 : {
      26             220 :         zend_llist_init(&PG(tick_functions), sizeof(void(*)(int)), NULL, 1);
      27             220 :         return SUCCESS;
      28                 : }
      29                 : 
      30                 : void php_shutdown_ticks(TSRMLS_D)
      31             219 : {
      32             219 :         zend_llist_destroy(&PG(tick_functions));
      33             219 : }
      34                 : 
      35                 : static int php_compare_tick_functions(void *elem1, void *elem2)
      36               0 : {
      37                 :         void(*func1)(int);
      38                 :         void(*func2)(int);
      39               0 :         memcpy(&func1, elem1, sizeof(void(*)(int)));
      40               0 :         memcpy(&func2, elem2, sizeof(void(*)(int)));
      41               0 :         return (func1 == func2);
      42                 : }
      43                 : 
      44                 : PHPAPI void php_add_tick_function(void (*func)(int))
      45               0 : {
      46                 :         TSRMLS_FETCH();
      47                 : 
      48               0 :         zend_llist_add_element(&PG(tick_functions), (void *)&func);
      49               0 : }
      50                 : 
      51                 : PHPAPI void php_remove_tick_function(void (*func)(int))
      52               0 : {
      53                 :         TSRMLS_FETCH();
      54                 : 
      55               0 :         zend_llist_del_element(&PG(tick_functions), (void *)func,
      56                 :                                                    (int(*)(void*, void*))php_compare_tick_functions);
      57               0 : }
      58                 : 
      59                 : static void php_tick_iterator(void *data, void *arg TSRMLS_DC)
      60               0 : {
      61                 :         void (*func)(int);
      62                 : 
      63               0 :         memcpy(&func, data, sizeof(void(*)(int)));
      64               0 :         func(*((int *)arg));
      65               0 : }
      66                 : 
      67                 : void php_run_ticks(int count)
      68               0 : {
      69                 :         TSRMLS_FETCH();
      70                 : 
      71               0 :         zend_llist_apply_with_argument(&PG(tick_functions), (llist_apply_with_arg_func_t) php_tick_iterator, &count TSRMLS_CC);
      72               0 : }
      73                 : 
      74                 : /*
      75                 :  * Local variables:
      76                 :  * tab-width: 4
      77                 :  * c-basic-offset: 4
      78                 :  * End:
      79                 :  * vim600: sw=4 ts=4 fdm=marker
      80                 :  * vim<600: sw=4 ts=4
      81                 :  */

Generated by: LTP GCOV extension version 1.5