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