From: Jarkko Hietaniemi Date: Mon, 22 Oct 2001 21:23:15 +0000 (+0000) Subject: MacOS Classic timeofday(), from Chris Nandor. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=db8356711f401c24973a599023742ac2f28fd86f;p=p5sagit%2Fp5-mst-13.2.git MacOS Classic timeofday(), from Chris Nandor. p4raw-id: //depot/perl@12594 --- diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs index 3bb1aa4..e0ac4fb 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)