3 * Copyright (c) 1996-2002 Douglas E. Wegscheid. All rights reserved.
5 * Copyright (c) 2002,2003,2004,2005 Jarkko Hietaniemi. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the same terms as Perl itself.
14 #define PERL_NO_GET_CONTEXT
19 #if defined(__CYGWIN__) && defined(HAS_W32API_WINDOWS_H)
20 # include <w32api/windows.h>
21 # define CYGWIN_WITH_W32API
26 # include <sys/time.h>
30 # include <sys/select.h>
37 #ifndef PerlProc_pause
38 # define PerlProc_pause() Pause()
44 # undef Pause /* In case perl.h did it already. */
45 # define Pause() sleep(~0) /* Zzz for a long time. */
48 /* Though the cpp define ITIMER_VIRTUAL is available the functionality
49 * is not supported in Cygwin as of August 2004, ditto for Win32.
50 * Neither are ITIMER_PROF or ITIMER_REALPROF implemented. --jhi
52 #if defined(__CYGWIN__) || defined(WIN32)
53 # undef ITIMER_VIRTUAL
55 # undef ITIMER_REALPROF
58 /* 5.004 doesn't define PL_sv_undef */
59 #ifndef ATLEASTFIVEOHOHFIVE
61 # define PL_sv_undef sv_undef
65 #include "const-c.inc"
67 #if defined(WIN32) || defined(CYGWIN_WITH_W32API)
69 #ifndef HAS_GETTIMEOFDAY
70 # define HAS_GETTIMEOFDAY
73 /* shows up in winsock.h?
81 unsigned __int64 ft_i64;
85 #define MY_CXT_KEY "Time::HiRes_" XS_VERSION
88 unsigned long run_count;
89 unsigned __int64 base_ticks;
90 unsigned __int64 tick_frequency;
91 FT_t base_systime_as_filetime;
92 unsigned __int64 reset_time;
97 /* Number of 100 nanosecond units from 1/1/1601 to 1/1/1970 */
99 # define Const64(x) x##LL
101 # define Const64(x) x##i64
103 #define EPOCH_BIAS Const64(116444736000000000)
105 /* NOTE: This does not compute the timezone info (doing so can be expensive,
106 * and appears to be unsupported even by glibc) */
108 /* dMY_CXT needs a Perl context and we don't want to call PERL_GET_CONTEXT
109 for performance reasons */
112 #define gettimeofday(tp, not_used) _gettimeofday(aTHX_ tp, not_used)
114 /* If the performance counter delta drifts more than 0.5 seconds from the
115 * system time then we recalibrate to the system time. This means we may
116 * move *backwards* in time! */
117 #define MAX_PERF_COUNTER_SKEW Const64(5000000) /* 0.5 seconds */
119 /* Reset reading from the performance counter every five minutes.
120 * Many PC clocks just seem to be so bad. */
121 #define MAX_PERF_COUNTER_TICKS Const64(300000000) /* 300 seconds */
124 _gettimeofday(pTHX_ struct timeval *tp, void *not_used)
128 unsigned __int64 ticks;
131 if (MY_CXT.run_count++ == 0 ||
132 MY_CXT.base_systime_as_filetime.ft_i64 > MY_CXT.reset_time) {
133 QueryPerformanceFrequency((LARGE_INTEGER*)&MY_CXT.tick_frequency);
134 QueryPerformanceCounter((LARGE_INTEGER*)&MY_CXT.base_ticks);
135 GetSystemTimeAsFileTime(&MY_CXT.base_systime_as_filetime.ft_val);
136 ft.ft_i64 = MY_CXT.base_systime_as_filetime.ft_i64;
137 MY_CXT.reset_time = ft.ft_i64 + MAX_PERF_COUNTER_TICKS;
141 QueryPerformanceCounter((LARGE_INTEGER*)&ticks);
142 ticks -= MY_CXT.base_ticks;
143 ft.ft_i64 = MY_CXT.base_systime_as_filetime.ft_i64
144 + Const64(10000000) * (ticks / MY_CXT.tick_frequency)
145 +(Const64(10000000) * (ticks % MY_CXT.tick_frequency)) / MY_CXT.tick_frequency;
146 diff = ft.ft_i64 - MY_CXT.base_systime_as_filetime.ft_i64;
147 if (diff < -MAX_PERF_COUNTER_SKEW || diff > MAX_PERF_COUNTER_SKEW) {
148 MY_CXT.base_ticks += ticks;
149 GetSystemTimeAsFileTime(&MY_CXT.base_systime_as_filetime.ft_val);
150 ft.ft_i64 = MY_CXT.base_systime_as_filetime.ft_i64;
154 /* seconds since epoch */
155 tp->tv_sec = (long)((ft.ft_i64 - EPOCH_BIAS) / Const64(10000000));
157 /* microseconds remaining */
158 tp->tv_usec = (long)((ft.ft_i64 / Const64(10)) % Const64(1000000));
164 #if defined(WIN32) && !defined(ATLEASTFIVEOHOHFIVE)
166 sleep(unsigned int t)
173 #if !defined(HAS_GETTIMEOFDAY) && defined(VMS)
174 #define HAS_GETTIMEOFDAY
177 #include <time.h> /* gettimeofday */
178 #include <stdlib.h> /* qdiv */
179 #include <starlet.h> /* sys$gettim */
182 #include <lib$routines.h> /* lib$ediv() */
186 VMS binary time is expressed in 100 nano-seconds since
187 system base time which is 17-NOV-1858 00:00:00.00
190 #define DIV_100NS_TO_SECS 10000000L
191 #define DIV_100NS_TO_USECS 10L
194 gettimeofday is supposed to return times since the epoch
195 so need to determine this in terms of VMS base time
197 static $DESCRIPTOR(dscepoch,"01-JAN-1970 00:00:00.00");
200 static long base_adjust[2]={0L,0L};
202 static __int64 base_adjust=0;
207 If we don't have gettimeofday, then likely we are on a VMS machine that
208 operates on local time rather than UTC...so we have to zone-adjust.
209 This code gleefully swiped from VMS.C
212 /* method used to handle UTC conversions:
213 * 1 == CRTL gmtime(); 2 == SYS$TIMEZONE_DIFFERENTIAL; 3 == no correction
215 static int gmtime_emulation_type;
216 /* number of secs to add to UTC POSIX-style time to get local time */
217 static long int utc_offset_secs;
218 static struct dsc$descriptor_s fildevdsc =
219 { 12, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$FILE_DEV" };
220 static struct dsc$descriptor_s *fildev[] = { &fildevdsc, NULL };
222 static time_t toutc_dst(time_t loc) {
225 if ((rsltmp = localtime(&loc)) == NULL) return -1;
226 loc -= utc_offset_secs;
227 if (rsltmp->tm_isdst) loc -= 3600;
231 static time_t toloc_dst(time_t utc) {
234 utc += utc_offset_secs;
235 if ((rsltmp = localtime(&utc)) == NULL) return -1;
236 if (rsltmp->tm_isdst) utc += 3600;
240 #define _toutc(secs) ((secs) == (time_t) -1 ? (time_t) -1 : \
241 ((gmtime_emulation_type || timezone_setup()), \
242 (gmtime_emulation_type == 1 ? toutc_dst(secs) : \
243 ((secs) - utc_offset_secs))))
245 #define _toloc(secs) ((secs) == (time_t) -1 ? (time_t) -1 : \
246 ((gmtime_emulation_type || timezone_setup()), \
247 (gmtime_emulation_type == 1 ? toloc_dst(secs) : \
248 ((secs) + utc_offset_secs))))
255 if (gmtime_emulation_type == 0) {
257 time_t base = 15 * 86400; /* 15jan71; to avoid month/year ends between */
258 /* results of calls to gmtime() and localtime() */
261 gmtime_emulation_type++;
262 if ((tm_p = gmtime(&base)) == NULL) { /* CRTL gmtime() is a fake */
263 char off[LNM$C_NAMLENGTH+1];;
265 gmtime_emulation_type++;
266 if (!Perl_vmstrnenv("SYS$TIMEZONE_DIFFERENTIAL",off,0,fildev,0)) {
267 gmtime_emulation_type++;
269 Perl_warn(aTHX_ "no UTC offset information; assuming local time is UTC");
271 else { utc_offset_secs = atol(off); }
273 else { /* We've got a working gmtime() */
274 struct tm gmt, local;
277 tm_p = localtime(&base);
279 utc_offset_secs = (local.tm_mday - gmt.tm_mday) * 86400;
280 utc_offset_secs += (local.tm_hour - gmt.tm_hour) * 3600;
281 utc_offset_secs += (local.tm_min - gmt.tm_min) * 60;
282 utc_offset_secs += (local.tm_sec - gmt.tm_sec);
290 gettimeofday (struct timeval *tp, void *tpz)
296 long div_100ns_to_secs;
297 long div_100ns_to_usecs;
305 In case of error, tv_usec = 0 and tv_sec = VMS condition code.
306 The return from function is also set to -1.
307 This is not exactly as per the manual page.
313 if (base_adjust[0]==0 && base_adjust[1]==0) {
315 if (base_adjust==0) { /* Need to determine epoch adjustment */
317 ret=sys$bintim(&dscepoch,&base_adjust);
318 if (1 != (ret &&1)) {
324 ret=sys$gettim(&quad); /* Get VMS system time */
325 if ((1 && ret) == 1) {
327 quad[0] -= base_adjust[0]; /* convert to epoch offset */
328 quad[1] -= base_adjust[1]; /* convert 2nd half of quadword */
329 div_100ns_to_secs = DIV_100NS_TO_SECS;
330 div_100ns_to_usecs = DIV_100NS_TO_USECS;
331 lib$ediv(&div_100ns_to_secs,&quad,&quo,&rem);
334 lib$ediv(&div_100ns_to_usecs,&quad1,&quo1,&rem1);
335 tp->tv_sec = quo; /* Whole seconds */
336 tp->tv_usec = quo1; /* Micro-seconds */
338 quad -= base_adjust; /* convert to epoch offset */
339 ans1=qdiv(quad,DIV_100NS_TO_SECS);
340 ans2=qdiv(ans1.rem,DIV_100NS_TO_USECS);
341 tp->tv_sec = ans1.quot; /* Whole seconds */
342 tp->tv_usec = ans2.quot; /* Micro-seconds */
350 if (VMSISH_TIME) tp->tv_sec = _toloc(tp->tv_sec);
352 if (!VMSISH_TIME) tp->tv_sec = _toutc(tp->tv_sec);
360 /* Do not use H A S _ N A N O S L E E P
361 * so that Perl Configure doesn't scan for it.
362 * The TIME_HIRES_NANOSLEEP is set by Makefile.PL. */
363 #if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP)
365 #define usleep hrt_unanosleep /* could conflict with ncurses for static build */
368 hrt_unanosleep(unsigned long usec) /* This is used to emulate usleep. */
371 res.tv_sec = usec/1000/1000;
372 res.tv_nsec = ( usec - res.tv_sec*1000*1000 ) * 1000;
373 nanosleep(&res, NULL);
376 #endif /* #if !defined(HAS_USLEEP) && defined(TIME_HIRES_NANOSLEEP) */
378 #if !defined(HAS_USLEEP) && defined(HAS_SELECT)
379 #ifndef SELECT_IS_BROKEN
381 #define usleep hrt_usleep /* could conflict with ncurses for static build */
384 hrt_usleep(unsigned long usec)
389 select(0, (Select_fd_set_t)NULL, (Select_fd_set_t)NULL,
390 (Select_fd_set_t)NULL, &tv);
393 #endif /* #if !defined(HAS_USLEEP) && defined(HAS_SELECT) */
395 #if !defined(HAS_USLEEP) && defined(WIN32)
397 #define usleep hrt_usleep /* could conflict with ncurses for static build */
400 hrt_usleep(unsigned long usec)
406 #endif /* #if !defined(HAS_USLEEP) && defined(WIN32) */
409 #if !defined(HAS_UALARM) && defined(HAS_SETITIMER)
411 #define ualarm hrt_ualarm /* could conflict with ncurses for static build */
414 hrt_ualarm(int usec, int interval)
416 struct itimerval itv;
417 itv.it_value.tv_sec = usec / 1000000;
418 itv.it_value.tv_usec = usec % 1000000;
419 itv.it_interval.tv_sec = interval / 1000000;
420 itv.it_interval.tv_usec = interval % 1000000;
421 return setitimer(ITIMER_REAL, &itv, 0);
423 #endif /* #if !defined(HAS_UALARM) && defined(HAS_SETITIMER) */
425 #if !defined(HAS_UALARM) && defined(VMS)
427 #define ualarm vms_ualarm
429 #include <lib$routines.h>
437 #define VMSERR(s) (!((s)&1))
440 us_to_VMS(useconds_t mseconds, unsigned long v[])
449 iss = lib$addx(qq,qq,qq);
450 if (VMSERR(iss)) lib$signal(iss);
451 iss = lib$subx(v,qq,v);
452 if (VMSERR(iss)) lib$signal(iss);
453 iss = lib$addx(qq,qq,qq);
454 if (VMSERR(iss)) lib$signal(iss);
455 iss = lib$subx(v,qq,v);
456 if (VMSERR(iss)) lib$signal(iss);
457 iss = lib$subx(v,qq,v);
458 if (VMSERR(iss)) lib$signal(iss);
462 VMS_to_us(unsigned long v[])
465 unsigned long div=10,quot, rem;
467 iss = lib$ediv(&div,v,",&rem);
468 if (VMSERR(iss)) lib$signal(iss);
473 typedef unsigned short word;
474 typedef struct _ualarm {
477 unsigned long delay[2];
478 unsigned long interval[2];
479 unsigned long remain[2];
484 static Alarm *a0, alarm_base;
489 static void ualarm_AST(Alarm *a);
492 vms_ualarm(int mseconds, int interval)
501 static struct item_list3 itmlst[2];
502 static int first = 1;
508 itmlst[0].code = JPI$_ASTEN;
509 itmlst[0].length = sizeof(asten);
510 itmlst[0].retlenaddr = NULL;
512 itmlst[1].length = 0;
513 itmlst[1].bufaddr = NULL;
514 itmlst[1].retlenaddr = NULL;
516 iss = lib$get_ef(&alarm_ef);
517 if (VMSERR(iss)) lib$signal(iss);
520 a0->function = UAL_NULL;
522 itmlst[0].bufaddr = &asten;
524 iss = sys$getjpiw(0,0,0,itmlst,0,0,0);
525 if (VMSERR(iss)) lib$signal(iss);
526 if (!(asten&0x08)) return -1;
530 a->function = UAL_SET;
532 a->function = UAL_CLEAR;
535 us_to_VMS(mseconds, a->delay);
537 us_to_VMS(interval, a->interval);
542 iss = sys$clref(alarm_ef);
543 if (VMSERR(iss)) lib$signal(iss);
545 iss = sys$dclast(ualarm_AST,a,0);
546 if (VMSERR(iss)) lib$signal(iss);
548 iss = sys$waitfr(alarm_ef);
549 if (VMSERR(iss)) lib$signal(iss);
551 if (a->function == UAL_ACTIVE)
552 return VMS_to_us(a->remain);
563 unsigned long now[2];
565 iss = sys$gettim(now);
566 if (VMSERR(iss)) lib$signal(iss);
568 if (a->function == UAL_SET || a->function == UAL_CLEAR) {
569 if (a0->function == UAL_ACTIVE) {
570 iss = sys$cantim(a0,PSL$C_USER);
571 if (VMSERR(iss)) lib$signal(iss);
573 iss = lib$subx(a0->remain, now, a->remain);
574 if (VMSERR(iss)) lib$signal(iss);
576 if (a->remain[1] & 0x80000000)
577 a->remain[0] = a->remain[1] = 0;
580 if (a->function == UAL_SET) {
581 a->function = a0->function;
582 a0->function = UAL_ACTIVE;
583 a0->repeat = a->repeat;
585 a0->interval[0] = a->interval[0];
586 a0->interval[1] = a->interval[1];
588 a0->delay[0] = a->delay[0];
589 a0->delay[1] = a->delay[1];
591 iss = lib$subx(now, a0->delay, a0->remain);
592 if (VMSERR(iss)) lib$signal(iss);
594 iss = sys$setimr(0,a0->delay,ualarm_AST,a0);
595 if (VMSERR(iss)) lib$signal(iss);
597 a->function = a0->function;
598 a0->function = UAL_NULL;
600 iss = sys$setef(alarm_ef);
601 if (VMSERR(iss)) lib$signal(iss);
602 } else if (a->function == UAL_ACTIVE) {
604 iss = lib$subx(now, a->interval, a->remain);
605 if (VMSERR(iss)) lib$signal(iss);
607 iss = sys$setimr(0,a->interval,ualarm_AST,a);
608 if (VMSERR(iss)) lib$signal(iss);
610 a->function = UAL_NULL;
613 if (VMSERR(iss)) lib$signal(iss);
614 lib$signal(SS$_ASTFLT);
616 lib$signal(SS$_BADPARAM);
620 #endif /* #if !defined(HAS_UALARM) && defined(VMS) */
622 #ifdef HAS_GETTIMEOFDAY
625 myU2time(pTHX_ UV *ret)
629 status = gettimeofday (&Tp, NULL);
643 status = gettimeofday (&Tp, NULL);
644 return status == 0 ? Tp.tv_sec + (Tp.tv_usec / 1000000.) : -1.0;
647 #endif /* #ifdef HAS_GETTIMEOFDAY */
649 MODULE = Time::HiRes PACKAGE = Time::HiRes
658 #ifdef ATLEASTFIVEOHOHFIVE
659 #ifdef HAS_GETTIMEOFDAY
661 hv_store(PL_modglobal, "Time::NVtime", 12, newSViv(PTR2IV(myNVtime)), 0);
662 hv_store(PL_modglobal, "Time::U2time", 12, newSViv(PTR2IV(myU2time)), 0);
668 #if defined(USE_ITHREADS) && defined(MY_CXT_KEY)
677 INCLUDE: const-xs.inc
679 #if defined(HAS_USLEEP) && defined(HAS_GETTIMEOFDAY)
685 struct timeval Ta, Tb;
687 gettimeofday(&Ta, NULL);
689 if (useconds > 1E6) {
690 IV seconds = (IV) (useconds / 1E6);
691 /* If usleep() has been implemented using setitimer()
692 * then this contortion is unnecessary-- but usleep()
693 * may be implemented in some other way, so let's contort. */
696 useconds -= 1E6 * seconds;
698 } else if (useconds < 0.0)
699 croak("Time::HiRes::usleep(%"NVgf"): negative time not invented yet", useconds);
700 usleep((U32)useconds);
703 gettimeofday(&Tb, NULL);
705 printf("[%ld %ld] [%ld %ld]\n", Tb.tv_sec, Tb.tv_usec, Ta.tv_sec, Ta.tv_usec);
707 RETVAL = 1E6*(Tb.tv_sec-Ta.tv_sec)+(NV)((IV)Tb.tv_usec-(IV)Ta.tv_usec);
712 #if defined(TIME_HIRES_NANOSLEEP)
718 struct timeval Ta, Tb;
720 gettimeofday(&Ta, NULL);
723 if (nseconds > 1E9) {
724 IV seconds = (IV) (nseconds / 1E9);
727 nseconds -= 1E9 * seconds;
729 } else if (nseconds < 0.0)
730 croak("Time::HiRes::nanosleep(%"NVgf"): negative time not invented yet", nseconds);
731 tsa.tv_sec = (IV) (nseconds / 1E9);
732 tsa.tv_nsec = (IV) nseconds - tsa.tv_sec * 1E9;
733 nanosleep(&tsa, NULL);
736 gettimeofday(&Tb, NULL);
737 RETVAL = 1E3*(1E6*(Tb.tv_sec-Ta.tv_sec)+(NV)((IV)Tb.tv_usec-(IV)Ta.tv_usec));
742 #endif /* #if defined(TIME_HIRES_NANOSLEEP) */
747 struct timeval Ta, Tb;
749 gettimeofday(&Ta, NULL);
751 NV seconds = SvNV(ST(0));
752 if (seconds >= 0.0) {
753 UV useconds = (UV)(1E6 * (seconds - (UV)seconds));
756 if ((IV)useconds < 0) {
757 #if defined(__sparc64__) && defined(__GNUC__)
758 /* Sparc64 gcc 2.95.3 (e.g. on NetBSD) has a bug
759 * where (0.5 - (UV)(0.5)) will under certain
760 * circumstances (if the double is cast to UV more
761 * than once?) evaluate to -0.5, instead of 0.5. */
762 useconds = -(IV)useconds;
763 #endif /* #if defined(__sparc64__) && defined(__GNUC__) */
764 if ((IV)useconds < 0)
765 croak("Time::HiRes::sleep(%"NVgf"): internal error: useconds < 0 (unsigned %"UVuf" signed %"IVdf")", seconds, useconds, (IV)useconds);
769 croak("Time::HiRes::sleep(%"NVgf"): negative time not invented yet", seconds);
772 gettimeofday(&Tb, NULL);
774 printf("[%ld %ld] [%ld %ld]\n", Tb.tv_sec, Tb.tv_usec, Ta.tv_sec, Ta.tv_usec);
776 RETVAL = (NV)(Tb.tv_sec-Ta.tv_sec)+0.000001*(NV)(Tb.tv_usec-Ta.tv_usec);
781 #endif /* #if defined(HAS_USLEEP) && defined(HAS_GETTIMEOFDAY) */
786 ualarm(useconds,interval=0)
790 if (useconds < 0 || interval < 0)
791 croak("Time::HiRes::ualarm(%d, %d): negative time not invented yet", useconds, interval);
792 RETVAL = ualarm(useconds, interval);
798 alarm(seconds,interval=0)
802 if (seconds < 0.0 || interval < 0.0)
803 croak("Time::HiRes::alarm(%"NVgf", %"NVgf"): negative time not invented yet", seconds, interval);
804 RETVAL = (NV)ualarm(seconds * 1000000,
805 interval * 1000000) / 1E6;
810 #endif /* #ifdef HAS_UALARM */
812 #ifdef HAS_GETTIMEOFDAY
813 # ifdef MACOS_TRADITIONAL /* fix epoch TZ and use unsigned time_t */
821 status = gettimeofday (&Tp, &Tz);
824 Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
825 if (GIMME == G_ARRAY) {
827 /* Mac OS (Classic) has unsigned time_t */
828 PUSHs(sv_2mortal(newSVuv(Tp.tv_sec)));
829 PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
832 PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec / 1000000.0))));
843 status = gettimeofday (&Tp, &Tz);
845 Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
846 RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.0);
853 # else /* MACOS_TRADITIONAL */
860 status = gettimeofday (&Tp, NULL);
862 if (GIMME == G_ARRAY) {
864 PUSHs(sv_2mortal(newSViv(Tp.tv_sec)));
865 PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
868 PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec / 1000000.0))));
878 status = gettimeofday (&Tp, NULL);
880 RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.);
887 # endif /* MACOS_TRADITIONAL */
888 #endif /* #ifdef HAS_GETTIMEOFDAY */
890 #if defined(HAS_GETITIMER) && defined(HAS_SETITIMER)
892 #define TV2NV(tv) ((NV)((tv).tv_sec) + 0.000001 * (NV)((tv).tv_usec))
895 setitimer(which, seconds, interval = 0)
900 struct itimerval newit;
901 struct itimerval oldit;
903 if (seconds < 0.0 || interval < 0.0)
904 croak("Time::HiRes::setitimer(%"IVdf", %"NVgf", %"NVgf"): negative time not invented yet", (IV)which, seconds, interval);
905 newit.it_value.tv_sec = seconds;
906 newit.it_value.tv_usec =
907 (seconds - (NV)newit.it_value.tv_sec) * 1000000.0;
908 newit.it_interval.tv_sec = interval;
909 newit.it_interval.tv_usec =
910 (interval - (NV)newit.it_interval.tv_sec) * 1000000.0;
911 if (setitimer(which, &newit, &oldit) == 0) {
913 PUSHs(sv_2mortal(newSVnv(TV2NV(oldit.it_value))));
914 if (GIMME == G_ARRAY) {
916 PUSHs(sv_2mortal(newSVnv(TV2NV(oldit.it_interval))));
924 struct itimerval nowit;
926 if (getitimer(which, &nowit) == 0) {
928 PUSHs(sv_2mortal(newSVnv(TV2NV(nowit.it_value))));
929 if (GIMME == G_ARRAY) {
931 PUSHs(sv_2mortal(newSVnv(TV2NV(nowit.it_interval))));
935 #endif /* #if defined(HAS_GETITIMER) && defined(HAS_SETITIMER) */