Skip to content

Commit 3f42577

Browse files
committed
various: timespec/timeval.tv_sec is time_t, not long, according to POSIX
This matters on 32 bit systems configured with 64 bit time_t (so they survive beyond 2038). Casting them to long is causing loss of bits and badly mismatched time data. Signed-off-by: Alexander Kanavin <[email protected]>
1 parent 79c6bd0 commit 3f42577

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Alexander Foken
7272
Alexander Gernler <[email protected]>
7373
Alexander Gough <[email protected]>
7474
Alexander Hartmaier <[email protected]>
75+
Alexander Kanavin <[email protected]>
7576
Alexander Klimov <[email protected]>
7677
Alexander Nikolov <[email protected]>
7778
Alexander Smishlajev <[email protected]>

dist/threads-shared/lib/threads/shared.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use Config;
88

99
use Scalar::Util qw(reftype refaddr blessed);
1010

11-
our $VERSION = '1.68'; # Please update the pod, too.
11+
our $VERSION = '1.69'; # Please update the pod, too.
1212
my $XS_VERSION = $VERSION;
1313
$VERSION = eval $VERSION;
1414

dist/threads-shared/shared.xs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ Perl_sharedsv_cond_timedwait(perl_cond *cond, perl_mutex *mut, double abs)
697697
struct timespec ts;
698698
int got_it = 0;
699699

700-
ts.tv_sec = (long)abs;
700+
ts.tv_sec = (time_t)abs;
701701
abs -= (NV)ts.tv_sec;
702702
ts.tv_nsec = (long)(abs * 1000000000.0);
703703

doio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,9 +2874,9 @@ nothing in the core.
28742874
else {
28752875
Zero(&utbuf, sizeof utbuf, char);
28762876
#ifdef HAS_FUTIMES
2877-
utbuf[0].tv_sec = (long)SvIV(accessed); /* time accessed */
2877+
utbuf[0].tv_sec = (time_t)SvIV(accessed); /* time accessed */
28782878
utbuf[0].tv_usec = 0;
2879-
utbuf[1].tv_sec = (long)SvIV(modified); /* time modified */
2879+
utbuf[1].tv_sec = (time_t)SvIV(modified); /* time modified */
28802880
utbuf[1].tv_usec = 0;
28812881
#elif defined(BIG_TIME)
28822882
utbuf.actime = (Time_t)SvNV(accessed); /* time accessed */

pp_sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ PP(pp_sselect)
12281228
value = SvNV_nomg(sv);
12291229
if (value < 0.0)
12301230
value = 0.0;
1231-
timebuf.tv_sec = (long)value;
1231+
timebuf.tv_sec = (time_t)value;
12321232
value -= (NV)timebuf.tv_sec;
12331233
timebuf.tv_usec = (long)(value * 1000000.0);
12341234
}

0 commit comments

Comments
 (0)