Revision history for Perl extension Time::HiRes.
+1.69 - actually run a test for nanosleep since e.g. in AIX 4.2
+ it seems that one can link in nanosleep() but then calling
+ it fails instantly and sets errno to ENOSYS (Not implemented).
+ This may be fixable in the AIX case by figuring out the right
+ (realtime POSIX?) libs and whatnot, but in the general case
+ running a real test case is better. (Of course, this change
+ will no doubt run into portability problems because of the
+ execution step...)
+ (from José Auguste-tienne)
+ - support XSLoader also since it's much faster
+ (from Alexey Tourbin)
+ - add SEE ALSO (BSD::Resource and Time::TAI64)
+
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
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
+@ISA = qw(Exporter);
@EXPORT = qw( );
@EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval
d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
d_nanosleep);
-$VERSION = '1.68';
+$VERSION = '1.69';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
goto &$AUTOLOAD;
}
-bootstrap Time::HiRes;
+eval {
+ require XSLoader;
+ XSLoader::load('Time::HiRes', $XS_VERSION);
+ 1;
+} or do {
+ require DynaLoader;
+ local @ISA = qw(DynaLoader);
+ bootstrap Time::HiRes $XS_VERSION;
+};
# Preloaded methods go here.
drift off from the system clock (and the original time()) by up to 0.5
seconds. Time::HiRes will notice this eventually and recalibrate.
+=head1 SEE ALSO
+
+L<BSD::Resource>, L<Time::TAI64>.
+
=head1 AUTHORS
D. Wegscheid <wegscd@whirlpool.com>
printf "cccmd = $cccmd\n" if $VERBOSE;
my $res = system($cccmd);
$ok = defined($res) && $res==0 && -s $tmp_exe && -x _;
+
+ if ( $ok && exists $args{run} && $args{run}) {
+ my $abs_tmp_exe =
+ File::Spec->
+ catfile(File::Spec->rel2abs(File::Spec->curdir),
+ $tmp_exe);
+ printf "Running $abs_tmp_exe..." if $VERBOSE;
+ if (system($abs_tmp_exe) == 0) {
+ $ok = $? == 0;
+ } else {
+ print "system('$abs_tmp_exe') failed: $?\n";
+ }
+ }
unlink("$tmp.c", $tmp_exe);
}
}
- $ok;
+ return $ok;
}
sub has_gettimeofday {
return 0;
}
+sub has_nanosleep {
+ return 1 if
+ try_compile_and_link(<<EOM, run => 1);
+#include <time.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+/* int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); */
+
+int main() {
+ struct timespec ts1, ts2;
+ ts1.tv_sec = 0;
+ ts1.tv_nsec = 750000000;
+ ts2.tv_sec = 0;
+ ts2.tv_nsec = 0;
+ nanosleep(&ts1, &ts2); /* E.g. in AIX nanosleep() might return ENOSYS. */
+ exit(errno);
+}
+EOM
+}
+
sub has_include {
my ($inc) = @_;
return 1 if
$DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
}
} elsif ($^O ne 'mpeix' && # MPE/iX falsely finds nanosleep.
- has_x ("nanosleep (NULL, NULL)")) {
+ has_nanosleep()) {
$has_nanosleep++;
$DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
}