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
- 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
- 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
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
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;
$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()... ";
if ($^O =~ /Win32/i) {
$DEFINE = '-DSELECT_IS_BROKEN';
$LIBS = [];
+ print "System is $^O, skipping full configure...\n";
} else {
init();
}
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;
# 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";