Source file
src/runtime/sys_openbsd2.go
Documentation: runtime
1
2
3
4
5
6
7 package runtime
8
9 import (
10 "internal/abi"
11 "internal/runtime/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) (ret int32, errno int32) {
165 args := struct {
166 fd, cmd, arg int32
167 ret, errno int32
168 }{fd, cmd, arg, 0, 0}
169 libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&args))
170 return args.ret, args.errno
171 }
172 func fcntl_trampoline()
173
174
175 func nanotime1() int64 {
176 var ts timespec
177 args := struct {
178 clock_id int32
179 tp unsafe.Pointer
180 }{_CLOCK_MONOTONIC, unsafe.Pointer(&ts)}
181 if errno := libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args)); errno < 0 {
182
183 systemstack(func() {
184 println("runtime: errno", -errno)
185 throw("clock_gettime failed")
186 })
187 }
188 return ts.tv_sec*1e9 + int64(ts.tv_nsec)
189 }
190 func clock_gettime_trampoline()
191
192
193 func walltime() (int64, int32) {
194 var ts timespec
195 args := struct {
196 clock_id int32
197 tp unsafe.Pointer
198 }{_CLOCK_REALTIME, unsafe.Pointer(&ts)}
199 if errno := libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args)); errno < 0 {
200
201 systemstack(func() {
202 println("runtime: errno", -errno)
203 throw("clock_gettime failed")
204 })
205 }
206 return ts.tv_sec, int32(ts.tv_nsec)
207 }
208
209
210
211 func kqueue() int32 {
212 return libcCall(unsafe.Pointer(abi.FuncPCABI0(kqueue_trampoline)), nil)
213 }
214 func kqueue_trampoline()
215
216
217
218 func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timespec) int32 {
219 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(kevent_trampoline)), unsafe.Pointer(&kq))
220 KeepAlive(ch)
221 KeepAlive(ev)
222 KeepAlive(ts)
223 return ret
224 }
225 func kevent_trampoline()
226
227
228
229 func sigaction(sig uint32, new *sigactiont, old *sigactiont) {
230 libcCall(unsafe.Pointer(abi.FuncPCABI0(sigaction_trampoline)), unsafe.Pointer(&sig))
231 KeepAlive(new)
232 KeepAlive(old)
233 }
234 func sigaction_trampoline()
235
236
237
238 func sigprocmask(how uint32, new *sigset, old *sigset) {
239
240
241 asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(sigprocmask_trampoline)), unsafe.Pointer(&how))
242 KeepAlive(new)
243 KeepAlive(old)
244 }
245 func sigprocmask_trampoline()
246
247
248
249 func sigaltstack(new *stackt, old *stackt) {
250 libcCall(unsafe.Pointer(abi.FuncPCABI0(sigaltstack_trampoline)), unsafe.Pointer(&new))
251 KeepAlive(new)
252 KeepAlive(old)
253 }
254 func sigaltstack_trampoline()
255
256
257 func exitThread(wait *atomic.Uint32) {
258 throw("exitThread")
259 }
260
261
262
263 func issetugid() (ret int32) {
264 libcCall(unsafe.Pointer(abi.FuncPCABI0(issetugid_trampoline)), unsafe.Pointer(&ret))
265 return
266 }
267 func issetugid_trampoline()
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
294
295
296
297
298
299
300
301
302
303
304
View as plain text