build: generate package.xml
[m6w6/ext-psi] / php_psi.h
1 /*******************************************************************************
2 Copyright (c) 2016, Michael Wallner <mike@php.net>.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
18 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *******************************************************************************/
25
26 #ifndef PHP_PSI_H
27 #define PHP_PSI_H
28
29 extern zend_module_entry psi_module_entry;
30 #define phpext_psi_ptr &psi_module_entry
31
32 #define PHP_PSI_VERSION "0.1.0"
33
34 #ifdef PHP_WIN32
35 # define PHP_PSI_API __declspec(dllexport)
36 #elif defined(__GNUC__) && __GNUC__ >= 4
37 # define PHP_PSI_API __attribute__ ((visibility("default")))
38 #else
39 # define PHP_PSI_API
40 #endif
41
42 #ifdef ZTS
43 #include "TSRM.h"
44 #endif
45
46 static inline int psi_check_env(const char *var) {
47 char *set = getenv(var);
48 return (set && *set && '0' != *set);
49 }
50
51 typedef struct psi_object {
52 void *data;
53 void (*dtor)(void *data);
54 size_t size;
55 zend_object std;
56 } psi_object;
57
58 static inline psi_object *PSI_OBJ(zval *zv, zend_object *zo) {
59 if (zv) {
60 zo = Z_OBJ_P(zv);
61 }
62 if (!zo) {
63 return NULL;
64 }
65 return (void *) (((char *) zo) - zo->handlers->offset);
66 }
67
68 PHP_PSI_API zend_object *psi_object_init(zend_class_entry *ce);
69 PHP_PSI_API zend_object *psi_object_init_ex(zend_class_entry *ce, void *data, void (*dtor)(void *));
70 PHP_PSI_API zend_class_entry *psi_object_get_class_entry();
71
72 ZEND_BEGIN_MODULE_GLOBALS(psi)
73 char *engine;
74 char *directory;
75 struct psi_context *context;
76 ZEND_END_MODULE_GLOBALS(psi);
77
78 ZEND_EXTERN_MODULE_GLOBALS(psi);
79
80 #define PSI_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(psi, v)
81
82 #if defined(ZTS) && defined(COMPILE_DL_PSI)
83 ZEND_TSRMLS_CACHE_EXTERN();
84 #endif
85
86 #endif /* PHP_PSI_H */
87
88
89 /*
90 * Local variables:
91 * tab-width: 4
92 * c-basic-offset: 4
93 * End:
94 * vim600: noet sw=4 ts=4 fdm=marker
95 * vim<600: noet sw=4 ts=4
96 */