runtime: use futexes with 64-bit time on Linux

Linux introduced new syscalls to fix the year 2038 issue.
To still be able to use the old ones, the Kconfig option
COMPAT_32BIT_TIME would be necessary.

Use the new syscall with 64-bit values for futex by default.
Define _ENOSYS for detecting if it's not available.
Add a fallback to use the older syscall in case the new one is
not available, since Go runs on Linux from 2.6.32 on, per
https://go.dev/wiki/MinimumRequirements.

Updates #75133

Change-Id: I65daff0a3d06b55440ff05d8f5a9aa1c07eb201d
GitHub-Last-Rev: 96dd1bd84b
GitHub-Pull-Request: golang/go#75306
Reviewed-on: https://go-review.googlesource.com/c/go/+/701615
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Daniel Maslowski 2025-09-18 15:43:42 +00:00 committed by Jorropo
parent 0ab038af62
commit 3cf1aaf8b9
19 changed files with 186 additions and 22 deletions

View file

@ -9,6 +9,7 @@ const (
_EINTR = 0x4
_EAGAIN = 0xb
_ENOMEM = 0xc
_ENOSYS = 0x26
_PROT_NONE = 0x0
_PROT_READ = 0x1
@ -136,16 +137,30 @@ type fpstate struct {
anon0 [48]byte
}
type timespec struct {
// The timespec structs and types are defined in Linux in
// include/uapi/linux/time_types.h and include/uapi/asm-generic/posix_types.h.
type timespec32 struct {
tv_sec int32
tv_nsec int32
}
//go:nosplit
func (ts *timespec) setNsec(ns int64) {
func (ts *timespec32) setNsec(ns int64) {
ts.tv_sec = timediv(ns, 1e9, &ts.tv_nsec)
}
type timespec struct {
tv_sec int64
tv_nsec int64
}
//go:nosplit
func (ts *timespec) setNsec(ns int64) {
var newNS int32
ts.tv_sec = int64(timediv(ns, 1e9, &newNS))
ts.tv_nsec = int64(newNS)
}
type timeval struct {
tv_sec int32
tv_usec int32
@ -223,8 +238,8 @@ type ucontext struct {
}
type itimerspec struct {
it_interval timespec
it_value timespec
it_interval timespec32
it_value timespec32
}
type itimerval struct {