summaryrefslogtreecommitdiff
path: root/ext/Time/HiRes
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2007-03-04 04:51:28 +0000
committerSteve Peters <steve@fisharerojo.org>2007-03-04 04:51:28 +0000
commited94752d3e14e57ddb49df6f1f1d23eb25daf7af (patch)
treee51d656c1581bda9bf1d9c4d3cda12335d2ae74f /ext/Time/HiRes
parentc0e08cf6f1fc66c8b78e47112b803770d4cc7e4a (diff)
downloadperl-ed94752d3e14e57ddb49df6f1f1d23eb25daf7af.tar.gz
Upgrade to Time-HiRes-1.9707
p4raw-id: //depot/perl@30457
Diffstat (limited to 'ext/Time/HiRes')
-rw-r--r--ext/Time/HiRes/HiRes.pm2
-rw-r--r--ext/Time/HiRes/t/HiRes.t29
2 files changed, 26 insertions, 5 deletions
diff --git a/ext/Time/HiRes/HiRes.pm b/ext/Time/HiRes/HiRes.pm
index 7d31760573..605e223d4e 100644
--- a/ext/Time/HiRes/HiRes.pm
+++ b/ext/Time/HiRes/HiRes.pm
@@ -23,7 +23,7 @@ require DynaLoader;
stat
);
-$VERSION = '1.9705';
+$VERSION = '1.9707';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
diff --git a/ext/Time/HiRes/t/HiRes.t b/ext/Time/HiRes/t/HiRes.t
index d9c5739fc0..d5504e877f 100644
--- a/ext/Time/HiRes/t/HiRes.t
+++ b/ext/Time/HiRes/t/HiRes.t
@@ -247,6 +247,9 @@ unless ( defined &Time::HiRes::gettimeofday
}
} else {
use Time::HiRes qw(time alarm sleep);
+ eval { require POSIX };
+ my $use_sigaction =
+ !$@ && defined &POSIX::sigaction && &POSIX::SIGALRM > 0;
my ($f, $r, $i, $not, $ok);
@@ -260,7 +263,20 @@ unless ( defined &Time::HiRes::gettimeofday
$r = [Time::HiRes::gettimeofday()];
$i = 5;
- $SIG{ALRM} = "tick";
+ my $oldaction;
+ if ($use_sigaction) {
+ $oldaction = new POSIX::SigAction;
+ printf "# sigaction tick, ALRM = %d\n", &POSIX::SIGALRM;
+ # Perl's deferred signals may be too wimpy to break through
+ # a restartable select(), so use POSIX::sigaction if available.
+ POSIX::sigaction(&POSIX::SIGALRM, POSIX::SigAction->new("tick"),
+ $oldaction)
+ or die "Error setting SIGALRM handler with sigaction: $!\n";
+ } else {
+ print "# SIG tick\n";
+ $SIG{ALRM} = "tick";
+ }
+
while ($i > 0)
{
alarm(0.3);
@@ -295,14 +311,18 @@ unless ( defined &Time::HiRes::gettimeofday
print "# Tick! $i $ival\n";
my $exp = 0.3 * (5 - $i);
# This test is more sensitive, so impose a softer limit.
- if (abs($ival/$exp - 1) > 3*$limit) {
+ if (abs($ival/$exp - 1) > 4*$limit) {
my $ratio = abs($ival/$exp);
$not = "tick: $exp sleep took $ival ratio $ratio";
$i = 0;
}
}
- alarm(0); # can't cancel usig %SIG
+ if ($use_sigaction) {
+ POSIX::sigaction(&POSIX::SIGALRM, $oldaction);
+ } else {
+ alarm(0); # can't cancel usig %SIG
+ }
print $not ? "not ok 17 # $not\n" : "ok 17 # $ok\n";
}
@@ -613,9 +633,10 @@ if ($have_ualarm) {
my $dt = $t1 - $t0;
print "# dt = $dt\n";
my $r = $dt / ($n/1e6);
+ print "# r = $r\n";
ok $i,
($n < 1_000_000 || # Too much noise.
- $r >= 0.9 && $r <= 1.5), "ualarm($n) close enough";
+ $r >= 0.8 && $r <= 1.6), "ualarm($n) close enough";
}
} else {
print "# No ualarm\n";