Source file
src/runtime/sys_darwin.go
1
2
3
4
5 package runtime
6
7 import (
8 "internal/abi"
9 "unsafe"
10 )
11
12
13
14
15
16
17
18
19
20 func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
21 args := struct{ fn, a1, a2, a3, r1, r2, err uintptr }{fn, a1, a2, a3, r1, r2, err}
22 entersyscall()
23 libcCall(unsafe.Pointer(abi.FuncPCABI0(syscall)), unsafe.Pointer(&args))
24 exitsyscall()
25 return args.r1, args.r2, args.err
26 }
27 func syscall()
28
29
30
31 func syscall_syscallX(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
32 args := struct{ fn, a1, a2, a3, r1, r2, err uintptr }{fn, a1, a2, a3, r1, r2, err}
33 entersyscall()
34 libcCall(unsafe.Pointer(abi.FuncPCABI0(syscallX)), unsafe.Pointer(&args))
35 exitsyscall()
36 return args.r1, args.r2, args.err
37 }
38 func syscallX()
39
40
41
42 func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
43 args := struct{ fn, a1, a2, a3, a4, a5, a6, r1, r2, err uintptr }{fn, a1, a2, a3, a4, a5, a6, r1, r2, err}
44 entersyscall()
45 libcCall(unsafe.Pointer(abi.FuncPCABI0(syscall6)), unsafe.Pointer(&args))
46 exitsyscall()
47 return args.r1, args.r2, args.err
48 }
49 func syscall6()
50
51
52
53 func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
54 args := struct{ fn, a1, a2, a3, a4, a5, a6, r1, r2, err uintptr }{fn, a1, a2, a3, a4, a5, a6, r1, r2, err}
55 entersyscall()
56 libcCall(unsafe.Pointer(abi.FuncPCABI0(syscall6X)), unsafe.Pointer(&args))
57 exitsyscall()
58 return args.r1, args.r2, args.err
59 }
60 func syscall6X()
61
62
63
64 func syscall_syscallPtr(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
65 args := struct{ fn, a1, a2, a3, r1, r2, err uintptr }{fn, a1, a2, a3, r1, r2, err}
66 entersyscall()
67 libcCall(unsafe.Pointer(abi.FuncPCABI0(syscallPtr)), unsafe.Pointer(&args))
68 exitsyscall()
69 return args.r1, args.r2, args.err
70 }
71 func syscallPtr()
72
73
74
75 func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
76 args := struct{ fn, a1, a2, a3, r1, r2, err uintptr }{fn, a1, a2, a3, r1, r2, err}
77 libcCall(unsafe.Pointer(abi.FuncPCABI0(syscall)), unsafe.Pointer(&args))
78 return args.r1, args.r2, args.err
79 }
80
81
82
83 func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
84 args := struct{ fn, a1, a2, a3, a4, a5, a6, r1, r2, err uintptr }{fn, a1, a2, a3, a4, a5, a6, r1, r2, err}
85 libcCall(unsafe.Pointer(abi.FuncPCABI0(syscall6)), unsafe.Pointer(&args))
86 return args.r1, args.r2, args.err
87 }
88
89
90
91
92
93 func crypto_x509_syscall(fn, a1, a2, a3, a4, a5 uintptr, f1 float64) (r1 uintptr) {
94 args := struct {
95 fn, a1, a2, a3, a4, a5 uintptr
96 f1 float64
97 r1 uintptr
98 }{fn, a1, a2, a3, a4, a5, f1, r1}
99 entersyscall()
100 libcCall(unsafe.Pointer(abi.FuncPCABI0(syscall_x509)), unsafe.Pointer(&args))
101 exitsyscall()
102 return args.r1
103 }
104 func syscall_x509()
105
106
107
108
109
110
111 func pthread_attr_init(attr *pthreadattr) int32 {
112 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_attr_init_trampoline)), unsafe.Pointer(&attr))
113 KeepAlive(attr)
114 return ret
115 }
116 func pthread_attr_init_trampoline()
117
118
119
120 func pthread_attr_getstacksize(attr *pthreadattr, size *uintptr) int32 {
121 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_attr_getstacksize_trampoline)), unsafe.Pointer(&attr))
122 KeepAlive(attr)
123 KeepAlive(size)
124 return ret
125 }
126 func pthread_attr_getstacksize_trampoline()
127
128
129
130 func pthread_attr_setdetachstate(attr *pthreadattr, state int) int32 {
131 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_attr_setdetachstate_trampoline)), unsafe.Pointer(&attr))
132 KeepAlive(attr)
133 return ret
134 }
135 func pthread_attr_setdetachstate_trampoline()
136
137
138
139 func pthread_create(attr *pthreadattr, start uintptr, arg unsafe.Pointer) int32 {
140 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_create_trampoline)), unsafe.Pointer(&attr))
141 KeepAlive(attr)
142 KeepAlive(arg)
143 return ret
144 }
145 func pthread_create_trampoline()
146
147
148
149 func raise(sig uint32) {
150 libcCall(unsafe.Pointer(abi.FuncPCABI0(raise_trampoline)), unsafe.Pointer(&sig))
151 }
152 func raise_trampoline()
153
154
155
156 func pthread_self() (t pthread) {
157 libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_self_trampoline)), unsafe.Pointer(&t))
158 return
159 }
160 func pthread_self_trampoline()
161
162
163
164 func pthread_kill(t pthread, sig uint32) {
165 libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_kill_trampoline)), unsafe.Pointer(&t))
166 return
167 }
168 func pthread_kill_trampoline()
169
170
171
172
173
174 func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (unsafe.Pointer, int) {
175 args := struct {
176 addr unsafe.Pointer
177 n uintptr
178 prot, flags, fd int32
179 off uint32
180 ret1 unsafe.Pointer
181 ret2 int
182 }{addr, n, prot, flags, fd, off, nil, 0}
183 libcCall(unsafe.Pointer(abi.FuncPCABI0(mmap_trampoline)), unsafe.Pointer(&args))
184 return args.ret1, args.ret2
185 }
186 func mmap_trampoline()
187
188
189
190 func munmap(addr unsafe.Pointer, n uintptr) {
191 libcCall(unsafe.Pointer(abi.FuncPCABI0(munmap_trampoline)), unsafe.Pointer(&addr))
192 KeepAlive(addr)
193 }
194 func munmap_trampoline()
195
196
197
198 func madvise(addr unsafe.Pointer, n uintptr, flags int32) {
199 libcCall(unsafe.Pointer(abi.FuncPCABI0(madvise_trampoline)), unsafe.Pointer(&addr))
200 KeepAlive(addr)
201 }
202 func madvise_trampoline()
203
204
205
206 func mlock(addr unsafe.Pointer, n uintptr) {
207 libcCall(unsafe.Pointer(abi.FuncPCABI0(mlock_trampoline)), unsafe.Pointer(&addr))
208 KeepAlive(addr)
209 }
210 func mlock_trampoline()
211
212
213
214 func read(fd int32, p unsafe.Pointer, n int32) int32 {
215 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd))
216 KeepAlive(p)
217 return ret
218 }
219 func read_trampoline()
220
221 func pipe() (r, w int32, errno int32) {
222 var p [2]int32
223 errno = libcCall(unsafe.Pointer(abi.FuncPCABI0(pipe_trampoline)), noescape(unsafe.Pointer(&p)))
224 return p[0], p[1], errno
225 }
226 func pipe_trampoline()
227
228
229
230 func closefd(fd int32) int32 {
231 return libcCall(unsafe.Pointer(abi.FuncPCABI0(close_trampoline)), unsafe.Pointer(&fd))
232 }
233 func close_trampoline()
234
235
236
237
238
239
240 func exit(code int32) {
241 libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code))
242 }
243 func exit_trampoline()
244
245
246
247 func usleep(usec uint32) {
248 libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec))
249 }
250 func usleep_trampoline()
251
252
253
254 func usleep_no_g(usec uint32) {
255 asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec))
256 }
257
258
259
260 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 {
261 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(write_trampoline)), unsafe.Pointer(&fd))
262 KeepAlive(p)
263 return ret
264 }
265 func write_trampoline()
266
267
268
269 func open(name *byte, mode, perm int32) (ret int32) {
270 ret = libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name))
271 KeepAlive(name)
272 return
273 }
274 func open_trampoline()
275
276
277
278 func nanotime1() int64 {
279 var r struct {
280 t int64
281 numer, denom uint32
282 }
283 libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime_trampoline)), unsafe.Pointer(&r))
284
285
286
287 t := r.t
288 if r.numer != 1 {
289 t *= int64(r.numer)
290 }
291 if r.denom != 1 {
292 t /= int64(r.denom)
293 }
294 return t
295 }
296 func nanotime_trampoline()
297
298
299
300 func walltime() (int64, int32) {
301 var t timespec
302 libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime_trampoline)), unsafe.Pointer(&t))
303 return t.tv_sec, int32(t.tv_nsec)
304 }
305 func walltime_trampoline()
306
307
308
309 func sigaction(sig uint32, new *usigactiont, old *usigactiont) {
310 libcCall(unsafe.Pointer(abi.FuncPCABI0(sigaction_trampoline)), unsafe.Pointer(&sig))
311 KeepAlive(new)
312 KeepAlive(old)
313 }
314 func sigaction_trampoline()
315
316
317
318 func sigprocmask(how uint32, new *sigset, old *sigset) {
319 libcCall(unsafe.Pointer(abi.FuncPCABI0(sigprocmask_trampoline)), unsafe.Pointer(&how))
320 KeepAlive(new)
321 KeepAlive(old)
322 }
323 func sigprocmask_trampoline()
324
325
326
327 func sigaltstack(new *stackt, old *stackt) {
328 if new != nil && new.ss_flags&_SS_DISABLE != 0 && new.ss_size == 0 {
329
330
331
332
333 new.ss_size = 32768
334 }
335 libcCall(unsafe.Pointer(abi.FuncPCABI0(sigaltstack_trampoline)), unsafe.Pointer(&new))
336 KeepAlive(new)
337 KeepAlive(old)
338 }
339 func sigaltstack_trampoline()
340
341
342
343 func raiseproc(sig uint32) {
344 libcCall(unsafe.Pointer(abi.FuncPCABI0(raiseproc_trampoline)), unsafe.Pointer(&sig))
345 }
346 func raiseproc_trampoline()
347
348
349
350 func setitimer(mode int32, new, old *itimerval) {
351 libcCall(unsafe.Pointer(abi.FuncPCABI0(setitimer_trampoline)), unsafe.Pointer(&mode))
352 KeepAlive(new)
353 KeepAlive(old)
354 }
355 func setitimer_trampoline()
356
357
358
359 func sysctl(mib *uint32, miblen uint32, oldp *byte, oldlenp *uintptr, newp *byte, newlen uintptr) int32 {
360 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(sysctl_trampoline)), unsafe.Pointer(&mib))
361 KeepAlive(mib)
362 KeepAlive(oldp)
363 KeepAlive(oldlenp)
364 KeepAlive(newp)
365 return ret
366 }
367 func sysctl_trampoline()
368
369
370
371 func sysctlbyname(name *byte, oldp *byte, oldlenp *uintptr, newp *byte, newlen uintptr) int32 {
372 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(sysctlbyname_trampoline)), unsafe.Pointer(&name))
373 KeepAlive(name)
374 KeepAlive(oldp)
375 KeepAlive(oldlenp)
376 KeepAlive(newp)
377 return ret
378 }
379 func sysctlbyname_trampoline()
380
381
382
383 func fcntl(fd, cmd, arg int32) int32 {
384 return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd))
385 }
386 func fcntl_trampoline()
387
388
389
390 func kqueue() int32 {
391 v := libcCall(unsafe.Pointer(abi.FuncPCABI0(kqueue_trampoline)), nil)
392 return v
393 }
394 func kqueue_trampoline()
395
396
397
398 func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timespec) int32 {
399 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(kevent_trampoline)), unsafe.Pointer(&kq))
400 KeepAlive(ch)
401 KeepAlive(ev)
402 KeepAlive(ts)
403 return ret
404 }
405 func kevent_trampoline()
406
407
408
409 func pthread_mutex_init(m *pthreadmutex, attr *pthreadmutexattr) int32 {
410 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_mutex_init_trampoline)), unsafe.Pointer(&m))
411 KeepAlive(m)
412 KeepAlive(attr)
413 return ret
414 }
415 func pthread_mutex_init_trampoline()
416
417
418
419 func pthread_mutex_lock(m *pthreadmutex) int32 {
420 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_mutex_lock_trampoline)), unsafe.Pointer(&m))
421 KeepAlive(m)
422 return ret
423 }
424 func pthread_mutex_lock_trampoline()
425
426
427
428 func pthread_mutex_unlock(m *pthreadmutex) int32 {
429 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_mutex_unlock_trampoline)), unsafe.Pointer(&m))
430 KeepAlive(m)
431 return ret
432 }
433 func pthread_mutex_unlock_trampoline()
434
435
436
437 func pthread_cond_init(c *pthreadcond, attr *pthreadcondattr) int32 {
438 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_cond_init_trampoline)), unsafe.Pointer(&c))
439 KeepAlive(c)
440 KeepAlive(attr)
441 return ret
442 }
443 func pthread_cond_init_trampoline()
444
445
446
447 func pthread_cond_wait(c *pthreadcond, m *pthreadmutex) int32 {
448 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_cond_wait_trampoline)), unsafe.Pointer(&c))
449 KeepAlive(c)
450 KeepAlive(m)
451 return ret
452 }
453 func pthread_cond_wait_trampoline()
454
455
456
457 func pthread_cond_timedwait_relative_np(c *pthreadcond, m *pthreadmutex, t *timespec) int32 {
458 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_cond_timedwait_relative_np_trampoline)), unsafe.Pointer(&c))
459 KeepAlive(c)
460 KeepAlive(m)
461 KeepAlive(t)
462 return ret
463 }
464 func pthread_cond_timedwait_relative_np_trampoline()
465
466
467
468 func pthread_cond_signal(c *pthreadcond) int32 {
469 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_cond_signal_trampoline)), unsafe.Pointer(&c))
470 KeepAlive(c)
471 return ret
472 }
473 func pthread_cond_signal_trampoline()
474
475
476 func exitThread(wait *uint32) {
477 }
478
479
480 func closeonexec(fd int32) {
481 fcntl(fd, _F_SETFD, _FD_CLOEXEC)
482 }
483
484
485 func setNonblock(fd int32) {
486 flags := fcntl(fd, _F_GETFL, 0)
487 fcntl(fd, _F_SETFL, flags|_O_NONBLOCK)
488 }
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
View as plain text