From: Steve Peters Date: Sun, 6 Nov 2005 18:38:02 +0000 (+0000) Subject: Upgrade to Time-HiRes-1.82 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82cbdcc3d460f16b26646afbb27f32075e0e0595;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Time-HiRes-1.82 p4raw-id: //depot/perl@26021 --- diff --git a/ext/Time/HiRes/Changes b/ext/Time/HiRes/Changes index 391753a..a31ab07 100644 --- a/ext/Time/HiRes/Changes +++ b/ext/Time/HiRes/Changes @@ -1,5 +1,12 @@ Revision history for Perl extension Time::HiRes. +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 + H. Merijn Brand + - 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] - try to be more robust and consistent in the detection of CLOCK_REALTIME and ITIMER_VIRTUAL in HiRes.t: the proper @@ -134,7 +141,9 @@ Revision history for Perl extension Time::HiRes. - fix the 'hierachy' typo in Makefile.PL [rt.cpan.org #8492] - should now build in Solaris [rt.cpan.org #7165] (since 1.64) - should now build in Cygwin [rt.cpan.org #7535] (since 1.64) - - close also [rt.cpan.org #5933] "Time::HiRes::time does not pick up time adjustments like ntp" since ever reproducing it in the same environment + - close also [rt.cpan.org #5933] "Time::HiRes::time does not + pick up time adjustments like ntp" since ever reproducing it + (and therefore verifying a possible fix) in the same environment has become rather unlikely 1.65 [2004-09-18] diff --git a/ext/Time/HiRes/HiRes.pm b/ext/Time/HiRes/HiRes.pm index 2f781d3..ffb027f 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.81'; +$VERSION = '1.82'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -105,7 +105,8 @@ Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers setitimer ($which, $floating_seconds, $floating_interval ); getitimer ($which); - $realtime = clock_gettime(CLOCK_REALTIME); + $realtime = clock_gettime(CLOCK_REALTIME); + $resolution = clock_getres(CLOCK_REALTIME); =head1 DESCRIPTION @@ -119,10 +120,10 @@ C, and C/C calls. If your system lacks C or an emulation of it you don't get C or the one-argument form of C. -If your system lacks all of C, C, C, -and C, you don't get C, -C, or C. If your -system lacks both C and C you don't get +If your system lacks all of C, C, +C, and C, you don't get C, +C, or C. +If your system lacks both C and C you don't get C or C. If you try to import an unimplemented function in the C statement diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs index 201e99f..d4d1304 100644 --- a/ext/Time/HiRes/HiRes.xs +++ b/ext/Time/HiRes/HiRes.xs @@ -65,7 +65,17 @@ extern "C" { # endif #endif -#include "const-c.inc" +#if defined(TIME_HIRES_CLOCK_GETTIME) && defined(_STRUCT_ITIMERSPEC) + +/* HP-UX has CLOCK_XXX values but as enums, not as defines. + * The only way to detect these would be to test compile for each. */ +# ifdef __hpux +# define CLOCK_REALTIME CLOCK_REALTIME +# define CLOCK_VIRTUAL CLOCK_VIRTUAL +# define CLOCK_PROFILE CLOCK_PROFILE +# endif /* # ifdef __hpux */ + +#endif /* #if defined(TIME_HIRES_CLOCK_GETTIME) && defined(_STRUCT_ITIMERSPEC) */ #if defined(WIN32) || defined(CYGWIN_WITH_W32API) @@ -678,6 +688,8 @@ myNVtime() #endif /* #ifdef HAS_GETTIMEOFDAY */ +#include "const-c.inc" + MODULE = Time::HiRes PACKAGE = Time::HiRes PROTOTYPES: ENABLE diff --git a/ext/Time/HiRes/Makefile.PL b/ext/Time/HiRes/Makefile.PL index bfa65e0..0105609 100644 --- a/ext/Time/HiRes/Makefile.PL +++ b/ext/Time/HiRes/Makefile.PL @@ -594,9 +594,9 @@ sub doConstants { d_nanosleep d_clock_gettime d_clock_getres)) { my $macro = $_; if ($macro =~ /^(d_nanosleep|d_clock_gettime|d_clock_getres)$/) { - $macro =~ s/d_(.*)/TIME_HIRES_\U$1/; + $macro =~ s/^d_(.+)/TIME_HIRES_\U$1/; } else { - $macro =~ s/d_(.*)/HAS_\U$1/; + $macro =~ s/^d_(.+)/HAS_\U$1/; } push @names, {name => $_, macro => $macro, value => 1, default => ["IV", "0"]}; diff --git a/ext/Time/HiRes/t/HiRes.t b/ext/Time/HiRes/t/HiRes.t index efa8ba6..5bee26f 100644 --- a/ext/Time/HiRes/t/HiRes.t +++ b/ext/Time/HiRes/t/HiRes.t @@ -54,6 +54,8 @@ import Time::HiRes 'clock_getres' if $have_clock_getres; use Config; +use Time::HiRes qw(gettimeofday); + my $have_alarm = $Config{d_alarm}; my $have_fork = $Config{d_fork}; my $waitfor = 60; # 10-20 seconds is normal (load affects this). @@ -140,6 +142,7 @@ unless ($have_usleep) { skip 7..8; } else { + use Time::HiRes qw(usleep); my $one = time; usleep(10_000); my $two = time; @@ -178,7 +181,7 @@ unless ($have_usleep && $have_gettimeofday) { skip 11; } else { - my $r = [gettimeofday()]; + my $r = [ gettimeofday() ]; Time::HiRes::sleep( 0.5 ); my $f = tv_interval $r; ok 11, $f > 0.4 && $f < 0.9, "slept $f instead of 0.5 secs."; @@ -333,7 +336,10 @@ unless ( defined &Time::HiRes::setitimer $SIG{VTALRM} = 'DEFAULT'; } -if ($have_gettimeofday) { +if ($have_gettimeofday && + $have_usleep) { + use Time::HiRes qw(usleep); + my ($t0, $td); my $sleep = 1.5; # seconds