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]
d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
d_nanosleep);
-$VERSION = '1.66';
+$VERSION = '1.68';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
Issues a C<ualarm> call; the C<$interval_useconds> is optional and
will be zero if unspecified, resulting in C<alarm>-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
be imported, resulting in a nice drop-in replacement for the C<sleep>
provided with perl, see the L</EXAMPLES> 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 ] )
take the sum of the times specified for the the C<alarm()> and the
C<select()>, not just the time of the C<alarm()>.
-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 ] )
and Cygwin have only C<ITIMER_REAL>, and only Solaris seems to have
C<ITIMER_REALPROF> (which is used to profile multithreaded programs).
-C<ITIMER_REAL> results in C<alarm()>-like behavior. Time is counted in
+C<ITIMER_REAL> results in C<alarm()>-like behaviour. Time is counted in
I<real time>; that is, wallclock time. C<SIGALRM> is delivered when
the timer expires.
Here is an example of using C<NVtime> 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");
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
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
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
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