From 26e22fd982477a29dff41463848adbca7379d504 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Sun, 26 Jun 2005 20:06:10 +0000 Subject: [PATCH] Upgrade to Time::HiRes 1.69 p4raw-id: //depot/perl@24985 --- ext/Time/HiRes/Changes | 13 +++++++++++++ ext/Time/HiRes/HiRes.pm | 17 +++++++++++++++-- ext/Time/HiRes/Makefile.PL | 40 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/ext/Time/HiRes/Changes b/ext/Time/HiRes/Changes index 10b4243..5661bbc 100644 --- a/ext/Time/HiRes/Changes +++ b/ext/Time/HiRes/Changes @@ -1,5 +1,18 @@ 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 diff --git a/ext/Time/HiRes/HiRes.pm b/ext/Time/HiRes/HiRes.pm index f158830..a14dbb0 100644 --- a/ext/Time/HiRes/HiRes.pm +++ b/ext/Time/HiRes/HiRes.pm @@ -7,6 +7,7 @@ require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); +@ISA = qw(Exporter); @EXPORT = qw( ); @EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval @@ -15,7 +16,7 @@ require DynaLoader; d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer d_nanosleep); -$VERSION = '1.68'; +$VERSION = '1.69'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -32,7 +33,15 @@ sub AUTOLOAD { 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. @@ -363,6 +372,10 @@ platforms like Cygwin and MinGW) the Time::HiRes::time() may temporarily 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, L. + =head1 AUTHORS D. Wegscheid diff --git a/ext/Time/HiRes/Makefile.PL b/ext/Time/HiRes/Makefile.PL index 51bf35a..fe547ab 100644 --- a/ext/Time/HiRes/Makefile.PL +++ b/ext/Time/HiRes/Makefile.PL @@ -135,11 +135,24 @@ sub try_compile_and_link { 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 { @@ -202,6 +215,29 @@ EOM return 0; } +sub has_nanosleep { + return 1 if + try_compile_and_link(< 1); +#include +#include +#include +#include +#include + +/* 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 @@ -344,7 +380,7 @@ EOD $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'; } -- 1.8.3.1