44918f057db2b78cfef4af9c1c3bcbfd21891021
[m6w6/ext-psi] / php_psi.h
1 #ifndef PHP_PSI_H
2 #define PHP_PSI_H
3
4 extern zend_module_entry psi_module_entry;
5 #define phpext_psi_ptr &psi_module_entry
6
7 #define PHP_PSI_VERSION "0.1.0"
8
9 #ifdef PHP_WIN32
10 # define PHP_PSI_API __declspec(dllexport)
11 #elif defined(__GNUC__) && __GNUC__ >= 4
12 # define PHP_PSI_API __attribute__ ((visibility("default")))
13 #else
14 # define PHP_PSI_API
15 #endif
16
17 #ifdef ZTS
18 #include "TSRM.h"
19 #endif
20
21 #include "context.h"
22
23 void psi_error_wrapper(PSI_Token *t, int type, const char *msg, ...);
24 void psi_error(int type, const char *fn, unsigned ln, const char *msg, ...);
25 void psi_verror(int type, const char *fn, unsigned ln, const char *msg, va_list argv);
26
27 static inline int psi_check_env(const char *var) {
28 char *set = getenv(var);
29 return (set && *set && '0' != *set);
30 }
31
32 typedef struct psi_object {
33 void *data;
34 size_t size;
35 zend_object std;
36 } psi_object;
37
38 static inline psi_object *PSI_OBJ(zval *zv, zend_object *zo) {
39 if (zv) {
40 zo = Z_OBJ_P(zv);
41 }
42 return (void *) (((char *) zo) - zo->handlers->offset);
43 }
44
45 PHP_PSI_API zend_class_entry *psi_object_get_class_entry();
46
47 ZEND_BEGIN_MODULE_GLOBALS(psi)
48 char *engine;
49 char *directory;
50 PSI_Context context;
51 ZEND_END_MODULE_GLOBALS(psi);
52
53 ZEND_EXTERN_MODULE_GLOBALS(psi);
54
55 #define PSI_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(psi, v)
56
57 #if defined(ZTS) && defined(COMPILE_DL_PSI)
58 ZEND_TSRMLS_CACHE_EXTERN();
59 #endif
60
61 #endif /* PHP_PSI_H */
62
63
64 /*
65 * Local variables:
66 * tab-width: 4
67 * c-basic-offset: 4
68 * End:
69 * vim600: noet sw=4 ts=4 fdm=marker
70 * vim<600: noet sw=4 ts=4
71 */