xref: /php-src/ext/zend_test/php_test.h (revision f4557b48)
1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) The PHP Group                                          |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | https://www.php.net/license/3_01.txt                                 |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Author:                                                              |
14   +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_TEST_H
18 #define PHP_TEST_H
19 
20 #include "fiber.h"
21 
22 extern zend_module_entry zend_test_module_entry;
23 #define phpext_zend_test_ptr &zend_test_module_entry
24 
25 #define PHP_ZEND_TEST_VERSION "0.1.0"
26 
27 #ifdef ZTS
28 #include "TSRM.h"
29 #endif
30 
31 #if defined(ZTS) && defined(COMPILE_DL_ZEND_TEST)
32 ZEND_TSRMLS_CACHE_EXTERN()
33 #endif
34 
35 ZEND_BEGIN_MODULE_GLOBALS(zend_test)
36 	int observer_enabled;
37 	int observer_show_output;
38 	int observer_observe_all;
39 	int observer_observe_includes;
40 	int observer_observe_functions;
41 	int observer_observe_declaring;
42 	zend_array *observer_observe_function_names;
43 	int observer_show_return_type;
44 	int observer_show_return_value;
45 	int observer_show_init_backtrace;
46 	int observer_show_opcode;
47 	char *observer_show_opcode_in_user_handler;
48 	int observer_nesting_depth;
49 	int observer_fiber_init;
50 	int observer_fiber_switch;
51 	int observer_fiber_destroy;
52 	int observer_execute_internal;
53 	HashTable global_weakmap;
54 	int replace_zend_execute_ex;
55 	int register_passes;
56 	bool print_stderr_mshutdown;
57 	zend_long limit_copy_file_range;
58 	int observe_opline_in_zendmm;
59 	zend_mm_heap* zend_orig_heap;
60 	zend_mm_heap* zend_test_heap;
61 	zend_test_fiber *active_fiber;
62 	zend_long quantity_value;
63 	zend_string *str_test;
64 	zend_string *not_empty_str_test;
65 	int zend_mm_custom_handlers_enabled;
66 
67 	// the previous heap that was found in ZendMM
68 	zend_mm_heap* original_heap;
69 	// the custom handlers that might have been found in the previous heap
70 	void* (*custom_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
71 	void (*custom_free)(void* ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
72 	void* (*custom_realloc)(void *, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
73 	size_t (*custom_gc)(void);
74 	void (*custom_shutdown)(bool, bool);
75 	// this is our heap that we install our custom handlers on and inject into
76 	// ZendMM
77 	zend_mm_heap* observed_heap;
78 ZEND_END_MODULE_GLOBALS(zend_test)
79 
80 extern ZEND_DECLARE_MODULE_GLOBALS(zend_test)
81 
82 #define ZT_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(zend_test, v)
83 
84 struct bug79096 {
85 	uint64_t a;
86 	uint64_t b;
87 };
88 
89 #ifdef PHP_WIN32
90 #	define PHP_ZEND_TEST_API __declspec(dllexport)
91 #elif defined(__GNUC__) && __GNUC__ >= 4
92 #	define PHP_ZEND_TEST_API __attribute__ ((visibility("default")))
93 #else
94 #	define PHP_ZEND_TEST_API
95 #endif
96 
97 PHP_ZEND_TEST_API int ZEND_FASTCALL bug78270(const char *str, size_t str_len);
98 
99 PHP_ZEND_TEST_API struct bug79096 bug79096(void);
100 PHP_ZEND_TEST_API void bug79532(off_t *array, size_t elems);
101 
102 extern PHP_ZEND_TEST_API int *(*bug79177_cb)(void);
103 PHP_ZEND_TEST_API void bug79177(void);
104 
105 #endif
106