X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2FTime%2FHiRes%2FHiRes.xs;h=83db8664f0da882e44bd633f92ca4a11ab1314ac;hb=5cdb7193c99562e084aa84a8d7e591d45d76305a;hp=21003756a45b70def144052e29c14377b0c5b769;hpb=3c72ec0095d5296c829ece3ce089509b7f8a14ab;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs index 2100375..83db866 100644 --- a/ext/Time/HiRes/HiRes.xs +++ b/ext/Time/HiRes/HiRes.xs @@ -107,15 +107,23 @@ gettimeofday (struct timeval *tp, int nothing) */ static $DESCRIPTOR(dscepoch,"01-JAN-1970 00:00:00.00"); +#ifdef __VAX +static long base_adjust=0L; +#else static __int64 base_adjust=0; +#endif int gettimeofday (struct timeval *tp, void *tpz) { long ret; +#ifdef __VAX + long quad; + div_t ans1,ans2; +#else __int64 quad; __qdiv_t ans1,ans2; - +#endif /* In case of error, tv_usec = 0 and tv_sec = VMS condition code. The return from function is also set to -1. @@ -135,8 +143,13 @@ gettimeofday (struct timeval *tp, void *tpz) ret=sys$gettim(&quad); /* Get VMS system time */ if ((1 && ret) == 1) { quad -= base_adjust; /* convert to epoch offset */ +#ifdef __VAX + ans1=div(quad,DIV_100NS_TO_SECS); + ans2=div(ans1.rem,DIV_100NS_TO_USECS); +#else ans1=qdiv(quad,DIV_100NS_TO_SECS); ans2=qdiv(ans1.rem,DIV_100NS_TO_USECS); +#endif tp->tv_sec = ans1.quot; /* Whole seconds */ tp->tv_usec = ans2.quot; /* Micro-seconds */ } else { @@ -196,7 +209,7 @@ hrt_ualarm(int usec, int interval) #ifdef HAS_GETTIMEOFDAY -static void +static int myU2time(UV *ret) { struct timeval Tp; @@ -204,6 +217,7 @@ myU2time(UV *ret) status = gettimeofday (&Tp, NULL); ret[0] = Tp.tv_sec; ret[1] = Tp.tv_usec; + return status; } static NV @@ -212,7 +226,7 @@ myNVtime() struct timeval Tp; int status; status = gettimeofday (&Tp, NULL); - return Tp.tv_sec + (Tp.tv_usec / 1000000.); + return status == 0 ? Tp.tv_sec + (Tp.tv_usec / 1000000.) : -1.0; } #endif @@ -223,8 +237,12 @@ PROTOTYPES: ENABLE BOOT: #ifdef HAS_GETTIMEOFDAY - hv_store(PL_modglobal, "Time::NVtime", 12, newSViv((IV) myNVtime), 0); - hv_store(PL_modglobal, "Time::U2time", 12, newSViv((IV) myU2time), 0); +{ + UV auv[2]; + hv_store(PL_modglobal, "Time::NVtime", 12, newSViv((IV) myNVtime()), 0); + if (myU2time(auv) == 0) + hv_store(PL_modglobal, "Time::U2time", 12, newSViv((IV) auv[0]), 0); +} #endif IV @@ -265,6 +283,9 @@ alarm(fseconds,finterval=0) uinterval = finterval * 1000000; RETVAL = ualarm (useconds, uinterval); + OUTPUT: + RETVAL + #endif #ifdef HAS_GETTIMEOFDAY