aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_linux32.go
diff options
context:
space:
mode:
authorJorropo <jorropo.pgm@gmail.com>2026-03-04 10:01:11 +0100
committerGopher Robot <gobot@golang.org>2026-04-06 10:01:22 -0700
commitba402cd756a02cd80bcd76a2f7afc22ae2041c6c (patch)
tree7ec950909238e2bfa126fd95e40875ad0699a99c /src/runtime/os_linux32.go
parent6110cd6f83caa1f255189c209711c216d649c6d7 (diff)
downloadgo-ba402cd756a02cd80bcd76a2f7afc22ae2041c6c.tar.xz
runtime: fix timespec definition on 32bits systems
The nsec field of timespec is a C long even when using 64bits time on 32bits systems. This is because by timespec API if nsec never holds more than a second worth of nanoseconds. If it would theses would increment the sec field while the nsec field would get the amount of nanoseconds modulus a second. Fixes #77934 Change-Id: I9803998ba70123eb3b226379bd72b11cae972c38 Reviewed-on: https://go-review.googlesource.com/c/go/+/751341 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/os_linux32.go')
-rw-r--r--src/runtime/os_linux32.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/runtime/os_linux32.go b/src/runtime/os_linux32.go
index 02cb18f32d..1ee1cdcaf9 100644
--- a/src/runtime/os_linux32.go
+++ b/src/runtime/os_linux32.go
@@ -31,7 +31,7 @@ func futex(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe
var ts32 timespec32
var pts32 *timespec32
if ts != nil {
- ts32.setNsec(ts.tv_sec*1e9 + ts.tv_nsec)
+ ts32.setNsec(ts.tv_sec*1e9 + int64(ts.tv_nsec))
pts32 = &ts32
}
return futex_time32(addr, op, val, pts32, addr2, val3)
@@ -53,14 +53,14 @@ func timer_settime(timerid int32, flags int32, new, old *itimerspec) int32 {
var new32, old32 *itimerspec32
if new != nil {
- newts.it_interval.setNsec(new.it_interval.tv_sec*1e9 + new.it_interval.tv_nsec)
- newts.it_value.setNsec(new.it_value.tv_sec*1e9 + new.it_value.tv_nsec)
+ newts.it_interval.setNsec(new.it_interval.tv_sec*1e9 + int64(new.it_interval.tv_nsec))
+ newts.it_value.setNsec(new.it_value.tv_sec*1e9 + int64(new.it_value.tv_nsec))
new32 = &newts
}
if old != nil {
- oldts.it_interval.setNsec(old.it_interval.tv_sec*1e9 + old.it_interval.tv_nsec)
- oldts.it_value.setNsec(old.it_value.tv_sec*1e9 + old.it_value.tv_nsec)
+ oldts.it_interval.setNsec(old.it_interval.tv_sec*1e9 + int64(old.it_interval.tv_nsec))
+ oldts.it_value.setNsec(old.it_value.tv_sec*1e9 + int64(old.it_value.tv_nsec))
old32 = &oldts
}