myNVtime = INT2PTR(double(*)(), SvIV(*svp));
printf("The current time is: %f\n", (*myNVtime)());
+=head1 DIAGNOSTICS
+
+=head2 negative time not invented yet
+
+You tried to use a negative time argument.
+
+=head2 internal error: useconds < 0 (unsigned ... signed ...)
+
+Something went horribly wrong-- the number of microseconds that cannot
+become negative just became negative. Maybe your compiler is broken?
+
=head1 CAVEATS
Notice that the core time() maybe rounding rather than truncating.
}
else {
my $r = [gettimeofday()];
- #jTime::HiRes::sleep 0.5;
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.";
# ifdef IVSIZE
# if IVSIZE == LONGSIZE
# define IVdf "ld"
+# define UVuf "lu"
# else
# if IVSIZE == INTSIZE
# define IVdf "d"
+# define UVuf "u"
# endif
# endif
# else
UV useconds = (UV)(1E6 * (seconds - (UV)seconds));
if (seconds >= 1.0)
sleep((U32)seconds);
+ if ((IV)useconds < 0) {
+#if defined(__sparc64__) && defined(__GNUC__)
+ /* Sparc64 gcc 2.95.3 (e.g. on NetBSD) has a bug
+ * where (0.5 - (UV)(0.5)) will under certain
+ * circumstances (if the double is cast to UV more
+ * than once?) evaluate to -0.5, instead of 0.5. */
+ useconds = -(IV)useconds;
+#endif
+ if ((IV)useconds < 0)
+ croak("Time::HiRes::sleep(%"NVgf"): internal error: useconds < 0 (unsigned %"UVuf" signed %"IVdf")", seconds, useconds, (IV)useconds);
+ }
usleep(useconds);
} else
croak("Time::HiRes::sleep(%"NVgf"): negative time not invented yet", seconds);