Skip to content

Commit 2150cb9

Browse files
author
Ion Bazan
committed
Merged PHP7 and PHP7 code - first step
1 parent 22442e5 commit 2150cb9

File tree

7 files changed

+822
-1854
lines changed

7 files changed

+822
-1854
lines changed

config.m4

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,5 @@ if test "$PHP_TIMECOP" != "no"; then
3535
AC_MSG_RESULT([$PHP_VERSION])
3636
fi
3737

38-
if test "$PHP_MAJOR_VERSION" -eq 5; then
39-
PHP_NEW_EXTENSION(timecop, timecop_php5.c tc_timeval.c, $ext_shared)
40-
else
41-
PHP_NEW_EXTENSION(timecop, timecop_php7.c tc_timeval.c, $ext_shared)
42-
fi
38+
PHP_NEW_EXTENSION(timecop, timecop.c tc_timeval.c, $ext_shared)
4339
fi

config.w32

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,5 @@
44
ARG_ENABLE("timecop", "enable timecop support", "no");
55

66
if (PHP_TIMECOP != "no") {
7-
if (PHP_VERSION <= 5) {
8-
EXTENSION("timecop", "timecop_php5.c tc_timeval.c");
9-
} else {
10-
EXTENSION("timecop", "timecop_php7.c tc_timeval.c");
11-
}
7+
EXTENSION("timecop", "timecop.c tc_timeval.c");
128
}
13-

tc_timeval.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ SOFTWARE.
2626

2727
int tc_timeval_add(tc_timeval *ret, const tc_timeval *arg1, const tc_timeval *arg2)
2828
{
29-
#if PHP_MAJOR_VERSION >= 7
3029
zend_long sec, usec;
31-
#else
32-
long sec, usec;
33-
#endif
3430
usec = arg1->usec + arg2->usec;
3531
sec = arg1->sec + arg2->sec;
3632
if (usec < 0) {
@@ -51,11 +47,7 @@ int tc_timeval_add(tc_timeval *ret, const tc_timeval *arg1, const tc_timeval *ar
5147
}
5248
int tc_timeval_sub(tc_timeval *ret, const tc_timeval *arg1, const tc_timeval *arg2)
5349
{
54-
#if PHP_MAJOR_VERSION >= 7
5550
zend_long sec, usec;
56-
#else
57-
long sec, usec;
58-
#endif
5951
usec = arg1->usec - arg2->usec;
6052
sec = arg1->sec - arg2->sec;
6153
if (usec < 0) {
@@ -75,17 +67,9 @@ int tc_timeval_sub(tc_timeval *ret, const tc_timeval *arg1, const tc_timeval *ar
7567
return 0;
7668
}
7769

78-
#if PHP_MAJOR_VERSION >= 7
7970
int tc_timeval_mul(tc_timeval *ret, const tc_timeval *arg1, const zend_long arg2)
80-
#else
81-
int tc_timeval_mul(tc_timeval *ret, const tc_timeval *arg1, const long arg2)
82-
#endif
8371
{
84-
#if PHP_MAJOR_VERSION >= 7
8572
zend_long sec, usec;
86-
#else
87-
long sec, usec;
88-
#endif
8973
usec = arg1->usec * arg2;
9074
sec = arg1->sec * arg2;
9175
if (usec < 0) {

tc_timeval.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,19 @@ SOFTWARE.
2929
# define USEC_PER_SEC 1000000
3030
#endif
3131

32+
#if PHP_MAJOR_VERSION < 7
33+
typedef long zend_long;
34+
#endif
35+
3236
typedef struct _tc_timeval {
33-
#if PHP_MAJOR_VERSION >= 7
3437
zend_long sec;
3538
zend_long usec;
36-
#else
37-
long sec;
38-
long usec;
39-
#endif
4039
} tc_timeval;
4140

4241

4342
int tc_timeval_add(tc_timeval *ret, const tc_timeval *arg1, const tc_timeval *arg2);
4443
int tc_timeval_sub(tc_timeval *ret, const tc_timeval *arg1, const tc_timeval *arg2);
45-
#if PHP_MAJOR_VERSION >= 7
4644
int tc_timeval_mul(tc_timeval *ret, const tc_timeval *arg1, const zend_long arg2);
47-
#else
48-
int tc_timeval_mul(tc_timeval *ret, const tc_timeval *arg1, const long arg2);
49-
#endif
5045

5146
#endif /* TC_TIMEVAL_H */
5247

0 commit comments

Comments
 (0)