Source file
src/runtime/sys_openbsd2.go
1
2
3
4
5
6
7 package runtime
8
9 import (
10 "internal/abi"
11 "runtime/internal/atomic"
12 "unsafe"
13 )
14
15
16
17
18
19
20 func exit(code int32) {
21 libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code))
22 }
23 func exit_trampoline()
24
25
26
27 func getthrid() (tid int32) {
28 libcCall(unsafe.Pointer(abi.FuncPCABI0(getthrid_trampoline)), unsafe.Pointer(&tid))
29 return
30 }
31 func getthrid_trampoline()
32
33
34
35 func raiseproc(sig uint32) {
36 libcCall(unsafe.Pointer(abi.FuncPCABI0(raiseproc_trampoline)), unsafe.Pointer(&sig))
37 }
38 func raiseproc_trampoline()
39
40
41
42 func thrkill(tid int32, sig int) {
43 libcCall(unsafe.Pointer(abi.FuncPCABI0(thrkill_trampoline)), unsafe.Pointer(&tid))
44 }
45 func thrkill_trampoline()
46
47
48
49
50
51
52 func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (unsafe.Pointer, int) {
53 args := struct {
54 addr unsafe.Pointer
55 n uintptr
56 prot, flags, fd int32
57 off uint32
58 ret1 unsafe.Pointer
59 ret2 int
60 }{addr, n, prot, flags, fd, off, nil, 0}
61 libcCall(unsafe.Pointer(abi.FuncPCABI0(mmap_trampoline)), unsafe.Pointer(&args))
62 KeepAlive(addr)
63 return args.ret1, args.ret2
64 }
65 func mmap_trampoline()
66
67
68
69 func munmap(addr unsafe.Pointer, n uintptr) {
70 libcCall(unsafe.Pointer(abi.FuncPCABI0(munmap_trampoline)), unsafe.Pointer(&addr))
71 KeepAlive(addr)
72 }
73 func munmap_trampoline()
74
75
76
77 func madvise(addr unsafe.Pointer, n uintptr, flags int32) {
78 libcCall(unsafe.Pointer(abi.FuncPCABI0(madvise_trampoline)), unsafe.Pointer(&addr))
79 KeepAlive(addr)
80 }
81 func madvise_trampoline()
82
83
84
85 func open(name *byte, mode, perm int32) (ret int32) {
86 ret = libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name))
87 KeepAlive(name)
88 return
89 }
90 func open_trampoline()
91
92
93
94 func closefd(fd int32) int32 {
95 return libcCall(unsafe.Pointer(abi.FuncPCABI0(close_trampoline)), unsafe.Pointer(&fd))
96 }
97 func close_trampoline()
98
99
100
101 func read(fd int32, p unsafe.Pointer, n int32) int32 {
102 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd))
103 KeepAlive(p)
104 return ret
105 }
106 func read_trampoline()
107
108
109
110 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 {
111 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(write_trampoline)), unsafe.Pointer(&fd))
112 KeepAlive(p)
113 return ret
114 }
115 func write_trampoline()
116
117 func pipe2(flags int32) (r, w int32, errno int32) {
118 var p [2]int32
119 args := struct {
120 p unsafe.Pointer
121 flags int32
122 }{noescape(unsafe.Pointer(&p)), flags}
123 errno = libcCall(unsafe.Pointer(abi.FuncPCABI0(pipe2_trampoline)), unsafe.Pointer(&args))
124 return p[0], p[1], errno
125 }
126 func pipe2_trampoline()
127
128
129
130 func setitimer(mode int32, new, old *itimerval) {
131 libcCall(unsafe.Pointer(abi.FuncPCABI0(setitimer_trampoline)), unsafe.Pointer(&mode))
132 KeepAlive(new)
133 KeepAlive(old)
134 }
135 func setitimer_trampoline()
136
137
138
139 func usleep(usec uint32) {
140 libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec))
141 }
142 func usleep_trampoline()
143
144
145
146 func usleep_no_g(usec uint32) {
147 asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec))
148 }
149
150
151
152 func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32 {
153 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(sysctl_trampoline)), unsafe.Pointer(&mib))
154 KeepAlive(mib)
155 KeepAlive(out)
156 KeepAlive(size)
157 KeepAlive(dst)
158 return ret
159 }
160 func sysctl_trampoline()
161
162
163
164 func fcntl(fd, cmd, arg int32) int32 {
165 return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd))
166 }
167 func fcntl_trampoline()
168
169
170 func nanotime1() int64 {
171 var ts timespec
172 args := struct {
173 clock_id int32
174 tp unsafe.Pointer
175 }{_CLOCK_MONOTONIC, unsafe.Pointer(&ts)}
176 if errno := libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args)); errno < 0 {
177
178 systemstack(func() {
179 println("runtime: errno", -errno)
180 throw("clock_gettime failed")
181 })
182 }
183 return ts.tv_sec*1e9 + int64(ts.tv_nsec)
184 }
185 func clock_gettime_trampoline()
186
187
188 func walltime() (int64, int32) {
189 var ts timespec
190 args := struct {
191 clock_id int32
192 tp unsafe.Pointer
193 }{_CLOCK_REALTIME, unsafe.Pointer(&ts)}
194 if errno := libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args)); errno < 0 {
195
196 systemstack(func() {
197 println("runtime: errno", -errno)
198 throw("clock_gettime failed")
199 })
200 }
201 return ts.tv_sec, int32(ts.tv_nsec)
202 }
203
204
205
206 func kqueue() int32 {
207 return libcCall(unsafe.Pointer(abi.FuncPCABI0(kqueue_trampoline)), nil)
208 }
209 func kqueue_trampoline()
210
211
212
213 func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timespec) int32 {
214 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(kevent_trampoline)), unsafe.Pointer(&kq))
215 KeepAlive(ch)
216 KeepAlive(ev)
217 KeepAlive(ts)
218 return ret
219 }
220 func kevent_trampoline()
221
222
223
224 func sigaction(sig uint32, new *sigactiont, old *sigactiont) {
225 libcCall(unsafe.Pointer(abi.FuncPCABI0(sigaction_trampoline)), unsafe.Pointer(&sig))
226 KeepAlive(new)
227 KeepAlive(old)
228 }
229 func sigaction_trampoline()
230
231
232
233 func sigprocmask(how uint32, new *sigset, old *sigset) {
234
235
236 asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(sigprocmask_trampoline)), unsafe.Pointer(&how))
237 KeepAlive(new)
238 KeepAlive(old)
239 }
240 func sigprocmask_trampoline()
241
242
243
244 func sigaltstack(new *stackt, old *stackt) {
245 libcCall(unsafe.Pointer(abi.FuncPCABI0(sigaltstack_trampoline)), unsafe.Pointer(&new))
246 KeepAlive(new)
247 KeepAlive(old)
248 }
249 func sigaltstack_trampoline()
250
251
252 func exitThread(wait *atomic.Uint32) {
253 }
254
255
256 func closeonexec(fd int32) {
257 fcntl(fd, _F_SETFD, _FD_CLOEXEC)
258 }
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
View as plain text