]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: merge all the linux 32 and 64 bits files into one for each
authorJorropo <jorropo.pgm@gmail.com>
Thu, 23 Oct 2025 08:54:00 +0000 (10:54 +0200)
committerJorropo <jorropo.pgm@gmail.com>
Wed, 26 Nov 2025 20:36:16 +0000 (12:36 -0800)
Change-Id: I57067c9724dad2fba518b900d6f6a049cc32099e
Reviewed-on: https://go-review.googlesource.com/c/go/+/714081
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
src/runtime/os_linux32.go [moved from src/runtime/os_linux_settime32.go with 55% similarity]
src/runtime/os_linux64.go [moved from src/runtime/os_linux_futex64.go with 81% similarity]
src/runtime/os_linux_futex32.go [deleted file]
src/runtime/os_linux_settime64.go [deleted file]

similarity index 55%
rename from src/runtime/os_linux_settime32.go
rename to src/runtime/os_linux32.go
index e6c5d9f95c0ee0ded18c9e7d3a6ce162eaedb753..16de6fb350f62490d4176a90a5b4a086043306cc 100644 (file)
@@ -6,9 +6,38 @@
 
 package runtime
 
-import "internal/runtime/atomic"
+import (
+       "internal/runtime/atomic"
+       "unsafe"
+)
 
-var timer32bitOnly atomic.Bool
+//go:noescape
+func futex_time32(addr unsafe.Pointer, op int32, val uint32, ts *timespec32, addr2 unsafe.Pointer, val3 uint32) int32
+
+//go:noescape
+func futex_time64(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32
+
+var isFutexTime32bitOnly atomic.Bool
+
+//go:nosplit
+func futex(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32 {
+       if !isFutexTime32bitOnly.Load() {
+               ret := futex_time64(addr, op, val, ts, addr2, val3)
+               // futex_time64 is only supported on Linux 5.0+
+               if ret != -_ENOSYS {
+                       return ret
+               }
+               isFutexTime32bitOnly.Store(true)
+       }
+       // Downgrade ts.
+       var ts32 timespec32
+       var pts32 *timespec32
+       if ts != nil {
+               ts32.setNsec(ts.tv_sec*1e9 + ts.tv_nsec)
+               pts32 = &ts32
+       }
+       return futex_time32(addr, op, val, pts32, addr2, val3)
+}
 
 //go:noescape
 func timer_settime32(timerid int32, flags int32, new, old *itimerspec32) int32
@@ -16,15 +45,17 @@ func timer_settime32(timerid int32, flags int32, new, old *itimerspec32) int32
 //go:noescape
 func timer_settime64(timerid int32, flags int32, new, old *itimerspec) int32
 
+var isSetTime32bitOnly atomic.Bool
+
 //go:nosplit
 func timer_settime(timerid int32, flags int32, new, old *itimerspec) int32 {
-       if !timer32bitOnly.Load() {
+       if !isSetTime32bitOnly.Load() {
                ret := timer_settime64(timerid, flags, new, old)
                // timer_settime64 is only supported on Linux 5.0+
                if ret != -_ENOSYS {
                        return ret
                }
-               timer32bitOnly.Store(true)
+               isSetTime32bitOnly.Store(true)
        }
 
        var newts, oldts itimerspec32
similarity index 81%
rename from src/runtime/os_linux_futex64.go
rename to src/runtime/os_linux64.go
index 2448e30cf1b0009861468ebd1275ca2c9bff801a..7b70d80fbe5a89c19a02730e3555e75e58fa5b8f 100644 (file)
@@ -12,3 +12,6 @@ import (
 
 //go:noescape
 func futex(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32
+
+//go:noescape
+func timer_settime(timerid int32, flags int32, new, old *itimerspec) int32
diff --git a/src/runtime/os_linux_futex32.go b/src/runtime/os_linux_futex32.go
deleted file mode 100644 (file)
index c5cffa2..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2025 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && (386 || arm || mips || mipsle || (gccgo && (ppc || s390)))
-
-package runtime
-
-import (
-       "internal/runtime/atomic"
-       "unsafe"
-)
-
-//go:noescape
-func futex_time32(addr unsafe.Pointer, op int32, val uint32, ts *timespec32, addr2 unsafe.Pointer, val3 uint32) int32
-
-//go:noescape
-func futex_time64(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32
-
-var is32bitOnly atomic.Bool
-
-//go:nosplit
-func futex(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32 {
-       if !is32bitOnly.Load() {
-               ret := futex_time64(addr, op, val, ts, addr2, val3)
-               // futex_time64 is only supported on Linux 5.0+
-               if ret != -_ENOSYS {
-                       return ret
-               }
-               is32bitOnly.Store(true)
-       }
-       // Downgrade ts.
-       var ts32 timespec32
-       var pts32 *timespec32
-       if ts != nil {
-               ts32.setNsec(ts.tv_sec*1e9 + ts.tv_nsec)
-               pts32 = &ts32
-       }
-       return futex_time32(addr, op, val, pts32, addr2, val3)
-}
diff --git a/src/runtime/os_linux_settime64.go b/src/runtime/os_linux_settime64.go
deleted file mode 100644 (file)
index dfacf56..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2025 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && !(386 || arm || mips || mipsle || (gccgo && (ppc || s390)))
-
-package runtime
-
-//go:noescape
-func timer_settime(timerid int32, flags int32, new, old *itimerspec) int32