This source file includes following definitions.
- php_startup_ticks
- php_deactivate_ticks
- php_shutdown_ticks
- php_compare_tick_functions
- php_add_tick_function
- php_remove_tick_function
- php_tick_iterator
- php_run_ticks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "php.h"
22 #include "php_ticks.h"
23
24 int php_startup_ticks(TSRMLS_D)
25 {
26 zend_llist_init(&PG(tick_functions), sizeof(void(*)(int)), NULL, 1);
27 return SUCCESS;
28 }
29
30 void php_deactivate_ticks(TSRMLS_D)
31 {
32 zend_llist_clean(&PG(tick_functions));
33 }
34
35 void php_shutdown_ticks(TSRMLS_D)
36 {
37 zend_llist_destroy(&PG(tick_functions));
38 }
39
40 static int php_compare_tick_functions(void *elem1, void *elem2)
41 {
42 void(*func1)(int);
43 void(*func2)(int);
44 memcpy(&func1, elem1, sizeof(void(*)(int)));
45 memcpy(&func2, elem2, sizeof(void(*)(int)));
46 return (func1 == func2);
47 }
48
49 PHPAPI void php_add_tick_function(void (*func)(int))
50 {
51 TSRMLS_FETCH();
52
53 zend_llist_add_element(&PG(tick_functions), (void *)&func);
54 }
55
56 PHPAPI void php_remove_tick_function(void (*func)(int))
57 {
58 TSRMLS_FETCH();
59
60 zend_llist_del_element(&PG(tick_functions), (void *)func,
61 (int(*)(void*, void*))php_compare_tick_functions);
62 }
63
64 static void php_tick_iterator(void *data, void *arg TSRMLS_DC)
65 {
66 void (*func)(int);
67
68 memcpy(&func, data, sizeof(void(*)(int)));
69 func(*((int *)arg));
70 }
71
72 void php_run_ticks(int count)
73 {
74 TSRMLS_FETCH();
75
76 zend_llist_apply_with_argument(&PG(tick_functions), (llist_apply_with_arg_func_t) php_tick_iterator, &count TSRMLS_CC);
77 }
78
79
80
81
82
83
84
85
86