Coverage Report

Created: 2026-06-02 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/php-src/main/php_ticks.c
Line
Count
Source
1
/*
2
   +----------------------------------------------------------------------+
3
   | Copyright © The PHP Group and Contributors.                          |
4
   +----------------------------------------------------------------------+
5
   | This source file is subject to the Modified BSD License that is      |
6
   | bundled with this package in the file LICENSE, and is available      |
7
   | through the World Wide Web at <https://www.php.net/license/>.        |
8
   |                                                                      |
9
   | SPDX-License-Identifier: BSD-3-Clause                                |
10
   +----------------------------------------------------------------------+
11
   | Author: Stig Bakken <ssb@php.net>                                    |
12
   +----------------------------------------------------------------------+
13
*/
14
15
#include "php.h"
16
#include "php_ticks.h"
17
18
struct st_tick_function
19
{
20
  void (*func)(int, void *);
21
  void *arg;
22
};
23
24
void php_startup_ticks(void)
25
2
{
26
2
  zend_llist_init(&PG(tick_functions), sizeof(struct st_tick_function), NULL, 1);
27
2
}
28
29
void php_deactivate_ticks(void)
30
38.2k
{
31
38.2k
  zend_llist_clean(&PG(tick_functions));
32
38.2k
}
33
34
void php_shutdown_ticks(php_core_globals *core_globals)
35
0
{
36
0
  zend_llist_destroy(&core_globals->tick_functions);
37
0
}
38
39
static int php_compare_tick_functions(void *elem1, void *elem2)
40
0
{
41
0
  struct st_tick_function *e1 = (struct st_tick_function *)elem1;
42
0
  struct st_tick_function *e2 = (struct st_tick_function *)elem2;
43
0
  return e1->func == e2->func && e1->arg == e2->arg;
44
0
}
45
46
PHPAPI void php_add_tick_function(void (*func)(int, void*), void * arg)
47
0
{
48
0
  struct st_tick_function tmp = {func, arg};
49
0
  zend_llist_add_element(&PG(tick_functions), (void *)&tmp);
50
0
}
51
52
PHPAPI void php_remove_tick_function(void (*func)(int, void *), void * arg)
53
0
{
54
0
  struct st_tick_function tmp = {func, arg};
55
0
  zend_llist_del_element(&PG(tick_functions), (void *)&tmp, (int(*)(void*, void*))php_compare_tick_functions);
56
0
}
57
58
static void php_tick_iterator(void *d, void *arg)
59
0
{
60
0
  struct st_tick_function *data = (struct st_tick_function *)d;
61
0
  data->func(*((int *)arg), data->arg);
62
0
}
63
64
void php_run_ticks(int count)
65
0
{
66
0
  zend_llist_apply_with_argument(&PG(tick_functions), (llist_apply_with_arg_func_t) php_tick_iterator, &count);
67
0
}