From: Rafael Garcia-Suarez Date: Mon, 16 May 2005 08:03:15 +0000 (+0000) Subject: Upgrade to Time::HiRes 1.68 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=993164ab7bc2b8526620ee422e7ba8a504b6da4d;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Time::HiRes 1.68 p4raw-id: //depot/perl@24472 --- diff --git a/ext/Time/HiRes/Changes b/ext/Time/HiRes/Changes index dfcb9d9..10b4243 100644 --- a/ext/Time/HiRes/Changes +++ b/ext/Time/HiRes/Changes @@ -1,5 +1,19 @@ Revision history for Perl extension Time::HiRes. +1.68 + - somehow 1.67 had a lot of doubled lines (a major cut-and-paste + error suspected), but miraculously it still worked since the + doubling took place below the __END__ token + - undef Pause() before defining it to avoid redefinition warnings + during compilation in case perl.h had already defined Pause() + (part of perl change #24271) + - minor doc tweaks + +1.67 + - (internal) don't ignore the return value of gettimeofday() + - (external) return undef or an empty if the C gettimeofday() fails + (affects Time::HiRes gettimeofday() and the hires time()) + 1.66 - add nanosleep() - fix the 'hierachy' typo in Makefile.PL [rt.cpan.org #8492] diff --git a/ext/Time/HiRes/HiRes.pm b/ext/Time/HiRes/HiRes.pm index 42326fd..f158830 100644 --- a/ext/Time/HiRes/HiRes.pm +++ b/ext/Time/HiRes/HiRes.pm @@ -15,7 +15,7 @@ require DynaLoader; d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer d_nanosleep); -$VERSION = '1.66'; +$VERSION = '1.68'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -151,7 +151,7 @@ Getting even accuracy of one thousand nanoseconds is good. Issues a C call; the C<$interval_useconds> is optional and will be zero if unspecified, resulting in C-like behaviour. -Note that the interaction between alarms and sleeps are unspecified. +Note that the interaction between alarms and sleeps is unspecified. =item tv_interval @@ -194,7 +194,7 @@ seconds actually slept (a floating point value). This function can be imported, resulting in a nice drop-in replacement for the C provided with perl, see the L below. -Note that the interaction between alarms and sleeps are unspecified. +Note that the interaction between alarms and sleeps is unspecified. =item alarm ( $floating_seconds [, $interval_floating_seconds ] ) @@ -210,7 +210,7 @@ This means that an C followed by a C may together take the sum of the times specified for the the C and the C, not just the time of the C. -Note that the interaction between alarms and sleeps are unspecified. +Note that the interaction between alarms and sleeps is unspecified. =item setitimer ( $which, $floating_seconds [, $interval_floating_seconds ] ) @@ -235,7 +235,7 @@ UNIX platforms usually have the first three, but (for example) Win32 and Cygwin have only C, and only Solaris seems to have C (which is used to profile multithreaded programs). -C results in C-like behavior. Time is counted in +C results in C-like behaviour. Time is counted in I; that is, wallclock time. C is delivered when the timer expires. @@ -331,7 +331,7 @@ emulations for it.) Here is an example of using C from C: - double (*myNVtime)(); + double (*myNVtime)(); /* Returns -1 on failure. */ SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); if (!svp) croak("Time::HiRes is required"); if (!SvIOK(*svp)) croak("Time::NVtime isn't a function pointer"); diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs index b9040eb..f945edb 100644 --- a/ext/Time/HiRes/HiRes.xs +++ b/ext/Time/HiRes/HiRes.xs @@ -811,16 +811,18 @@ gettimeofday() 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)))); + if (status == 0) { + 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 @@ -831,8 +833,12 @@ time() 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); + if (status == 0) { + Tp.tv_sec += Tz.tz_minuteswest * 60; /* adjust for TZ */ + RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.0); + } else { + RETVAL = -1.0; + } OUTPUT: RETVAL @@ -844,13 +850,15 @@ gettimeofday() PPCODE: int status; status = gettimeofday (&Tp, NULL); - if (GIMME == G_ARRAY) { - EXTEND(sp, 2); - PUSHs(sv_2mortal(newSViv(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)))); + if (status == 0) { + if (GIMME == G_ARRAY) { + EXTEND(sp, 2); + PUSHs(sv_2mortal(newSViv(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 @@ -860,7 +868,11 @@ time() CODE: int status; status = gettimeofday (&Tp, NULL); - RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.); + if (status == 0) { + RETVAL = Tp.tv_sec + (Tp.tv_usec / 1000000.); + } else { + RETVAL = -1.0; + } OUTPUT: RETVAL