Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/Time-HiRes/Changes
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Revision history for the Perl extension Time::HiRes.
build failures with MSVC.
- don't try to suppress C++ compatibility warnings in C++ builds, since
that warns.
- Fix sleep's prototype to match CORE::sleep (;$).

1.9764 [2020-08-10]
- Fix a bunch of repeated-word typos
Expand Down
2 changes: 1 addition & 1 deletion dist/Time-HiRes/HiRes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ our @EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval
stat lstat utime
);

our $VERSION = '1.9778';
our $VERSION = '1.9779';
our $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;

Expand Down
1 change: 1 addition & 0 deletions dist/Time-HiRes/HiRes.xs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,7 @@ nanosleep(nsec)

NV
sleep(...)
PROTOTYPE: ;$
PREINIT:
struct timeval Ta, Tb;
CODE:
Expand Down
8 changes: 3 additions & 5 deletions dist/Time-HiRes/t/alarm.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use Config;
my $limit = 0.25; # 25% is acceptable slosh for testing timers

my $xdefine = '';
if (open(XDEFINE, "<", "xdefine")) {
chomp($xdefine = <XDEFINE> || "");
close(XDEFINE);
if (open(my $fh, "<", "xdefine")) {
chomp($xdefine = <$fh> || "");
close($fh);
}

my $can_subsecond_alarm =
Expand Down Expand Up @@ -224,5 +224,3 @@ SKIP: {
ok $got == 0 or print("# $got\n");
}
}

1;
2 changes: 0 additions & 2 deletions dist/Time-HiRes/t/clock.t
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,3 @@ SKIP: {
$clock[2] > $clock[1] &&
$clock[3] > $clock[2];
}

1;
2 changes: 0 additions & 2 deletions dist/Time-HiRes/t/gettimeofday.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ ok $f - $two[0] < 2 or print("# $f - $two[0] >= 2\n");
my $r = [Time::HiRes::gettimeofday()];
my $g = Time::HiRes::tv_interval $r;
ok $g < 2 or print("# $g\n");

1;
2 changes: 0 additions & 2 deletions dist/Time-HiRes/t/itimer.t
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,3 @@ print("# at end, i=$i\n");
is($virt, 0, "time left should be zero");

$SIG{VTALRM} = 'DEFAULT';

1;
2 changes: 0 additions & 2 deletions dist/Time-HiRes/t/nanosleep.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ SKIP: {
skip "flapping test - more than 0.9 sec could be necessary...", 1 if $ENV{CI};
cmp_ok $d, '<', 0.9 or diag("# slept $d secs $f to $f2\n");
}

1;
16 changes: 10 additions & 6 deletions dist/Time-HiRes/t/sleep.t
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
use strict;

use Test::More tests => 4;
use Test::More tests => 5;
BEGIN { push @INC, '.' }
use t::Watchdog;

BEGIN { require_ok "Time::HiRes"; }

use Config;

SKIP: {
skip "no hi-res sleep", 1 unless defined &Time::HiRes::sleep;
is prototype(\&Time::HiRes::sleep), prototype('CORE::sleep'),
"Time::HiRes::sleep's prototype matches CORE::sleep's";
}

my $xdefine = '';
if (open(XDEFINE, "<", "xdefine")) {
chomp($xdefine = <XDEFINE> || "");
close(XDEFINE);
if (open(my $fh, "<", "xdefine")) {
chomp($xdefine = <$fh> || "");
close($fh);
}

my $can_subsecond_alarm =
Expand All @@ -35,5 +41,3 @@ SKIP: {
printf("# sleep...%s\n", Time::HiRes::tv_interval($r));
ok 1;
}

1;
20 changes: 9 additions & 11 deletions dist/Time-HiRes/t/stat.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ my @mtime;
for (1..5) {
note "cycle $_";
Time::HiRes::sleep(rand(0.1) + 0.1);
open(X, '>', $$);
print X $$;
close(X);
open(my $fh, '>', $$);
print $fh $$;
close($fh);
my($a, $stat, $b) = ("a", [Time::HiRes::stat($$)], "b");
is $a, "a", "stat stack discipline";
is $b, "b", "stat stack discipline";
Expand All @@ -43,9 +43,9 @@ for (1..5) {
}
is_deeply $lstat, $stat, "write: stat and lstat returned same values";
Time::HiRes::sleep(rand(0.1) + 0.1);
open(X, '<', $$);
<X>;
close(X);
open(my $fh, '<', $$);
<$fh>;
close($fh);
$stat = [Time::HiRes::stat($$)];
push @atime, $stat->[8];
$lstat = [Time::HiRes::lstat($$)];
Expand Down Expand Up @@ -88,9 +88,9 @@ SKIP: {
my $targetname = "tgt$$";
my $linkname = "link$$";
SKIP: {
open(X, '>', $targetname);
print X $$;
close(X);
open(my $fh, '>', $targetname);
print $fh $$;
close($fh);
eval { symlink $targetname, $linkname or die "can't symlink: $!"; };
skip "can't symlink", 7 if $@ ne "";
note "compare Time::HiRes::stat with ::lstat";
Expand All @@ -111,5 +111,3 @@ SKIP: {
}
1 while unlink $linkname;
1 while unlink $targetname;

1;
10 changes: 7 additions & 3 deletions dist/Time-HiRes/t/time.t
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use strict;

use Test::More tests => 2;
use Test::More tests => 3;
BEGIN { push @INC, '.' }
use t::Watchdog;

BEGIN { require_ok "Time::HiRes"; }

SKIP: {
skip "no hi-res time", 1 unless defined &Time::HiRes::time;
is prototype(\&Time::HiRes::time), prototype('CORE::time'),
"Time::HiRes::time's prototype matches CORE::time's";
}

SKIP: {
skip "no gettimeofday", 1 unless &Time::HiRes::d_gettimeofday;
my ($s, $n, $i) = (0);
Expand All @@ -20,5 +26,3 @@ SKIP: {
or print("# Time::HiRes::time() not close to CORE::time()\n");
printf("# s = $s, n = $n, s/n = %s\n", abs($s)/$n);
}

1;
2 changes: 0 additions & 2 deletions dist/Time-HiRes/t/tv_interval.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ BEGIN { require_ok "Time::HiRes"; }

my $f = Time::HiRes::tv_interval [5, 100_000], [10, 500_000];
ok abs($f - 5.4) < 0.001 or print("# $f\n");

1;
2 changes: 0 additions & 2 deletions dist/Time-HiRes/t/ualarm.t
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,3 @@ for my $n (100_000, 1_100_000, 2_200_000, 4_300_000) {
my $got2 = Time::HiRes::ualarm(0);
ok $got2 == 0 or print("# $got2\n");
}

1;
2 changes: 0 additions & 2 deletions dist/Time-HiRes/t/usleep.t
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,3 @@ SKIP: {
ok $a < $limit or print("# $msg\n");
}
}

1;
2 changes: 0 additions & 2 deletions dist/Time-HiRes/t/utime.t
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,3 @@ print "# negative mtime dies;\n";
};

done_testing();

1;
16 changes: 14 additions & 2 deletions pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,21 @@ XXX Remove this section if F<Porting/corelist-perldelta.pl> did not add any cont

=item *

L<XXX> has been upgraded from version A.xx to B.yy.
L<Time::HiRes> has been upgraded from version 1.9778 to 1.9779.

XXX If there was something important to note about this change, include that here.
The subsecond-resolution C<sleep> function provided by L<Time::HiRes> now has
the same prototype as perl's built-in L<sleep function|perlfunc/sleep>. This
means it now requires a scalar argument, not a list, just like C<CORE::sleep>:

use Time::HiRes qw(sleep);

sleep(1, "foo", "bar"); # Syntax error.
# It used to silently ignore the extra arguments.

my @t = 42;
sleep @t;
# Evaluates @t in scalar context (giving the number of elements)
# and sleeps for one second. It used to sleep for 42 seconds.

=back

Expand Down
Loading