Debian Codegraph @

src/runtime/sys_openbsd.go

raw
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build openbsd && !mips64
6
7 package runtime
8
9 import (
10 "internal/abi"
11 "unsafe"
12 )
13
14 // The *_trampoline functions convert from the Go calling convention to the C calling convention
15 // and then call the underlying libc function. These are defined in sys_openbsd_$ARCH.s.
16
17 //go:nosplit
18 //go:cgo_unsafe_args
19 func pthread_attr_init(attr *pthreadattr) int32 {
20 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_attr_init_trampoline)), unsafe.Pointer(&attr))
21 KeepAlive(attr)
22 return ret
23 }
24 func pthread_attr_init_trampoline()
25
26 //go:nosplit
27 //go:cgo_unsafe_args
28 func pthread_attr_destroy(attr *pthreadattr) int32 {
29 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_attr_destroy_trampoline)), unsafe.Pointer(&attr))
30 KeepAlive(attr)
31 return ret
32 }
33 func pthread_attr_destroy_trampoline()
34
35 //go:nosplit
36 //go:cgo_unsafe_args
37 func pthread_attr_getstacksize(attr *pthreadattr, size *uintptr) int32 {
38 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_attr_getstacksize_trampoline)), unsafe.Pointer(&attr))
39 KeepAlive(attr)
40 KeepAlive(size)
41 return ret
42 }
43 func pthread_attr_getstacksize_trampoline()
44
45 //go:nosplit
46 //go:cgo_unsafe_args
47 func pthread_attr_setdetachstate(attr *pthreadattr, state int) int32 {
48 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_attr_setdetachstate_trampoline)), unsafe.Pointer(&attr))
49 KeepAlive(attr)
50 return ret
51 }
52 func pthread_attr_setdetachstate_trampoline()
53
54 //go:nosplit
55 //go:cgo_unsafe_args
56 func pthread_create(attr *pthreadattr, start uintptr, arg unsafe.Pointer) int32 {
57 ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(pthread_create_trampoline)), unsafe.Pointer(&attr))
58 KeepAlive(attr)
59 KeepAlive(arg) // Just for consistency. Arg of course needs to be kept alive for the start function.
60 return ret
61 }
62 func pthread_create_trampoline()
63
64 // Tell the linker that the libc_* functions are to be found
65 // in a system library, with the libc_ prefix missing.
66
67 //go:cgo_import_dynamic libc_pthread_attr_init pthread_attr_init "libpthread.so"
68 //go:cgo_import_dynamic libc_pthread_attr_destroy pthread_attr_destroy "libpthread.so"
69 //go:cgo_import_dynamic libc_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so"
70 //go:cgo_import_dynamic libc_pthread_attr_setdetachstate pthread_attr_setdetachstate "libpthread.so"
71 //go:cgo_import_dynamic libc_pthread_create pthread_create "libpthread.so"
72 //go:cgo_import_dynamic libc_pthread_sigmask pthread_sigmask "libpthread.so"
73
74 //go:cgo_import_dynamic _ _ "libpthread.so"
75 //go:cgo_import_dynamic _ _ "libc.so"