File: | obj/gnu/usr.bin/perl/dist/Time-HiRes/HiRes.c |
Warning: | line 2240, column 8 Value stored to 'nsec' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * This file was generated automatically by ExtUtils::ParseXS version 3.40 from the |
3 | * contents of HiRes.xs. Do not edit this file, edit HiRes.xs instead. |
4 | * |
5 | * ANY CHANGES MADE HERE WILL BE LOST! |
6 | * |
7 | */ |
8 | |
9 | #line 1 "HiRes.xs" |
10 | /* |
11 | * |
12 | * Copyright (c) 1996-2002 Douglas E. Wegscheid. All rights reserved. |
13 | * |
14 | * Copyright (c) 2002-2010 Jarkko Hietaniemi. |
15 | * All rights reserved. |
16 | * |
17 | * Copyright (C) 2011, 2012, 2013 Andrew Main (Zefram) <zefram@fysh.org> |
18 | * |
19 | * This program is free software; you can redistribute it and/or modify |
20 | * it under the same terms as Perl itself. |
21 | */ |
22 | |
23 | #ifdef __cplusplus |
24 | extern "C" { |
25 | #endif |
26 | #define PERL_NO_GET_CONTEXT |
27 | #include "EXTERN.h" |
28 | #include "perl.h" |
29 | #include "XSUB.h" |
30 | #ifdef USE_PPPORT_H |
31 | # include "ppport.h" |
32 | #endif |
33 | #if defined(__CYGWIN__) && defined(HAS_W32API_WINDOWS_H) |
34 | # include <w32api/windows.h> |
35 | # define CYGWIN_WITH_W32API |
36 | #endif |
37 | #ifdef WIN32 |
38 | # include <time.h> |
39 | #else |
40 | # include <sys/time.h> |
41 | #endif |
42 | #ifdef HAS_SELECT |
43 | # ifdef I_SYS_SELECT |
44 | # include <sys/select.h> |
45 | # endif |
46 | #endif |
47 | #if defined(TIME_HIRES_CLOCK_GETTIME_SYSCALL) || defined(TIME_HIRES_CLOCK_GETRES_SYSCALL) |
48 | # include <syscall.h> |
49 | #endif |
50 | #ifdef __cplusplus |
51 | } |
52 | #endif |
53 | |
54 | #define PERL_VERSION_DECIMAL(r,v,s)(r*1000000 + v*1000 + s) (r*1000000 + v*1000 + s) |
55 | #define PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) \ |
56 | PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)(5*1000000 + 32*1000 + 1) |
57 | #define PERL_VERSION_GE(r,v,s)((5*1000000 + 32*1000 + 1) >= (r*1000000 + v*1000 + s)) \ |
58 | (PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) >= PERL_VERSION_DECIMAL(r,v,s)(r*1000000 + v*1000 + s)) |
59 | |
60 | #ifndef GCC_DIAG_IGNORE |
61 | # define GCC_DIAG_IGNORE(x)GCC diagnostic push GCC diagnostic ignored "x" |
62 | # define GCC_DIAG_RESTOREGCC diagnostic pop |
63 | #endif |
64 | #ifndef GCC_DIAG_IGNORE_STMT |
65 | # define GCC_DIAG_IGNORE_STMT(x)GCC diagnostic push GCC diagnostic ignored "x" (void)0 GCC_DIAG_IGNORE(x)GCC diagnostic push GCC diagnostic ignored "x" NOOP(void)0 |
66 | # define GCC_DIAG_RESTORE_STMTGCC diagnostic pop (void)0 GCC_DIAG_RESTOREGCC diagnostic pop NOOP(void)0 |
67 | #endif |
68 | |
69 | #if PERL_VERSION_GE(5,7,3)((5*1000000 + 32*1000 + 1) >= (5*1000000 + 7*1000 + 3)) && !PERL_VERSION_GE(5,10,1)((5*1000000 + 32*1000 + 1) >= (5*1000000 + 10*1000 + 1)) |
70 | # undef SAVEOP |
71 | # define SAVEOP()Perl_save_pushptr( (void *)(PL_op),18) SAVEVPTR(PL_op)Perl_save_vptr( (void*)&(PL_op)) |
72 | #endif |
73 | |
74 | #define IV_1E61000000 1000000 |
75 | #define IV_1E710000000 10000000 |
76 | #define IV_1E91000000000 1000000000 |
77 | |
78 | #define NV_1E61000000.0 1000000.0 |
79 | #define NV_1E710000000.0 10000000.0 |
80 | #define NV_1E91000000000.0 1000000000.0 |
81 | |
82 | #ifndef PerlProc_pause |
83 | # define PerlProc_pause()pause() Pausepause() |
84 | #endif |
85 | |
86 | #ifdef HAS_PAUSE |
87 | # define Pausepause pause |
88 | #else |
89 | # undef Pausepause /* In case perl.h did it already. */ |
90 | # define Pausepause() sleep(~0) /* Zzz for a long time. */ |
91 | #endif |
92 | |
93 | /* Though the cpp define ITIMER_VIRTUAL is available the functionality |
94 | * is not supported in Cygwin as of August 2004, ditto for Win32. |
95 | * Neither are ITIMER_PROF or ITIMER_REALPROF implemented. --jhi |
96 | */ |
97 | #if defined(__CYGWIN__) || defined(WIN32) |
98 | # undef ITIMER_VIRTUAL1 |
99 | # undef ITIMER_PROF2 |
100 | # undef ITIMER_REALPROF |
101 | #endif |
102 | |
103 | #ifndef TIME_HIRES_CLOCKID_T1 |
104 | typedef int clockid_t; |
105 | #endif |
106 | |
107 | #if defined(TIME_HIRES_CLOCK_GETTIME1) && defined(_STRUCT_ITIMERSPEC) |
108 | |
109 | /* HP-UX has CLOCK_XXX values but as enums, not as defines. |
110 | * The only way to detect these would be to test compile for each. */ |
111 | # ifdef __hpux |
112 | /* However, it seems that at least in HP-UX 11.31 ia64 there *are* |
113 | * defines for these, so let's try detecting them. */ |
114 | # ifndef CLOCK_REALTIME0 |
115 | # define CLOCK_REALTIME0 CLOCK_REALTIME0 |
116 | # define CLOCK_VIRTUAL CLOCK_VIRTUAL |
117 | # define CLOCK_PROFILE CLOCK_PROFILE |
118 | # endif |
119 | # endif /* # ifdef __hpux */ |
120 | |
121 | #endif /* #if defined(TIME_HIRES_CLOCK_GETTIME) && defined(_STRUCT_ITIMERSPEC) */ |
122 | |
123 | #if defined(WIN32) || defined(CYGWIN_WITH_W32API) |
124 | |
125 | # ifndef HAS_GETTIMEOFDAY |
126 | # define HAS_GETTIMEOFDAY |
127 | # endif |
128 | |
129 | /* shows up in winsock.h? |
130 | struct timeval { |
131 | long tv_sec; |
132 | long tv_usec; |
133 | } |
134 | */ |
135 | |
136 | typedef union { |
137 | unsigned __int64 ft_i64; |
138 | FILETIME ft_val; |
139 | } FT_t; |
140 | |
141 | # define MY_CXT_KEY "Time::HiRes_" XS_VERSION"1.9764" |
142 | |
143 | typedef struct { |
144 | unsigned long run_count; |
145 | unsigned __int64 base_ticks; |
146 | unsigned __int64 tick_frequency; |
147 | FT_t base_systime_as_filetime; |
148 | unsigned __int64 reset_time; |
149 | } my_cxt_t; |
150 | |
151 | /* Visual C++ 2013 and older don't have the timespec structure */ |
152 | # if defined(_MSC_VER) && _MSC_VER < 1900 |
153 | struct timespec { |
154 | time_t tv_sec; |
155 | long tv_nsec; |
156 | }; |
157 | # endif |
158 | |
159 | START_MY_CXTstatic my_cxt_t my_cxt; |
160 | |
161 | /* Number of 100 nanosecond units from 1/1/1601 to 1/1/1970 */ |
162 | # ifdef __GNUC__4 |
163 | # define Const64(x) x##LL |
164 | # else |
165 | # define Const64(x) x##i64 |
166 | # endif |
167 | # define EPOCH_BIAS Const64(116444736000000000) |
168 | |
169 | # ifdef Const64 |
170 | # ifdef __GNUC__4 |
171 | # define IV_1E6LL 1000000LL /* Needed because of Const64() ##-appends LL (or i64). */ |
172 | # define IV_1E7LL 10000000LL |
173 | # define IV_1E9LL 1000000000LL |
174 | # else |
175 | # define IV_1E6i64 1000000i64 |
176 | # define IV_1E7i64 10000000i64 |
177 | # define IV_1E9i64 1000000000i64 |
178 | # endif |
179 | # endif |
180 | |
181 | /* NOTE: This does not compute the timezone info (doing so can be expensive, |
182 | * and appears to be unsupported even by glibc) */ |
183 | |
184 | /* dMY_CXT needs a Perl context and we don't want to call PERL_GET_CONTEXT |
185 | for performance reasons */ |
186 | |
187 | # undef gettimeofday |
188 | # define gettimeofday(tp, not_used) _gettimeofday(aTHX_ tp, not_used) |
189 | |
190 | # undef GetSystemTimePreciseAsFileTime |
191 | # define GetSystemTimePreciseAsFileTime(out) _GetSystemTimePreciseAsFileTime(aTHX_ out) |
192 | |
193 | # undef clock_gettime |
194 | # define clock_gettime(clock_id, tp) _clock_gettime(aTHX_ clock_id, tp) |
195 | |
196 | # undef clock_getres |
197 | # define clock_getres(clock_id, tp) _clock_getres(clock_id, tp) |
198 | |
199 | # ifndef CLOCK_REALTIME0 |
200 | # define CLOCK_REALTIME0 1 |
201 | # define CLOCK_MONOTONIC3 2 |
202 | # endif |
203 | |
204 | /* If the performance counter delta drifts more than 0.5 seconds from the |
205 | * system time then we recalibrate to the system time. This means we may |
206 | * move *backwards* in time! */ |
207 | # define MAX_PERF_COUNTER_SKEW Const64(5000000) /* 0.5 seconds */ |
208 | |
209 | /* Reset reading from the performance counter every five minutes. |
210 | * Many PC clocks just seem to be so bad. */ |
211 | # define MAX_PERF_COUNTER_TICKS Const64(300000000) /* 300 seconds */ |
212 | |
213 | /* |
214 | * Windows 8 introduced GetSystemTimePreciseAsFileTime(), but currently we have |
215 | * to support older systems, so for now we provide our own implementation. |
216 | * In the future we will switch to the real deal. |
217 | */ |
218 | static void |
219 | _GetSystemTimePreciseAsFileTime(pTHX_ FILETIME *out) |
220 | { |
221 | dMY_CXTstruct Perl___notused_struct; |
222 | FT_t ft; |
223 | |
224 | if (MY_CXTmy_cxt.run_count++ == 0 || |
225 | MY_CXTmy_cxt.base_systime_as_filetime.ft_i64 > MY_CXTmy_cxt.reset_time) { |
226 | |
227 | QueryPerformanceFrequency((LARGE_INTEGER*)&MY_CXTmy_cxt.tick_frequency); |
228 | QueryPerformanceCounter((LARGE_INTEGER*)&MY_CXTmy_cxt.base_ticks); |
229 | GetSystemTimeAsFileTime(&MY_CXTmy_cxt.base_systime_as_filetime.ft_val); |
230 | ft.ft_i64 = MY_CXTmy_cxt.base_systime_as_filetime.ft_i64; |
231 | MY_CXTmy_cxt.reset_time = ft.ft_i64 + MAX_PERF_COUNTER_TICKS; |
232 | } |
233 | else { |
234 | __int64 diff; |
235 | unsigned __int64 ticks; |
236 | QueryPerformanceCounter((LARGE_INTEGER*)&ticks); |
237 | ticks -= MY_CXTmy_cxt.base_ticks; |
238 | ft.ft_i64 = MY_CXTmy_cxt.base_systime_as_filetime.ft_i64 |
239 | + Const64(IV_1E710000000) * (ticks / MY_CXTmy_cxt.tick_frequency) |
240 | +(Const64(IV_1E710000000) * (ticks % MY_CXTmy_cxt.tick_frequency)) / MY_CXTmy_cxt.tick_frequency; |
241 | diff = ft.ft_i64 - MY_CXTmy_cxt.base_systime_as_filetime.ft_i64; |
242 | if (diff < -MAX_PERF_COUNTER_SKEW || diff > MAX_PERF_COUNTER_SKEW) { |
243 | MY_CXTmy_cxt.base_ticks += ticks; |
244 | GetSystemTimeAsFileTime(&MY_CXTmy_cxt.base_systime_as_filetime.ft_val); |
245 | ft.ft_i64 = MY_CXTmy_cxt.base_systime_as_filetime.ft_i64; |
246 | } |
247 | } |
248 | |
249 | *out = ft.ft_val; |
250 | |
251 | return; |
252 | } |
253 | |
254 | static int |
255 | _gettimeofday(pTHX_ struct timeval *tp, void *not_used) |
256 | { |
257 | FT_t ft; |
258 | |
259 | PERL_UNUSED_ARG(not_used)((void)sizeof(not_used)); |
260 | |
261 | GetSystemTimePreciseAsFileTime(&ft.ft_val); |
262 | |
263 | /* seconds since epoch */ |
264 | tp->tv_sec = (long)((ft.ft_i64 - EPOCH_BIAS) / Const64(IV_1E710000000)); |
265 | |
266 | /* microseconds remaining */ |
267 | tp->tv_usec = (long)((ft.ft_i64 / Const64(10)) % Const64(IV_1E61000000)); |
268 | |
269 | return 0; |
270 | } |
271 | |
272 | static int |
273 | _clock_gettime(pTHX_ clockid_t clock_id, struct timespec *tp) |
274 | { |
275 | FT_t ft; |
276 | |
277 | switch (clock_id) { |
278 | case CLOCK_REALTIME0: { |
279 | FT_t ft; |
280 | |
281 | GetSystemTimePreciseAsFileTime(&ft.ft_val); |
282 | tp->tv_sec = (time_t)((ft.ft_i64 - EPOCH_BIAS) / IV_1E710000000); |
283 | tp->tv_nsec = (long)((ft.ft_i64 % IV_1E710000000) * 100); |
284 | break; |
285 | } |
286 | case CLOCK_MONOTONIC3: { |
287 | unsigned __int64 freq, ticks; |
288 | |
289 | QueryPerformanceFrequency((LARGE_INTEGER*)&freq); |
290 | QueryPerformanceCounter((LARGE_INTEGER*)&ticks); |
291 | |
292 | tp->tv_sec = (time_t)(ticks / freq); |
293 | tp->tv_nsec = (long)((IV_1E91000000000 * (ticks % freq)) / freq); |
294 | break; |
295 | } |
296 | default: |
297 | errno(*__errno()) = EINVAL22; |
298 | return 1; |
299 | } |
300 | |
301 | return 0; |
302 | } |
303 | |
304 | static int |
305 | _clock_getres(clockid_t clock_id, struct timespec *tp) |
306 | { |
307 | unsigned __int64 freq, qpc_res_ns; |
308 | |
309 | QueryPerformanceFrequency((LARGE_INTEGER*)&freq); |
310 | qpc_res_ns = IV_1E91000000000 > freq ? IV_1E91000000000 / freq : 1; |
311 | |
312 | switch (clock_id) { |
313 | case CLOCK_REALTIME0: |
314 | tp->tv_sec = 0; |
315 | /* the resolution can't be smaller than 100ns because our implementation |
316 | * of CLOCK_REALTIME is using FILETIME internally */ |
317 | tp->tv_nsec = (long)(qpc_res_ns > 100 ? qpc_res_ns : 100); |
318 | break; |
319 | |
320 | case CLOCK_MONOTONIC3: |
321 | tp->tv_sec = 0; |
322 | tp->tv_nsec = (long)qpc_res_ns; |
323 | break; |
324 | |
325 | default: |
326 | errno(*__errno()) = EINVAL22; |
327 | return 1; |
328 | } |
329 | |
330 | return 0; |
331 | } |
332 | |
333 | #endif /* #if defined(WIN32) || defined(CYGWIN_WITH_W32API) */ |
334 | |
335 | #if !defined(HAS_GETTIMEOFDAY) && defined(VMS) |
336 | # define HAS_GETTIMEOFDAY |
337 | |
338 | # include <lnmdef.h> |
339 | # include <time.h> /* gettimeofday */ |
340 | # include <stdlib.h> /* qdiv */ |
341 | # include <starlet.h> /* sys$gettim */ |
342 | # include <descrip.h> |
343 | # ifdef __VAX |
344 | # include <lib$routines.h> /* lib$ediv() */ |
345 | # endif |
346 | |
347 | /* |
348 | VMS binary time is expressed in 100 nano-seconds since |
349 | system base time which is 17-NOV-1858 00:00:00.00 |
350 | */ |
351 | |
352 | # define DIV_100NS_TO_SECS 10000000L |
353 | # define DIV_100NS_TO_USECS 10L |
354 | |
355 | /* |
356 | gettimeofday is supposed to return times since the epoch |
357 | so need to determine this in terms of VMS base time |
358 | */ |
359 | static $DESCRIPTOR(dscepoch,"01-JAN-1970 00:00:00.00"); |
360 | |
361 | # ifdef __VAX |
362 | static long base_adjust[2]={0L,0L}; |
363 | # else |
364 | static __int64 base_adjust=0; |
365 | # endif |
366 | |
367 | /* |
368 | |
369 | If we don't have gettimeofday, then likely we are on a VMS machine that |
370 | operates on local time rather than UTC...so we have to zone-adjust. |
371 | This code gleefully swiped from VMS.C |
372 | |
373 | */ |
374 | /* method used to handle UTC conversions: |
375 | * 1 == CRTL gmtime(); 2 == SYS$TIMEZONE_DIFFERENTIAL; 3 == no correction |
376 | */ |
377 | static int gmtime_emulation_type; |
378 | /* number of secs to add to UTC POSIX-style time to get local time */ |
379 | static long int utc_offset_secs; |
380 | static struct dsc$descriptor_s fildevdsc = |
381 | { 12, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$FILE_DEV" }; |
382 | static struct dsc$descriptor_s *fildev[] = { &fildevdsc, NULL((void*)0) }; |
383 | |
384 | static time_t toutc_dst(time_t loc) { |
385 | struct tm *rsltmp; |
386 | |
387 | if ((rsltmp = localtime(&loc)) == NULL((void*)0)) return -1; |
388 | loc -= utc_offset_secs; |
389 | if (rsltmp->tm_isdst) loc -= 3600; |
390 | return loc; |
391 | } |
392 | |
393 | static time_t toloc_dst(time_t utc) { |
394 | struct tm *rsltmp; |
395 | |
396 | utc += utc_offset_secs; |
397 | if ((rsltmp = localtime(&utc)) == NULL((void*)0)) return -1; |
398 | if (rsltmp->tm_isdst) utc += 3600; |
399 | return utc; |
400 | } |
401 | |
402 | # define _toutc(secs) ((secs) == (time_t) -1 ? (time_t) -1 : \ |
403 | ((gmtime_emulation_type || timezone_setup()), \ |
404 | (gmtime_emulation_type == 1 ? toutc_dst(secs) : \ |
405 | ((secs) - utc_offset_secs)))) |
406 | |
407 | # define _toloc(secs) ((secs) == (time_t) -1 ? (time_t) -1 : \ |
408 | ((gmtime_emulation_type || timezone_setup()), \ |
409 | (gmtime_emulation_type == 1 ? toloc_dst(secs) : \ |
410 | ((secs) + utc_offset_secs)))) |
411 | |
412 | static int |
413 | timezone_setup(void) |
414 | { |
415 | struct tm *tm_p; |
416 | |
417 | if (gmtime_emulation_type == 0) { |
418 | int dstnow; |
419 | time_t base = 15 * 86400; /* 15jan71; to avoid month/year ends between */ |
420 | /* results of calls to gmtime() and localtime() */ |
421 | /* for same &base */ |
422 | |
423 | gmtime_emulation_type++; |
424 | if ((tm_p = gmtime(&base)) == NULL((void*)0)) { /* CRTL gmtime() is a fake */ |
425 | char off[LNM$C_NAMLENGTH+1];; |
426 | |
427 | gmtime_emulation_type++; |
428 | if (!Perl_vmstrnenv("SYS$TIMEZONE_DIFFERENTIAL",off,0,fildev,0)) { |
429 | gmtime_emulation_type++; |
430 | utc_offset_secs = 0; |
431 | Perl_warn(aTHX_ "no UTC offset information; assuming local time is UTC"); |
432 | } |
433 | else { utc_offset_secs = atol(off); } |
434 | } |
435 | else { /* We've got a working gmtime() */ |
436 | struct tm gmt, local; |
437 | |
438 | gmt = *tm_p; |
439 | tm_p = localtime(&base); |
440 | local = *tm_p; |
441 | utc_offset_secs = (local.tm_mday - gmt.tm_mday) * 86400; |
442 | utc_offset_secs += (local.tm_hour - gmt.tm_hour) * 3600; |
443 | utc_offset_secs += (local.tm_min - gmt.tm_min) * 60; |
444 | utc_offset_secs += (local.tm_sec - gmt.tm_sec); |
445 | } |
446 | } |
447 | return 1; |
448 | } |
449 | |
450 | |
451 | int |
452 | gettimeofday (struct timeval *tp, void *tpz) |
453 | { |
454 | long ret; |
455 | # ifdef __VAX |
456 | long quad[2]; |
457 | long quad1[2]; |
458 | long div_100ns_to_secs; |
459 | long div_100ns_to_usecs; |
460 | long quo,rem; |
461 | long quo1,rem1; |
462 | # else |
463 | __int64 quad; |
464 | __qdiv_t ans1,ans2; |
465 | # endif |
466 | /* |
467 | In case of error, tv_usec = 0 and tv_sec = VMS condition code. |
468 | The return from function is also set to -1. |
469 | This is not exactly as per the manual page. |
470 | */ |
471 | |
472 | tp->tv_usec = 0; |
473 | |
474 | # ifdef __VAX |
475 | if (base_adjust[0]==0 && base_adjust[1]==0) { |
476 | # else |
477 | if (base_adjust==0) { /* Need to determine epoch adjustment */ |
478 | # endif |
479 | ret=sys$bintim(&dscepoch,&base_adjust); |
480 | if (1 != (ret &&1)) { |
481 | tp->tv_sec = ret; |
482 | return -1; |
483 | } |
484 | } |
485 | |
486 | ret=sys$gettim(&quad); /* Get VMS system time */ |
487 | if ((1 && ret) == 1) { |
488 | # ifdef __VAX |
489 | quad[0] -= base_adjust[0]; /* convert to epoch offset */ |
490 | quad[1] -= base_adjust[1]; /* convert 2nd half of quadword */ |
491 | div_100ns_to_secs = DIV_100NS_TO_SECS; |
492 | div_100ns_to_usecs = DIV_100NS_TO_USECS; |
493 | lib$ediv(&div_100ns_to_secs,&quad,&quo,&rem); |
494 | quad1[0] = rem; |
495 | quad1[1] = 0L; |
496 | lib$ediv(&div_100ns_to_usecs,&quad1,&quo1,&rem1); |
497 | tp->tv_sec = quo; /* Whole seconds */ |
498 | tp->tv_usec = quo1; /* Micro-seconds */ |
499 | # else |
500 | quad -= base_adjust; /* convert to epoch offset */ |
501 | ans1=qdiv(quad,DIV_100NS_TO_SECS); |
502 | ans2=qdiv(ans1.rem,DIV_100NS_TO_USECS); |
503 | tp->tv_sec = ans1.quot; /* Whole seconds */ |
504 | tp->tv_usec = ans2.quot; /* Micro-seconds */ |
505 | # endif |
506 | } else { |
507 | tp->tv_sec = ret; |
508 | return -1; |
509 | } |
510 | # ifdef VMSISH_TIME |
511 | # ifdef RTL_USES_UTC |
512 | if (VMSISH_TIME) tp->tv_sec = _toloc(tp->tv_sec); |
513 | # else |
514 | if (!VMSISH_TIME) tp->tv_sec = _toutc(tp->tv_sec); |
515 | # endif |
516 | # endif |
517 | return 0; |
518 | } |
519 | #endif /* #if !defined(HAS_GETTIMEOFDAY) && defined(VMS) */ |
520 | |
521 | |
522 | /* Do not use H A S _ N A N O S L E E P |
523 | * so that Perl Configure doesn't scan for it (and pull in -lrt and |
524 | * the like which are not usually good ideas for the default Perl). |
525 | * (We are part of the core perl now.) |
526 | * The TIME_HIRES_NANOSLEEP is set by Makefile.PL. */ |
527 | #if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP1) |
528 | # define HAS_USLEEP |
529 | # define usleep hrt_usleep /* could conflict with ncurses for static build */ |
530 | |
531 | static void |
532 | hrt_usleep(unsigned long usec) /* This is used to emulate usleep. */ |
533 | { |
534 | struct timespec res; |
535 | res.tv_sec = usec / IV_1E61000000; |
536 | res.tv_nsec = ( usec - res.tv_sec * IV_1E61000000 ) * 1000; |
537 | nanosleep(&res, NULL((void*)0)); |
538 | } |
539 | |
540 | #endif /* #if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP) */ |
541 | |
542 | #if !defined(HAS_USLEEP) && defined(HAS_SELECT) |
543 | # ifndef SELECT_IS_BROKEN |
544 | # define HAS_USLEEP |
545 | # define usleep hrt_usleep /* could conflict with ncurses for static build */ |
546 | |
547 | static void |
548 | hrt_usleep(unsigned long usec) |
549 | { |
550 | struct timeval tv; |
551 | tv.tv_sec = 0; |
552 | tv.tv_usec = usec; |
553 | select(0, (Select_fd_set_tfd_set *)NULL((void*)0), (Select_fd_set_tfd_set *)NULL((void*)0), |
554 | (Select_fd_set_tfd_set *)NULL((void*)0), &tv); |
555 | } |
556 | # endif |
557 | #endif /* #if !defined(HAS_USLEEP) && defined(HAS_SELECT) */ |
558 | |
559 | #if !defined(HAS_USLEEP) && defined(WIN32) |
560 | # define HAS_USLEEP |
561 | # define usleep hrt_usleep /* could conflict with ncurses for static build */ |
562 | |
563 | static void |
564 | hrt_usleep(unsigned long usec) |
565 | { |
566 | long msec; |
567 | msec = usec / 1000; |
568 | Sleep (msec); |
569 | } |
570 | #endif /* #if !defined(HAS_USLEEP) && defined(WIN32) */ |
571 | |
572 | #if !defined(HAS_USLEEP) && defined(HAS_POLL) |
573 | # define HAS_USLEEP |
574 | # define usleep hrt_usleep /* could conflict with ncurses for static build */ |
575 | |
576 | static void |
577 | hrt_usleep(unsigned long usec) |
578 | { |
579 | int msec = usec / 1000; |
580 | poll(0, 0, msec); |
581 | } |
582 | |
583 | #endif /* #if !defined(HAS_USLEEP) && defined(HAS_POLL) */ |
584 | |
585 | #if defined(HAS_SETITIMER) && defined(ITIMER_REAL0) |
586 | |
587 | static int |
588 | hrt_ualarm_itimero(struct itimerval *oitv, int usec, int uinterval) |
589 | { |
590 | struct itimerval itv; |
591 | itv.it_value.tv_sec = usec / IV_1E61000000; |
592 | itv.it_value.tv_usec = usec % IV_1E61000000; |
593 | itv.it_interval.tv_sec = uinterval / IV_1E61000000; |
594 | itv.it_interval.tv_usec = uinterval % IV_1E61000000; |
595 | return setitimer(ITIMER_REAL0, &itv, oitv); |
596 | } |
597 | |
598 | #endif /* #if !defined(HAS_UALARM) && defined(HAS_SETITIMER) */ |
599 | |
600 | #if !defined(HAS_UALARM) && defined(HAS_SETITIMER) |
601 | # define HAS_UALARM |
602 | # define ualarm hrt_ualarm_itimer /* could conflict with ncurses for static build */ |
603 | #endif |
604 | |
605 | #if !defined(HAS_UALARM) && defined(VMS) |
606 | # define HAS_UALARM |
607 | # define ualarm vms_ualarm |
608 | |
609 | # include <lib$routines.h> |
610 | # include <ssdef.h> |
611 | # include <starlet.h> |
612 | # include <descrip.h> |
613 | # include <signal.h> |
614 | # include <jpidef.h> |
615 | # include <psldef.h> |
616 | |
617 | # define VMSERR(s) (!((s)&1)) |
618 | |
619 | static void |
620 | us_to_VMS(useconds_t mseconds, unsigned long v[]) |
621 | { |
622 | int iss; |
623 | unsigned long qq[2]; |
624 | |
625 | qq[0] = mseconds; |
626 | qq[1] = 0; |
627 | v[0] = v[1] = 0; |
628 | |
629 | iss = lib$addx(qq,qq,qq); |
630 | if (VMSERR(iss)) lib$signal(iss); |
631 | iss = lib$subx(v,qq,v); |
632 | if (VMSERR(iss)) lib$signal(iss); |
633 | iss = lib$addx(qq,qq,qq); |
634 | if (VMSERR(iss)) lib$signal(iss); |
635 | iss = lib$subx(v,qq,v); |
636 | if (VMSERR(iss)) lib$signal(iss); |
637 | iss = lib$subx(v,qq,v); |
638 | if (VMSERR(iss)) lib$signal(iss); |
639 | } |
640 | |
641 | static int |
642 | VMS_to_us(unsigned long v[]) |
643 | { |
644 | int iss; |
645 | unsigned long div=10,quot, rem; |
646 | |
647 | iss = lib$ediv(&div,v,",&rem); |
648 | if (VMSERR(iss)) lib$signal(iss); |
649 | |
650 | return quot; |
651 | } |
652 | |
653 | typedef unsigned short word; |
654 | typedef struct _ualarm { |
655 | int function; |
656 | int repeat; |
657 | unsigned long delay[2]; |
658 | unsigned long interval[2]; |
659 | unsigned long remain[2]; |
660 | } Alarm; |
661 | |
662 | |
663 | static int alarm_ef; |
664 | static Alarm *a0, alarm_base; |
665 | # define UAL_NULL 0 |
666 | # define UAL_SET 1 |
667 | # define UAL_CLEAR 2 |
668 | # define UAL_ACTIVE 4 |
669 | static void ualarm_AST(Alarm *a); |
670 | |
671 | static int |
672 | vms_ualarm(int mseconds, int interval) |
673 | { |
674 | Alarm *a, abase; |
675 | struct item_list3 { |
676 | word length; |
677 | word code; |
678 | void *bufaddr; |
679 | void *retlenaddr; |
680 | } ; |
681 | static struct item_list3 itmlst[2]; |
682 | static int first = 1; |
683 | unsigned long asten; |
684 | int iss, enabled; |
685 | |
686 | if (first) { |
687 | first = 0; |
688 | itmlst[0].code = JPI$_ASTEN; |
689 | itmlst[0].length = sizeof(asten); |
690 | itmlst[0].retlenaddr = NULL((void*)0); |
691 | itmlst[1].code = 0; |
692 | itmlst[1].length = 0; |
693 | itmlst[1].bufaddr = NULL((void*)0); |
694 | itmlst[1].retlenaddr = NULL((void*)0); |
695 | |
696 | iss = lib$get_ef(&alarm_ef); |
697 | if (VMSERR(iss)) lib$signal(iss); |
698 | |
699 | a0 = &alarm_base; |
700 | a0->function = UAL_NULL; |
701 | } |
702 | itmlst[0].bufaddr = &asten; |
703 | |
704 | iss = sys$getjpiw(0,0,0,itmlst,0,0,0); |
705 | if (VMSERR(iss)) lib$signal(iss); |
706 | if (!(asten&0x08)) return -1; |
707 | |
708 | a = &abase; |
709 | if (mseconds) { |
710 | a->function = UAL_SET; |
711 | } else { |
712 | a->function = UAL_CLEAR; |
713 | } |
714 | |
715 | us_to_VMS(mseconds, a->delay); |
716 | if (interval) { |
717 | us_to_VMS(interval, a->interval); |
718 | a->repeat = 1; |
719 | } else |
720 | a->repeat = 0; |
721 | |
722 | iss = sys$clref(alarm_ef); |
723 | if (VMSERR(iss)) lib$signal(iss); |
724 | |
725 | iss = sys$dclast(ualarm_AST,a,0); |
726 | if (VMSERR(iss)) lib$signal(iss); |
727 | |
728 | iss = sys$waitfr(alarm_ef); |
729 | if (VMSERR(iss)) lib$signal(iss); |
730 | |
731 | if (a->function == UAL_ACTIVE) |
732 | return VMS_to_us(a->remain); |
733 | else |
734 | return 0; |
735 | } |
736 | |
737 | |
738 | |
739 | static void |
740 | ualarm_AST(Alarm *a) |
741 | { |
742 | int iss; |
743 | unsigned long now[2]; |
744 | |
745 | iss = sys$gettim(now); |
746 | if (VMSERR(iss)) lib$signal(iss); |
747 | |
748 | if (a->function == UAL_SET || a->function == UAL_CLEAR) { |
749 | if (a0->function == UAL_ACTIVE) { |
750 | iss = sys$cantim(a0,PSL$C_USER); |
751 | if (VMSERR(iss)) lib$signal(iss); |
752 | |
753 | iss = lib$subx(a0->remain, now, a->remain); |
754 | if (VMSERR(iss)) lib$signal(iss); |
755 | |
756 | if (a->remain[1] & 0x80000000) |
757 | a->remain[0] = a->remain[1] = 0; |
758 | } |
759 | |
760 | if (a->function == UAL_SET) { |
761 | a->function = a0->function; |
762 | a0->function = UAL_ACTIVE; |
763 | a0->repeat = a->repeat; |
764 | if (a0->repeat) { |
765 | a0->interval[0] = a->interval[0]; |
766 | a0->interval[1] = a->interval[1]; |
767 | } |
768 | a0->delay[0] = a->delay[0]; |
769 | a0->delay[1] = a->delay[1]; |
770 | |
771 | iss = lib$subx(now, a0->delay, a0->remain); |
772 | if (VMSERR(iss)) lib$signal(iss); |
773 | |
774 | iss = sys$setimr(0,a0->delay,ualarm_AST,a0); |
775 | if (VMSERR(iss)) lib$signal(iss); |
776 | } else { |
777 | a->function = a0->function; |
778 | a0->function = UAL_NULL; |
779 | } |
780 | iss = sys$setef(alarm_ef); |
781 | if (VMSERR(iss)) lib$signal(iss); |
782 | } else if (a->function == UAL_ACTIVE) { |
783 | if (a->repeat) { |
784 | iss = lib$subx(now, a->interval, a->remain); |
785 | if (VMSERR(iss)) lib$signal(iss); |
786 | |
787 | iss = sys$setimr(0,a->interval,ualarm_AST,a); |
788 | if (VMSERR(iss)) lib$signal(iss); |
789 | } else { |
790 | a->function = UAL_NULL; |
791 | } |
792 | iss = sys$wake(0,0); |
793 | if (VMSERR(iss)) lib$signal(iss); |
794 | lib$signal(SS$_ASTFLT); |
795 | } else { |
796 | lib$signal(SS$_BADPARAM); |
797 | } |
798 | } |
799 | |
800 | #endif /* #if !defined(HAS_UALARM) && defined(VMS) */ |
801 | |
802 | #ifdef HAS_GETTIMEOFDAY |
803 | |
804 | static int |
805 | myU2time(pTHX_ UV *ret) |
806 | { |
807 | struct timeval Tp; |
808 | int status; |
809 | status = gettimeofday (&Tp, NULL((void*)0)); |
810 | ret[0] = Tp.tv_sec; |
811 | ret[1] = Tp.tv_usec; |
812 | return status; |
813 | } |
814 | |
815 | static NV |
816 | myNVtime() |
817 | { |
818 | # ifdef WIN32 |
819 | dTHXstruct Perl___notused_struct; |
820 | # endif |
821 | struct timeval Tp; |
822 | int status; |
823 | status = gettimeofday (&Tp, NULL((void*)0)); |
824 | return status == 0 ? Tp.tv_sec + (Tp.tv_usec / NV_1E61000000.0) : -1.0; |
825 | } |
826 | |
827 | #endif /* #ifdef HAS_GETTIMEOFDAY */ |
828 | |
829 | static void |
830 | hrstatns(UV *atime_nsec, UV *mtime_nsec, UV *ctime_nsec) |
831 | { |
832 | dTHXstruct Perl___notused_struct; |
833 | #if TIME_HIRES_STAT1 == 1 |
834 | *atime_nsec = PL_statcache.st_atimespecst_atim.tv_nsec; |
835 | *mtime_nsec = PL_statcache.st_mtimespecst_mtim.tv_nsec; |
836 | *ctime_nsec = PL_statcache.st_ctimespecst_ctim.tv_nsec; |
837 | #elif TIME_HIRES_STAT1 == 2 |
838 | *atime_nsec = PL_statcache.st_atimensecst_atim.tv_nsec; |
839 | *mtime_nsec = PL_statcache.st_mtimensecst_mtim.tv_nsec; |
840 | *ctime_nsec = PL_statcache.st_ctimensecst_ctim.tv_nsec; |
841 | #elif TIME_HIRES_STAT1 == 3 |
842 | *atime_nsec = PL_statcache.st_atime_n; |
843 | *mtime_nsec = PL_statcache.st_mtime_n; |
844 | *ctime_nsec = PL_statcache.st_ctime_n; |
845 | #elif TIME_HIRES_STAT1 == 4 |
846 | *atime_nsec = PL_statcache.st_atim.tv_nsec; |
847 | *mtime_nsec = PL_statcache.st_mtim.tv_nsec; |
848 | *ctime_nsec = PL_statcache.st_ctim.tv_nsec; |
849 | #elif TIME_HIRES_STAT1 == 5 |
850 | *atime_nsec = PL_statcache.st_uatime * 1000; |
851 | *mtime_nsec = PL_statcache.st_umtime * 1000; |
852 | *ctime_nsec = PL_statcache.st_uctime * 1000; |
853 | #else /* !TIME_HIRES_STAT */ |
854 | *atime_nsec = 0; |
855 | *mtime_nsec = 0; |
856 | *ctime_nsec = 0; |
857 | #endif /* !TIME_HIRES_STAT */ |
858 | } |
859 | |
860 | /* Until Apple implements clock_gettime() |
861 | * (ditto clock_getres() and clock_nanosleep()) |
862 | * we will emulate them using the Mach kernel interfaces. */ |
863 | #if defined(PERL_DARWIN) && \ |
864 | (defined(TIME_HIRES_CLOCK_GETTIME_EMULATION) || \ |
865 | defined(TIME_HIRES_CLOCK_GETRES_EMULATION) || \ |
866 | defined(TIME_HIRES_CLOCK_NANOSLEEP_EMULATION)) |
867 | |
868 | # ifndef CLOCK_REALTIME0 |
869 | # define CLOCK_REALTIME0 0x01 |
870 | # define CLOCK_MONOTONIC3 0x02 |
871 | # endif |
872 | |
873 | # ifndef TIMER_ABSTIME0x1 |
874 | # define TIMER_ABSTIME0x1 0x01 |
875 | # endif |
876 | |
877 | # ifdef USE_ITHREADS |
878 | # define PERL_DARWIN_MUTEX |
879 | # endif |
880 | |
881 | # ifdef PERL_DARWIN_MUTEX |
882 | STATICstatic perl_mutex darwin_time_mutex; |
883 | # endif |
884 | |
885 | # include <mach/mach_time.h> |
886 | |
887 | static uint64_t absolute_time_init; |
888 | static mach_timebase_info_data_t timebase_info; |
889 | static struct timespec timespec_init; |
890 | |
891 | static int darwin_time_init() { |
892 | struct timeval tv; |
893 | int success = 1; |
894 | # ifdef PERL_DARWIN_MUTEX |
895 | MUTEX_LOCK(&darwin_time_mutex)(void)0; |
896 | # endif |
897 | if (absolute_time_init == 0) { |
898 | /* mach_absolute_time() cannot fail */ |
899 | absolute_time_init = mach_absolute_time(); |
900 | success = mach_timebase_info(&timebase_info) == KERN_SUCCESS; |
901 | if (success) { |
902 | success = gettimeofday(&tv, NULL((void*)0)) == 0; |
903 | if (success) { |
904 | timespec_init.tv_sec = tv.tv_sec; |
905 | timespec_init.tv_nsec = tv.tv_usec * 1000; |
906 | } |
907 | } |
908 | } |
909 | # ifdef PERL_DARWIN_MUTEX |
910 | MUTEX_UNLOCK(&darwin_time_mutex)(void)0; |
911 | # endif |
912 | return success; |
913 | } |
914 | |
915 | # ifdef TIME_HIRES_CLOCK_GETTIME_EMULATION |
916 | static int th_clock_gettime(clockid_t clock_id, struct timespec *ts) { |
917 | if (darwin_time_init() && timebase_info.denom) { |
918 | switch (clock_id) { |
919 | case CLOCK_REALTIME0: |
920 | { |
921 | uint64_t nanos = |
922 | ((mach_absolute_time() - absolute_time_init) * |
923 | (uint64_t)timebase_info.numer) / (uint64_t)timebase_info.denom; |
924 | ts->tv_sec = timespec_init.tv_sec + nanos / IV_1E91000000000; |
925 | ts->tv_nsec = timespec_init.tv_nsec + nanos % IV_1E91000000000; |
926 | return 0; |
927 | } |
928 | |
929 | case CLOCK_MONOTONIC3: |
930 | { |
931 | uint64_t nanos = |
932 | (mach_absolute_time() * |
933 | (uint64_t)timebase_info.numer) / (uint64_t)timebase_info.denom; |
934 | ts->tv_sec = nanos / IV_1E91000000000; |
935 | ts->tv_nsec = nanos - ts->tv_sec * IV_1E91000000000; |
936 | return 0; |
937 | } |
938 | |
939 | default: |
940 | break; |
941 | } |
942 | } |
943 | |
944 | SETERRNO(EINVAL, LIB_INVARG)((*__errno()) = (22)); |
945 | return -1; |
946 | } |
947 | |
948 | # define clock_gettime(clock_id, ts) th_clock_gettime((clock_id), (ts)) |
949 | |
950 | # endif /* TIME_HIRES_CLOCK_GETTIME_EMULATION */ |
951 | |
952 | # ifdef TIME_HIRES_CLOCK_GETRES_EMULATION |
953 | static int th_clock_getres(clockid_t clock_id, struct timespec *ts) { |
954 | if (darwin_time_init() && timebase_info.denom) { |
955 | switch (clock_id) { |
956 | case CLOCK_REALTIME0: |
957 | case CLOCK_MONOTONIC3: |
958 | ts->tv_sec = 0; |
959 | /* In newer kernels both the numer and denom are one, |
960 | * resulting in conversion factor of one, which is of |
961 | * course unrealistic. */ |
962 | ts->tv_nsec = timebase_info.numer / timebase_info.denom; |
963 | return 0; |
964 | default: |
965 | break; |
966 | } |
967 | } |
968 | |
969 | SETERRNO(EINVAL, LIB_INVARG)((*__errno()) = (22)); |
970 | return -1; |
971 | } |
972 | |
973 | # define clock_getres(clock_id, ts) th_clock_getres((clock_id), (ts)) |
974 | # endif /* TIME_HIRES_CLOCK_GETRES_EMULATION */ |
975 | |
976 | # ifdef TIME_HIRES_CLOCK_NANOSLEEP_EMULATION |
977 | static int th_clock_nanosleep(clockid_t clock_id, int flags, |
978 | const struct timespec *rqtp, |
979 | struct timespec *rmtp) { |
980 | if (darwin_time_init()) { |
981 | switch (clock_id) { |
982 | case CLOCK_REALTIME0: |
983 | case CLOCK_MONOTONIC3: |
984 | { |
985 | uint64_t nanos = rqtp->tv_sec * IV_1E91000000000 + rqtp->tv_nsec; |
986 | int success; |
987 | if ((flags & TIMER_ABSTIME0x1)) { |
988 | uint64_t back = |
989 | timespec_init.tv_sec * IV_1E91000000000 + timespec_init.tv_nsec; |
990 | nanos = nanos > back ? nanos - back : 0; |
991 | } |
992 | success = |
993 | mach_wait_until(mach_absolute_time() + nanos) == KERN_SUCCESS; |
994 | |
995 | /* In the relative sleep, the rmtp should be filled in with |
996 | * the 'unused' part of the rqtp in case the sleep gets |
997 | * interrupted by a signal. But it is unknown how signals |
998 | * interact with mach_wait_until(). In the absolute sleep, |
999 | * the rmtp should stay untouched. */ |
1000 | rmtp->tv_sec = 0; |
1001 | rmtp->tv_nsec = 0; |
1002 | |
1003 | return success; |
1004 | } |
1005 | |
1006 | default: |
1007 | break; |
1008 | } |
1009 | } |
1010 | |
1011 | SETERRNO(EINVAL, LIB_INVARG)((*__errno()) = (22)); |
1012 | return -1; |
1013 | } |
1014 | |
1015 | # define clock_nanosleep(clock_id, flags, rqtp, rmtp) \ |
1016 | th_clock_nanosleep((clock_id), (flags), (rqtp), (rmtp)) |
1017 | |
1018 | # endif /* TIME_HIRES_CLOCK_NANOSLEEP_EMULATION */ |
1019 | |
1020 | #endif /* PERL_DARWIN */ |
1021 | |
1022 | /* The macOS headers warn about using certain interfaces in |
1023 | * OS-release-ignorant manner, for example: |
1024 | * |
1025 | * warning: 'futimens' is only available on macOS 10.13 or newer |
1026 | * [-Wunguarded-availability-new] |
1027 | * |
1028 | * (ditto for utimensat) |
1029 | * |
1030 | * There is clang __builtin_available() *runtime* check for this. |
1031 | * The gotchas are that neither __builtin_available() nor __has_builtin() |
1032 | * are always available. |
1033 | */ |
1034 | #ifndef __has_builtin |
1035 | # define0 __has_builtin(x)0 0 /* non-clang */ |
1036 | #endif |
1037 | #ifdef HAS_FUTIMENS1 |
1038 | # if defined(PERL_DARWIN) && __has_builtin(__builtin_available)1 |
1039 | # define FUTIMENS_AVAILABLE1 __builtin_available(macOS 10.13, *) |
1040 | # else |
1041 | # define FUTIMENS_AVAILABLE1 1 |
1042 | # endif |
1043 | #else |
1044 | # define FUTIMENS_AVAILABLE1 0 |
1045 | #endif |
1046 | #ifdef HAS_UTIMENSAT1 |
1047 | # if defined(PERL_DARWIN) && __has_builtin(__builtin_available)1 |
1048 | # define UTIMENSAT_AVAILABLE1 __builtin_available(macOS 10.13, *) |
1049 | # else |
1050 | # define UTIMENSAT_AVAILABLE1 1 |
1051 | # endif |
1052 | #else |
1053 | # define UTIMENSAT_AVAILABLE1 0 |
1054 | #endif |
1055 | |
1056 | #include "const-c.inc" |
1057 | |
1058 | #if (defined(TIME_HIRES_NANOSLEEP1)) || \ |
1059 | (defined(TIME_HIRES_CLOCK_NANOSLEEP) && defined(TIMER_ABSTIME0x1)) |
1060 | |
1061 | static void |
1062 | nanosleep_init(NV nsec, |
1063 | struct timespec *sleepfor, |
1064 | struct timespec *unslept) { |
1065 | sleepfor->tv_sec = (Time_ttime_t)(nsec / NV_1E91000000000.0); |
1066 | sleepfor->tv_nsec = (long)(nsec - ((NV)sleepfor->tv_sec) * NV_1E91000000000.0); |
1067 | unslept->tv_sec = 0; |
1068 | unslept->tv_nsec = 0; |
1069 | } |
1070 | |
1071 | static NV |
1072 | nsec_without_unslept(struct timespec *sleepfor, |
1073 | const struct timespec *unslept) { |
1074 | if (sleepfor->tv_sec >= unslept->tv_sec) { |
1075 | sleepfor->tv_sec -= unslept->tv_sec; |
1076 | if (sleepfor->tv_nsec >= unslept->tv_nsec) { |
1077 | sleepfor->tv_nsec -= unslept->tv_nsec; |
1078 | } else if (sleepfor->tv_sec > 0) { |
1079 | sleepfor->tv_sec--; |
1080 | sleepfor->tv_nsec += IV_1E91000000000; |
1081 | sleepfor->tv_nsec -= unslept->tv_nsec; |
1082 | } else { |
1083 | sleepfor->tv_sec = 0; |
1084 | sleepfor->tv_nsec = 0; |
1085 | } |
1086 | } else { |
1087 | sleepfor->tv_sec = 0; |
1088 | sleepfor->tv_nsec = 0; |
1089 | } |
1090 | return ((NV)sleepfor->tv_sec) * NV_1E91000000000.0 + ((NV)sleepfor->tv_nsec); |
1091 | } |
1092 | |
1093 | #endif |
1094 | |
1095 | /* In case Perl and/or Devel::PPPort are too old, minimally emulate |
1096 | * IS_SAFE_PATHNAME() (which looks for zero bytes in the pathname). */ |
1097 | #ifndef IS_SAFE_PATHNAME |
1098 | # if PERL_VERSION32 >= 12 /* Perl_ck_warner is 5.10.0 -> */ |
1099 | # ifdef WARN_SYSCALLS57 |
1100 | # define WARNEMUCAT WARN_SYSCALLS57 /* 5.22.0 -> */ |
1101 | # else |
1102 | # define WARNEMUCAT WARN_MISC12 |
1103 | # endif |
1104 | # define WARNEMU(opname) Perl_ck_warner(aTHX_ packWARN(WARNEMUCAT)(WARNEMUCAT ), "Invalid \\0 character in pathname for %s",opname) |
1105 | # else |
1106 | # define WARNEMU(opname) Perl_warn(aTHX_ "Invalid \\0 character in pathname for %s",opname) |
1107 | # endif |
1108 | # define IS_SAFE_PATHNAME(pv, len, opname)(Perl_is_safe_syscall( ((pv)), ((len)), ("pathname"), ((opname )))) (((len)>1)&&memchr((pv), 0, (len)-1)?(SETERRNO(ENOENT, LIB_INVARG)((*__errno()) = (2)),WARNEMU(opname),FALSE(0)):(TRUE(1))) |
1109 | #endif |
1110 | |
1111 | #line 1112 "HiRes.c" |
1112 | #ifndef PERL_UNUSED_VAR |
1113 | # define PERL_UNUSED_VAR(var)((void)sizeof(var)) if (0) var = var |
1114 | #endif |
1115 | |
1116 | #ifndef dVARstruct Perl___notused_struct |
1117 | # define dVARstruct Perl___notused_struct dNOOPstruct Perl___notused_struct |
1118 | #endif |
1119 | |
1120 | |
1121 | /* This stuff is not part of the API! You have been warned. */ |
1122 | #ifndef PERL_VERSION_DECIMAL |
1123 | # define PERL_VERSION_DECIMAL(r,v,s)(r*1000000 + v*1000 + s) (r*1000000 + v*1000 + s) |
1124 | #endif |
1125 | #ifndef PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) |
1126 | # define PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) \ |
1127 | PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)(5*1000000 + 32*1000 + 1) |
1128 | #endif |
1129 | #ifndef PERL_VERSION_GE |
1130 | # define PERL_VERSION_GE(r,v,s)((5*1000000 + 32*1000 + 1) >= (r*1000000 + v*1000 + s)) \ |
1131 | (PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) >= PERL_VERSION_DECIMAL(r,v,s)(r*1000000 + v*1000 + s)) |
1132 | #endif |
1133 | #ifndef PERL_VERSION_LE |
1134 | # define PERL_VERSION_LE(r,v,s)((5*1000000 + 32*1000 + 1) <= (r*1000000 + v*1000 + s)) \ |
1135 | (PERL_DECIMAL_VERSION(5*1000000 + 32*1000 + 1) <= PERL_VERSION_DECIMAL(r,v,s)(r*1000000 + v*1000 + s)) |
1136 | #endif |
1137 | |
1138 | /* XS_INTERNAL is the explicit static-linkage variant of the default |
1139 | * XS macro. |
1140 | * |
1141 | * XS_EXTERNAL is the same as XS_INTERNAL except it does not include |
1142 | * "STATIC", ie. it exports XSUB symbols. You probably don't want that |
1143 | * for anything but the BOOT XSUB. |
1144 | * |
1145 | * See XSUB.h in core! |
1146 | */ |
1147 | |
1148 | |
1149 | /* TODO: This might be compatible further back than 5.10.0. */ |
1150 | #if PERL_VERSION_GE(5, 10, 0)((5*1000000 + 32*1000 + 1) >= (5*1000000 + 10*1000 + 0)) && PERL_VERSION_LE(5, 15, 1)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 15*1000 + 1)) |
1151 | # undef XS_EXTERNAL |
1152 | # undef XS_INTERNAL |
1153 | # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) |
1154 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) __declspec(dllexport) XSPROTO(name)void name( CV* cv __attribute__((unused))) |
1155 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) STATICstatic XSPROTO(name)void name( CV* cv __attribute__((unused))) |
1156 | # endif |
1157 | # if defined(__SYMBIAN32__) |
1158 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) EXPORT_C XSPROTO(name)void name( CV* cv __attribute__((unused))) |
1159 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) EXPORT_C STATICstatic XSPROTO(name)void name( CV* cv __attribute__((unused))) |
1160 | # endif |
1161 | # ifndef XS_EXTERNAL |
1162 | # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) |
1163 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) void name(pTHX_ CV* cv __attribute__unused____attribute__((unused))) |
1164 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) STATICstatic void name(pTHX_ CV* cv __attribute__unused____attribute__((unused))) |
1165 | # else |
1166 | # ifdef __cplusplus |
1167 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) extern "C" XSPROTO(name)void name( CV* cv __attribute__((unused))) |
1168 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) static XSPROTO(name)void name( CV* cv __attribute__((unused))) |
1169 | # else |
1170 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) XSPROTO(name)void name( CV* cv __attribute__((unused))) |
1171 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) STATICstatic XSPROTO(name)void name( CV* cv __attribute__((unused))) |
1172 | # endif |
1173 | # endif |
1174 | # endif |
1175 | #endif |
1176 | |
1177 | /* perl >= 5.10.0 && perl <= 5.15.1 */ |
1178 | |
1179 | |
1180 | /* The XS_EXTERNAL macro is used for functions that must not be static |
1181 | * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL |
1182 | * macro defined, the best we can do is assume XS is the same. |
1183 | * Dito for XS_INTERNAL. |
1184 | */ |
1185 | #ifndef XS_EXTERNAL |
1186 | # define XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) XS(name)void name( CV* cv __attribute__((unused))) |
1187 | #endif |
1188 | #ifndef XS_INTERNAL |
1189 | # define XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) XS(name)void name( CV* cv __attribute__((unused))) |
1190 | #endif |
1191 | |
1192 | /* Now, finally, after all this mess, we want an ExtUtils::ParseXS |
1193 | * internal macro that we're free to redefine for varying linkage due |
1194 | * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use |
1195 | * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to! |
1196 | */ |
1197 | |
1198 | #undef XS_EUPXS |
1199 | #if defined(PERL_EUPXS_ALWAYS_EXPORT) |
1200 | # define XS_EUPXS(name)static void name( CV* cv __attribute__((unused))) XS_EXTERNAL(name)void name( CV* cv __attribute__((unused))) |
1201 | #else |
1202 | /* default to internal */ |
1203 | # define XS_EUPXS(name)static void name( CV* cv __attribute__((unused))) XS_INTERNAL(name)static void name( CV* cv __attribute__((unused))) |
1204 | #endif |
1205 | |
1206 | #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE((void)0); ((void)0) |
1207 | #define PERL_ARGS_ASSERT_CROAK_XS_USAGE((void)0); ((void)0) assert(cv)((void)0); assert(params)((void)0) |
1208 | |
1209 | /* prototype to pass -Wmissing-prototypes */ |
1210 | STATICstatic void |
1211 | S_croak_xs_usage(const CV *const cv, const char *const params); |
1212 | |
1213 | STATICstatic void |
1214 | S_croak_xs_usage(const CV *const cv, const char *const params) |
1215 | { |
1216 | const GV *const gv = CvGV(cv)Perl_CvGV( (CV *)(cv)); |
1217 | |
1218 | PERL_ARGS_ASSERT_CROAK_XS_USAGE((void)0); ((void)0); |
1219 | |
1220 | if (gv) { |
1221 | const char *const gvname = GvNAME(gv)((((XPVGV*)(gv)->sv_any)->xiv_u.xivu_namehek))->hek_key; |
1222 | const HV *const stash = GvSTASH(gv)(((XPVGV*)(gv)->sv_any)->xnv_u.xgv_stash); |
1223 | const char *const hvname = stash ? HvNAME(stash)((((stash)->sv_flags & 0x02000000) && ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV*) (stash )->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_name && ( ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_count ? * ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_names : ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_name )) ? (( ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash )[((XPVHV*) (stash)->sv_any)->xhv_max+1]))->xhv_name_count ? *((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_names : ((struct xpvhv_aux*)&(((stash)->sv_u.svu_hash)[((XPVHV *) (stash)->sv_any)->xhv_max+1]))->xhv_name_u.xhvnameu_name ))->hek_key : ((void*)0)) : NULL((void*)0); |
1224 | |
1225 | if (hvname) |
1226 | Perl_croak_nocontextPerl_croak("Usage: %s::%s(%s)", hvname, gvname, params); |
1227 | else |
1228 | Perl_croak_nocontextPerl_croak("Usage: %s(%s)", gvname, params); |
1229 | } else { |
1230 | /* Pants. I don't think that it should be possible to get here. */ |
1231 | Perl_croak_nocontextPerl_croak("Usage: CODE(0x%" UVxf"lx" ")(%s)", PTR2UV(cv)(UV)(cv), params); |
1232 | } |
1233 | } |
1234 | #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE((void)0); ((void)0) |
1235 | |
1236 | #define croak_xs_usagePerl_croak_xs_usage S_croak_xs_usage |
1237 | |
1238 | #endif |
1239 | |
1240 | /* NOTE: the prototype of newXSproto() is different in versions of perls, |
1241 | * so we define a portable version of newXSproto() |
1242 | */ |
1243 | #ifdef newXS_flags |
1244 | #define newXSproto_portable(name, c_impl, file, proto)Perl_newXS_flags( name,c_impl,file,proto,0) newXS_flags(name, c_impl, file, proto, 0)Perl_newXS_flags( name,c_impl,file,proto,0) |
1245 | #else |
1246 | #define newXSproto_portable(name, c_impl, file, proto)Perl_newXS_flags( name,c_impl,file,proto,0) (PL_Sv=(SV*)newXS(name, c_impl, file)Perl_newXS( name,c_impl,file), sv_setpv(PL_Sv, proto)Perl_sv_setpv( PL_Sv,proto), (CV*)PL_Sv) |
1247 | #endif /* !defined(newXS_flags) */ |
1248 | |
1249 | #if PERL_VERSION_LE(5, 21, 5)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 21*1000 + 5)) |
1250 | # define newXS_deffile(a,b)Perl_newXS_deffile( a,b) Perl_newXS(aTHX_ a,b,file) |
1251 | #else |
1252 | # define newXS_deffile(a,b)Perl_newXS_deffile( a,b) Perl_newXS_deffile(aTHX_ a,b) |
1253 | #endif |
1254 | |
1255 | #line 1256 "HiRes.c" |
1256 | #if defined(USE_ITHREADS) && defined(MY_CXT_KEY) |
1257 | #define XSubPPtmpAAAA 1 |
1258 | |
1259 | |
1260 | XS_EUPXS(XS_Time__HiRes_CLONE)static void XS_Time__HiRes_CLONE( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1261 | XS_EUPXS(XS_Time__HiRes_CLONE)static void XS_Time__HiRes_CLONE( CV* cv __attribute__((unused ))) |
1262 | { |
1263 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1264 | PERL_UNUSED_VAR(cv)((void)sizeof(cv)); /* -W */ |
1265 | PERL_UNUSED_VAR(items)((void)sizeof(items)); /* -W */ |
1266 | { |
1267 | #line 1131 "HiRes.xs" |
1268 | MY_CXT_CLONE(void)0; |
1269 | #line 1270 "HiRes.c" |
1270 | } |
1271 | XSRETURN_EMPTYdo { do { const IV tmpXSoff = (0); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); } while (0); |
1272 | } |
1273 | |
1274 | #endif |
1275 | |
1276 | /* INCLUDE: Including 'const-xs.inc' from 'HiRes.xs' */ |
1277 | |
1278 | |
1279 | XS_EUPXS(XS_Time__HiRes_constant)static void XS_Time__HiRes_constant( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1280 | XS_EUPXS(XS_Time__HiRes_constant)static void XS_Time__HiRes_constant( CV* cv __attribute__((unused ))) |
1281 | { |
1282 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1283 | if (items != 1) |
1284 | croak_xs_usagePerl_croak_xs_usage(cv, "sv"); |
1285 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
1286 | SPsp -= items; |
1287 | { |
1288 | #line 4 "./const-xs.inc" |
1289 | #ifdef dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()) |
1290 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); /* Faster if we have it. */ |
1291 | #else |
1292 | dTARGETSV * targ = (PL_curpad[PL_op->op_targ]); |
1293 | #endif |
1294 | STRLEN len; |
1295 | int type; |
1296 | IV iv = 0; /* avoid uninit var warning */ |
1297 | /* NV nv; Uncomment this if you need to return NVs */ |
1298 | /* const char *pv; Uncomment this if you need to return PVs */ |
1299 | #line 1300 "HiRes.c" |
1300 | SV * sv = ST(0)PL_stack_base[ax + (0)] |
1301 | ; |
1302 | const char * s = SvPV(sv, len)((((sv)->sv_flags & (0x00000400|0x00200000)) == 0x00000400 ) ? ((len = ((XPV*) (sv)->sv_any)->xpv_cur), ((sv)-> sv_u.svu_pv)) : Perl_sv_2pv_flags( sv,&len,2)); |
1303 | #line 18 "./const-xs.inc" |
1304 | /* Change this to constant(aTHX_ s, len, &iv, &nv); |
1305 | if you need to return both NVs and IVs */ |
1306 | type = constant(aTHX_ s, len, &iv); |
1307 | /* Return 1 or 2 items. First is error message, or undef if no error. |
1308 | Second, if present, is found value */ |
1309 | switch (type) { |
1310 | case PERL_constant_NOTFOUND1: |
1311 | sv = |
1312 | sv_2mortal(newSVpvf("%s is not a valid Time::HiRes macro", s))Perl_sv_2mortal( Perl_newSVpvf("%s is not a valid Time::HiRes macro" , s)); |
1313 | PUSHs(sv)(*++sp = (sv)); |
1314 | break; |
1315 | case PERL_constant_NOTDEF2: |
1316 | sv = sv_2mortal(newSVpvf(Perl_sv_2mortal( Perl_newSVpvf( "Your vendor has not defined Time::HiRes macro %s, used" , s)) |
1317 | "Your vendor has not defined Time::HiRes macro %s, used",Perl_sv_2mortal( Perl_newSVpvf( "Your vendor has not defined Time::HiRes macro %s, used" , s)) |
1318 | s))Perl_sv_2mortal( Perl_newSVpvf( "Your vendor has not defined Time::HiRes macro %s, used" , s)); |
1319 | PUSHs(sv)(*++sp = (sv)); |
1320 | break; |
1321 | case PERL_constant_ISIV3: |
1322 | EXTEND(SP, 2)do { (void)0; if (__builtin_expect(((((2) < 0 || PL_stack_max - (sp) < (2))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(2) > sizeof(ssize_t) && ((ssize_t) (2) != (2)) ? -1 : (2))); ((void)sizeof(sp)); } } while (0); |
1323 | PUSHs(&PL_sv_undef)(*++sp = (&(PL_sv_immortals[1]))); |
1324 | PUSHi(iv)do { do { IV TARGi_iv = iv; if (__builtin_expect((((((targ)-> sv_flags & (0xff|(0x08000000|0x00010000|0x00000800|0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000); targ ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ,TARGi_iv ); } while (0); (*++sp = (targ)); } while (0); |
1325 | break; |
1326 | /* Uncomment this if you need to return NOs |
1327 | case PERL_constant_ISNO: |
1328 | EXTEND(SP, 2); |
1329 | PUSHs(&PL_sv_undef); |
1330 | PUSHs(&PL_sv_no); |
1331 | break; */ |
1332 | /* Uncomment this if you need to return NVs |
1333 | case PERL_constant_ISNV: |
1334 | EXTEND(SP, 2); |
1335 | PUSHs(&PL_sv_undef); |
1336 | PUSHn(nv); |
1337 | break; */ |
1338 | /* Uncomment this if you need to return PVs |
1339 | case PERL_constant_ISPV: |
1340 | EXTEND(SP, 2); |
1341 | PUSHs(&PL_sv_undef); |
1342 | PUSHp(pv, strlen(pv)); |
1343 | break; */ |
1344 | /* Uncomment this if you need to return PVNs |
1345 | case PERL_constant_ISPVN: |
1346 | EXTEND(SP, 2); |
1347 | PUSHs(&PL_sv_undef); |
1348 | PUSHp(pv, iv); |
1349 | break; */ |
1350 | /* Uncomment this if you need to return SVs |
1351 | case PERL_constant_ISSV: |
1352 | EXTEND(SP, 2); |
1353 | PUSHs(&PL_sv_undef); |
1354 | PUSHs(sv); |
1355 | break; */ |
1356 | /* Uncomment this if you need to return UNDEFs |
1357 | case PERL_constant_ISUNDEF: |
1358 | break; */ |
1359 | /* Uncomment this if you need to return UVs |
1360 | case PERL_constant_ISUV: |
1361 | EXTEND(SP, 2); |
1362 | PUSHs(&PL_sv_undef); |
1363 | PUSHu((UV)iv); |
1364 | break; */ |
1365 | /* Uncomment this if you need to return YESs |
1366 | case PERL_constant_ISYES: |
1367 | EXTEND(SP, 2); |
1368 | PUSHs(&PL_sv_undef); |
1369 | PUSHs(&PL_sv_yes); |
1370 | break; */ |
1371 | default: |
1372 | sv = sv_2mortal(newSVpvf(Perl_sv_2mortal( Perl_newSVpvf( "Unexpected return type %d while processing Time::HiRes macro %s, used" , type, s)) |
1373 | "Unexpected return type %d while processing Time::HiRes macro %s, used",Perl_sv_2mortal( Perl_newSVpvf( "Unexpected return type %d while processing Time::HiRes macro %s, used" , type, s)) |
1374 | type, s))Perl_sv_2mortal( Perl_newSVpvf( "Unexpected return type %d while processing Time::HiRes macro %s, used" , type, s)); |
1375 | PUSHs(sv)(*++sp = (sv)); |
1376 | } |
1377 | #line 1378 "HiRes.c" |
1378 | PUTBACKPL_stack_sp = sp; |
1379 | return; |
1380 | } |
1381 | } |
1382 | |
1383 | |
1384 | /* INCLUDE: Returning to 'HiRes.xs' from 'const-xs.inc' */ |
1385 | |
1386 | #if defined(HAS_USLEEP) && defined(HAS_GETTIMEOFDAY) |
1387 | #define XSubPPtmpAAAB1 1 |
1388 | |
1389 | |
1390 | XS_EUPXS(XS_Time__HiRes_usleep)static void XS_Time__HiRes_usleep( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1391 | XS_EUPXS(XS_Time__HiRes_usleep)static void XS_Time__HiRes_usleep( CV* cv __attribute__((unused ))) |
1392 | { |
1393 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1394 | if (items != 1) |
1395 | croak_xs_usagePerl_croak_xs_usage(cv, "useconds"); |
1396 | { |
1397 | NV useconds = (NV)SvNV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (0)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (0 )],2)) |
1398 | ; |
1399 | #line 1143 "HiRes.xs" |
1400 | struct timeval Ta, Tb; |
1401 | #line 1402 "HiRes.c" |
1402 | NV RETVAL; |
1403 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1404 | #line 1145 "HiRes.xs" |
1405 | gettimeofday(&Ta, NULL((void*)0)); |
1406 | if (items > 0) { |
1407 | if (useconds >= NV_1E61000000.0) { |
1408 | IV seconds = (IV) (useconds / NV_1E61000000.0); |
1409 | /* If usleep() has been implemented using setitimer() |
1410 | * then this contortion is unnecessary-- but usleep() |
1411 | * may be implemented in some other way, so let's contort. */ |
1412 | if (seconds) { |
1413 | sleep(seconds); |
1414 | useconds -= NV_1E61000000.0 * seconds; |
1415 | } |
1416 | } else if (useconds < 0.0) |
1417 | croakPerl_croak("Time::HiRes::usleep(%" NVgf"g" |
1418 | "): negative time not invented yet", useconds); |
1419 | |
1420 | usleep((U32)useconds); |
1421 | } else |
1422 | PerlProc_pause()pause(); |
1423 | |
1424 | gettimeofday(&Tb, NULL((void*)0)); |
1425 | # if 0 |
1426 | printf("[%ld %ld] [%ld %ld]\n", Tb.tv_sec, Tb.tv_usec, Ta.tv_sec, Ta.tv_usec); |
1427 | # endif |
1428 | RETVAL = NV_1E61000000.0*(Tb.tv_sec-Ta.tv_sec)+(NV)((IV)Tb.tv_usec-(IV)Ta.tv_usec); |
1429 | |
1430 | #line 1431 "HiRes.c" |
1431 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
1432 | } |
1433 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1434 | } |
1435 | |
1436 | # if defined(TIME_HIRES_NANOSLEEP1) |
1437 | #define XSubPPtmpAAAC1 1 |
1438 | |
1439 | |
1440 | XS_EUPXS(XS_Time__HiRes_nanosleep)static void XS_Time__HiRes_nanosleep( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1441 | XS_EUPXS(XS_Time__HiRes_nanosleep)static void XS_Time__HiRes_nanosleep( CV* cv __attribute__((unused ))) |
1442 | { |
1443 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1444 | if (items != 1) |
1445 | croak_xs_usagePerl_croak_xs_usage(cv, "nsec"); |
1446 | { |
1447 | NV nsec = (NV)SvNV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (0)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (0 )],2)) |
1448 | ; |
1449 | #line 1179 "HiRes.xs" |
1450 | struct timespec sleepfor, unslept; |
1451 | #line 1452 "HiRes.c" |
1452 | NV RETVAL; |
1453 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1454 | #line 1181 "HiRes.xs" |
1455 | if (nsec < 0.0) |
1456 | croakPerl_croak("Time::HiRes::nanosleep(%" NVgf"g" |
1457 | "): negative time not invented yet", nsec); |
1458 | nanosleep_init(nsec, &sleepfor, &unslept); |
1459 | if (nanosleep(&sleepfor, &unslept) == 0) { |
1460 | RETVAL = nsec; |
1461 | } else { |
1462 | RETVAL = nsec_without_unslept(&sleepfor, &unslept); |
1463 | } |
1464 | #line 1465 "HiRes.c" |
1465 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
1466 | } |
1467 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1468 | } |
1469 | |
1470 | # else /* #if defined(TIME_HIRES_NANOSLEEP) */ |
1471 | #define XSubPPtmpAAAD 1 |
1472 | |
1473 | |
1474 | XS_EUPXS(XS_Time__HiRes_nanosleep)static void XS_Time__HiRes_nanosleep( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1475 | XS_EUPXS(XS_Time__HiRes_nanosleep)static void XS_Time__HiRes_nanosleep( CV* cv __attribute__((unused ))) |
1476 | { |
1477 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1478 | if (items != 1) |
1479 | croak_xs_usagePerl_croak_xs_usage(cv, "nsec"); |
1480 | { |
1481 | NV nsec = (NV)SvNV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (0)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (0 )],2)) |
1482 | ; |
1483 | NV RETVAL; |
1484 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1485 | #line 1199 "HiRes.xs" |
1486 | PERL_UNUSED_ARG(nsec)((void)sizeof(nsec)); |
1487 | croakPerl_croak("Time::HiRes::nanosleep(): unimplemented in this platform"); |
1488 | RETVAL = 0.0; |
1489 | #line 1490 "HiRes.c" |
1490 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
1491 | } |
1492 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1493 | } |
1494 | |
1495 | # endif /* #if defined(TIME_HIRES_NANOSLEEP) */ |
1496 | |
1497 | XS_EUPXS(XS_Time__HiRes_sleep)static void XS_Time__HiRes_sleep( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1498 | XS_EUPXS(XS_Time__HiRes_sleep)static void XS_Time__HiRes_sleep( CV* cv __attribute__((unused ))) |
1499 | { |
1500 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1501 | PERL_UNUSED_VAR(cv)((void)sizeof(cv)); /* -W */ |
1502 | PERL_UNUSED_VAR(items)((void)sizeof(items)); /* -W */ |
1503 | { |
1504 | #line 1210 "HiRes.xs" |
1505 | struct timeval Ta, Tb; |
1506 | #line 1507 "HiRes.c" |
1507 | NV RETVAL; |
1508 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1509 | #line 1212 "HiRes.xs" |
1510 | gettimeofday(&Ta, NULL((void*)0)); |
1511 | if (items > 0) { |
1512 | NV seconds = SvNV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (0)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (0 )],2)); |
1513 | if (seconds >= 0.0) { |
1514 | UV useconds = (UV)(1E6 * (seconds - (UV)seconds)); |
1515 | if (seconds >= 1.0) |
1516 | sleep((U32)seconds); |
1517 | if ((IV)useconds < 0) { |
1518 | # if defined(__sparc64__) && defined(__GNUC__4) |
1519 | /* Sparc64 gcc 2.95.3 (e.g. on NetBSD) has a bug |
1520 | * where (0.5 - (UV)(0.5)) will under certain |
1521 | * circumstances (if the double is cast to UV more |
1522 | * than once?) evaluate to -0.5, instead of 0.5. */ |
1523 | useconds = -(IV)useconds; |
1524 | # endif /* #if defined(__sparc64__) && defined(__GNUC__) */ |
1525 | if ((IV)useconds < 0) |
1526 | croakPerl_croak("Time::HiRes::sleep(%" NVgf"g" |
1527 | "): internal error: useconds < 0 (unsigned %" UVuf"lu" |
1528 | " signed %" IVdf"ld" ")", |
1529 | seconds, useconds, (IV)useconds); |
1530 | } |
1531 | usleep(useconds); |
1532 | } else |
1533 | croakPerl_croak("Time::HiRes::sleep(%" NVgf"g" |
1534 | "): negative time not invented yet", seconds); |
1535 | } else |
1536 | PerlProc_pause()pause(); |
1537 | |
1538 | gettimeofday(&Tb, NULL((void*)0)); |
1539 | # if 0 |
1540 | printf("[%ld %ld] [%ld %ld]\n", Tb.tv_sec, Tb.tv_usec, Ta.tv_sec, Ta.tv_usec); |
1541 | # endif |
1542 | RETVAL = (NV)(Tb.tv_sec-Ta.tv_sec)+0.000001*(NV)(Tb.tv_usec-Ta.tv_usec); |
1543 | |
1544 | #line 1545 "HiRes.c" |
1545 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
1546 | } |
1547 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1548 | } |
1549 | |
1550 | #else /* #if defined(HAS_USLEEP) && defined(HAS_GETTIMEOFDAY) */ |
1551 | #define XSubPPtmpAAAE 1 |
1552 | |
1553 | |
1554 | XS_EUPXS(XS_Time__HiRes_usleep)static void XS_Time__HiRes_usleep( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1555 | XS_EUPXS(XS_Time__HiRes_usleep)static void XS_Time__HiRes_usleep( CV* cv __attribute__((unused ))) |
1556 | { |
1557 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1558 | if (items != 1) |
1559 | croak_xs_usagePerl_croak_xs_usage(cv, "useconds"); |
1560 | { |
1561 | NV useconds = (NV)SvNV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (0)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (0 )],2)) |
1562 | ; |
1563 | NV RETVAL; |
1564 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1565 | #line 1255 "HiRes.xs" |
1566 | PERL_UNUSED_ARG(useconds)((void)sizeof(useconds)); |
1567 | croakPerl_croak("Time::HiRes::usleep(): unimplemented in this platform"); |
1568 | RETVAL = 0.0; |
1569 | #line 1570 "HiRes.c" |
1570 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
1571 | } |
1572 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1573 | } |
1574 | |
1575 | #endif /* #if defined(HAS_USLEEP) && defined(HAS_GETTIMEOFDAY) */ |
1576 | #ifdef HAS_UALARM |
1577 | #define XSubPPtmpAAAF1 1 |
1578 | |
1579 | |
1580 | XS_EUPXS(XS_Time__HiRes_ualarm)static void XS_Time__HiRes_ualarm( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1581 | XS_EUPXS(XS_Time__HiRes_ualarm)static void XS_Time__HiRes_ualarm( CV* cv __attribute__((unused ))) |
1582 | { |
1583 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1584 | if (items < 1 || items > 2) |
1585 | croak_xs_usagePerl_croak_xs_usage(cv, "useconds, uinterval=0"); |
1586 | { |
1587 | int useconds = (int)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
1588 | ; |
1589 | int uinterval; |
1590 | IV RETVAL; |
1591 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1592 | |
1593 | if (items < 2) |
1594 | uinterval = 0; |
1595 | else { |
1596 | uinterval = (int)SvIV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (1)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 1)],2)) |
1597 | ; |
1598 | } |
1599 | #line 1270 "HiRes.xs" |
1600 | if (useconds < 0 || uinterval < 0) |
1601 | croakPerl_croak("Time::HiRes::ualarm(%d, %d): negative time not invented yet", useconds, uinterval); |
1602 | # if defined(HAS_SETITIMER) && defined(ITIMER_REAL0) |
1603 | { |
1604 | struct itimerval itv; |
1605 | if (hrt_ualarm_itimero(&itv, useconds, uinterval)) { |
1606 | /* To conform to ualarm's interface, we're actually ignoring |
1607 | an error here. */ |
1608 | RETVAL = 0; |
1609 | } else { |
1610 | RETVAL = itv.it_value.tv_sec * IV_1E61000000 + itv.it_value.tv_usec; |
1611 | } |
1612 | } |
1613 | # else |
1614 | if (useconds >= IV_1E61000000 || uinterval >= IV_1E61000000) |
1615 | croakPerl_croak("Time::HiRes::ualarm(%d, %d): useconds or uinterval" |
1616 | " equal to or more than %" IVdf"ld", |
1617 | useconds, uinterval, IV_1E61000000); |
1618 | |
1619 | RETVAL = ualarm(useconds, uinterval); |
1620 | # endif |
1621 | |
1622 | #line 1623 "HiRes.c" |
1623 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)do { do { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } while (0); (*++sp = (targ)); } while (0); |
1624 | } |
1625 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1626 | } |
1627 | |
1628 | |
1629 | XS_EUPXS(XS_Time__HiRes_alarm)static void XS_Time__HiRes_alarm( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1630 | XS_EUPXS(XS_Time__HiRes_alarm)static void XS_Time__HiRes_alarm( CV* cv __attribute__((unused ))) |
1631 | { |
1632 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1633 | if (items < 1 || items > 2) |
1634 | croak_xs_usagePerl_croak_xs_usage(cv, "seconds, interval=0"); |
1635 | { |
1636 | NV seconds = (NV)SvNV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (0)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (0 )],2)) |
1637 | ; |
1638 | NV interval; |
1639 | NV RETVAL; |
1640 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1641 | |
1642 | if (items < 2) |
1643 | interval = 0; |
1644 | else { |
1645 | interval = (NV)SvNV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (1)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (1 )],2)) |
1646 | ; |
1647 | } |
1648 | #line 1300 "HiRes.xs" |
1649 | if (seconds < 0.0 || interval < 0.0) |
1650 | croakPerl_croak("Time::HiRes::alarm(%" NVgf"g" ", %" NVgf"g" |
1651 | "): negative time not invented yet", seconds, interval); |
1652 | |
1653 | { |
1654 | IV iseconds = (IV)seconds; |
1655 | IV iinterval = (IV)interval; |
1656 | NV fseconds = seconds - iseconds; |
1657 | NV finterval = interval - iinterval; |
1658 | IV useconds, uinterval; |
1659 | if (fseconds >= 1.0 || finterval >= 1.0) |
1660 | croakPerl_croak("Time::HiRes::alarm(%" NVgf"g" ", %" NVgf"g" |
1661 | "): seconds or interval too large to split correctly", |
1662 | seconds, interval); |
1663 | |
1664 | useconds = IV_1E61000000 * fseconds; |
1665 | uinterval = IV_1E61000000 * finterval; |
1666 | # if defined(HAS_SETITIMER) && defined(ITIMER_REAL0) |
1667 | { |
1668 | struct itimerval nitv, oitv; |
1669 | nitv.it_value.tv_sec = iseconds; |
1670 | nitv.it_value.tv_usec = useconds; |
1671 | nitv.it_interval.tv_sec = iinterval; |
1672 | nitv.it_interval.tv_usec = uinterval; |
1673 | if (setitimer(ITIMER_REAL0, &nitv, &oitv)) { |
1674 | /* To conform to alarm's interface, we're actually ignoring |
1675 | an error here. */ |
1676 | RETVAL = 0; |
1677 | } else { |
1678 | RETVAL = oitv.it_value.tv_sec + ((NV)oitv.it_value.tv_usec) / NV_1E61000000.0; |
1679 | } |
1680 | } |
1681 | # else |
1682 | if (iseconds || iinterval) |
1683 | croakPerl_croak("Time::HiRes::alarm(%" NVgf"g" ", %" NVgf"g" |
1684 | "): seconds or interval equal to or more than 1.0 ", |
1685 | seconds, interval); |
1686 | |
1687 | RETVAL = (NV)ualarm( useconds, uinterval ) / NV_1E61000000.0; |
1688 | # endif |
1689 | } |
1690 | |
1691 | #line 1692 "HiRes.c" |
1692 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
1693 | } |
1694 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1695 | } |
1696 | |
1697 | #else /* #ifdef HAS_UALARM */ |
1698 | #define XSubPPtmpAAAG 1 |
1699 | |
1700 | |
1701 | XS_EUPXS(XS_Time__HiRes_ualarm)static void XS_Time__HiRes_ualarm( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1702 | XS_EUPXS(XS_Time__HiRes_ualarm)static void XS_Time__HiRes_ualarm( CV* cv __attribute__((unused ))) |
1703 | { |
1704 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1705 | if (items < 1 || items > 2) |
1706 | croak_xs_usagePerl_croak_xs_usage(cv, "useconds, interval=0"); |
1707 | { |
1708 | int useconds = (int)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
1709 | ; |
1710 | int interval; |
1711 | int RETVAL; |
1712 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1713 | |
1714 | if (items < 2) |
1715 | interval = 0; |
1716 | else { |
1717 | interval = (int)SvIV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (1)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 1)],2)) |
1718 | ; |
1719 | } |
1720 | #line 1352 "HiRes.xs" |
1721 | PERL_UNUSED_ARG(useconds)((void)sizeof(useconds)); |
1722 | PERL_UNUSED_ARG(interval)((void)sizeof(interval)); |
1723 | croakPerl_croak("Time::HiRes::ualarm(): unimplemented in this platform"); |
1724 | RETVAL = -1; |
1725 | #line 1726 "HiRes.c" |
1726 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)do { do { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } while (0); (*++sp = (targ)); } while (0); |
1727 | } |
1728 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1729 | } |
1730 | |
1731 | |
1732 | XS_EUPXS(XS_Time__HiRes_alarm)static void XS_Time__HiRes_alarm( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1733 | XS_EUPXS(XS_Time__HiRes_alarm)static void XS_Time__HiRes_alarm( CV* cv __attribute__((unused ))) |
1734 | { |
1735 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1736 | if (items < 1 || items > 2) |
1737 | croak_xs_usagePerl_croak_xs_usage(cv, "seconds, interval=0"); |
1738 | { |
1739 | NV seconds = (NV)SvNV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (0)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (0 )],2)) |
1740 | ; |
1741 | NV interval; |
1742 | NV RETVAL; |
1743 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1744 | |
1745 | if (items < 2) |
1746 | interval = 0; |
1747 | else { |
1748 | interval = (NV)SvNV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (1)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (1 )],2)) |
1749 | ; |
1750 | } |
1751 | #line 1364 "HiRes.xs" |
1752 | PERL_UNUSED_ARG(seconds)((void)sizeof(seconds)); |
1753 | PERL_UNUSED_ARG(interval)((void)sizeof(interval)); |
1754 | croakPerl_croak("Time::HiRes::alarm(): unimplemented in this platform"); |
1755 | RETVAL = 0.0; |
1756 | #line 1757 "HiRes.c" |
1757 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
1758 | } |
1759 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1760 | } |
1761 | |
1762 | #endif /* #ifdef HAS_UALARM */ |
1763 | #ifdef HAS_GETTIMEOFDAY |
1764 | #define XSubPPtmpAAAH1 1 |
1765 | |
1766 | |
1767 | XS_EUPXS(XS_Time__HiRes_gettimeofday)static void XS_Time__HiRes_gettimeofday( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
1768 | XS_EUPXS(XS_Time__HiRes_gettimeofday)static void XS_Time__HiRes_gettimeofday( CV* cv __attribute__ ((unused))) |
1769 | { |
1770 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1771 | if (items != 0) |
1772 | croak_xs_usagePerl_croak_xs_usage(cv, ""); |
1773 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
1774 | SPsp -= items; |
1775 | { |
1776 | #line 1378 "HiRes.xs" |
1777 | struct timeval Tp; |
1778 | #line 1779 "HiRes.c" |
1779 | #line 1380 "HiRes.xs" |
1780 | int status; |
1781 | status = gettimeofday (&Tp, NULL((void*)0)); |
1782 | if (status == 0) { |
1783 | if (GIMME(PL_op->op_flags & 3 ? ((PL_op->op_flags & 3) == 3 ? 3 : 2) : Perl_dowantarray()) == G_ARRAY3) { |
1784 | EXTEND(sp, 2)do { (void)0; if (__builtin_expect(((((2) < 0 || PL_stack_max - (sp) < (2))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(2) > sizeof(ssize_t) && ((ssize_t) (2) != (2)) ? -1 : (2))); ((void)sizeof(sp)); } } while (0); |
1785 | PUSHs(sv_2mortal(newSViv(Tp.tv_sec)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( Tp.tv_sec)))); |
1786 | PUSHs(sv_2mortal(newSViv(Tp.tv_usec)))(*++sp = (Perl_sv_2mortal( Perl_newSViv( Tp.tv_usec)))); |
1787 | } else { |
1788 | EXTEND(sp, 1)do { (void)0; if (__builtin_expect(((((1) < 0 || PL_stack_max - (sp) < (1))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(1) > sizeof(ssize_t) && ((ssize_t) (1) != (1)) ? -1 : (1))); ((void)sizeof(sp)); } } while (0); |
1789 | PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec / NV_1E6))))(*++sp = (Perl_sv_2mortal( Perl_newSVnv( Tp.tv_sec + (Tp.tv_usec / 1000000.0))))); |
1790 | } |
1791 | } |
1792 | #line 1793 "HiRes.c" |
1793 | PUTBACKPL_stack_sp = sp; |
1794 | return; |
1795 | } |
1796 | } |
1797 | |
1798 | |
1799 | XS_EUPXS(XS_Time__HiRes_time)static void XS_Time__HiRes_time( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1800 | XS_EUPXS(XS_Time__HiRes_time)static void XS_Time__HiRes_time( CV* cv __attribute__((unused ))) |
1801 | { |
1802 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1803 | if (items != 0) |
1804 | croak_xs_usagePerl_croak_xs_usage(cv, ""); |
1805 | { |
1806 | #line 1396 "HiRes.xs" |
1807 | struct timeval Tp; |
1808 | #line 1809 "HiRes.c" |
1809 | NV RETVAL; |
1810 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1811 | #line 1398 "HiRes.xs" |
1812 | int status; |
1813 | status = gettimeofday (&Tp, NULL((void*)0)); |
1814 | if (status == 0) { |
1815 | RETVAL = Tp.tv_sec + (Tp.tv_usec / NV_1E61000000.0); |
1816 | } else { |
1817 | RETVAL = -1.0; |
1818 | } |
1819 | #line 1820 "HiRes.c" |
1820 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
1821 | } |
1822 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
1823 | } |
1824 | |
1825 | #endif /* #ifdef HAS_GETTIMEOFDAY */ |
1826 | #if defined(HAS_GETITIMER) && defined(HAS_SETITIMER) |
1827 | # define TV2NV(tv)((NV)((tv).tv_sec) + 0.000001 * (NV)((tv).tv_usec)) ((NV)((tv).tv_sec) + 0.000001 * (NV)((tv).tv_usec)) |
1828 | #define XSubPPtmpAAAI1 1 |
1829 | |
1830 | |
1831 | XS_EUPXS(XS_Time__HiRes_setitimer)static void XS_Time__HiRes_setitimer( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1832 | XS_EUPXS(XS_Time__HiRes_setitimer)static void XS_Time__HiRes_setitimer( CV* cv __attribute__((unused ))) |
1833 | { |
1834 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1835 | if (items < 2 || items > 3) |
1836 | croak_xs_usagePerl_croak_xs_usage(cv, "which, seconds, interval = 0"); |
1837 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
1838 | SPsp -= items; |
1839 | { |
1840 | int which = (int)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
1841 | ; |
1842 | NV seconds = (NV)SvNV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (1)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (1 )],2)) |
1843 | ; |
1844 | NV interval; |
1845 | #line 1420 "HiRes.xs" |
1846 | struct itimerval newit; |
1847 | struct itimerval oldit; |
1848 | #line 1849 "HiRes.c" |
1849 | |
1850 | if (items < 3) |
1851 | interval = 0; |
1852 | else { |
1853 | interval = (NV)SvNV(ST(2))((((PL_stack_base[ax + (2)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (2)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (2 )],2)) |
1854 | ; |
1855 | } |
1856 | #line 1423 "HiRes.xs" |
1857 | if (seconds < 0.0 || interval < 0.0) |
1858 | croakPerl_croak("Time::HiRes::setitimer(%" IVdf"ld" ", %" NVgf"g" ", %" NVgf"g" |
1859 | "): negative time not invented yet", |
1860 | (IV)which, seconds, interval); |
1861 | newit.it_value.tv_sec = (IV)seconds; |
1862 | newit.it_value.tv_usec = |
1863 | (IV)((seconds - (NV)newit.it_value.tv_sec) * NV_1E61000000.0); |
1864 | newit.it_interval.tv_sec = (IV)interval; |
1865 | newit.it_interval.tv_usec = |
1866 | (IV)((interval - (NV)newit.it_interval.tv_sec) * NV_1E61000000.0); |
1867 | /* on some platforms the 1st arg to setitimer is an enum, which |
1868 | * causes -Wc++-compat to complain about passing an int instead |
1869 | */ |
1870 | GCC_DIAG_IGNORE_STMT(-Wc++-compat)GCC diagnostic push
GCC diagnostic ignored "-Wc++-compat"
( void)0; |
1871 | if (setitimer(which, &newit, &oldit) == 0) { |
1872 | EXTEND(sp, 1)do { (void)0; if (__builtin_expect(((((1) < 0 || PL_stack_max - (sp) < (1))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(1) > sizeof(ssize_t) && ((ssize_t) (1) != (1)) ? -1 : (1))); ((void)sizeof(sp)); } } while (0); |
1873 | PUSHs(sv_2mortal(newSVnv(TV2NV(oldit.it_value))))(*++sp = (Perl_sv_2mortal( Perl_newSVnv( ((NV)((oldit.it_value ).tv_sec) + 0.000001 * (NV)((oldit.it_value).tv_usec)))))); |
1874 | if (GIMME(PL_op->op_flags & 3 ? ((PL_op->op_flags & 3) == 3 ? 3 : 2) : Perl_dowantarray()) == G_ARRAY3) { |
1875 | EXTEND(sp, 1)do { (void)0; if (__builtin_expect(((((1) < 0 || PL_stack_max - (sp) < (1))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(1) > sizeof(ssize_t) && ((ssize_t) (1) != (1)) ? -1 : (1))); ((void)sizeof(sp)); } } while (0); |
1876 | PUSHs(sv_2mortal(newSVnv(TV2NV(oldit.it_interval))))(*++sp = (Perl_sv_2mortal( Perl_newSVnv( ((NV)((oldit.it_interval ).tv_sec) + 0.000001 * (NV)((oldit.it_interval).tv_usec)))))); |
1877 | } |
1878 | } |
1879 | GCC_DIAG_RESTORE_STMTGCC diagnostic pop (void)0; |
1880 | #line 1881 "HiRes.c" |
1881 | PUTBACKPL_stack_sp = sp; |
1882 | return; |
1883 | } |
1884 | } |
1885 | |
1886 | |
1887 | XS_EUPXS(XS_Time__HiRes_getitimer)static void XS_Time__HiRes_getitimer( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1888 | XS_EUPXS(XS_Time__HiRes_getitimer)static void XS_Time__HiRes_getitimer( CV* cv __attribute__((unused ))) |
1889 | { |
1890 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1891 | if (items != 1) |
1892 | croak_xs_usagePerl_croak_xs_usage(cv, "which"); |
1893 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
1894 | SPsp -= items; |
1895 | { |
1896 | int which = (int)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
1897 | ; |
1898 | #line 1451 "HiRes.xs" |
1899 | struct itimerval nowit; |
1900 | #line 1901 "HiRes.c" |
1901 | #line 1453 "HiRes.xs" |
1902 | /* on some platforms the 1st arg to getitimer is an enum, which |
1903 | * causes -Wc++-compat to complain about passing an int instead |
1904 | */ |
1905 | GCC_DIAG_IGNORE_STMT(-Wc++-compat)GCC diagnostic push
GCC diagnostic ignored "-Wc++-compat"
( void)0; |
1906 | if (getitimer(which, &nowit) == 0) { |
1907 | EXTEND(sp, 1)do { (void)0; if (__builtin_expect(((((1) < 0 || PL_stack_max - (sp) < (1))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(1) > sizeof(ssize_t) && ((ssize_t) (1) != (1)) ? -1 : (1))); ((void)sizeof(sp)); } } while (0); |
1908 | PUSHs(sv_2mortal(newSVnv(TV2NV(nowit.it_value))))(*++sp = (Perl_sv_2mortal( Perl_newSVnv( ((NV)((nowit.it_value ).tv_sec) + 0.000001 * (NV)((nowit.it_value).tv_usec)))))); |
1909 | if (GIMME(PL_op->op_flags & 3 ? ((PL_op->op_flags & 3) == 3 ? 3 : 2) : Perl_dowantarray()) == G_ARRAY3) { |
1910 | EXTEND(sp, 1)do { (void)0; if (__builtin_expect(((((1) < 0 || PL_stack_max - (sp) < (1))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(1) > sizeof(ssize_t) && ((ssize_t) (1) != (1)) ? -1 : (1))); ((void)sizeof(sp)); } } while (0); |
1911 | PUSHs(sv_2mortal(newSVnv(TV2NV(nowit.it_interval))))(*++sp = (Perl_sv_2mortal( Perl_newSVnv( ((NV)((nowit.it_interval ).tv_sec) + 0.000001 * (NV)((nowit.it_interval).tv_usec)))))); |
1912 | } |
1913 | } |
1914 | GCC_DIAG_RESTORE_STMTGCC diagnostic pop (void)0; |
1915 | #line 1916 "HiRes.c" |
1916 | PUTBACKPL_stack_sp = sp; |
1917 | return; |
1918 | } |
1919 | } |
1920 | |
1921 | #endif /* #if defined(HAS_GETITIMER) && defined(HAS_SETITIMER) */ |
1922 | #if defined(TIME_HIRES_UTIME1) |
1923 | #define XSubPPtmpAAAJ1 1 |
1924 | |
1925 | |
1926 | XS_EUPXS(XS_Time__HiRes_utime)static void XS_Time__HiRes_utime( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
1927 | XS_EUPXS(XS_Time__HiRes_utime)static void XS_Time__HiRes_utime( CV* cv __attribute__((unused ))) |
1928 | { |
1929 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
1930 | if (items < 2) |
1931 | croak_xs_usagePerl_croak_xs_usage(cv, "accessed, modified, ..."); |
1932 | { |
1933 | #line 1475 "HiRes.xs" |
1934 | SV* accessed; |
1935 | SV* modified; |
1936 | SV* file; |
1937 | |
1938 | struct timespec utbuf[2]; |
1939 | struct timespec *utbufp = utbuf; |
1940 | int tot; |
1941 | |
1942 | #line 1943 "HiRes.c" |
1943 | I32 RETVAL; |
1944 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
1945 | #line 1484 "HiRes.xs" |
1946 | accessed = ST(0)PL_stack_base[ax + (0)]; |
1947 | modified = ST(1)PL_stack_base[ax + (1)]; |
1948 | items -= 2; |
1949 | tot = 0; |
1950 | |
1951 | if ( accessed == &PL_sv_undef(PL_sv_immortals[1]) && modified == &PL_sv_undef(PL_sv_immortals[1]) ) |
1952 | utbufp = NULL((void*)0); |
1953 | else { |
1954 | if (SvNV(accessed)((((accessed)->sv_flags & (0x00000200|0x00200000)) == 0x00000200 ) ? ((XPVNV*) (accessed)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags ( accessed,2)) < 0.0 || SvNV(modified)((((modified)->sv_flags & (0x00000200|0x00200000)) == 0x00000200 ) ? ((XPVNV*) (modified)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags ( modified,2)) < 0.0) |
1955 | croakPerl_croak("Time::HiRes::utime(%" NVgf"g" ", %" NVgf"g" |
1956 | "): negative time not invented yet", |
1957 | SvNV(accessed)((((accessed)->sv_flags & (0x00000200|0x00200000)) == 0x00000200 ) ? ((XPVNV*) (accessed)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags ( accessed,2)), SvNV(modified)((((modified)->sv_flags & (0x00000200|0x00200000)) == 0x00000200 ) ? ((XPVNV*) (modified)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags ( modified,2))); |
1958 | Zero(&utbuf, sizeof utbuf, char)((void)(__builtin_expect(((((( sizeof(size_t) < sizeof(sizeof utbuf) || sizeof(char) > ((size_t)1 << 8*(sizeof(size_t ) - sizeof(sizeof utbuf)))) ? (size_t)(sizeof utbuf) : ((size_t )-1)/sizeof(char)) > ((size_t)-1)/sizeof(char))) ? (_Bool) 1 : (_Bool)0),(0)) && (Perl_croak_memory_wrap(),0)), ( (void)0), (void)memset((char*)(&utbuf),0,(sizeof utbuf) * sizeof(char))); |
1959 | |
1960 | utbuf[0].tv_sec = (Time_ttime_t)SvNV(accessed)((((accessed)->sv_flags & (0x00000200|0x00200000)) == 0x00000200 ) ? ((XPVNV*) (accessed)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags ( accessed,2)); /* time accessed */ |
1961 | utbuf[0].tv_nsec = (long)( |
1962 | (SvNV(accessed)((((accessed)->sv_flags & (0x00000200|0x00200000)) == 0x00000200 ) ? ((XPVNV*) (accessed)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags ( accessed,2)) - (NV)utbuf[0].tv_sec) |
1963 | * NV_1E91000000000.0 + (NV)0.5); |
1964 | |
1965 | utbuf[1].tv_sec = (Time_ttime_t)SvNV(modified)((((modified)->sv_flags & (0x00000200|0x00200000)) == 0x00000200 ) ? ((XPVNV*) (modified)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags ( modified,2)); /* time modified */ |
1966 | utbuf[1].tv_nsec = (long)( |
1967 | (SvNV(modified)((((modified)->sv_flags & (0x00000200|0x00200000)) == 0x00000200 ) ? ((XPVNV*) (modified)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags ( modified,2)) - (NV)utbuf[1].tv_sec) |
1968 | * NV_1E91000000000.0 + (NV)0.5); |
1969 | } |
1970 | |
1971 | while (items > 0) { |
1972 | file = POPs(*sp--); items--; |
1973 | |
1974 | if (SvROK(file)((file)->sv_flags & 0x00000800) && GvIO(SvRV(file))( (((file)->sv_u.svu_rv)) && ( ((svtype)(((const SV *)(((file)->sv_u.svu_rv)))->sv_flags & 0xff)) == SVt_PVGV || ((svtype)(((const SV*)(((file)->sv_u.svu_rv)))->sv_flags & 0xff)) == SVt_PVLV ) && (0+(((file)->sv_u.svu_rv ))->sv_u.svu_gp) ? ((0+(((file)->sv_u.svu_rv))->sv_u .svu_gp)->gp_io) : ((void*)0) ) && IoIFP(sv_2io(SvRV(file)))(Perl_sv_2io( ((file)->sv_u.svu_rv)))->sv_u.svu_fp) { |
1975 | int fd = PerlIO_fileno(IoIFP(sv_2io(file)))Perl_PerlIO_fileno( (Perl_sv_2io( file))->sv_u.svu_fp); |
1976 | if (fd < 0) { |
1977 | SETERRNO(EBADF,RMS_IFI)((*__errno()) = (9)); |
1978 | } else { |
1979 | # ifdef HAS_FUTIMENS1 |
1980 | if (FUTIMENS_AVAILABLE1) { |
1981 | if (futimens(fd, utbufp) == 0) { |
1982 | tot++; |
1983 | } |
1984 | } else { |
1985 | croakPerl_croak("futimens unimplemented in this platform"); |
1986 | } |
1987 | # else /* HAS_FUTIMENS */ |
1988 | croakPerl_croak("futimens unimplemented in this platform"); |
1989 | # endif /* HAS_FUTIMENS */ |
1990 | } |
1991 | } |
1992 | else { |
1993 | # ifdef HAS_UTIMENSAT1 |
1994 | if (UTIMENSAT_AVAILABLE1) { |
1995 | STRLEN len; |
1996 | char * name = SvPV(file, len)((((file)->sv_flags & (0x00000400|0x00200000)) == 0x00000400 ) ? ((len = ((XPV*) (file)->sv_any)->xpv_cur), ((file)-> sv_u.svu_pv)) : Perl_sv_2pv_flags( file,&len,2)); |
1997 | if (IS_SAFE_PATHNAME(name, len, "utime")(Perl_is_safe_syscall( ((name)), ((len)), ("pathname"), (("utime" )))) && |
1998 | utimensat(AT_FDCWD-100, name, utbufp, 0) == 0) { |
1999 | |
2000 | tot++; |
2001 | } |
2002 | } else { |
2003 | croakPerl_croak("utimensat unimplemented in this platform"); |
2004 | } |
2005 | # else /* HAS_UTIMENSAT */ |
2006 | croakPerl_croak("utimensat unimplemented in this platform"); |
2007 | # endif /* HAS_UTIMENSAT */ |
2008 | } |
2009 | } /* while items */ |
2010 | RETVAL = tot; |
2011 | |
2012 | #line 2013 "HiRes.c" |
2013 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)do { do { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } while (0); (*++sp = (targ)); } while (0); |
2014 | } |
2015 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2016 | } |
2017 | |
2018 | #else /* #if defined(TIME_HIRES_UTIME) */ |
2019 | #define XSubPPtmpAAAK 1 |
2020 | |
2021 | |
2022 | XS_EUPXS(XS_Time__HiRes_utime)static void XS_Time__HiRes_utime( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
2023 | XS_EUPXS(XS_Time__HiRes_utime)static void XS_Time__HiRes_utime( CV* cv __attribute__((unused ))) |
2024 | { |
2025 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2026 | if (items < 2) |
2027 | croak_xs_usagePerl_croak_xs_usage(cv, "accessed, modified, ..."); |
2028 | { |
2029 | I32 RETVAL; |
2030 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2031 | #line 1558 "HiRes.xs" |
2032 | croakPerl_croak("Time::HiRes::utime(): unimplemented in this platform"); |
2033 | RETVAL = 0; |
2034 | #line 2035 "HiRes.c" |
2035 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHi((IV)RETVAL)do { do { IV TARGi_iv = (IV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000)|0x80000000)) == SVt_IV) & (1 ? !(((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool) 0),(0))) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0) ,(1))) { ((void)0); (targ)->sv_flags |= (0x00000100|0x00001000 ); targ->sv_u.svu_iv = TARGi_iv; } else Perl_sv_setiv_mg( targ ,TARGi_iv); } while (0); (*++sp = (targ)); } while (0); |
2036 | } |
2037 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2038 | } |
2039 | |
2040 | #endif /* #if defined(TIME_HIRES_UTIME) */ |
2041 | #if defined(TIME_HIRES_CLOCK_GETTIME1) |
2042 | #define XSubPPtmpAAAL1 1 |
2043 | |
2044 | |
2045 | XS_EUPXS(XS_Time__HiRes_clock_gettime)static void XS_Time__HiRes_clock_gettime( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
2046 | XS_EUPXS(XS_Time__HiRes_clock_gettime)static void XS_Time__HiRes_clock_gettime( CV* cv __attribute__ ((unused))) |
2047 | { |
2048 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2049 | if (items < 0 || items > 1) |
2050 | croak_xs_usagePerl_croak_xs_usage(cv, "clock_id = CLOCK_REALTIME"); |
2051 | { |
2052 | clockid_t clock_id; |
2053 | #line 1571 "HiRes.xs" |
2054 | struct timespec ts; |
2055 | int status = -1; |
2056 | #line 2057 "HiRes.c" |
2057 | NV RETVAL; |
2058 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2059 | |
2060 | if (items < 1) |
2061 | clock_id = CLOCK_REALTIME0; |
2062 | else { |
2063 | clock_id = (clockid_t)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
2064 | ; |
2065 | } |
2066 | #line 1574 "HiRes.xs" |
2067 | # ifdef TIME_HIRES_CLOCK_GETTIME_SYSCALL |
2068 | status = syscall(SYS_clock_gettime, clock_id, &ts); |
2069 | # else |
2070 | status = clock_gettime(clock_id, &ts); |
2071 | # endif |
2072 | RETVAL = status == 0 ? ts.tv_sec + (NV) ts.tv_nsec / NV_1E91000000000.0 : -1; |
2073 | |
2074 | #line 2075 "HiRes.c" |
2075 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
2076 | } |
2077 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2078 | } |
2079 | |
2080 | #else /* if defined(TIME_HIRES_CLOCK_GETTIME) */ |
2081 | #define XSubPPtmpAAAM 1 |
2082 | |
2083 | |
2084 | XS_EUPXS(XS_Time__HiRes_clock_gettime)static void XS_Time__HiRes_clock_gettime( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
2085 | XS_EUPXS(XS_Time__HiRes_clock_gettime)static void XS_Time__HiRes_clock_gettime( CV* cv __attribute__ ((unused))) |
2086 | { |
2087 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2088 | if (items < 0 || items > 1) |
2089 | croak_xs_usagePerl_croak_xs_usage(cv, "clock_id = 0"); |
2090 | { |
2091 | clockid_t clock_id; |
2092 | NV RETVAL; |
2093 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2094 | |
2095 | if (items < 1) |
2096 | clock_id = 0; |
2097 | else { |
2098 | clock_id = (clockid_t)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
2099 | ; |
2100 | } |
2101 | #line 1590 "HiRes.xs" |
2102 | PERL_UNUSED_ARG(clock_id)((void)sizeof(clock_id)); |
2103 | croakPerl_croak("Time::HiRes::clock_gettime(): unimplemented in this platform"); |
2104 | RETVAL = 0.0; |
2105 | #line 2106 "HiRes.c" |
2106 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
2107 | } |
2108 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2109 | } |
2110 | |
2111 | #endif /* #if defined(TIME_HIRES_CLOCK_GETTIME) */ |
2112 | #if defined(TIME_HIRES_CLOCK_GETRES1) |
2113 | #define XSubPPtmpAAAN1 1 |
2114 | |
2115 | |
2116 | XS_EUPXS(XS_Time__HiRes_clock_getres)static void XS_Time__HiRes_clock_getres( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
2117 | XS_EUPXS(XS_Time__HiRes_clock_getres)static void XS_Time__HiRes_clock_getres( CV* cv __attribute__ ((unused))) |
2118 | { |
2119 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2120 | if (items < 0 || items > 1) |
2121 | croak_xs_usagePerl_croak_xs_usage(cv, "clock_id = CLOCK_REALTIME"); |
2122 | { |
2123 | clockid_t clock_id; |
2124 | #line 1604 "HiRes.xs" |
2125 | int status = -1; |
2126 | struct timespec ts; |
2127 | #line 2128 "HiRes.c" |
2128 | NV RETVAL; |
2129 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2130 | |
2131 | if (items < 1) |
2132 | clock_id = CLOCK_REALTIME0; |
2133 | else { |
2134 | clock_id = (clockid_t)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
2135 | ; |
2136 | } |
2137 | #line 1607 "HiRes.xs" |
2138 | # ifdef TIME_HIRES_CLOCK_GETRES_SYSCALL |
2139 | status = syscall(SYS_clock_getres, clock_id, &ts); |
2140 | # else |
2141 | status = clock_getres(clock_id, &ts); |
2142 | # endif |
2143 | RETVAL = status == 0 ? ts.tv_sec + (NV) ts.tv_nsec / NV_1E91000000000.0 : -1; |
2144 | |
2145 | #line 2146 "HiRes.c" |
2146 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
2147 | } |
2148 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2149 | } |
2150 | |
2151 | #else /* if defined(TIME_HIRES_CLOCK_GETRES) */ |
2152 | #define XSubPPtmpAAAO 1 |
2153 | |
2154 | |
2155 | XS_EUPXS(XS_Time__HiRes_clock_getres)static void XS_Time__HiRes_clock_getres( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
2156 | XS_EUPXS(XS_Time__HiRes_clock_getres)static void XS_Time__HiRes_clock_getres( CV* cv __attribute__ ((unused))) |
2157 | { |
2158 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2159 | if (items < 0 || items > 1) |
2160 | croak_xs_usagePerl_croak_xs_usage(cv, "clock_id = 0"); |
2161 | { |
2162 | clockid_t clock_id; |
2163 | NV RETVAL; |
2164 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2165 | |
2166 | if (items < 1) |
2167 | clock_id = 0; |
2168 | else { |
2169 | clock_id = (clockid_t)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
2170 | ; |
2171 | } |
2172 | #line 1623 "HiRes.xs" |
2173 | PERL_UNUSED_ARG(clock_id)((void)sizeof(clock_id)); |
2174 | croakPerl_croak("Time::HiRes::clock_getres(): unimplemented in this platform"); |
2175 | RETVAL = 0.0; |
2176 | #line 2177 "HiRes.c" |
2177 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
2178 | } |
2179 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2180 | } |
2181 | |
2182 | #endif /* #if defined(TIME_HIRES_CLOCK_GETRES) */ |
2183 | #if defined(TIME_HIRES_CLOCK_NANOSLEEP) && defined(TIMER_ABSTIME0x1) |
2184 | #define XSubPPtmpAAAP 1 |
2185 | |
2186 | |
2187 | XS_EUPXS(XS_Time__HiRes_clock_nanosleep)static void XS_Time__HiRes_clock_nanosleep( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
2188 | XS_EUPXS(XS_Time__HiRes_clock_nanosleep)static void XS_Time__HiRes_clock_nanosleep( CV* cv __attribute__ ((unused))) |
2189 | { |
2190 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2191 | if (items < 2 || items > 3) |
2192 | croak_xs_usagePerl_croak_xs_usage(cv, "clock_id, nsec, flags = 0"); |
2193 | { |
2194 | clockid_t clock_id = (clockid_t)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
2195 | ; |
2196 | NV nsec = (NV)SvNV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (1)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (1 )],2)) |
2197 | ; |
2198 | int flags; |
2199 | #line 1639 "HiRes.xs" |
2200 | struct timespec sleepfor, unslept; |
2201 | #line 2202 "HiRes.c" |
2202 | NV RETVAL; |
2203 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2204 | |
2205 | if (items < 3) |
2206 | flags = 0; |
2207 | else { |
2208 | flags = (int)SvIV(ST(2))((((PL_stack_base[ax + (2)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (2)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 2)],2)) |
2209 | ; |
2210 | } |
2211 | #line 1641 "HiRes.xs" |
2212 | if (nsec < 0.0) |
2213 | croakPerl_croak("Time::HiRes::clock_nanosleep(..., %" NVgf"g" |
2214 | "): negative time not invented yet", nsec); |
2215 | nanosleep_init(nsec, &sleepfor, &unslept); |
2216 | if (clock_nanosleep(clock_id, flags, &sleepfor, &unslept) == 0) { |
2217 | RETVAL = nsec; |
2218 | } else { |
2219 | RETVAL = nsec_without_unslept(&sleepfor, &unslept); |
2220 | } |
2221 | #line 2222 "HiRes.c" |
2222 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
2223 | } |
2224 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2225 | } |
2226 | |
2227 | #else /* if defined(TIME_HIRES_CLOCK_NANOSLEEP) && defined(TIMER_ABSTIME) */ |
2228 | #define XSubPPtmpAAAQ1 1 |
2229 | |
2230 | |
2231 | XS_EUPXS(XS_Time__HiRes_clock_nanosleep)static void XS_Time__HiRes_clock_nanosleep( CV* cv __attribute__ ((unused))); /* prototype to pass -Wmissing-prototypes */ |
2232 | XS_EUPXS(XS_Time__HiRes_clock_nanosleep)static void XS_Time__HiRes_clock_nanosleep( CV* cv __attribute__ ((unused))) |
2233 | { |
2234 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2235 | if (items < 2 || items > 3) |
2236 | croak_xs_usagePerl_croak_xs_usage(cv, "clock_id, nsec, flags = 0"); |
2237 | { |
2238 | clockid_t clock_id = (clockid_t)SvIV(ST(0))((((PL_stack_base[ax + (0)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (0)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 0)],2)) |
2239 | ; |
2240 | NV nsec = (NV)SvNV(ST(1))((((PL_stack_base[ax + (1)])->sv_flags & (0x00000200|0x00200000 )) == 0x00000200) ? ((XPVNV*) (PL_stack_base[ax + (1)])->sv_any )->xnv_u.xnv_nv : Perl_sv_2nv_flags( PL_stack_base[ax + (1 )],2)) |
Value stored to 'nsec' during its initialization is never read | |
2241 | ; |
2242 | int flags; |
2243 | NV RETVAL; |
2244 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2245 | |
2246 | if (items < 3) |
2247 | flags = 0; |
2248 | else { |
2249 | flags = (int)SvIV(ST(2))((((PL_stack_base[ax + (2)])->sv_flags & (0x00000100|0x00200000 )) == 0x00000100) ? ((XPVIV*) (PL_stack_base[ax + (2)])->sv_any )->xiv_u.xivu_iv : Perl_sv_2iv_flags( PL_stack_base[ax + ( 2)],2)) |
2250 | ; |
2251 | } |
2252 | #line 1661 "HiRes.xs" |
2253 | PERL_UNUSED_ARG(clock_id)((void)sizeof(clock_id)); |
2254 | PERL_UNUSED_ARG(nsec)((void)sizeof(nsec)); |
2255 | PERL_UNUSED_ARG(flags)((void)sizeof(flags)); |
2256 | croakPerl_croak("Time::HiRes::clock_nanosleep(): unimplemented in this platform"); |
2257 | RETVAL = 0.0; |
2258 | #line 2259 "HiRes.c" |
2259 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
2260 | } |
2261 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2262 | } |
2263 | |
2264 | #endif /* #if defined(TIME_HIRES_CLOCK_NANOSLEEP) && defined(TIMER_ABSTIME) */ |
2265 | #if defined(TIME_HIRES_CLOCK1) && defined(CLOCKS_PER_SEC100) |
2266 | #define XSubPPtmpAAAR1 1 |
2267 | |
2268 | |
2269 | XS_EUPXS(XS_Time__HiRes_clock)static void XS_Time__HiRes_clock( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
2270 | XS_EUPXS(XS_Time__HiRes_clock)static void XS_Time__HiRes_clock( CV* cv __attribute__((unused ))) |
2271 | { |
2272 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2273 | if (items != 0) |
2274 | croak_xs_usagePerl_croak_xs_usage(cv, ""); |
2275 | { |
2276 | #line 1676 "HiRes.xs" |
2277 | clock_t clocks; |
2278 | #line 2279 "HiRes.c" |
2279 | NV RETVAL; |
2280 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2281 | #line 1678 "HiRes.xs" |
2282 | clocks = clock(); |
2283 | RETVAL = clocks == (clock_t) -1 ? (clock_t) -1 : (NV)clocks / (NV)CLOCKS_PER_SEC100; |
2284 | |
2285 | #line 2286 "HiRes.c" |
2286 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
2287 | } |
2288 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2289 | } |
2290 | |
2291 | #else /* if defined(TIME_HIRES_CLOCK) && defined(CLOCKS_PER_SEC) */ |
2292 | #define XSubPPtmpAAAS 1 |
2293 | |
2294 | |
2295 | XS_EUPXS(XS_Time__HiRes_clock)static void XS_Time__HiRes_clock( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
2296 | XS_EUPXS(XS_Time__HiRes_clock)static void XS_Time__HiRes_clock( CV* cv __attribute__((unused ))) |
2297 | { |
2298 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2299 | if (items != 0) |
2300 | croak_xs_usagePerl_croak_xs_usage(cv, ""); |
2301 | { |
2302 | NV RETVAL; |
2303 | dXSTARGSV * const targ = ((PL_op->op_private & 0x04) ? (PL_curpad [PL_op->op_targ]) : Perl_sv_newmortal()); |
2304 | #line 1689 "HiRes.xs" |
2305 | croakPerl_croak("Time::HiRes::clock(): unimplemented in this platform"); |
2306 | RETVAL = 0.0; |
2307 | #line 2308 "HiRes.c" |
2308 | XSprePUSH(sp = PL_stack_base + ax - 1); PUSHn((NV)RETVAL)do { do { NV TARGn_nv = (NV)RETVAL; if (__builtin_expect((((( (targ)->sv_flags & (0xff|(0x08000000|0x00010000|0x00000800 |0x01000000 |0x00800000|0x10000000))) == SVt_NV) & (1 ? ! (((__builtin_expect(((PL_tainted) ? (_Bool)1 : (_Bool)0),(0)) ) ? (_Bool)1 : (_Bool)0)) : 1)) ? (_Bool)1 : (_Bool)0),(1))) { ((void)0); (targ)->sv_flags |= (0x00000200|0x00002000); do { ((void)0); ((void)0); (((XPVNV*)(targ)->sv_any)->xnv_u .xnv_nv = (TARGn_nv)); } while (0); } else Perl_sv_setnv_mg( targ ,TARGn_nv); } while (0); (*++sp = (targ)); } while (0); |
2309 | } |
2310 | XSRETURN(1)do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2311 | } |
2312 | |
2313 | #endif /* #if defined(TIME_HIRES_CLOCK) && defined(CLOCKS_PER_SEC) */ |
2314 | |
2315 | XS_EUPXS(XS_Time__HiRes_stat)static void XS_Time__HiRes_stat( CV* cv __attribute__((unused ))); /* prototype to pass -Wmissing-prototypes */ |
2316 | XS_EUPXS(XS_Time__HiRes_stat)static void XS_Time__HiRes_stat( CV* cv __attribute__((unused ))) |
2317 | { |
2318 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2319 | dXSI32I32 ix = ((XPVCV*)({ void *_p = ((cv)->sv_any); _p; }))-> xcv_start_u.xcv_xsubany.any_i32; |
2320 | PERL_UNUSED_VAR(cv)((void)sizeof(cv)); /* -W */ |
2321 | PERL_UNUSED_VAR(items)((void)sizeof(items)); /* -W */ |
2322 | PERL_UNUSED_VAR(ax)((void)sizeof(ax)); /* -Wall */ |
2323 | SPsp -= items; |
2324 | { |
2325 | #line 1700 "HiRes.xs" |
2326 | OP fakeop; |
2327 | int nret; |
2328 | #line 2329 "HiRes.c" |
2329 | #line 1705 "HiRes.xs" |
2330 | XPUSHs(sv_2mortal(newSVsv(items == 1 ? ST(0) : DEFSV)))do { do { (void)0; if (__builtin_expect(((((1) < 0 || PL_stack_max - (sp) < (1))) ? (_Bool)1 : (_Bool)0),(0))) { sp = Perl_stack_grow ( sp,sp,(sizeof(1) > sizeof(ssize_t) && ((ssize_t) (1) != (1)) ? -1 : (1))); ((void)sizeof(sp)); } } while (0); * ++sp = (Perl_sv_2mortal( Perl_newSVsv_flags( (items == 1 ? PL_stack_base [ax + (0)] : (*((0+(PL_defgv)->sv_u.svu_gp)->gp_sv ? & ((0+(PL_defgv)->sv_u.svu_gp)->gp_sv) : &((0+(Perl_gv_add_by_type ( (PL_defgv),SVt_NULL))->sv_u.svu_gp)->gp_sv)))),2|16)) ); } while (0); |
2331 | PUTBACKPL_stack_sp = sp; |
2332 | ENTERPerl_push_scope(); |
2333 | PL_laststatval = -1; |
2334 | SAVEOP()Perl_save_pushptr( (void *)(PL_op),18); |
2335 | Zero(&fakeop, 1, OP)((void)(__builtin_expect(((((( sizeof(size_t) < sizeof(1) || sizeof(OP) > ((size_t)1 << 8*(sizeof(size_t) - sizeof (1)))) ? (size_t)(1) : ((size_t)-1)/sizeof(OP)) > ((size_t )-1)/sizeof(OP))) ? (_Bool)1 : (_Bool)0),(0)) && (Perl_croak_memory_wrap (),0)), ((void)0), (void)memset((char*)(&fakeop),0,(1) * sizeof (OP))); |
2336 | fakeop.op_type = ix ? OP_LSTAT : OP_STAT; |
2337 | fakeop.op_ppaddr = PL_ppaddr[fakeop.op_type]; |
2338 | fakeop.op_flags = GIMME_VPerl_gimme_V() == G_ARRAY3 ? OPf_WANT_LIST3 : |
2339 | GIMME_VPerl_gimme_V() == G_SCALAR2 ? OPf_WANT_SCALAR2 : OPf_WANT_VOID1; |
2340 | PL_op = &fakeop; |
2341 | (void)fakeop.op_ppaddr(aTHX); |
2342 | SPAGAINsp = PL_stack_sp; |
2343 | LEAVEPerl_pop_scope(); |
2344 | nret = SPsp+1 - &ST(0)PL_stack_base[ax + (0)]; |
2345 | if (nret == 13) { |
2346 | UV atime = SvUV(ST( 8))((((PL_stack_base[ax + (8)])->sv_flags & (0x00000100|0x80000000 |0x00200000)) == (0x00000100|0x80000000)) ? ((XPVUV*) (PL_stack_base [ax + (8)])->sv_any)->xuv_u.xivu_uv : Perl_sv_2uv_flags ( PL_stack_base[ax + (8)],2)); |
2347 | UV mtime = SvUV(ST( 9))((((PL_stack_base[ax + (9)])->sv_flags & (0x00000100|0x80000000 |0x00200000)) == (0x00000100|0x80000000)) ? ((XPVUV*) (PL_stack_base [ax + (9)])->sv_any)->xuv_u.xivu_uv : Perl_sv_2uv_flags ( PL_stack_base[ax + (9)],2)); |
2348 | UV ctime = SvUV(ST(10))((((PL_stack_base[ax + (10)])->sv_flags & (0x00000100| 0x80000000|0x00200000)) == (0x00000100|0x80000000)) ? ((XPVUV *) (PL_stack_base[ax + (10)])->sv_any)->xuv_u.xivu_uv : Perl_sv_2uv_flags( PL_stack_base[ax + (10)],2)); |
2349 | UV atime_nsec; |
2350 | UV mtime_nsec; |
2351 | UV ctime_nsec; |
2352 | hrstatns(&atime_nsec, &mtime_nsec, &ctime_nsec); |
2353 | if (atime_nsec) |
2354 | ST( 8)PL_stack_base[ax + (8)] = sv_2mortal(newSVnv(atime + (NV) atime_nsec / NV_1E9))Perl_sv_2mortal( Perl_newSVnv( atime + (NV) atime_nsec / 1000000000.0 )); |
2355 | if (mtime_nsec) |
2356 | ST( 9)PL_stack_base[ax + (9)] = sv_2mortal(newSVnv(mtime + (NV) mtime_nsec / NV_1E9))Perl_sv_2mortal( Perl_newSVnv( mtime + (NV) mtime_nsec / 1000000000.0 )); |
2357 | if (ctime_nsec) |
2358 | ST(10)PL_stack_base[ax + (10)] = sv_2mortal(newSVnv(ctime + (NV) ctime_nsec / NV_1E9))Perl_sv_2mortal( Perl_newSVnv( ctime + (NV) ctime_nsec / 1000000000.0 )); |
2359 | } |
2360 | XSRETURN(nret)do { const IV tmpXSoff = (nret); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); |
2361 | #line 2362 "HiRes.c" |
2362 | PUTBACKPL_stack_sp = sp; |
2363 | return; |
2364 | } |
2365 | } |
2366 | |
2367 | #ifdef __cplusplus |
2368 | extern "C" |
2369 | #endif |
2370 | XS_EXTERNAL(boot_Time__HiRes)void boot_Time__HiRes( CV* cv __attribute__((unused))); /* prototype to pass -Wmissing-prototypes */ |
2371 | XS_EXTERNAL(boot_Time__HiRes)void boot_Time__HiRes( CV* cv __attribute__((unused))) |
2372 | { |
2373 | #if PERL_VERSION_LE(5, 21, 5)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 21*1000 + 5)) |
2374 | dVARstruct Perl___notused_struct; dXSARGSSV **sp = PL_stack_sp; I32 ax = Perl_POPMARK(); SV **mark = PL_stack_base + ax++; I32 items = (I32)(sp - mark); |
2375 | #else |
2376 | dVARstruct Perl___notused_struct; dXSBOOTARGSXSAPIVERCHKI32 ax = Perl_xs_handshake((((sizeof(struct PerlHandShakeInterpreter )) << 16) | ((sizeof("" "1.9764" "")-1) > 0xFF ? (Perl_croak ("panic: handshake overflow"), 0xFF) : (sizeof("" "1.9764" "" )-1) << 8) | ((((1)) ? (_Bool)1 : (_Bool)0) ? 0x00000020 : 0) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000080 : 0) | (( ((1)) ? (_Bool)1 : (_Bool)0) ? 0x00000040 : 0) | ((sizeof("" "v" "5" "." "32" "." "0" "")-1) > 0x0000001F ? (Perl_croak("panic: handshake overflow" ), 0x0000001F) : (sizeof("" "v" "5" "." "32" "." "0" "")-1))) , cv, "HiRes.c", "v" "5" "." "32" "." "0", "1.9764"); SV **mark = PL_stack_base + ax; SV **sp = PL_stack_sp; I32 items = (I32 )(sp - mark); |
2377 | #endif |
2378 | #if (PERL_REVISION5 == 5 && PERL_VERSION32 < 9) |
2379 | char* file = __FILE__"HiRes.c"; |
2380 | #else |
2381 | const char* file = __FILE__"HiRes.c"; |
2382 | #endif |
2383 | |
2384 | PERL_UNUSED_VAR(file)((void)sizeof(file)); |
2385 | |
2386 | PERL_UNUSED_VAR(cv)((void)sizeof(cv)); /* -W */ |
2387 | PERL_UNUSED_VAR(items)((void)sizeof(items)); /* -W */ |
2388 | #if PERL_VERSION_LE(5, 21, 5)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 21*1000 + 5)) |
2389 | XS_VERSION_BOOTCHECKPerl_xs_handshake((((sizeof(struct PerlHandShakeInterpreter)) << 16) | ((sizeof("" "1.9764" "")-1) > 0xFF ? (Perl_croak ("panic: handshake overflow"), 0xFF) : (sizeof("" "1.9764" "" )-1) << 8) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000020 : 0) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000080 : 0) | (( ((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000040 : 0) | ((sizeof("" "" "")-1) > 0x0000001F ? (Perl_croak("panic: handshake overflow" ), 0x0000001F) : (sizeof("" "" "")-1))), cv, "HiRes.c", items , ax, "1.9764"); |
2390 | # ifdef XS_APIVERSION_BOOTCHECKPerl_xs_handshake((((sizeof(struct PerlHandShakeInterpreter)) << 16) | ((sizeof("" "" "")-1) > 0xFF ? (Perl_croak ("panic: handshake overflow"), 0xFF) : (sizeof("" "" "")-1) << 8) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000020 : 0) | (((( 0)) ? (_Bool)1 : (_Bool)0) ? 0x00000080 : 0) | ((((0)) ? (_Bool )1 : (_Bool)0) ? 0x00000040 : 0) | ((sizeof("" "v" "5" "." "32" "." "0" "")-1) > 0x0000001F ? (Perl_croak("panic: handshake overflow" ), 0x0000001F) : (sizeof("" "v" "5" "." "32" "." "0" "")-1))) , cv, "HiRes.c", items, ax, "v" "5" "." "32" "." "0") |
2391 | XS_APIVERSION_BOOTCHECKPerl_xs_handshake((((sizeof(struct PerlHandShakeInterpreter)) << 16) | ((sizeof("" "" "")-1) > 0xFF ? (Perl_croak ("panic: handshake overflow"), 0xFF) : (sizeof("" "" "")-1) << 8) | ((((0)) ? (_Bool)1 : (_Bool)0) ? 0x00000020 : 0) | (((( 0)) ? (_Bool)1 : (_Bool)0) ? 0x00000080 : 0) | ((((0)) ? (_Bool )1 : (_Bool)0) ? 0x00000040 : 0) | ((sizeof("" "v" "5" "." "32" "." "0" "")-1) > 0x0000001F ? (Perl_croak("panic: handshake overflow" ), 0x0000001F) : (sizeof("" "v" "5" "." "32" "." "0" "")-1))) , cv, "HiRes.c", items, ax, "v" "5" "." "32" "." "0"); |
2392 | # endif |
2393 | #endif |
2394 | |
2395 | { |
2396 | CV * cv; |
2397 | |
2398 | #if XSubPPtmpAAAA |
2399 | (void)newXSproto_portable("Time::HiRes::CLONE", XS_Time__HiRes_CLONE, file, ";@")Perl_newXS_flags( "Time::HiRes::CLONE",XS_Time__HiRes_CLONE,file ,";@",0); |
2400 | #endif |
2401 | (void)newXSproto_portable("Time::HiRes::constant", XS_Time__HiRes_constant, file, "$")Perl_newXS_flags( "Time::HiRes::constant",XS_Time__HiRes_constant ,file,"$",0); |
2402 | #if XSubPPtmpAAAB1 |
2403 | (void)newXSproto_portable("Time::HiRes::usleep", XS_Time__HiRes_usleep, file, "$")Perl_newXS_flags( "Time::HiRes::usleep",XS_Time__HiRes_usleep ,file,"$",0); |
2404 | #if XSubPPtmpAAAC1 |
2405 | (void)newXSproto_portable("Time::HiRes::nanosleep", XS_Time__HiRes_nanosleep, file, "$")Perl_newXS_flags( "Time::HiRes::nanosleep",XS_Time__HiRes_nanosleep ,file,"$",0); |
2406 | #endif |
2407 | #if XSubPPtmpAAAD |
2408 | (void)newXSproto_portable("Time::HiRes::nanosleep", XS_Time__HiRes_nanosleep, file, "$")Perl_newXS_flags( "Time::HiRes::nanosleep",XS_Time__HiRes_nanosleep ,file,"$",0); |
2409 | #endif |
2410 | (void)newXSproto_portable("Time::HiRes::sleep", XS_Time__HiRes_sleep, file, ";@")Perl_newXS_flags( "Time::HiRes::sleep",XS_Time__HiRes_sleep,file ,";@",0); |
2411 | #endif |
2412 | #if XSubPPtmpAAAE |
2413 | (void)newXSproto_portable("Time::HiRes::usleep", XS_Time__HiRes_usleep, file, "$")Perl_newXS_flags( "Time::HiRes::usleep",XS_Time__HiRes_usleep ,file,"$",0); |
2414 | #endif |
2415 | #if XSubPPtmpAAAF1 |
2416 | (void)newXSproto_portable("Time::HiRes::ualarm", XS_Time__HiRes_ualarm, file, "$;$")Perl_newXS_flags( "Time::HiRes::ualarm",XS_Time__HiRes_ualarm ,file,"$;$",0); |
2417 | (void)newXSproto_portable("Time::HiRes::alarm", XS_Time__HiRes_alarm, file, "$;$")Perl_newXS_flags( "Time::HiRes::alarm",XS_Time__HiRes_alarm,file ,"$;$",0); |
2418 | #endif |
2419 | #if XSubPPtmpAAAG |
2420 | (void)newXSproto_portable("Time::HiRes::ualarm", XS_Time__HiRes_ualarm, file, "$;$")Perl_newXS_flags( "Time::HiRes::ualarm",XS_Time__HiRes_ualarm ,file,"$;$",0); |
2421 | (void)newXSproto_portable("Time::HiRes::alarm", XS_Time__HiRes_alarm, file, "$;$")Perl_newXS_flags( "Time::HiRes::alarm",XS_Time__HiRes_alarm,file ,"$;$",0); |
2422 | #endif |
2423 | #if XSubPPtmpAAAH1 |
2424 | (void)newXSproto_portable("Time::HiRes::gettimeofday", XS_Time__HiRes_gettimeofday, file, "")Perl_newXS_flags( "Time::HiRes::gettimeofday",XS_Time__HiRes_gettimeofday ,file,"",0); |
2425 | (void)newXSproto_portable("Time::HiRes::time", XS_Time__HiRes_time, file, "")Perl_newXS_flags( "Time::HiRes::time",XS_Time__HiRes_time,file ,"",0); |
2426 | #endif |
2427 | #if XSubPPtmpAAAI1 |
2428 | (void)newXSproto_portable("Time::HiRes::setitimer", XS_Time__HiRes_setitimer, file, "$$;$")Perl_newXS_flags( "Time::HiRes::setitimer",XS_Time__HiRes_setitimer ,file,"$$;$",0); |
2429 | (void)newXSproto_portable("Time::HiRes::getitimer", XS_Time__HiRes_getitimer, file, "$")Perl_newXS_flags( "Time::HiRes::getitimer",XS_Time__HiRes_getitimer ,file,"$",0); |
2430 | #endif |
2431 | #if XSubPPtmpAAAJ1 |
2432 | (void)newXSproto_portable("Time::HiRes::utime", XS_Time__HiRes_utime, file, "$$@")Perl_newXS_flags( "Time::HiRes::utime",XS_Time__HiRes_utime,file ,"$$@",0); |
2433 | #endif |
2434 | #if XSubPPtmpAAAK |
2435 | (void)newXSproto_portable("Time::HiRes::utime", XS_Time__HiRes_utime, file, "$$;@")Perl_newXS_flags( "Time::HiRes::utime",XS_Time__HiRes_utime,file ,"$$;@",0); |
2436 | #endif |
2437 | #if XSubPPtmpAAAL1 |
2438 | (void)newXSproto_portable("Time::HiRes::clock_gettime", XS_Time__HiRes_clock_gettime, file, ";$")Perl_newXS_flags( "Time::HiRes::clock_gettime",XS_Time__HiRes_clock_gettime ,file,";$",0); |
2439 | #endif |
2440 | #if XSubPPtmpAAAM |
2441 | (void)newXSproto_portable("Time::HiRes::clock_gettime", XS_Time__HiRes_clock_gettime, file, ";$")Perl_newXS_flags( "Time::HiRes::clock_gettime",XS_Time__HiRes_clock_gettime ,file,";$",0); |
2442 | #endif |
2443 | #if XSubPPtmpAAAN1 |
2444 | (void)newXSproto_portable("Time::HiRes::clock_getres", XS_Time__HiRes_clock_getres, file, ";$")Perl_newXS_flags( "Time::HiRes::clock_getres",XS_Time__HiRes_clock_getres ,file,";$",0); |
2445 | #endif |
2446 | #if XSubPPtmpAAAO |
2447 | (void)newXSproto_portable("Time::HiRes::clock_getres", XS_Time__HiRes_clock_getres, file, ";$")Perl_newXS_flags( "Time::HiRes::clock_getres",XS_Time__HiRes_clock_getres ,file,";$",0); |
2448 | #endif |
2449 | #if XSubPPtmpAAAP |
2450 | (void)newXSproto_portable("Time::HiRes::clock_nanosleep", XS_Time__HiRes_clock_nanosleep, file, "$$;$")Perl_newXS_flags( "Time::HiRes::clock_nanosleep",XS_Time__HiRes_clock_nanosleep ,file,"$$;$",0); |
2451 | #endif |
2452 | #if XSubPPtmpAAAQ1 |
2453 | (void)newXSproto_portable("Time::HiRes::clock_nanosleep", XS_Time__HiRes_clock_nanosleep, file, "$$;$")Perl_newXS_flags( "Time::HiRes::clock_nanosleep",XS_Time__HiRes_clock_nanosleep ,file,"$$;$",0); |
2454 | #endif |
2455 | #if XSubPPtmpAAAR1 |
2456 | (void)newXSproto_portable("Time::HiRes::clock", XS_Time__HiRes_clock, file, "")Perl_newXS_flags( "Time::HiRes::clock",XS_Time__HiRes_clock,file ,"",0); |
2457 | #endif |
2458 | #if XSubPPtmpAAAS |
2459 | (void)newXSproto_portable("Time::HiRes::clock", XS_Time__HiRes_clock, file, "")Perl_newXS_flags( "Time::HiRes::clock",XS_Time__HiRes_clock,file ,"",0); |
2460 | #endif |
2461 | cv = newXSproto_portable("Time::HiRes::lstat", XS_Time__HiRes_stat, file, ";$")Perl_newXS_flags( "Time::HiRes::lstat",XS_Time__HiRes_stat,file ,";$",0); |
2462 | XSANY((XPVCV*)({ void *_p = ((cv)->sv_any); _p; }))->xcv_start_u .xcv_xsubany.any_i32 = 1; |
2463 | cv = newXSproto_portable("Time::HiRes::stat", XS_Time__HiRes_stat, file, ";$")Perl_newXS_flags( "Time::HiRes::stat",XS_Time__HiRes_stat,file ,";$",0); |
2464 | XSANY((XPVCV*)({ void *_p = ((cv)->sv_any); _p; }))->xcv_start_u .xcv_xsubany.any_i32 = 0; |
2465 | } |
2466 | |
2467 | /* Initialisation Section */ |
2468 | |
2469 | #line 1107 "HiRes.xs" |
2470 | { |
2471 | #ifdef MY_CXT_KEY |
2472 | MY_CXT_INIT(void)0; |
2473 | #endif |
2474 | #ifdef HAS_GETTIMEOFDAY |
2475 | { |
2476 | (void) hv_store(PL_modglobal, "Time::NVtime", 12,((SV**) Perl_hv_common_key_len( (PL_modglobal),("Time::NVtime" ),(12),(0x04|0x20),(Perl_newSViv( (IV)(myNVtime))),(0))) |
2477 | newSViv(PTR2IV(myNVtime)), 0)((SV**) Perl_hv_common_key_len( (PL_modglobal),("Time::NVtime" ),(12),(0x04|0x20),(Perl_newSViv( (IV)(myNVtime))),(0))); |
2478 | (void) hv_store(PL_modglobal, "Time::U2time", 12,((SV**) Perl_hv_common_key_len( (PL_modglobal),("Time::U2time" ),(12),(0x04|0x20),(Perl_newSViv( (IV)(myU2time))),(0))) |
2479 | newSViv(PTR2IV(myU2time)), 0)((SV**) Perl_hv_common_key_len( (PL_modglobal),("Time::U2time" ),(12),(0x04|0x20),(Perl_newSViv( (IV)(myU2time))),(0))); |
2480 | } |
2481 | #endif |
2482 | #if defined(PERL_DARWIN) |
2483 | # if defined(USE_ITHREADS) && defined(PERL_DARWIN_MUTEX) |
2484 | MUTEX_INIT(&darwin_time_mutex)(void)0; |
2485 | # endif |
2486 | #endif |
2487 | } |
2488 | |
2489 | #if XSubPPtmpAAAA |
2490 | #endif |
2491 | #if XSubPPtmpAAAB1 |
2492 | #if XSubPPtmpAAAC1 |
2493 | #endif |
2494 | #if XSubPPtmpAAAD |
2495 | #endif |
2496 | #endif |
2497 | #if XSubPPtmpAAAE |
2498 | #endif |
2499 | #if XSubPPtmpAAAF1 |
2500 | #endif |
2501 | #if XSubPPtmpAAAG |
2502 | #endif |
2503 | #if XSubPPtmpAAAH1 |
2504 | #endif |
2505 | #if XSubPPtmpAAAI1 |
2506 | #endif |
2507 | #if XSubPPtmpAAAJ1 |
2508 | #endif |
2509 | #if XSubPPtmpAAAK |
2510 | #endif |
2511 | #if XSubPPtmpAAAL1 |
2512 | #endif |
2513 | #if XSubPPtmpAAAM |
2514 | #endif |
2515 | #if XSubPPtmpAAAN1 |
2516 | #endif |
2517 | #if XSubPPtmpAAAO |
2518 | #endif |
2519 | #if XSubPPtmpAAAP |
2520 | #endif |
2521 | #if XSubPPtmpAAAQ1 |
2522 | #endif |
2523 | #if XSubPPtmpAAAR1 |
2524 | #endif |
2525 | #if XSubPPtmpAAAS |
2526 | #endif |
2527 | #line 2528 "HiRes.c" |
2528 | |
2529 | /* End of Initialisation Section */ |
2530 | |
2531 | #if PERL_VERSION_LE(5, 21, 5)((5*1000000 + 32*1000 + 1) <= (5*1000000 + 21*1000 + 5)) |
2532 | # if PERL_VERSION_GE(5, 9, 0)((5*1000000 + 32*1000 + 1) >= (5*1000000 + 9*1000 + 0)) |
2533 | if (PL_unitcheckav) |
2534 | call_list(PL_scopestack_ix, PL_unitcheckav)Perl_call_list( PL_scopestack_ix,PL_unitcheckav); |
2535 | # endif |
2536 | XSRETURN_YESdo { (PL_stack_base[ax + (0)] = &(PL_sv_immortals[0]) ); do { const IV tmpXSoff = (1); ((void)0); PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); return; } while (0); } while (0); |
2537 | #else |
2538 | Perl_xs_boot_epilog(aTHX_ ax); |
2539 | #endif |
2540 | } |
2541 |