summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-10-22 21:23:15 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-10-22 21:23:15 +0000
commitdb8356711f401c24973a599023742ac2f28fd86f (patch)
tree04ef8a0bb3e91b4247afd9eb73ae728c2ad2e3b2 /ext
parent03765510f928d3bbc2f4c80d6607359655bee2bf (diff)
downloadperl-db8356711f401c24973a599023742ac2f28fd86f.tar.gz
MacOS Classic timeofday(), from Chris Nandor.
p4raw-id: //depot/perl@12594
Diffstat (limited to 'ext')
-rw-r--r--ext/Time/HiRes/HiRes.xs35
1 files changed, 35 insertions, 0 deletions
diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs
index 3bb1aa4162..e0ac4fb8cf 100644
--- a/ext/Time/HiRes/HiRes.xs
+++ b/ext/Time/HiRes/HiRes.xs
@@ -442,7 +442,41 @@ alarm(fseconds,finterval=0)
#endif
#ifdef HAS_GETTIMEOFDAY
+# ifdef MACOS_TRADITIONAL /* fix epoch TZ and use unsigned time_t */
+void
+gettimeofday()
+ PREINIT:
+ struct timeval Tp;
+ struct timezone Tz;
+ PPCODE:
+ int status;
+ status = gettimeofday (&Tp, &Tz);
+ Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
+
+ if (GIMME == G_ARRAY) {
+ EXTEND(sp, 2);
+ /* Mac OS (Classic) has unsigned time_t */
+ PUSHs(sv_2mortal(newSVuv(Tp.tv_sec)));
+ PUSHs(sv_2mortal(newSViv(Tp.tv_usec)));
+ } else {
+ EXTEND(sp, 1);
+ PUSHs(sv_2mortal(newSVnv(Tp.tv_sec + (Tp.tv_usec / 1000000.0))));
+ }
+
+NV
+time()
+ PREINIT:
+ struct timeval Tp;
+ struct timezone Tz;
+ CODE:
+ int status;
+ status = gettimeofday (&Tp, &Tz);
+ Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */
+ RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.0);
+ OUTPUT:
+ RETVAL
+# else /* MACOS_TRADITIONAL */
void
gettimeofday()
PREINIT:
@@ -470,6 +504,7 @@ time()
OUTPUT:
RETVAL
+# endif /* MACOS_TRADITIONAL */
#endif
#if defined(HAS_GETITIMER) && defined(HAS_SETITIMER)