aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/os_linux.c
diff options
context:
space:
mode:
authorRémy Oudompheng <oudomphe@phare.normalesup.org>2013-03-18 20:11:11 +0100
committerRémy Oudompheng <oudomphe@phare.normalesup.org>2013-03-18 20:11:11 +0100
commitba50e4f1203ad5cc20b7ada2fce4da62ab195622 (patch)
treebc15b58f8552e26bd235ec6b04d3a40a7771c8a5 /src/pkg/runtime/os_linux.c
parente7537157a53de8683167a512a67218bd3ea44e39 (diff)
downloadgo-ba50e4f1203ad5cc20b7ada2fce4da62ab195622.tar.xz
runtime: fix tv_sec 32-bit overflows in sleep routines.
Fixes #5063. R=golang-dev, minux.ma, rsc CC=golang-dev https://golang.org/cl/7876043
Diffstat (limited to 'src/pkg/runtime/os_linux.c')
-rw-r--r--src/pkg/runtime/os_linux.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/pkg/runtime/os_linux.c b/src/pkg/runtime/os_linux.c
index dc1e274378..8aa4c3d35d 100644
--- a/src/pkg/runtime/os_linux.c
+++ b/src/pkg/runtime/os_linux.c
@@ -36,15 +36,17 @@ void
runtime·futexsleep(uint32 *addr, uint32 val, int64 ns)
{
Timespec ts, *tsp;
+ int64 secs;
if(ns < 0)
tsp = nil;
else {
- ts.tv_sec = ns/1000000000LL;
- ts.tv_nsec = ns%1000000000LL;
+ secs = ns/1000000000LL;
// Avoid overflow
- if(ts.tv_sec > 1<<30)
- ts.tv_sec = 1<<30;
+ if(secs > 1LL<<30)
+ secs = 1LL<<30;
+ ts.tv_sec = secs;
+ ts.tv_nsec = ns%1000000000LL;
tsp = &ts;
}