From: Steve Peters Date: Tue, 3 Oct 2006 13:08:35 +0000 (+0000) Subject: Upgrade to Time-HiRes-1.91 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34f6948355c3813dae85d2f858b544061e7050ab;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Time-HiRes-1.91 p4raw-id: //depot/perl@28919 --- diff --git a/ext/Time/HiRes/Changes b/ext/Time/HiRes/Changes index a357ad6..b878c28 100644 --- a/ext/Time/HiRes/Changes +++ b/ext/Time/HiRes/Changes @@ -1,5 +1,12 @@ Revision history for Perl extension Time::HiRes. +1.91 [2006-09-28] + - ualarm() in SuSE 10.1 was overflowing after ~4.2 seconds, + probably due to a glibc bug/feature, workaround by using the + setitimer() variant if either useconds or interval >= IV_1E6 + (this case seems to vary between systems: are useconds + more than 999_999 for ualarm() defined or not) + 1.90 [2006-08-22] - tweak still needed for Const64(), from Jerry Hedden - get a freshly generated ppport.h diff --git a/ext/Time/HiRes/HiRes.pm b/ext/Time/HiRes/HiRes.pm index f032d9b..b975262 100644 --- a/ext/Time/HiRes/HiRes.pm +++ b/ext/Time/HiRes/HiRes.pm @@ -21,7 +21,7 @@ require DynaLoader; d_nanosleep d_clock_gettime d_clock_getres d_clock d_clock_nanosleep); -$VERSION = '1.90'; +$VERSION = '1.91'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -449,6 +449,12 @@ Here is an example of using C from C: =head1 DIAGNOSTICS +=head2 useconds or interval more than ... + +In ualarm() you tried to use number of microseconds or interval (also +in microseconds) more than 1_000_000 and setitimer() is not available +in your system to emulate that case. + =head2 negative time not invented yet You tried to use a negative time argument. diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs index df0a436..c27c563 100644 --- a/ext/Time/HiRes/HiRes.xs +++ b/ext/Time/HiRes/HiRes.xs @@ -468,12 +468,9 @@ hrt_usleep(unsigned long usec) #endif /* #if !defined(HAS_USLEEP) && defined(HAS_POLL) */ -#if !defined(HAS_UALARM) && defined(HAS_SETITIMER) -#define HAS_UALARM -#define ualarm hrt_ualarm /* could conflict with ncurses for static build */ - +#if defined(HAS_SETITIMER) && defined(ITIMER_REAL) int -hrt_ualarm(int usec, int interval) +hrt_ualarm_itimer(int usec, int interval) { struct itimerval itv; itv.it_value.tv_sec = usec / IV_1E6; @@ -484,6 +481,11 @@ hrt_ualarm(int usec, int interval) } #endif /* #if !defined(HAS_UALARM) && defined(HAS_SETITIMER) */ +#if !defined(HAS_UALARM) && defined(HAS_SETITIMER) +#define HAS_UALARM +#define ualarm hrt_ualarm_itimer /* could conflict with ncurses for static build */ +#endif + #if !defined(HAS_UALARM) && defined(VMS) #define HAS_UALARM #define ualarm vms_ualarm @@ -874,7 +876,14 @@ ualarm(useconds,interval=0) CODE: if (useconds < 0 || interval < 0) croak("Time::HiRes::ualarm(%d, %d): negative time not invented yet", useconds, interval); - RETVAL = ualarm(useconds, interval); + if (useconds >= IV_1E6 || interval >= IV_1E6) +#if defined(HAS_SETITIMER) && defined(ITIMER_REAL) + RETVAL = hrt_ualarm_itimer(useconds, interval); +#else + croak("Time::HiRes::ualarm(%d, %d): useconds or interval equal or more than %"IVdf, useconds, interval, IV_1E6); +#endif + else + RETVAL = ualarm(useconds, interval); OUTPUT: RETVAL