flush
[m6w6/ext-psi] / src / module.c
1
2 #ifdef HAVE_CONFIG_H
3 #include "config.h"
4 #endif
5
6 #include <jit/jit.h>
7
8 #include "php.h"
9 #include "php_ini.h"
10 #include "ext/standard/info.h"
11 #include "php_psi.h"
12
13 ZEND_DECLARE_MODULE_GLOBALS(psi);
14
15 PHP_INI_BEGIN()
16 STD_PHP_INI_ENTRY("psi.directory", "psis", PHP_INI_ALL, OnUpdateString, directory, zend_psi_globals, psi_globals)
17 PHP_INI_END();
18
19 PHP_MINIT_FUNCTION(psi)
20 {
21 jit_context_t ctx;
22
23 REGISTER_INI_ENTRIES();
24
25 jit_init();
26
27 if (!(ctx = jit_context_create())) {
28 zend_error(E_WARNING, "Could not initialize libjit!");
29 return FAILURE;
30 }
31
32 PSI_G(context) = ctx;
33
34 return SUCCESS;
35 }
36 PHP_MSHUTDOWN_FUNCTION(psi)
37 {
38 jit_context_t *ctx = PSI_G(context);
39
40 jit_context_destroy(ctx);
41
42 UNREGISTER_INI_ENTRIES();
43
44 return SUCCESS;
45 }
46
47 /* Remove if there's nothing to do at request start */
48 /* {{{ PHP_RINIT_FUNCTION
49 */
50 PHP_RINIT_FUNCTION(psi)
51 {
52 #if defined(COMPILE_DL_PSI) && defined(ZTS)
53 ZEND_TSRMLS_CACHE_UPDATE();
54 #endif
55 return SUCCESS;
56 }
57 /* }}} */
58
59 /* Remove if there's nothing to do at request end */
60 /* {{{ PHP_RSHUTDOWN_FUNCTION
61 */
62 PHP_RSHUTDOWN_FUNCTION(psi)
63 {
64 return SUCCESS;
65 }
66 /* }}} */
67
68 PHP_MINFO_FUNCTION(psi)
69 {
70 php_info_print_table_start();
71 php_info_print_table_header(2, "psi support", "enabled");
72 php_info_print_table_end();
73
74 DISPLAY_INI_ENTRIES();
75 }
76 const zend_function_entry psi_functions[] = {
77 PHP_FE_END
78 };
79
80 zend_module_entry psi_module_entry = {
81 STANDARD_MODULE_HEADER,
82 "psi",
83 psi_functions,
84 PHP_MINIT(psi),
85 PHP_MSHUTDOWN(psi),
86 PHP_RINIT(psi), /* Replace with NULL if there's nothing to do at request start */
87 PHP_RSHUTDOWN(psi), /* Replace with NULL if there's nothing to do at request end */
88 PHP_MINFO(psi),
89 PHP_PSI_VERSION,
90 STANDARD_MODULE_PROPERTIES
91 };
92
93 #ifdef COMPILE_DL_PSI
94 #ifdef ZTS
95 ZEND_TSRMLS_CACHE_DEFINE();
96 #endif
97 ZEND_GET_MODULE(psi)
98 #endif
99
100 /*
101 * Local variables:
102 * tab-width: 4
103 * c-basic-offset: 4
104 * End:
105 * vim600: noet sw=4 ts=4 fdm=marker
106 * vim<600: noet sw=4 ts=4
107 */