line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
* This file was generated automatically by ExtUtils::ParseXS version 3.34 from the |
3
|
|
|
|
|
|
|
* contents of MyTest.xs. Do not edit this file, edit MyTest.xs instead. |
4
|
|
|
|
|
|
|
* |
5
|
|
|
|
|
|
|
* ANY CHANGES MADE HERE WILL BE LOST! |
6
|
|
|
|
|
|
|
* |
7
|
|
|
|
|
|
|
*/ |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#line 1 "t/lib/MyTest.xs" |
10
|
|
|
|
|
|
|
#include |
11
|
|
|
|
|
|
|
#include |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
using namespace xs; |
14
|
|
|
|
|
|
|
using namespace panda::time; |
15
|
|
|
|
|
|
|
using panda::string; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#ifdef _WIN32 |
18
|
|
|
|
|
|
|
# define SYSTIMEGM(x) _mkgmtime(x) |
19
|
|
|
|
|
|
|
# define SYSTIMELOCAL(x) mktime(x) |
20
|
|
|
|
|
|
|
#else |
21
|
|
|
|
|
|
|
# define SYSTIMEGM(x) timegm(x) |
22
|
|
|
|
|
|
|
# define SYSTIMELOCAL(x) timelocal(x) |
23
|
|
|
|
|
|
|
#endif |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#line 26 "t/lib/MyTest.xs.cc" |
26
|
|
|
|
|
|
|
#ifndef PERL_UNUSED_VAR |
27
|
|
|
|
|
|
|
# define PERL_UNUSED_VAR(var) if (0) var = var |
28
|
|
|
|
|
|
|
#endif |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#ifndef dVAR |
31
|
|
|
|
|
|
|
# define dVAR dNOOP |
32
|
|
|
|
|
|
|
#endif |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
/* This stuff is not part of the API! You have been warned. */ |
36
|
|
|
|
|
|
|
#ifndef PERL_VERSION_DECIMAL |
37
|
|
|
|
|
|
|
# define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s) |
38
|
|
|
|
|
|
|
#endif |
39
|
|
|
|
|
|
|
#ifndef PERL_DECIMAL_VERSION |
40
|
|
|
|
|
|
|
# define PERL_DECIMAL_VERSION \ |
41
|
|
|
|
|
|
|
PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION) |
42
|
|
|
|
|
|
|
#endif |
43
|
|
|
|
|
|
|
#ifndef PERL_VERSION_GE |
44
|
|
|
|
|
|
|
# define PERL_VERSION_GE(r,v,s) \ |
45
|
|
|
|
|
|
|
(PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s)) |
46
|
|
|
|
|
|
|
#endif |
47
|
|
|
|
|
|
|
#ifndef PERL_VERSION_LE |
48
|
|
|
|
|
|
|
# define PERL_VERSION_LE(r,v,s) \ |
49
|
|
|
|
|
|
|
(PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s)) |
50
|
|
|
|
|
|
|
#endif |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
/* XS_INTERNAL is the explicit static-linkage variant of the default |
53
|
|
|
|
|
|
|
* XS macro. |
54
|
|
|
|
|
|
|
* |
55
|
|
|
|
|
|
|
* XS_EXTERNAL is the same as XS_INTERNAL except it does not include |
56
|
|
|
|
|
|
|
* "STATIC", ie. it exports XSUB symbols. You probably don't want that |
57
|
|
|
|
|
|
|
* for anything but the BOOT XSUB. |
58
|
|
|
|
|
|
|
* |
59
|
|
|
|
|
|
|
* See XSUB.h in core! |
60
|
|
|
|
|
|
|
*/ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
/* TODO: This might be compatible further back than 5.10.0. */ |
64
|
|
|
|
|
|
|
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1) |
65
|
|
|
|
|
|
|
# undef XS_EXTERNAL |
66
|
|
|
|
|
|
|
# undef XS_INTERNAL |
67
|
|
|
|
|
|
|
# if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) |
68
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name) |
69
|
|
|
|
|
|
|
# define XS_INTERNAL(name) STATIC XSPROTO(name) |
70
|
|
|
|
|
|
|
# endif |
71
|
|
|
|
|
|
|
# if defined(__SYMBIAN32__) |
72
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) EXPORT_C XSPROTO(name) |
73
|
|
|
|
|
|
|
# define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name) |
74
|
|
|
|
|
|
|
# endif |
75
|
|
|
|
|
|
|
# ifndef XS_EXTERNAL |
76
|
|
|
|
|
|
|
# if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) |
77
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__) |
78
|
|
|
|
|
|
|
# define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__) |
79
|
|
|
|
|
|
|
# else |
80
|
|
|
|
|
|
|
# ifdef __cplusplus |
81
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) extern "C" XSPROTO(name) |
82
|
|
|
|
|
|
|
# define XS_INTERNAL(name) static XSPROTO(name) |
83
|
|
|
|
|
|
|
# else |
84
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) XSPROTO(name) |
85
|
|
|
|
|
|
|
# define XS_INTERNAL(name) STATIC XSPROTO(name) |
86
|
|
|
|
|
|
|
# endif |
87
|
|
|
|
|
|
|
# endif |
88
|
|
|
|
|
|
|
# endif |
89
|
|
|
|
|
|
|
#endif |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
/* perl >= 5.10.0 && perl <= 5.15.1 */ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
/* The XS_EXTERNAL macro is used for functions that must not be static |
95
|
|
|
|
|
|
|
* like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL |
96
|
|
|
|
|
|
|
* macro defined, the best we can do is assume XS is the same. |
97
|
|
|
|
|
|
|
* Dito for XS_INTERNAL. |
98
|
|
|
|
|
|
|
*/ |
99
|
|
|
|
|
|
|
#ifndef XS_EXTERNAL |
100
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) XS(name) |
101
|
|
|
|
|
|
|
#endif |
102
|
|
|
|
|
|
|
#ifndef XS_INTERNAL |
103
|
|
|
|
|
|
|
# define XS_INTERNAL(name) XS(name) |
104
|
|
|
|
|
|
|
#endif |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
/* Now, finally, after all this mess, we want an ExtUtils::ParseXS |
107
|
|
|
|
|
|
|
* internal macro that we're free to redefine for varying linkage due |
108
|
|
|
|
|
|
|
* to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use |
109
|
|
|
|
|
|
|
* XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to! |
110
|
|
|
|
|
|
|
*/ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#undef XS_EUPXS |
113
|
|
|
|
|
|
|
#if defined(PERL_EUPXS_ALWAYS_EXPORT) |
114
|
|
|
|
|
|
|
# define XS_EUPXS(name) XS_EXTERNAL(name) |
115
|
|
|
|
|
|
|
#else |
116
|
|
|
|
|
|
|
/* default to internal */ |
117
|
|
|
|
|
|
|
# define XS_EUPXS(name) XS_INTERNAL(name) |
118
|
|
|
|
|
|
|
#endif |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE |
121
|
|
|
|
|
|
|
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
/* prototype to pass -Wmissing-prototypes */ |
124
|
|
|
|
|
|
|
STATIC void |
125
|
|
|
|
|
|
|
S_croak_xs_usage(const CV *const cv, const char *const params); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
STATIC void |
128
|
|
|
|
|
|
|
S_croak_xs_usage(const CV *const cv, const char *const params) |
129
|
|
|
|
|
|
|
{ |
130
|
|
|
|
|
|
|
const GV *const gv = CvGV(cv); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
PERL_ARGS_ASSERT_CROAK_XS_USAGE; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
if (gv) { |
135
|
|
|
|
|
|
|
const char *const gvname = GvNAME(gv); |
136
|
|
|
|
|
|
|
const HV *const stash = GvSTASH(gv); |
137
|
|
|
|
|
|
|
const char *const hvname = stash ? HvNAME(stash) : NULL; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
if (hvname) |
140
|
|
|
|
|
|
|
Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params); |
141
|
|
|
|
|
|
|
else |
142
|
|
|
|
|
|
|
Perl_croak_nocontext("Usage: %s(%s)", gvname, params); |
143
|
|
|
|
|
|
|
} else { |
144
|
|
|
|
|
|
|
/* Pants. I don't think that it should be possible to get here. */ |
145
|
|
|
|
|
|
|
Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
#undef PERL_ARGS_ASSERT_CROAK_XS_USAGE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
#define croak_xs_usage S_croak_xs_usage |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
#endif |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
/* NOTE: the prototype of newXSproto() is different in versions of perls, |
155
|
|
|
|
|
|
|
* so we define a portable version of newXSproto() |
156
|
|
|
|
|
|
|
*/ |
157
|
|
|
|
|
|
|
#ifdef newXS_flags |
158
|
|
|
|
|
|
|
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0) |
159
|
|
|
|
|
|
|
#else |
160
|
|
|
|
|
|
|
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv) |
161
|
|
|
|
|
|
|
#endif /* !defined(newXS_flags) */ |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
#if PERL_VERSION_LE(5, 21, 5) |
164
|
|
|
|
|
|
|
# define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file) |
165
|
|
|
|
|
|
|
#else |
166
|
|
|
|
|
|
|
# define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b) |
167
|
|
|
|
|
|
|
#endif |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
#line 170 "t/lib/MyTest.xs.cc" |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
XS_EUPXS(XS_MyTest_systimegm) { xs::throw_guard(cv, [=]() |
173
|
|
|
|
|
|
|
{ |
174
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
175
|
0
|
|
|
|
|
|
dXSI32; |
176
|
0
|
0
|
|
|
|
|
if (items < 6 || items > 7) |
|
|
0
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "sec, min, hour, mday, mon, year, isdst= -1"); |
178
|
|
|
|
|
|
|
{ |
179
|
|
|
|
|
|
|
time_t RETVAL; |
180
|
0
|
0
|
|
|
|
|
dXSTARG; |
|
|
0
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
int64_t sec = (int64_t)SvIV(ST(0)) |
|
|
0
|
|
|
|
|
|
182
|
|
|
|
|
|
|
; |
183
|
0
|
0
|
|
|
|
|
int64_t min = (int64_t)SvIV(ST(1)) |
|
|
0
|
|
|
|
|
|
184
|
|
|
|
|
|
|
; |
185
|
0
|
0
|
|
|
|
|
int64_t hour = (int64_t)SvIV(ST(2)) |
|
|
0
|
|
|
|
|
|
186
|
|
|
|
|
|
|
; |
187
|
0
|
0
|
|
|
|
|
int64_t mday = (int64_t)SvIV(ST(3)) |
|
|
0
|
|
|
|
|
|
188
|
|
|
|
|
|
|
; |
189
|
0
|
0
|
|
|
|
|
int64_t mon = (int64_t)SvIV(ST(4)) |
|
|
0
|
|
|
|
|
|
190
|
|
|
|
|
|
|
; |
191
|
0
|
0
|
|
|
|
|
int64_t year = (int64_t)SvIV(ST(5)) |
|
|
0
|
|
|
|
|
|
192
|
|
|
|
|
|
|
; |
193
|
|
|
|
|
|
|
int64_t isdst; |
194
|
|
|
|
|
|
|
|
195
|
0
|
0
|
|
|
|
|
if (items < 7) |
196
|
0
|
|
|
|
|
|
isdst = -1; |
197
|
|
|
|
|
|
|
else { |
198
|
0
|
|
|
|
|
|
isdst = (int64_t)SvIV(ST(6)) |
199
|
0
|
0
|
|
|
|
|
; |
|
|
0
|
|
|
|
|
|
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
#line 20 "t/lib/MyTest.xs" |
202
|
|
|
|
|
|
|
struct tm date; |
203
|
|
|
|
|
|
|
date.tm_sec = sec; |
204
|
|
|
|
|
|
|
date.tm_min = min; |
205
|
|
|
|
|
|
|
date.tm_hour = hour; |
206
|
|
|
|
|
|
|
date.tm_mday = mday; |
207
|
|
|
|
|
|
|
date.tm_mon = mon; |
208
|
|
|
|
|
|
|
date.tm_year = year; |
209
|
|
|
|
|
|
|
date.tm_isdst = isdst; |
210
|
|
|
|
|
|
|
if (ix == 0) RETVAL = SYSTIMEGM(&date); |
211
|
|
|
|
|
|
|
else RETVAL = SYSTIMELOCAL(&date); |
212
|
|
|
|
|
|
|
#line 213 "t/lib/MyTest.xs.cc" |
213
|
0
|
0
|
|
|
|
|
XSprePUSH; PUSHi((IV)RETVAL); |
|
|
0
|
|
|
|
|
|
214
|
|
|
|
|
|
|
} |
215
|
0
|
|
|
|
|
|
XSRETURN(1); |
216
|
0
|
0
|
|
|
|
|
}); } |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
4
|
|
|
|
|
|
XS_EUPXS(XS_MyTest_strftime) { xs::throw_guard(cv, [=]() |
221
|
|
|
|
|
|
|
{ |
222
|
2
|
|
|
|
|
|
dVAR; dXSARGS; |
223
|
2
|
50
|
|
|
|
|
if (items != 2) |
224
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "fmt, epoch"); |
225
|
|
|
|
|
|
|
{ |
226
|
|
|
|
|
|
|
const char * RETVAL; |
227
|
2
|
50
|
|
|
|
|
dXSTARG; |
|
|
0
|
|
|
|
|
|
228
|
2
|
50
|
|
|
|
|
const char* fmt = (const char *)SvPV_nolen(ST(0)) |
|
|
0
|
|
|
|
|
|
229
|
|
|
|
|
|
|
; |
230
|
2
|
50
|
|
|
|
|
time_t epoch = (time_t)SvIV(ST(1)) |
|
|
0
|
|
|
|
|
|
231
|
|
|
|
|
|
|
; |
232
|
|
|
|
|
|
|
#line 33 "t/lib/MyTest.xs" |
233
|
|
|
|
|
|
|
char buf[100]; |
234
|
|
|
|
|
|
|
datetime date; |
235
|
|
|
|
|
|
|
localtime(epoch, &date); |
236
|
|
|
|
|
|
|
auto sz = strftime(buf, sizeof(buf), fmt, &date); |
237
|
|
|
|
|
|
|
if (!sz) croak("should not happen"); |
238
|
|
|
|
|
|
|
RETVAL = buf; |
239
|
|
|
|
|
|
|
#line 240 "t/lib/MyTest.xs.cc" |
240
|
2
|
50
|
|
|
|
|
sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
241
|
|
|
|
|
|
|
} |
242
|
2
|
|
|
|
|
|
XSRETURN(1); |
243
|
2
|
50
|
|
|
|
|
}); } |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
#ifndef _WIN32 |
246
|
|
|
|
|
|
|
#define XSubPPtmpAAAA 1 |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
XS_EUPXS(XS_MyTest_test_gmtime) { xs::throw_guard(cv, [=]() |
251
|
|
|
|
|
|
|
{ |
252
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
253
|
0
|
|
|
|
|
|
dXSI32; |
254
|
0
|
0
|
|
|
|
|
if (items != 3) |
255
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "step, from, till"); |
256
|
|
|
|
|
|
|
{ |
257
|
|
|
|
|
|
|
bool RETVAL; |
258
|
0
|
0
|
|
|
|
|
ptime_t step = (ptime_t)SvIV(ST(0)) |
|
|
0
|
|
|
|
|
|
259
|
|
|
|
|
|
|
; |
260
|
0
|
0
|
|
|
|
|
ptime_t from = (ptime_t)SvIV(ST(1)) |
|
|
0
|
|
|
|
|
|
261
|
|
|
|
|
|
|
; |
262
|
0
|
0
|
|
|
|
|
ptime_t till = (ptime_t)SvIV(ST(2)) |
|
|
0
|
|
|
|
|
|
263
|
|
|
|
|
|
|
; |
264
|
|
|
|
|
|
|
#line 44 "t/lib/MyTest.xs" |
265
|
|
|
|
|
|
|
datetime date1; |
266
|
|
|
|
|
|
|
struct tm date2; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
string tzname = ix == 0 ? string("GMT") : tzlocal()->name; |
269
|
|
|
|
|
|
|
char* hstr = getenv("HARNESS_ACTIVE"); |
270
|
|
|
|
|
|
|
bool test = (hstr != NULL && strlen(hstr) > 0); |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
static bool sranded = false; |
273
|
|
|
|
|
|
|
if (!sranded) { srand(time(NULL)); sranded = true; } |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
bool isrand = false; |
276
|
|
|
|
|
|
|
ptime_t disperse, epoch; |
277
|
|
|
|
|
|
|
if (step == 0) { |
278
|
|
|
|
|
|
|
isrand = true; |
279
|
|
|
|
|
|
|
disperse = from; |
280
|
|
|
|
|
|
|
step = 1; |
281
|
|
|
|
|
|
|
from = 0; |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
int cnt = 0; |
285
|
|
|
|
|
|
|
for (ptime_t i = from; i < till; i += step) { |
286
|
|
|
|
|
|
|
cnt++; |
287
|
|
|
|
|
|
|
memset(&date1, 0, sizeof(date1)); |
288
|
|
|
|
|
|
|
memset(&date2, 0, sizeof(date2)); |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
if (isrand) epoch = rand() % (2*disperse) - disperse; |
291
|
|
|
|
|
|
|
else epoch = i; |
292
|
|
|
|
|
|
|
time_t sys_epoch = (time_t) epoch; |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
if (ix == 0) { |
295
|
|
|
|
|
|
|
gmtime(epoch, &date1); |
296
|
|
|
|
|
|
|
gmtime_r(&sys_epoch, &date2); |
297
|
|
|
|
|
|
|
} else { |
298
|
|
|
|
|
|
|
localtime(epoch, &date1); |
299
|
|
|
|
|
|
|
localtime_r(&sys_epoch, &date2); |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
if (cnt % 100000 == 0 && !test) printf("TESTED #%d, last %04i-%02i-%02i %02i:%02i:%02i (off:%ld, dst=%d, zone=%s)\n", cnt, date2.tm_year+1900, date2.tm_mon+1, date2.tm_mday, date2.tm_hour, date2.tm_min, date2.tm_sec, date2.tm_gmtoff, date2.tm_isdst, date2.tm_zone); |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
if (date1.year != (date2.tm_year + 1900) || date1.mon != date2.tm_mon || date1.mday != date2.tm_mday || |
305
|
|
|
|
|
|
|
date1.hour != date2.tm_hour || date1.min != date2.tm_min || date1.sec != date2.tm_sec || |
306
|
|
|
|
|
|
|
date1.isdst != date2.tm_isdst || date1.gmtoff != date2.tm_gmtoff || strcmp(date1.zone, date2.tm_zone) != 0) { |
307
|
|
|
|
|
|
|
warn( |
308
|
|
|
|
|
|
|
"zone=%.*s, epoch=%lli, got %d-%02lld-%02lld %02lld:%02lld:%02lld %d %d %d %d %s, should be %d-%02d-%02d %02d:%02d:%02d %d %d %d %ld %s", |
309
|
|
|
|
|
|
|
(int)tzname.length(), tzname.data(), (long long)epoch, |
310
|
|
|
|
|
|
|
date1.year, (long long)date1.mon+1, (long long)date1.mday, (long long)date1.hour, (long long)date1.min, (long long)date1.sec, |
311
|
|
|
|
|
|
|
date1.wday, date1.yday, date1.isdst, date1.gmtoff, date1.zone, |
312
|
|
|
|
|
|
|
date2.tm_year+1900, date2.tm_mon+1, date2.tm_mday, date2.tm_hour, date2.tm_min, date2.tm_sec, |
313
|
|
|
|
|
|
|
date2.tm_wday, date2.tm_yday, date2.tm_isdst, date2.tm_gmtoff, date2.tm_zone |
314
|
|
|
|
|
|
|
); |
315
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
if (!test) printf("TESTED %d TIMES\n", cnt); |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
RETVAL = true; |
322
|
|
|
|
|
|
|
#line 323 "t/lib/MyTest.xs.cc" |
323
|
0
|
0
|
|
|
|
|
ST(0) = boolSV(RETVAL); |
|
|
0
|
|
|
|
|
|
324
|
|
|
|
|
|
|
} |
325
|
0
|
|
|
|
|
|
XSRETURN(1); |
326
|
0
|
0
|
|
|
|
|
}); } |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
|
330
|
0
|
|
|
|
|
|
XS_EUPXS(XS_MyTest_test_timegm) { xs::throw_guard(cv, [=]() |
331
|
|
|
|
|
|
|
{ |
332
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
333
|
0
|
|
|
|
|
|
dXSI32; |
334
|
0
|
0
|
|
|
|
|
if (items != 3) |
335
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "step, from, till"); |
336
|
|
|
|
|
|
|
{ |
337
|
|
|
|
|
|
|
bool RETVAL; |
338
|
0
|
0
|
|
|
|
|
ptime_t step = (ptime_t)SvIV(ST(0)) |
|
|
0
|
|
|
|
|
|
339
|
|
|
|
|
|
|
; |
340
|
0
|
0
|
|
|
|
|
ptime_t from = (ptime_t)SvIV(ST(1)) |
|
|
0
|
|
|
|
|
|
341
|
|
|
|
|
|
|
; |
342
|
0
|
0
|
|
|
|
|
ptime_t till = (ptime_t)SvIV(ST(2)) |
|
|
0
|
|
|
|
|
|
343
|
|
|
|
|
|
|
; |
344
|
|
|
|
|
|
|
#line 104 "t/lib/MyTest.xs" |
345
|
|
|
|
|
|
|
datetime date1; |
346
|
|
|
|
|
|
|
struct tm date2; |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
char* hstr = getenv("HARNESS_ACTIVE"); |
349
|
|
|
|
|
|
|
bool test = (hstr != NULL && strlen(hstr) > 0); |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
static bool sranded = false; |
352
|
|
|
|
|
|
|
if (!sranded) { srand(time(NULL)); sranded = true; } |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
bool isrand = false; |
355
|
|
|
|
|
|
|
ptime_t disperce_years; |
356
|
|
|
|
|
|
|
if (step == 0) { |
357
|
|
|
|
|
|
|
isrand = true; |
358
|
|
|
|
|
|
|
step = 1; |
359
|
|
|
|
|
|
|
disperce_years = from; |
360
|
|
|
|
|
|
|
if (disperce_years > 200) disperce_years = 200; |
361
|
|
|
|
|
|
|
from = 0; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
int cnt = 0; |
365
|
|
|
|
|
|
|
for (ptime_t i = from; step > 0 ? (i < till) : (i > till); i += step) { |
366
|
|
|
|
|
|
|
cnt++; |
367
|
|
|
|
|
|
|
bzero(&date1, sizeof(date1)); |
368
|
|
|
|
|
|
|
bzero(&date2, sizeof(date2)); |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
if (isrand) { |
371
|
|
|
|
|
|
|
if (ix == 0) { |
372
|
|
|
|
|
|
|
int rnum = rand(); |
373
|
|
|
|
|
|
|
date1.sec = rnum % 10000 - 5000; |
374
|
|
|
|
|
|
|
rnum /= 1000; |
375
|
|
|
|
|
|
|
date1.min = rnum % 10000 - 5000; |
376
|
|
|
|
|
|
|
rnum /= 1000; |
377
|
|
|
|
|
|
|
date1.hour = rnum % 100 - 50; |
378
|
|
|
|
|
|
|
rnum = rand(); |
379
|
|
|
|
|
|
|
date1.mday = rnum % 100 - 50; |
380
|
|
|
|
|
|
|
rnum /= 100; |
381
|
|
|
|
|
|
|
date1.mon = rnum % 100 - 50; |
382
|
|
|
|
|
|
|
rnum /= 100; |
383
|
|
|
|
|
|
|
date1.year = rnum % 200 + 1910; |
384
|
|
|
|
|
|
|
} else { // dont test denormalized values (LINUX has bugs with them + when using leap seconds zone, our normalization may differ with OS) |
385
|
|
|
|
|
|
|
int rnum = rand(); |
386
|
|
|
|
|
|
|
date1.sec = rnum % 60; |
387
|
|
|
|
|
|
|
rnum /= 1000; |
388
|
|
|
|
|
|
|
date1.min = rnum % 60; |
389
|
|
|
|
|
|
|
rnum /= 1000; |
390
|
|
|
|
|
|
|
date1.hour = rnum % 24; |
391
|
|
|
|
|
|
|
rnum = rand(); |
392
|
|
|
|
|
|
|
date1.mday = rnum % 31 + 1; |
393
|
|
|
|
|
|
|
rnum /= 100; |
394
|
|
|
|
|
|
|
date1.mon = rnum % 11; |
395
|
|
|
|
|
|
|
rnum /= 100; |
396
|
|
|
|
|
|
|
date1.year = rnum % disperce_years + 1910; |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
else { |
400
|
|
|
|
|
|
|
if (ix == 0) gmtime(i, &date1); |
401
|
|
|
|
|
|
|
else localtime(i, &date1); |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
if (ix == 1) date1.isdst = -1; |
405
|
|
|
|
|
|
|
dt2tm(date2, date1); |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
datetime copy1 = date1; |
408
|
|
|
|
|
|
|
struct tm copy2 = date2; |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
ptime_t mytime; |
411
|
|
|
|
|
|
|
time_t truetime; |
412
|
|
|
|
|
|
|
if (ix == 0) { |
413
|
|
|
|
|
|
|
truetime = timegm(&date2); |
414
|
|
|
|
|
|
|
if (isrand) mytime = timegm(&date1); // need normalization |
415
|
|
|
|
|
|
|
else mytime = timegml(&date1); |
416
|
|
|
|
|
|
|
} else { |
417
|
|
|
|
|
|
|
mytime = timelocal(&date1); |
418
|
|
|
|
|
|
|
truetime = timelocal(&date2); |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
if (cnt % 100000 == 0 && !test) printf("TESTED #%d, last %04d-%02d-%02d %02d:%02d:%02d\n", cnt, date2.tm_year+1900, date2.tm_mon+1, date2.tm_mday, date2.tm_hour, date2.tm_min, date2.tm_sec); |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
bool same_ymdhms = (date1.year != (date2.tm_year + 1900) || date1.mon != date2.tm_mon || date1.mday != date2.tm_mday || date1.hour != date2.tm_hour || date1.min != date2.tm_min || date1.sec != date2.tm_sec) ? false : true; |
424
|
|
|
|
|
|
|
bool same_zone = (date1.isdst != date2.tm_isdst || date1.gmtoff != date2.tm_gmtoff || strcmp(date1.zone, date2.tm_zone) != 0) ? false : true; |
425
|
|
|
|
|
|
|
bool same_date = same_ymdhms && same_zone; |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
if (mytime != truetime || !same_date) { |
428
|
|
|
|
|
|
|
if (truetime == -1) continue; // OS cannot handle such dates |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
if (same_ymdhms && ix == 1) { // if ambiguity, OS may return unpredicted results. Lets handle that. |
431
|
|
|
|
|
|
|
datetime tmpdate = date1; |
432
|
|
|
|
|
|
|
tmpdate.isdst = 1; |
433
|
|
|
|
|
|
|
mytime = timelocal(&tmpdate); |
434
|
|
|
|
|
|
|
if (mytime == truetime) continue; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
warn( |
438
|
|
|
|
|
|
|
"MY: epoch=%lli (%04d/%02lld/%02lld %02lld:%02lld:%02lld %4s %d) from %04d/%02lld/%02lld %02lld:%02lld:%02lld DST=%d (%.*s)", |
439
|
|
|
|
|
|
|
(long long)mytime, |
440
|
|
|
|
|
|
|
date1.year, (long long)date1.mon+1, (long long)date1.mday, (long long)date1.hour, (long long)date1.min, (long long)date1.sec, |
441
|
|
|
|
|
|
|
date1.zone, date1.gmtoff, |
442
|
|
|
|
|
|
|
copy1.year, (long long)copy1.mon+1, (long long)copy1.mday, (long long)copy1.hour, (long long)copy1.min, (long long)copy1.sec, |
443
|
|
|
|
|
|
|
copy1.isdst, (int)tzlocal()->name.length(), tzlocal()->name.data() |
444
|
|
|
|
|
|
|
); |
445
|
|
|
|
|
|
|
warn( |
446
|
|
|
|
|
|
|
"OS: epoch=%li (%04d/%02d/%02d %02d:%02d:%02d %4s %ld) from %04d/%02d/%02d %02d:%02d:%02d DST=%d (%.*s)", |
447
|
|
|
|
|
|
|
truetime, date2.tm_year+1900, date2.tm_mon+1, date2.tm_mday, date2.tm_hour, date2.tm_min, date2.tm_sec, date2.tm_zone, date2.tm_gmtoff, |
448
|
|
|
|
|
|
|
copy2.tm_year+1900, copy2.tm_mon+1, copy2.tm_mday, copy2.tm_hour, copy2.tm_min, copy2.tm_sec, copy2.tm_isdst, (int)tzlocal()->name.length(), tzlocal()->name.data() |
449
|
|
|
|
|
|
|
); |
450
|
|
|
|
|
|
|
warn("diff is %lli", (long long)(mytime - truetime)); |
451
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
if (!test) printf("TESTED %d TIMES\n", cnt); |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
RETVAL = true; |
458
|
|
|
|
|
|
|
#line 459 "t/lib/MyTest.xs.cc" |
459
|
0
|
0
|
|
|
|
|
ST(0) = boolSV(RETVAL); |
460
|
|
|
|
|
|
|
} |
461
|
0
|
|
|
|
|
|
XSRETURN(1); |
462
|
0
|
0
|
|
|
|
|
}); } |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
|
466
|
0
|
|
|
|
|
|
XS_EUPXS(XS_MyTest_gmtime_bench) { xs::throw_guard(cv, [=]() |
467
|
|
|
|
|
|
|
{ |
468
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
469
|
0
|
|
|
|
|
|
dXSI32; |
470
|
0
|
0
|
|
|
|
|
if (items != 1) |
471
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "epoch"); |
472
|
|
|
|
|
|
|
{ |
473
|
0
|
|
|
|
|
|
Array RETVAL; |
474
|
0
|
0
|
|
|
|
|
ptime_t epoch = (ptime_t)SvIV(ST(0)) |
|
|
0
|
|
|
|
|
|
475
|
|
|
|
|
|
|
; |
476
|
|
|
|
|
|
|
#line 220 "t/lib/MyTest.xs" |
477
|
|
|
|
|
|
|
datetime date; |
478
|
|
|
|
|
|
|
ptime_t max_epoch = epoch + 10000; |
479
|
|
|
|
|
|
|
if (ix == 0) while(epoch++ < max_epoch) gmtime(epoch, &date); |
480
|
|
|
|
|
|
|
else if (ix == 1) while(epoch++ < max_epoch) localtime(epoch, &date); |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
RETVAL = Array::create(); |
483
|
|
|
|
|
|
|
RETVAL.push(Simple(date.sec)); |
484
|
|
|
|
|
|
|
RETVAL.push(Simple(date.min)); |
485
|
|
|
|
|
|
|
RETVAL.push(Simple(date.hour)); |
486
|
|
|
|
|
|
|
RETVAL.push(Simple(date.mday)); |
487
|
|
|
|
|
|
|
RETVAL.push(Simple(date.mon)); |
488
|
|
|
|
|
|
|
RETVAL.push(Simple(date.year)); |
489
|
|
|
|
|
|
|
RETVAL.push(Simple(date.wday)); |
490
|
|
|
|
|
|
|
RETVAL.push(Simple(date.yday)); |
491
|
|
|
|
|
|
|
RETVAL.push(Simple(date.isdst)); |
492
|
|
|
|
|
|
|
RETVAL.push(Simple(date.gmtoff)); |
493
|
|
|
|
|
|
|
RETVAL.push(Simple(date.zone)); |
494
|
|
|
|
|
|
|
#line 495 "t/lib/MyTest.xs.cc" |
495
|
|
|
|
|
|
|
{ |
496
|
|
|
|
|
|
|
SV * RETVALSV; |
497
|
0
|
|
|
|
|
|
RETVALSV = NULL; |
498
|
0
|
0
|
|
|
|
|
if (!RETVAL) XSRETURN_UNDEF; |
499
|
0
|
0
|
|
|
|
|
RETVALSV = newRV_noinc(RETVAL.detach()); |
500
|
0
|
0
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
501
|
0
|
0
|
|
|
|
|
ST(0) = RETVALSV; |
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
} |
504
|
0
|
|
|
|
|
|
XSRETURN(1); |
505
|
0
|
0
|
|
|
|
|
}); } |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
|
509
|
0
|
|
|
|
|
|
XS_EUPXS(XS_MyTest_posix_gmtime_bench) { xs::throw_guard(cv, [=]() |
510
|
|
|
|
|
|
|
{ |
511
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
512
|
0
|
|
|
|
|
|
dXSI32; |
513
|
0
|
0
|
|
|
|
|
if (items != 1) |
514
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "epoch"); |
515
|
|
|
|
|
|
|
{ |
516
|
0
|
|
|
|
|
|
Array RETVAL; |
517
|
0
|
0
|
|
|
|
|
time_t epoch = (time_t)SvIV(ST(0)) |
|
|
0
|
|
|
|
|
|
518
|
|
|
|
|
|
|
; |
519
|
|
|
|
|
|
|
#line 240 "t/lib/MyTest.xs" |
520
|
|
|
|
|
|
|
struct tm date; |
521
|
|
|
|
|
|
|
time_t max_epoch = epoch + 10000; |
522
|
|
|
|
|
|
|
if (ix == 0) while(epoch++ < max_epoch) gmtime_r(&epoch, &date); |
523
|
|
|
|
|
|
|
else if (ix == 1) while(epoch++ < max_epoch) localtime_r(&epoch, &date); |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
RETVAL = Array::create(); |
526
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_sec)); |
527
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_min)); |
528
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_hour)); |
529
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_mday)); |
530
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_mon)); |
531
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_year)); |
532
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_wday)); |
533
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_yday)); |
534
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_isdst)); |
535
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_gmtoff)); |
536
|
|
|
|
|
|
|
RETVAL.push(Simple(date.tm_zone)); |
537
|
|
|
|
|
|
|
#line 538 "t/lib/MyTest.xs.cc" |
538
|
|
|
|
|
|
|
{ |
539
|
|
|
|
|
|
|
SV * RETVALSV; |
540
|
0
|
|
|
|
|
|
RETVALSV = NULL; |
541
|
0
|
0
|
|
|
|
|
if (!RETVAL) XSRETURN_UNDEF; |
542
|
0
|
0
|
|
|
|
|
RETVALSV = newRV_noinc(RETVAL.detach()); |
543
|
0
|
0
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
544
|
0
|
0
|
|
|
|
|
ST(0) = RETVALSV; |
545
|
|
|
|
|
|
|
} |
546
|
|
|
|
|
|
|
} |
547
|
0
|
|
|
|
|
|
XSRETURN(1); |
548
|
0
|
0
|
|
|
|
|
}); } |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
|
552
|
0
|
|
|
|
|
|
XS_EUPXS(XS_MyTest_timegm_bench) { xs::throw_guard(cv, [=]() |
553
|
|
|
|
|
|
|
{ |
554
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
555
|
0
|
|
|
|
|
|
dXSI32; |
556
|
0
|
0
|
|
|
|
|
if (items != 6) |
557
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "sec, min, hour, mday, mon, year"); |
558
|
|
|
|
|
|
|
{ |
559
|
|
|
|
|
|
|
ptime_t RETVAL; |
560
|
0
|
0
|
|
|
|
|
dXSTARG; |
|
|
0
|
|
|
|
|
|
561
|
0
|
0
|
|
|
|
|
ptime_t sec = (ptime_t)SvIV(ST(0)) |
|
|
0
|
|
|
|
|
|
562
|
|
|
|
|
|
|
; |
563
|
0
|
0
|
|
|
|
|
ptime_t min = (ptime_t)SvIV(ST(1)) |
|
|
0
|
|
|
|
|
|
564
|
|
|
|
|
|
|
; |
565
|
0
|
0
|
|
|
|
|
ptime_t hour = (ptime_t)SvIV(ST(2)) |
|
|
0
|
|
|
|
|
|
566
|
|
|
|
|
|
|
; |
567
|
0
|
0
|
|
|
|
|
ptime_t mday = (ptime_t)SvIV(ST(3)) |
|
|
0
|
|
|
|
|
|
568
|
|
|
|
|
|
|
; |
569
|
0
|
0
|
|
|
|
|
ptime_t mon = (ptime_t)SvIV(ST(4)) |
|
|
0
|
|
|
|
|
|
570
|
|
|
|
|
|
|
; |
571
|
0
|
0
|
|
|
|
|
ptime_t year = (ptime_t)SvIV(ST(5)) |
|
|
0
|
|
|
|
|
|
572
|
|
|
|
|
|
|
; |
573
|
|
|
|
|
|
|
#line 260 "t/lib/MyTest.xs" |
574
|
|
|
|
|
|
|
datetime date; |
575
|
|
|
|
|
|
|
date.sec = sec; |
576
|
|
|
|
|
|
|
date.min = min; |
577
|
|
|
|
|
|
|
date.hour = hour; |
578
|
|
|
|
|
|
|
date.mday = mday; |
579
|
|
|
|
|
|
|
date.mon = mon; |
580
|
|
|
|
|
|
|
date.year = year; |
581
|
|
|
|
|
|
|
date.isdst = -1; |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
int i = 0; |
584
|
|
|
|
|
|
|
int cnt = 10000; |
585
|
|
|
|
|
|
|
RETVAL = 0; |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date); |
588
|
|
|
|
|
|
|
else if (ix == 1) while (i++ < cnt) RETVAL += timegml(&date); |
589
|
|
|
|
|
|
|
else if (ix == 2) while (i++ < cnt) RETVAL += timelocal(&date); |
590
|
|
|
|
|
|
|
else if (ix == 3) while (i++ < cnt) RETVAL += timelocall(&date); |
591
|
|
|
|
|
|
|
#line 592 "t/lib/MyTest.xs.cc" |
592
|
0
|
0
|
|
|
|
|
XSprePUSH; PUSHi((IV)RETVAL); |
|
|
0
|
|
|
|
|
|
593
|
|
|
|
|
|
|
} |
594
|
0
|
|
|
|
|
|
XSRETURN(1); |
595
|
0
|
0
|
|
|
|
|
}); } |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
|
599
|
0
|
|
|
|
|
|
XS_EUPXS(XS_MyTest_posix_timegm_bench) { xs::throw_guard(cv, [=]() |
600
|
|
|
|
|
|
|
{ |
601
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
602
|
0
|
|
|
|
|
|
dXSI32; |
603
|
0
|
0
|
|
|
|
|
if (items != 6) |
604
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "sec, min, hour, mday, mon, year"); |
605
|
|
|
|
|
|
|
{ |
606
|
|
|
|
|
|
|
time_t RETVAL; |
607
|
0
|
0
|
|
|
|
|
dXSTARG; |
|
|
0
|
|
|
|
|
|
608
|
0
|
0
|
|
|
|
|
int64_t sec = (int64_t)SvIV(ST(0)) |
|
|
0
|
|
|
|
|
|
609
|
|
|
|
|
|
|
; |
610
|
0
|
0
|
|
|
|
|
int64_t min = (int64_t)SvIV(ST(1)) |
|
|
0
|
|
|
|
|
|
611
|
|
|
|
|
|
|
; |
612
|
0
|
0
|
|
|
|
|
int64_t hour = (int64_t)SvIV(ST(2)) |
|
|
0
|
|
|
|
|
|
613
|
|
|
|
|
|
|
; |
614
|
0
|
0
|
|
|
|
|
int64_t mday = (int64_t)SvIV(ST(3)) |
|
|
0
|
|
|
|
|
|
615
|
|
|
|
|
|
|
; |
616
|
0
|
0
|
|
|
|
|
int64_t mon = (int64_t)SvIV(ST(4)) |
|
|
0
|
|
|
|
|
|
617
|
|
|
|
|
|
|
; |
618
|
0
|
0
|
|
|
|
|
int64_t year = (int64_t)SvIV(ST(5)) |
|
|
0
|
|
|
|
|
|
619
|
|
|
|
|
|
|
; |
620
|
|
|
|
|
|
|
#line 280 "t/lib/MyTest.xs" |
621
|
|
|
|
|
|
|
struct tm date; |
622
|
|
|
|
|
|
|
date.tm_sec = sec; |
623
|
|
|
|
|
|
|
date.tm_min = min; |
624
|
|
|
|
|
|
|
date.tm_hour = hour; |
625
|
|
|
|
|
|
|
date.tm_mday = mday; |
626
|
|
|
|
|
|
|
date.tm_mon = mon; |
627
|
|
|
|
|
|
|
date.tm_year = year-1900; |
628
|
|
|
|
|
|
|
date.tm_isdst = -1; |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
int i = 0; |
631
|
|
|
|
|
|
|
int cnt = 10000; |
632
|
|
|
|
|
|
|
RETVAL = 0; |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date); |
635
|
|
|
|
|
|
|
else if (ix == 1) while (i++ < cnt) RETVAL += timelocal(&date); |
636
|
|
|
|
|
|
|
#line 637 "t/lib/MyTest.xs.cc" |
637
|
0
|
0
|
|
|
|
|
XSprePUSH; PUSHi((IV)RETVAL); |
|
|
0
|
|
|
|
|
|
638
|
|
|
|
|
|
|
} |
639
|
0
|
|
|
|
|
|
XSRETURN(1); |
640
|
0
|
0
|
|
|
|
|
}); } |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
#endif |
643
|
|
|
|
|
|
|
#ifdef __cplusplus |
644
|
|
|
|
|
|
|
extern "C" |
645
|
|
|
|
|
|
|
#endif |
646
|
|
|
|
|
|
|
|
647
|
52
|
|
|
|
|
|
XS_EXTERNAL(boot_MyTest) { xs::throw_guard(cv, [=]() mutable |
648
|
|
|
|
|
|
|
{ |
649
|
|
|
|
|
|
|
#if PERL_VERSION_LE(5, 21, 5) |
650
|
|
|
|
|
|
|
dVAR; dXSARGS; |
651
|
|
|
|
|
|
|
#else |
652
|
26
|
50
|
|
|
|
|
dVAR; dXSBOOTARGSXSAPIVERCHK; |
|
|
50
|
|
|
|
|
|
653
|
|
|
|
|
|
|
#endif |
654
|
|
|
|
|
|
|
#if (PERL_REVISION == 5 && PERL_VERSION < 9) |
655
|
|
|
|
|
|
|
char* file = __FILE__; |
656
|
|
|
|
|
|
|
#else |
657
|
26
|
|
|
|
|
|
const char* file = __FILE__; |
658
|
|
|
|
|
|
|
#endif |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
PERL_UNUSED_VAR(file); |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
PERL_UNUSED_VAR(cv); /* -W */ |
663
|
|
|
|
|
|
|
PERL_UNUSED_VAR(items); /* -W */ |
664
|
|
|
|
|
|
|
#if PERL_VERSION_LE(5, 21, 5) |
665
|
|
|
|
|
|
|
XS_VERSION_BOOTCHECK; |
666
|
|
|
|
|
|
|
# ifdef XS_APIVERSION_BOOTCHECK |
667
|
|
|
|
|
|
|
XS_APIVERSION_BOOTCHECK; |
668
|
|
|
|
|
|
|
# endif |
669
|
|
|
|
|
|
|
#endif |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
{ |
672
|
|
|
|
|
|
|
CV * cv; |
673
|
|
|
|
|
|
|
|
674
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::systimegm", XS_MyTest_systimegm); |
675
|
26
|
|
|
|
|
|
XSANY.any_i32 = 0; |
676
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::systimelocal", XS_MyTest_systimegm); |
677
|
26
|
|
|
|
|
|
XSANY.any_i32 = 1; |
678
|
26
|
50
|
|
|
|
|
newXS_deffile("MyTest::strftime", XS_MyTest_strftime); |
679
|
|
|
|
|
|
|
#if XSubPPtmpAAAA |
680
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::test_gmtime", XS_MyTest_test_gmtime); |
681
|
26
|
|
|
|
|
|
XSANY.any_i32 = 0; |
682
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::test_localtime", XS_MyTest_test_gmtime); |
683
|
26
|
|
|
|
|
|
XSANY.any_i32 = 1; |
684
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::test_timegm", XS_MyTest_test_timegm); |
685
|
26
|
|
|
|
|
|
XSANY.any_i32 = 0; |
686
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::test_timelocal", XS_MyTest_test_timegm); |
687
|
26
|
|
|
|
|
|
XSANY.any_i32 = 1; |
688
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::gmtime_bench", XS_MyTest_gmtime_bench); |
689
|
26
|
|
|
|
|
|
XSANY.any_i32 = 0; |
690
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::localtime_bench", XS_MyTest_gmtime_bench); |
691
|
26
|
|
|
|
|
|
XSANY.any_i32 = 1; |
692
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::posix_gmtime_bench", XS_MyTest_posix_gmtime_bench); |
693
|
26
|
|
|
|
|
|
XSANY.any_i32 = 0; |
694
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::posix_localtime_bench", XS_MyTest_posix_gmtime_bench); |
695
|
26
|
|
|
|
|
|
XSANY.any_i32 = 1; |
696
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::timegm_bench", XS_MyTest_timegm_bench); |
697
|
26
|
|
|
|
|
|
XSANY.any_i32 = 0; |
698
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::timegml_bench", XS_MyTest_timegm_bench); |
699
|
26
|
|
|
|
|
|
XSANY.any_i32 = 1; |
700
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::timelocal_bench", XS_MyTest_timegm_bench); |
701
|
26
|
|
|
|
|
|
XSANY.any_i32 = 2; |
702
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::timelocall_bench", XS_MyTest_timegm_bench); |
703
|
26
|
|
|
|
|
|
XSANY.any_i32 = 3; |
704
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::posix_timegm_bench", XS_MyTest_posix_timegm_bench); |
705
|
26
|
|
|
|
|
|
XSANY.any_i32 = 0; |
706
|
26
|
50
|
|
|
|
|
cv = newXS_deffile("MyTest::posix_timelocal_bench", XS_MyTest_posix_timegm_bench); |
707
|
26
|
|
|
|
|
|
XSANY.any_i32 = 1; |
708
|
|
|
|
|
|
|
#endif |
709
|
|
|
|
|
|
|
} |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
/* Initialisation Section */ |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
#if XSubPPtmpAAAA |
714
|
|
|
|
|
|
|
#endif |
715
|
|
|
|
|
|
|
#line 716 "t/lib/MyTest.xs.cc" |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
/* End of Initialisation Section */ |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
#if PERL_VERSION_LE(5, 21, 5) |
720
|
|
|
|
|
|
|
# if PERL_VERSION_GE(5, 9, 0) |
721
|
|
|
|
|
|
|
if (PL_unitcheckav) |
722
|
|
|
|
|
|
|
call_list(PL_scopestack_ix, PL_unitcheckav); |
723
|
|
|
|
|
|
|
# endif |
724
|
|
|
|
|
|
|
XSRETURN_YES; |
725
|
|
|
|
|
|
|
#else |
726
|
26
|
|
|
|
|
|
Perl_xs_boot_epilog(aTHX_ ax); |
727
|
|
|
|
|
|
|
#endif |
728
|
52
|
50
|
|
|
|
|
}); } |
729
|
|
|
|
|
|
|
|