@@ -35,19 +35,12 @@ SOFTWARE.
35
35
#include "php_ini.h"
36
36
#include "ext/standard/info.h"
37
37
38
- #if !defined(PHP_VERSION_ID ) || PHP_VERSION_ID < 50300
39
- #include "ext/date/lib/timelib.h"
40
- #endif
41
-
42
- extern zend_module_entry timecop_module_entry ;
43
- #define phpext_timecop_ptr &timecop_module_entry
44
-
45
38
#ifdef PHP_WIN32
46
- # define PHP_TIMECOP_API __declspec(dllexport)
39
+ # define PHP_TIMECOP_API __declspec(dllexport)
47
40
#elif defined(__GNUC__ ) && __GNUC__ >= 4
48
- # define PHP_TIMECOP_API __attribute__ ((visibility("default")))
41
+ # define PHP_TIMECOP_API __attribute__ ((visibility("default")))
49
42
#else
50
- # define PHP_TIMECOP_API
43
+ # define PHP_TIMECOP_API
51
44
#endif
52
45
53
46
#ifdef ZTS
@@ -63,6 +56,10 @@ extern zend_module_entry timecop_module_entry;
63
56
#include "Zend/zend_interfaces.h"
64
57
#include "tc_timeval.h"
65
58
59
+
60
+ extern zend_module_entry timecop_module_entry ;
61
+ #define phpext_timecop_ptr &timecop_module_entry
62
+
66
63
PHP_MINIT_FUNCTION (timecop );
67
64
PHP_MSHUTDOWN_FUNCTION (timecop );
68
65
PHP_RINIT_FUNCTION (timecop );
@@ -112,30 +109,30 @@ PHP_METHOD(Timecop, freeze);
112
109
PHP_METHOD (Timecop , travel );
113
110
114
111
typedef enum timecop_mode_t {
115
- TIMECOP_MODE_REALTIME ,
116
- TIMECOP_MODE_FREEZE ,
117
- TIMECOP_MODE_TRAVEL
112
+ TIMECOP_MODE_REALTIME ,
113
+ TIMECOP_MODE_FREEZE ,
114
+ TIMECOP_MODE_TRAVEL
118
115
} timecop_mode_t ;
119
116
120
117
ZEND_BEGIN_MODULE_GLOBALS (timecop )
121
- long func_override ;
122
- long sync_request_time ;
123
- #if PHP_VERSION_ID >= 70000
124
- zval orig_request_time ;
118
+ long func_override ;
119
+ long sync_request_time ;
120
+ #if PHP_MAJOR_VERSION >= 7
121
+ zval orig_request_time ;
125
122
#else
126
- zval * orig_request_time ;
123
+ zval * orig_request_time ;
127
124
#endif
128
- timecop_mode_t timecop_mode ;
129
- tc_timeval freezed_time ;
130
- tc_timeval travel_origin ;
131
- tc_timeval travel_offset ;
132
- zend_long scaling_factor ;
133
- zend_class_entry * ce_DateTimeZone ;
134
- zend_class_entry * ce_DateTimeInterface ;
135
- zend_class_entry * ce_DateTime ;
136
- zend_class_entry * ce_TimecopDateTime ;
137
- zend_class_entry * ce_DateTimeImmutable ;
138
- zend_class_entry * ce_TimecopDateTimeImmutable ;
125
+ timecop_mode_t timecop_mode ;
126
+ tc_timeval freezed_time ;
127
+ tc_timeval travel_origin ;
128
+ tc_timeval travel_offset ;
129
+ zend_long scaling_factor ;
130
+ zend_class_entry * ce_DateTimeZone ;
131
+ zend_class_entry * ce_DateTimeInterface ;
132
+ zend_class_entry * ce_DateTime ;
133
+ zend_class_entry * ce_TimecopDateTime ;
134
+ zend_class_entry * ce_DateTimeImmutable ;
135
+ zend_class_entry * ce_TimecopDateTimeImmutable ;
139
136
ZEND_END_MODULE_GLOBALS (timecop )
140
137
141
138
#if ZEND_DEBUG
@@ -150,23 +147,23 @@ ZEND_END_MODULE_GLOBALS(timecop)
150
147
#define OVRD_CLASS_PREFIX "timecop"
151
148
152
149
#define ORIG_FUNC_NAME (fname ) \
153
- (TIMECOP_G(func_override) ? (SAVE_FUNC_PREFIX fname) : fname)
150
+ (TIMECOP_G(func_override) ? (SAVE_FUNC_PREFIX fname) : fname)
154
151
155
152
#define TIMECOP_OFE (fname ) {fname, OVRD_FUNC_PREFIX fname, SAVE_FUNC_PREFIX fname}
156
153
#define TIMECOP_OCE (cname , mname ) \
157
- {cname, mname, OVRD_CLASS_PREFIX cname, SAVE_FUNC_PREFIX mname}
154
+ {cname, mname, OVRD_CLASS_PREFIX cname, SAVE_FUNC_PREFIX mname}
158
155
159
156
struct timecop_override_func_entry {
160
- char * orig_func ;
161
- char * ovrd_func ;
162
- char * save_func ;
157
+ char * orig_func ;
158
+ char * ovrd_func ;
159
+ char * save_func ;
163
160
};
164
161
165
162
struct timecop_override_class_entry {
166
- char * orig_class ;
167
- char * orig_method ;
168
- char * ovrd_class ;
169
- char * save_method ;
163
+ char * orig_class ;
164
+ char * orig_method ;
165
+ char * ovrd_class ;
166
+ char * save_method ;
170
167
};
171
168
172
169
static void timecop_globals_ctor (zend_timecop_globals * globals TSRMLS_DC );
@@ -229,35 +226,35 @@ static inline void _call_php_function_with_params(const char *function_name, zva
229
226
230
227
#if PHP_MAJOR_VERSION >= 7
231
228
#define register_internal_class_ex (class_entry , parent_ce ) \
232
- zend_register_internal_class_ex(class_entry, parent_ce)
229
+ zend_register_internal_class_ex(class_entry, parent_ce)
233
230
#else
234
231
#define register_internal_class_ex (class_entry , parent_ce ) \
235
- zend_register_internal_class_ex(class_entry, parent_ce, NULL TSRMLS_CC)
232
+ zend_register_internal_class_ex(class_entry, parent_ce, NULL TSRMLS_CC)
236
233
#endif
237
234
238
235
#define call_php_method_with_0_params (obj , ce , method_name , retval ) \
239
- _call_php_method_with_0_params(obj, ce, method_name, retval TSRMLS_CC)
236
+ _call_php_method_with_0_params(obj, ce, method_name, retval TSRMLS_CC)
240
237
241
- #define call_php_method_with_1_params (obj , ce , method_name , retval , arg1 ) \
242
- _call_php_method_with_1_params(obj, ce, method_name, retval, arg1 TSRMLS_CC)
238
+ #define call_php_method_with_1_params (obj , ce , method_name , retval , arg1 ) \
239
+ _call_php_method_with_1_params(obj, ce, method_name, retval, arg1 TSRMLS_CC)
243
240
244
241
#define call_php_method_with_2_params (obj , ce , method_name , retval , arg1 , arg2 ) \
245
- _call_php_method_with_2_params(obj, ce, method_name, retval, arg1, arg2 TSRMLS_CC)
242
+ _call_php_method_with_2_params(obj, ce, method_name, retval, arg1, arg2 TSRMLS_CC)
246
243
247
244
#define call_php_function_with_0_params (function_name , retval ) \
248
- _call_php_function_with_0_params(function_name, retval TSRMLS_CC)
245
+ _call_php_function_with_0_params(function_name, retval TSRMLS_CC)
249
246
250
247
#define call_php_function_with_1_params (function_name , retval , arg1 ) \
251
- _call_php_function_with_1_params(function_name, retval, arg1 TSRMLS_CC)
248
+ _call_php_function_with_1_params(function_name, retval, arg1 TSRMLS_CC)
252
249
253
250
#define call_php_function_with_2_params (function_name , retval , arg1 , arg2 ) \
254
- _call_php_function_with_2_params(function_name, retval, arg1, arg2 TSRMLS_CC)
251
+ _call_php_function_with_2_params(function_name, retval, arg1, arg2 TSRMLS_CC)
255
252
256
253
#define call_php_function_with_3_params (function_name , retval , arg1 , arg2 , arg3 ) \
257
- _call_php_function_with_3_params(function_name, retval, arg1, arg2, arg3 TSRMLS_CC)
254
+ _call_php_function_with_3_params(function_name, retval, arg1, arg2, arg3 TSRMLS_CC)
258
255
259
256
#define call_php_function_with_params (function_name , retval , param_count , params ) \
260
- _call_php_function_with_params(function_name, retval, param_count, params TSRMLS_CC)
257
+ _call_php_function_with_params(function_name, retval, param_count, params TSRMLS_CC)
261
258
262
259
/* In every utility function you add that needs to use variables
263
260
in php_timecop_globals, call TSRMLS_FETCH(); after declaring other
@@ -282,7 +279,7 @@ static inline void _call_php_function_with_params(const char *function_name, zva
282
279
# endif
283
280
#endif
284
281
285
- #endif /* PHP_TIMECOP_H */
282
+ #endif /* PHP_TIMECOP_H */
286
283
287
284
/*
288
285
* Local variables:
0 commit comments