diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-11-21 08:58:59 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-11-21 08:58:59 +0000 |
commit | a5929ff3b853e58228aef2c6033d60fcf6e179d4 (patch) | |
tree | 8085a7f2a93968110999e6de3bf7a56126177db3 /ext/Time/HiRes | |
parent | fc009855d5dd3ec0391bdd89fe8d709ff3609d46 (diff) | |
download | perl-a5929ff3b853e58228aef2c6033d60fcf6e179d4.tar.gz |
Upgrade to Time::HiRes 1.83
p4raw-id: //depot/perl@26181
Diffstat (limited to 'ext/Time/HiRes')
-rw-r--r-- | ext/Time/HiRes/Changes | 19 | ||||
-rw-r--r-- | ext/Time/HiRes/HiRes.pm | 2 | ||||
-rw-r--r-- | ext/Time/HiRes/Makefile.PL | 15 | ||||
-rw-r--r-- | ext/Time/HiRes/t/HiRes.t | 48 |
4 files changed, 56 insertions, 28 deletions
diff --git a/ext/Time/HiRes/Changes b/ext/Time/HiRes/Changes index a31ab0737f..b61607f6b5 100644 --- a/ext/Time/HiRes/Changes +++ b/ext/Time/HiRes/Changes @@ -1,5 +1,14 @@ Revision history for Perl extension Time::HiRes. +1.83 [2005-11-19] + - has_symbol() was wrong since e.g. ITIMER_VIRTUAL is exported + via @EXPORT_OK even when it is not available. This is heinous. + @EXPORT_OK should be determined at Makefile.PL time. + - be more lenient is testing clock_gettime(): allow more slop, + and retry up to three times, sleeping a random nap between + the retries + - human months are one-based (noticed by Anton Berezin) + 1.82 [2005-10-06] - CLOCK_REALTIME is an enum value (of the clockid_t enum) in HP-UX (and might be so elsewhere, too), debugged by @@ -7,7 +16,7 @@ Revision history for Perl extension Time::HiRes. - include const-c.inc as late as possible (from Randy Kobes, [rt.cpan.org #15552] to avoid undefined usleep() on Win32 -1.81 [2005-10-05] +1.81 [2005-11-05] - try to be more robust and consistent in the detection of CLOCK_REALTIME and ITIMER_VIRTUAL in HiRes.t: the proper way is @@ -37,10 +46,10 @@ Revision history for Perl extension Time::HiRes. - fixed inside a comment HAS_POLL -> TIME_HIRES_NANOSLEEP - at the end of HiRest.t tell how close we were to termination -1.80 [2005-10-04] +1.80 [2005-11-04] - Gisle noticed a mistake (using HAS_NANOSLEEP) in 1.79 -1.79 [2005-10-03] +1.79 [2005-11-03] - try nanosleep for emulating usleep -- may help in some weird embedded realtime places which have nanosleep but neither usleep nor select nor poll (doesn't have to be weird embedded realtime @@ -49,12 +58,12 @@ Revision history for Perl extension Time::HiRes. SVR4 places that have neither usleep nor select - a redundant test guard in HiRes.t -1.78 [2005-10-03] +1.78 [2005-11-03] - ITIMER_VIRTUAL detection in HiRes.t had problems (that we cannot in the general case fail already at 'use' phase is suboptimal) - fixes to the documentation of clock_gettime() and clock_getres() -1.77 [2005-10-03] +1.77 [2005-11-03] - add support for the POSIX clock_gettime() and clock_getres(), if available, either as library calls or as syscalls - be more defensive about missing functionality: break out diff --git a/ext/Time/HiRes/HiRes.pm b/ext/Time/HiRes/HiRes.pm index ffb027fd2b..2b4269f026 100644 --- a/ext/Time/HiRes/HiRes.pm +++ b/ext/Time/HiRes/HiRes.pm @@ -17,7 +17,7 @@ require DynaLoader; d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer d_nanosleep d_clock_gettime d_clock_getres); -$VERSION = '1.82'; +$VERSION = '1.83'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; diff --git a/ext/Time/HiRes/Makefile.PL b/ext/Time/HiRes/Makefile.PL index 0105609b22..bce235e240 100644 --- a/ext/Time/HiRes/Makefile.PL +++ b/ext/Time/HiRes/Makefile.PL @@ -324,18 +324,22 @@ sub init { $DEFINE = ''; if ($Config{d_syscall}) { - print "Have syscall(), looking for syscall.h... "; + print "Have syscall()... looking for syscall.h... "; if (has_include('syscall.h')) { $SYSCALL_H = 'syscall.h'; } elsif (has_include('sys/syscall.h')) { $SYSCALL_H = 'sys/syscall.h'; } + } else { + print "No syscall()...\n"; } - if (defined $SYSCALL_H) { - print "found <$SYSCALL_H>.\n"; - } else { - print "NOT found.\n"; + if ($Config{d_syscall}) { + if (defined $SYSCALL_H) { + print "found <$SYSCALL_H>.\n"; + } else { + print "NOT found.\n"; + } } print "Looking for gettimeofday()... "; @@ -628,6 +632,7 @@ sub main { if ($^O =~ /Win32/i) { $DEFINE = '-DSELECT_IS_BROKEN'; $LIBS = []; + print "System is $^O, skipping full configure...\n"; } else { init(); } diff --git a/ext/Time/HiRes/t/HiRes.t b/ext/Time/HiRes/t/HiRes.t index 5bee26f72c..ad4959e3b6 100644 --- a/ext/Time/HiRes/t/HiRes.t +++ b/ext/Time/HiRes/t/HiRes.t @@ -33,9 +33,10 @@ my $have_clock_getres = &Time::HiRes::d_clock_getres; sub has_symbol { my $symbol = shift; - eval "import Time::HiRes qw($symbol)"; + eval "use Time::HiRes qw($symbol)"; return 0 unless $@ eq ''; - return exists &{"Time::HiRes::$symbol"}; + eval "my \$a = $symbol"; + return $@ eq ''; } printf "# have_gettimeofday = %d\n", $have_gettimeofday; @@ -496,23 +497,36 @@ if ($have_clock_gettime && # All implementations of clock_gettime() # are SUPPOSED TO support CLOCK_REALTIME. has_symbol('CLOCK_REALTIME')) { - my $t0 = clock_gettime(&CLOCK_REALTIME); - use Time::HiRes qw(sleep); - my $T = 1.5; - sleep($T); - my $t1 = clock_gettime(&CLOCK_REALTIME); - if ($t0 > 0 && $t1 > $t0) { - print "# t1 = $t1, t0 = $t0\n"; - my $dt = $t1 - $t0; - my $rt = abs(1 - $dt / $T); - if ($rt <= $limit) { - print "ok 30 # dt = $dt, r = $rt\n"; - } else { - print "not ok 30 # dt = $dt, rt = $rt\n"; + my $ok = 0; + TRY: { + for my $try (1..3) { + print "# CLOCK_REALTIME: try = $try\n"; + my $t0 = clock_gettime(&CLOCK_REALTIME); + use Time::HiRes qw(sleep); + my $T = 1.5; + sleep($T); + my $t1 = clock_gettime(&CLOCK_REALTIME); + if ($t0 > 0 && $t1 > $t0) { + print "# t1 = $t1, t0 = $t0\n"; + my $dt = $t1 - $t0; + my $rt = abs(1 - $dt / $T); + print "# dt = $dt, rt = $rt\n"; + if ($rt <= 2 * $limit) { + $ok = 1; + last TRY; + } + } else { + print "# Error: t0 = $t0, t1 = $t1\n"; + } + my $r = rand() + rand(); + printf "# Sleeping for %.6f seconds...\n"; + sleep($r); } + } + if ($ok) { + print "ok 30\n"; } else { - print "# Error: t0 = $t0, t1 = $t1\n"; - skip 30; + print "not ok 30\n"; } } else { print "# No clock_gettime\n"; |