Source file
src/runtime/os_linux32.go
1
2
3
4
5
6
7 package runtime
8
9 import (
10 "internal/runtime/atomic"
11 "unsafe"
12 )
13
14
15 func futex_time32(addr unsafe.Pointer, op int32, val uint32, ts *timespec32, addr2 unsafe.Pointer, val3 uint32) int32
16
17
18 func futex_time64(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32
19
20 var isFutexTime32bitOnly atomic.Bool
21
22
23 func futex(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32 {
24 if !isFutexTime32bitOnly.Load() {
25 ret := futex_time64(addr, op, val, ts, addr2, val3)
26
27 if ret != -_ENOSYS {
28 return ret
29 }
30 isFutexTime32bitOnly.Store(true)
31 }
32
33 var ts32 timespec32
34 var pts32 *timespec32
35 if ts != nil {
36 ts32.setNsec(ts.tv_sec*1e9 + ts.tv_nsec)
37 pts32 = &ts32
38 }
39 return futex_time32(addr, op, val, pts32, addr2, val3)
40 }
41
42
43 func timer_settime32(timerid int32, flags int32, new, old *itimerspec32) int32
44
45
46 func timer_settime64(timerid int32, flags int32, new, old *itimerspec) int32
47
48 var isSetTime32bitOnly atomic.Bool
49
50
51 func timer_settime(timerid int32, flags int32, new, old *itimerspec) int32 {
52 if !isSetTime32bitOnly.Load() {
53 ret := timer_settime64(timerid, flags, new, old)
54
55 if ret != -_ENOSYS {
56 return ret
57 }
58 isSetTime32bitOnly.Store(true)
59 }
60
61 var newts, oldts itimerspec32
62 var new32, old32 *itimerspec32
63
64 if new != nil {
65 newts.it_interval.setNsec(new.it_interval.tv_sec*1e9 + new.it_interval.tv_nsec)
66 newts.it_value.setNsec(new.it_value.tv_sec*1e9 + new.it_value.tv_nsec)
67 new32 = &newts
68 }
69
70 if old != nil {
71 oldts.it_interval.setNsec(old.it_interval.tv_sec*1e9 + old.it_interval.tv_nsec)
72 oldts.it_value.setNsec(old.it_value.tv_sec*1e9 + old.it_value.tv_nsec)
73 old32 = &oldts
74 }
75
76
77 return timer_settime32(timerid, flags, new32, old32)
78 }
79
View as plain text