File Coverage

t/lib/MyTest_xsgen.cc
Criterion Covered Total %
statement 31 149 20.8
branch 19 182 10.4
condition n/a
subroutine n/a
pod n/a
total 50 331 15.1


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             #include
13             #include
14             #include
15              
16             using namespace xs;
17             using namespace panda::date;
18             using panda::string;
19             using panda::string_view;
20              
21             #if !defined(_WIN32) && !defined(sun) && !defined(__sun)
22             #define DATE_TEST_SYS
23             #endif
24              
25              
26             #line 27 "t/lib/MyTest_xsgen.cc"
27             #ifndef PERL_UNUSED_VAR
28             # define PERL_UNUSED_VAR(var) if (0) var = var
29             #endif
30              
31             #ifndef dVAR
32             # define dVAR dNOOP
33             #endif
34              
35              
36             /* This stuff is not part of the API! You have been warned. */
37             #ifndef PERL_VERSION_DECIMAL
38             # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
39             #endif
40             #ifndef PERL_DECIMAL_VERSION
41             # define PERL_DECIMAL_VERSION \
42             PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
43             #endif
44             #ifndef PERL_VERSION_GE
45             # define PERL_VERSION_GE(r,v,s) \
46             (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
47             #endif
48             #ifndef PERL_VERSION_LE
49             # define PERL_VERSION_LE(r,v,s) \
50             (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
51             #endif
52              
53             /* XS_INTERNAL is the explicit static-linkage variant of the default
54             * XS macro.
55             *
56             * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
57             * "STATIC", ie. it exports XSUB symbols. You probably don't want that
58             * for anything but the BOOT XSUB.
59             *
60             * See XSUB.h in core!
61             */
62              
63              
64             /* TODO: This might be compatible further back than 5.10.0. */
65             #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
66             # undef XS_EXTERNAL
67             # undef XS_INTERNAL
68             # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
69             # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
70             # define XS_INTERNAL(name) STATIC XSPROTO(name)
71             # endif
72             # if defined(__SYMBIAN32__)
73             # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
74             # define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
75             # endif
76             # ifndef XS_EXTERNAL
77             # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
78             # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
79             # define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
80             # else
81             # ifdef __cplusplus
82             # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
83             # define XS_INTERNAL(name) static XSPROTO(name)
84             # else
85             # define XS_EXTERNAL(name) XSPROTO(name)
86             # define XS_INTERNAL(name) STATIC XSPROTO(name)
87             # endif
88             # endif
89             # endif
90             #endif
91              
92             /* perl >= 5.10.0 && perl <= 5.15.1 */
93              
94              
95             /* The XS_EXTERNAL macro is used for functions that must not be static
96             * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
97             * macro defined, the best we can do is assume XS is the same.
98             * Dito for XS_INTERNAL.
99             */
100             #ifndef XS_EXTERNAL
101             # define XS_EXTERNAL(name) XS(name)
102             #endif
103             #ifndef XS_INTERNAL
104             # define XS_INTERNAL(name) XS(name)
105             #endif
106              
107             /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
108             * internal macro that we're free to redefine for varying linkage due
109             * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
110             * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
111             */
112              
113             #undef XS_EUPXS
114             #if defined(PERL_EUPXS_ALWAYS_EXPORT)
115             # define XS_EUPXS(name) XS_EXTERNAL(name)
116             #else
117             /* default to internal */
118             # define XS_EUPXS(name) XS_INTERNAL(name)
119             #endif
120              
121             #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
122             #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
123              
124             /* prototype to pass -Wmissing-prototypes */
125             STATIC void
126             S_croak_xs_usage(const CV *const cv, const char *const params);
127              
128             STATIC void
129             S_croak_xs_usage(const CV *const cv, const char *const params)
130             {
131             const GV *const gv = CvGV(cv);
132              
133             PERL_ARGS_ASSERT_CROAK_XS_USAGE;
134              
135             if (gv) {
136             const char *const gvname = GvNAME(gv);
137             const HV *const stash = GvSTASH(gv);
138             const char *const hvname = stash ? HvNAME(stash) : NULL;
139              
140             if (hvname)
141             Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
142             else
143             Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
144             } else {
145             /* Pants. I don't think that it should be possible to get here. */
146             Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
147             }
148             }
149             #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
150              
151             #define croak_xs_usage S_croak_xs_usage
152              
153             #endif
154              
155             /* NOTE: the prototype of newXSproto() is different in versions of perls,
156             * so we define a portable version of newXSproto()
157             */
158             #ifdef newXS_flags
159             #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
160             #else
161             #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
162             #endif /* !defined(newXS_flags) */
163              
164             #if PERL_VERSION_LE(5, 21, 5)
165             # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
166             #else
167             # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
168             #endif
169              
170             #line 171 "t/lib/MyTest_xsgen.cc"
171              
172              
173 0           XS_EUPXS(XS_MyTest_bench_parse) { xs::throw_guard(cv, [=]()
174             {
175 0           dVAR; dXSARGS;
176 0 0         if (items != 1)
177 0           croak_xs_usage(cv, "str");
178             PERL_UNUSED_VAR(ax); /* -Wall */
179 0           SP -= items;
180             {
181 0           string_view str;
182              
183             { STRLEN __str_len;
184 0 0         const char* __str_buf = SvPV(ST(0), __str_len);
    0          
185 0           str = decltype(str)(__str_buf, __str_len); }
186             ;
187             #line 21 "t/lib/MyTest.xs"
188             Date date;
189             for (int i = 0; i < 1000; ++i) date.set(str);
190             #line 191 "t/lib/MyTest_xsgen.cc"
191 0           PUTBACK;
192 0           return;
193             }
194 0 0         }); }
195              
196              
197              
198 0           XS_EUPXS(XS_MyTest_bench_rparse) { xs::throw_guard(cv, [=]()
199             {
200 0           dVAR; dXSARGS;
201 0 0         if (items != 1)
202 0           croak_xs_usage(cv, "str");
203             PERL_UNUSED_VAR(ax); /* -Wall */
204 0           SP -= items;
205             {
206 0           string_view str;
207              
208             { STRLEN __str_len;
209 0 0         const char* __str_buf = SvPV(ST(0), __str_len);
    0          
210 0           str = decltype(str)(__str_buf, __str_len); }
211             ;
212             #line 26 "t/lib/MyTest.xs"
213             DateRel rel;
214             for (int i = 0; i < 1000; ++i) rel = str;
215             #line 216 "t/lib/MyTest_xsgen.cc"
216 0           PUTBACK;
217 0           return;
218             }
219 0 0         }); }
220              
221              
222              
223 0           XS_EUPXS(XS_MyTest_bench_strftime) { xs::throw_guard(cv, [=]()
224             {
225 0           dVAR; dXSARGS;
226 0 0         if (items != 1)
227 0           croak_xs_usage(cv, "format");
228             {
229             uint64_t RETVAL;
230 0 0         dXSTARG;
    0          
231 0           string_view format;
232              
233             { STRLEN __format_len;
234 0 0         const char* __format_buf = SvPV(ST(0), __format_len);
    0          
235 0           format = decltype(format)(__format_buf, __format_len); }
236             ;
237             #line 31 "t/lib/MyTest.xs"
238             auto date = Date::now();
239             RETVAL = 0;
240              
241             for (int i = 0; i < 1000; ++i) {
242             auto res = date.strftime(format);
243             RETVAL += res.length();
244             }
245             #line 246 "t/lib/MyTest_xsgen.cc"
246 0 0         XSprePUSH; PUSHu((UV)RETVAL);
    0          
247             }
248 0           XSRETURN(1);
249 0 0         }); }
250              
251              
252              
253 0           XS_EUPXS(XS_MyTest_bench_tzget) { xs::throw_guard(cv, [=]()
254             {
255 0           dVAR; dXSARGS;
256 0 0         if (items != 1)
257 0           croak_xs_usage(cv, "tz");
258             {
259             uint64_t RETVAL;
260 0 0         dXSTARG;
    0          
261 0           string_view tz;
262              
263             { STRLEN __tz_len;
264 0 0         const char* __tz_buf = SvPV(ST(0), __tz_len);
    0          
265 0           tz = decltype(tz)(__tz_buf, __tz_len); }
266             ;
267             #line 41 "t/lib/MyTest.xs"
268             RETVAL = 0;
269             for (int i = 0; i < 1000; ++i) RETVAL += (uint64_t)panda::time::tzget(tz).get();
270             #line 271 "t/lib/MyTest_xsgen.cc"
271 0 0         XSprePUSH; PUSHu((UV)RETVAL);
    0          
272             }
273 0           XSRETURN(1);
274 0 0         }); }
275              
276              
277              
278 0           XS_EUPXS(XS_MyTest_bench_hints_get) { xs::throw_guard(cv, [=]()
279             {
280 0           dVAR; dXSARGS;
281 0 0         if (items != 0)
282 0           croak_xs_usage(cv, "");
283             PERL_UNUSED_VAR(ax); /* -Wall */
284 0           SP -= items;
285             {
286             #line 46 "t/lib/MyTest.xs"
287             for (int i = 0; i < 1000; ++i) Scope::Hints::exists(xs::date::strict_hint_name);
288             #line 289 "t/lib/MyTest_xsgen.cc"
289 0           PUTBACK;
290 0           return;
291             }
292 0 0         }); }
293              
294              
295              
296 0           XS_EUPXS(XS_MyTest_get_strict_hint) { xs::throw_guard(cv, [=]()
297             {
298 0           dVAR; dXSARGS;
299 0 0         if (items != 0)
300 0           croak_xs_usage(cv, "");
301             {
302             bool RETVAL;
303             #line 50 "t/lib/MyTest.xs"
304             RETVAL = Scope::Hints::exists(xs::date::strict_hint_name);
305             #line 306 "t/lib/MyTest_xsgen.cc"
306 0 0         ST(0) = boolSV(RETVAL);
307             }
308 0           XSRETURN(1);
309 0 0         }); }
310              
311             #ifdef DATE_TEST_SYS
312             #define XSubPPtmpAAAA 1
313              
314              
315              
316 0           XS_EUPXS(XS_MyTest_gmtime_bench) { xs::throw_guard(cv, [=]()
317             {
318 0           dVAR; dXSARGS;
319 0           dXSI32;
320 0 0         if (items != 1)
321 0           croak_xs_usage(cv, "epoch");
322             {
323 0           Array RETVAL;
324 0 0         ptime_t epoch = xs::in(ST(0));
325             ;
326             #line 56 "t/lib/MyTest.xs"
327             datetime date;
328             ptime_t max_epoch = epoch + 10000;
329             if (ix == 0) while(epoch++ < max_epoch) gmtime(epoch, &date);
330             else if (ix == 1) while(epoch++ < max_epoch) localtime(epoch, &date);
331              
332             RETVAL = Array::create();
333             RETVAL.push(Simple(date.sec));
334             RETVAL.push(Simple(date.min));
335             RETVAL.push(Simple(date.hour));
336             RETVAL.push(Simple(date.mday));
337             RETVAL.push(Simple(date.mon));
338             RETVAL.push(Simple(date.year));
339             RETVAL.push(Simple(date.wday));
340             RETVAL.push(Simple(date.yday));
341             RETVAL.push(Simple(date.isdst));
342             RETVAL.push(Simple(date.gmtoff));
343             RETVAL.push(Simple(date.zone));
344             #line 345 "t/lib/MyTest_xsgen.cc"
345             {
346             SV * RETVALSV;
347 0           RETVALSV = NULL;
348 0 0         if (!RETVAL) XSRETURN_UNDEF;
349 0 0         RETVALSV = newRV_noinc(RETVAL.detach());
350 0 0         RETVALSV = sv_2mortal(RETVALSV);
351 0 0         ST(0) = RETVALSV;
352             }
353             }
354 0           XSRETURN(1);
355 0 0         }); }
356              
357              
358              
359 0           XS_EUPXS(XS_MyTest_posix_gmtime_bench) { xs::throw_guard(cv, [=]()
360             {
361 0           dVAR; dXSARGS;
362 0           dXSI32;
363 0 0         if (items != 1)
364 0           croak_xs_usage(cv, "epoch");
365             {
366 0           Array RETVAL;
367 0 0         time_t epoch = (time_t)SvIV(ST(0))
    0          
368             ;
369             #line 76 "t/lib/MyTest.xs"
370             struct tm date;
371             time_t max_epoch = epoch + 10000;
372             if (ix == 0) while(epoch++ < max_epoch) gmtime_r(&epoch, &date);
373             else if (ix == 1) while(epoch++ < max_epoch) localtime_r(&epoch, &date);
374              
375             RETVAL = Array::create();
376             RETVAL.push(Simple(date.tm_sec));
377             RETVAL.push(Simple(date.tm_min));
378             RETVAL.push(Simple(date.tm_hour));
379             RETVAL.push(Simple(date.tm_mday));
380             RETVAL.push(Simple(date.tm_mon));
381             RETVAL.push(Simple(date.tm_year));
382             RETVAL.push(Simple(date.tm_wday));
383             RETVAL.push(Simple(date.tm_yday));
384             RETVAL.push(Simple(date.tm_isdst));
385             RETVAL.push(Simple(date.tm_gmtoff));
386             RETVAL.push(Simple(date.tm_zone));
387             #line 388 "t/lib/MyTest_xsgen.cc"
388             {
389             SV * RETVALSV;
390 0           RETVALSV = NULL;
391 0 0         if (!RETVAL) XSRETURN_UNDEF;
392 0 0         RETVALSV = newRV_noinc(RETVAL.detach());
393 0 0         RETVALSV = sv_2mortal(RETVALSV);
394 0 0         ST(0) = RETVALSV;
395             }
396             }
397 0           XSRETURN(1);
398 0 0         }); }
399              
400              
401              
402 0           XS_EUPXS(XS_MyTest_timegm_bench) { xs::throw_guard(cv, [=]()
403             {
404 0           dVAR; dXSARGS;
405 0           dXSI32;
406 0 0         if (items != 6)
407 0           croak_xs_usage(cv, "sec, min, hour, mday, mon, year");
408             {
409             ptime_t RETVAL;
410 0 0         ptime_t sec = xs::in(ST(0));
411             ;
412 0 0         ptime_t min = xs::in(ST(1));
413             ;
414 0 0         ptime_t hour = xs::in(ST(2));
415             ;
416 0 0         ptime_t mday = xs::in(ST(3));
417             ;
418 0 0         ptime_t mon = xs::in(ST(4));
419             ;
420 0 0         ptime_t year = xs::in(ST(5));
421             ;
422             #line 96 "t/lib/MyTest.xs"
423             xs::Sv PROTO; PERL_UNUSED_VAR(PROTO);
424             datetime date;
425             date.sec = sec;
426             date.min = min;
427             date.hour = hour;
428             date.mday = mday;
429             date.mon = mon;
430             date.year = year;
431             date.isdst = -1;
432              
433             int i = 0;
434             int cnt = 10000;
435             RETVAL = 0;
436              
437             if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date);
438             else if (ix == 1) while (i++ < cnt) RETVAL += timegml(&date);
439             else if (ix == 2) while (i++ < cnt) RETVAL += timelocal(&date);
440             else if (ix == 3) while (i++ < cnt) RETVAL += timelocall(&date);
441             #line 442 "t/lib/MyTest_xsgen.cc"
442             {
443             SV * RETVALSV;
444 0 0         RETVALSV = xs::out(RETVAL, PROTO).detach();
445 0 0         RETVALSV = sv_2mortal(RETVALSV);
446 0           ST(0) = RETVALSV;
447             }
448             }
449 0           XSRETURN(1);
450 0 0         }); }
451              
452              
453              
454 0           XS_EUPXS(XS_MyTest_posix_timegm_bench) { xs::throw_guard(cv, [=]()
455             {
456 0           dVAR; dXSARGS;
457 0           dXSI32;
458 0 0         if (items != 6)
459 0           croak_xs_usage(cv, "sec, min, hour, mday, mon, year");
460             {
461             time_t RETVAL;
462 0 0         dXSTARG;
    0          
463 0 0         int64_t sec = (int64_t)SvIV(ST(0))
    0          
464             ;
465 0 0         int64_t min = (int64_t)SvIV(ST(1))
    0          
466             ;
467 0 0         int64_t hour = (int64_t)SvIV(ST(2))
    0          
468             ;
469 0 0         int64_t mday = (int64_t)SvIV(ST(3))
    0          
470             ;
471 0 0         int64_t mon = (int64_t)SvIV(ST(4))
    0          
472             ;
473 0 0         int64_t year = (int64_t)SvIV(ST(5))
    0          
474             ;
475             #line 116 "t/lib/MyTest.xs"
476             struct tm date;
477             date.tm_sec = sec;
478             date.tm_min = min;
479             date.tm_hour = hour;
480             date.tm_mday = mday;
481             date.tm_mon = mon;
482             date.tm_year = year-1900;
483             date.tm_isdst = -1;
484              
485             int i = 0;
486             int cnt = 10000;
487             RETVAL = 0;
488              
489             if (ix == 0) while (i++ < cnt) RETVAL += timegm(&date);
490             else if (ix == 1) while (i++ < cnt) RETVAL += timelocal(&date);
491             #line 492 "t/lib/MyTest_xsgen.cc"
492 0 0         XSprePUSH; PUSHi((IV)RETVAL);
    0          
493             }
494 0           XSRETURN(1);
495 0 0         }); }
496              
497             #endif
498             #ifdef __cplusplus
499             extern "C"
500             #endif
501              
502 94           XS_EXTERNAL(boot_MyTest) { xs::throw_guard(cv, [=]() mutable
503             {
504             #if PERL_VERSION_LE(5, 21, 5)
505             dVAR; dXSARGS;
506             #else
507 47 50         dVAR; dXSBOOTARGSXSAPIVERCHK;
    50          
508             #endif
509             #if (PERL_REVISION == 5 && PERL_VERSION < 9)
510             char* file = __FILE__;
511             #else
512 47           const char* file = __FILE__;
513             #endif
514              
515             PERL_UNUSED_VAR(file);
516              
517             PERL_UNUSED_VAR(cv); /* -W */
518             PERL_UNUSED_VAR(items); /* -W */
519             #if PERL_VERSION_LE(5, 21, 5)
520             XS_VERSION_BOOTCHECK;
521             # ifdef XS_APIVERSION_BOOTCHECK
522             XS_APIVERSION_BOOTCHECK;
523             # endif
524             #endif
525              
526             {
527             CV * cv;
528              
529 47 50         newXS_deffile("MyTest::bench_parse", XS_MyTest_bench_parse);
530 47 50         newXS_deffile("MyTest::bench_rparse", XS_MyTest_bench_rparse);
531 47 50         newXS_deffile("MyTest::bench_strftime", XS_MyTest_bench_strftime);
532 47 50         newXS_deffile("MyTest::bench_tzget", XS_MyTest_bench_tzget);
533 47 50         newXS_deffile("MyTest::bench_hints_get", XS_MyTest_bench_hints_get);
534 47 50         newXS_deffile("MyTest::get_strict_hint", XS_MyTest_get_strict_hint);
535             #if XSubPPtmpAAAA
536 47 50         cv = newXS_deffile("MyTest::gmtime_bench", XS_MyTest_gmtime_bench);
537 47           XSANY.any_i32 = 0;
538 47 50         cv = newXS_deffile("MyTest::localtime_bench", XS_MyTest_gmtime_bench);
539 47           XSANY.any_i32 = 1;
540 47 50         cv = newXS_deffile("MyTest::posix_gmtime_bench", XS_MyTest_posix_gmtime_bench);
541 47           XSANY.any_i32 = 0;
542 47 50         cv = newXS_deffile("MyTest::posix_localtime_bench", XS_MyTest_posix_gmtime_bench);
543 47           XSANY.any_i32 = 1;
544 47 50         cv = newXS_deffile("MyTest::timegm_bench", XS_MyTest_timegm_bench);
545 47           XSANY.any_i32 = 0;
546 47 50         cv = newXS_deffile("MyTest::timegml_bench", XS_MyTest_timegm_bench);
547 47           XSANY.any_i32 = 1;
548 47 50         cv = newXS_deffile("MyTest::timelocal_bench", XS_MyTest_timegm_bench);
549 47           XSANY.any_i32 = 2;
550 47 50         cv = newXS_deffile("MyTest::timelocall_bench", XS_MyTest_timegm_bench);
551 47           XSANY.any_i32 = 3;
552 47 50         cv = newXS_deffile("MyTest::posix_timegm_bench", XS_MyTest_posix_timegm_bench);
553 47           XSANY.any_i32 = 0;
554 47 50         cv = newXS_deffile("MyTest::posix_timelocal_bench", XS_MyTest_posix_timegm_bench);
555 47           XSANY.any_i32 = 1;
556             #endif
557             }
558              
559             /* Initialisation Section */
560              
561             #if XSubPPtmpAAAA
562             #endif
563             #line 564 "t/lib/MyTest_xsgen.cc"
564              
565             /* End of Initialisation Section */
566              
567             #if PERL_VERSION_LE(5, 21, 5)
568             # if PERL_VERSION_GE(5, 9, 0)
569             if (PL_unitcheckav)
570             call_list(PL_scopestack_ix, PL_unitcheckav);
571             # endif
572             XSRETURN_YES;
573             #else
574 47           Perl_xs_boot_epilog(aTHX_ ax);
575             #endif
576 94 50         }); }
577