@@ -35,19 +35,12 @@ SOFTWARE.
3535#include "php_ini.h"
3636#include "ext/standard/info.h"
3737
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-
4538#ifdef PHP_WIN32
46- # define PHP_TIMECOP_API __declspec(dllexport)
39+ # define PHP_TIMECOP_API __declspec(dllexport)
4740#elif defined(__GNUC__ ) && __GNUC__ >= 4
48- # define PHP_TIMECOP_API __attribute__ ((visibility("default")))
41+ # define PHP_TIMECOP_API __attribute__ ((visibility("default")))
4942#else
50- # define PHP_TIMECOP_API
43+ # define PHP_TIMECOP_API
5144#endif
5245
5346#ifdef ZTS
@@ -63,6 +56,10 @@ extern zend_module_entry timecop_module_entry;
6356#include "Zend/zend_interfaces.h"
6457#include "tc_timeval.h"
6558
59+
60+ extern zend_module_entry timecop_module_entry ;
61+ #define phpext_timecop_ptr &timecop_module_entry
62+
6663PHP_MINIT_FUNCTION (timecop );
6764PHP_MSHUTDOWN_FUNCTION (timecop );
6865PHP_RINIT_FUNCTION (timecop );
@@ -112,30 +109,30 @@ PHP_METHOD(Timecop, freeze);
112109PHP_METHOD (Timecop , travel );
113110
114111typedef 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
118115} timecop_mode_t ;
119116
120117ZEND_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 ;
125122#else
126- zval * orig_request_time ;
123+ zval * orig_request_time ;
127124#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 ;
139136ZEND_END_MODULE_GLOBALS (timecop )
140137
141138#if ZEND_DEBUG
@@ -150,23 +147,23 @@ ZEND_END_MODULE_GLOBALS(timecop)
150147#define OVRD_CLASS_PREFIX "timecop"
151148
152149#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)
154151
155152#define TIMECOP_OFE (fname ) {fname, OVRD_FUNC_PREFIX fname, SAVE_FUNC_PREFIX fname}
156153#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}
158155
159156struct 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 ;
163160};
164161
165162struct 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 ;
170167};
171168
172169static 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
229226
230227#if PHP_MAJOR_VERSION >= 7
231228#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)
233230#else
234231#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)
236233#endif
237234
238235#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)
240237
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)
243240
244241#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)
246243
247244#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)
249246
250247#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)
252249
253250#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)
255252
256253#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)
258255
259256#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)
261258
262259/* In every utility function you add that needs to use variables
263260 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
282279# endif
283280#endif
284281
285- #endif /* PHP_TIMECOP_H */
282+ #endif /* PHP_TIMECOP_H */
286283
287284/*
288285 * Local variables:
0 commit comments