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
- 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]
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;
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
If your system lacks C<gettimeofday()> or an emulation of it you don't
get C<gettimeofday()> or the one-argument form of C<tv_interval()>.
-If your system lacks all of C<nanosleep()>, C<usleep()>, C<select()>,
-and C<poll()>, you don't get C<Time::HiRes::usleep()>,
-C<Time::HiRes::nanosleep()>, or C<Time::HiRes::sleep()>. If your
-system lacks both C<ualarm()> and C<setitimer()> you don't get
+If your system lacks all of C<nanosleep()>, C<usleep()>,
+C<select()>, and C<poll>, you don't get C<Time::HiRes::usleep()>,
+C<Time::HiRes::nanosleep()>, or C<Time::HiRes::sleep()>.
+If your system lacks both C<ualarm()> and C<setitimer()> you don't get
C<Time::HiRes::ualarm()> or C<Time::HiRes::alarm()>.
If you try to import an unimplemented function in the C<use> statement
# 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)
#endif /* #ifdef HAS_GETTIMEOFDAY */
+#include "const-c.inc"
+
MODULE = Time::HiRes PACKAGE = Time::HiRes
PROTOTYPES: ENABLE
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"]};
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).
skip 7..8;
}
else {
+ use Time::HiRes qw(usleep);
my $one = time;
usleep(10_000);
my $two = time;
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.";
$SIG{VTALRM} = 'DEFAULT';
}
-if ($have_gettimeofday) {
+if ($have_gettimeofday &&
+ $have_usleep) {
+ use Time::HiRes qw(usleep);
+
my ($t0, $td);
my $sleep = 1.5; # seconds