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