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: 20 28 71.4 %
Date: 2016-09-18 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 7                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2016 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             : struct st_tick_function
      25             : {
      26             :         void (*func)(int, void *);
      27             :         void *arg;
      28             : };
      29             : 
      30       23922 : int php_startup_ticks(void)
      31             : {
      32       23922 :         zend_llist_init(&PG(tick_functions), sizeof(struct st_tick_function), NULL, 1);
      33       23922 :         return SUCCESS;
      34             : }
      35             : 
      36       23919 : void php_deactivate_ticks(void)
      37             : {
      38       23919 :         zend_llist_clean(&PG(tick_functions));
      39       23919 : }
      40             : 
      41       23963 : void php_shutdown_ticks(void)
      42             : {
      43       23963 :         zend_llist_destroy(&PG(tick_functions));
      44       23963 : }
      45             : 
      46           0 : static int php_compare_tick_functions(void *elem1, void *elem2)
      47             : {
      48           0 :   struct st_tick_function *e1 = (struct st_tick_function *)elem1;
      49           0 :   struct st_tick_function *e2 = (struct st_tick_function *)elem2;
      50           0 :   return e1->func == e2->func && e1->arg == e2->arg;
      51             : }
      52             : 
      53       23926 : PHPAPI void php_add_tick_function(void (*func)(int, void*), void * arg)
      54             : {
      55       23926 :         struct st_tick_function tmp = {func, arg};
      56       23926 :         zend_llist_add_element(&PG(tick_functions), (void *)&tmp);
      57       23926 : }
      58             : 
      59           0 : PHPAPI void php_remove_tick_function(void (*func)(int, void *), void * arg)
      60             : {
      61           0 :         struct st_tick_function tmp = {func, arg};
      62           0 :         zend_llist_del_element(&PG(tick_functions), (void *)&tmp, (int(*)(void*, void*))php_compare_tick_functions);
      63           0 : }
      64             : 
      65          57 : static void php_tick_iterator(void *d, void *arg)
      66             : {
      67          57 :         struct st_tick_function *data = (struct st_tick_function *)d;
      68          57 :         data->func(*((int *)arg), data->arg);
      69          57 : }
      70             : 
      71          35 : void php_run_ticks(int count)
      72             : {
      73          35 :         zend_llist_apply_with_argument(&PG(tick_functions), (llist_apply_with_arg_func_t) php_tick_iterator, &count);
      74          35 : }
      75             : 
      76             : /*
      77             :  * Local variables:
      78             :  * tab-width: 4
      79             :  * c-basic-offset: 4
      80             :  * End:
      81             :  * vim600: sw=4 ts=4 fdm=marker
      82             :  * vim<600: sw=4 ts=4
      83             :  */

Generated by: LCOV version 1.10

Generated at Sun, 18 Sep 2016 08:20:21 +0000 (8 days ago)

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