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 - main - php_ticks.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 19 26 73.1 %
Date: 2014-11-25 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 5                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2014 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$ */
      20             : 
      21             : #include "php.h"
      22             : #include "php_ticks.h"
      23             : 
      24       20225 : int php_startup_ticks(TSRMLS_D)
      25             : {
      26       20225 :         zend_llist_init(&PG(tick_functions), sizeof(void(*)(int)), NULL, 1);
      27       20225 :         return SUCCESS;
      28             : }
      29             : 
      30       20220 : void php_deactivate_ticks(TSRMLS_D)
      31             : {
      32       20220 :         zend_llist_clean(&PG(tick_functions));
      33       20220 : }
      34             : 
      35       20261 : void php_shutdown_ticks(TSRMLS_D)
      36             : {
      37       20261 :         zend_llist_destroy(&PG(tick_functions));
      38       20261 : }
      39             : 
      40           0 : static int php_compare_tick_functions(void *elem1, void *elem2)
      41             : {
      42             :         void(*func1)(int);
      43             :         void(*func2)(int);
      44           0 :         memcpy(&func1, elem1, sizeof(void(*)(int)));
      45           0 :         memcpy(&func2, elem2, sizeof(void(*)(int)));
      46           0 :         return (func1 == func2);
      47             : }
      48             : 
      49       20228 : PHPAPI void php_add_tick_function(void (*func)(int))
      50             : {
      51             :         TSRMLS_FETCH();
      52             : 
      53       20228 :         zend_llist_add_element(&PG(tick_functions), (void *)&func);
      54       20228 : }
      55             : 
      56           0 : PHPAPI void php_remove_tick_function(void (*func)(int))
      57             : {
      58             :         TSRMLS_FETCH();
      59             : 
      60           0 :         zend_llist_del_element(&PG(tick_functions), (void *)func,
      61             :                                                    (int(*)(void*, void*))php_compare_tick_functions);
      62           0 : }
      63             : 
      64          69 : static void php_tick_iterator(void *data, void *arg TSRMLS_DC)
      65             : {
      66             :         void (*func)(int);
      67             : 
      68          69 :         memcpy(&func, data, sizeof(void(*)(int)));
      69          69 :         func(*((int *)arg));
      70          69 : }
      71             : 
      72          45 : void php_run_ticks(int count)
      73             : {
      74             :         TSRMLS_FETCH();
      75             : 
      76          45 :         zend_llist_apply_with_argument(&PG(tick_functions), (llist_apply_with_arg_func_t) php_tick_iterator, &count TSRMLS_CC);
      77          45 : }
      78             : 
      79             : /*
      80             :  * Local variables:
      81             :  * tab-width: 4
      82             :  * c-basic-offset: 4
      83             :  * End:
      84             :  * vim600: sw=4 ts=4 fdm=marker
      85             :  * vim<600: sw=4 ts=4
      86             :  */

Generated by: LCOV version 1.10

Generated at Tue, 25 Nov 2014 09:11:09 +0000 (43 hours ago)

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