...

Source file src/runtime/sys_openbsd.go

Documentation: runtime

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

View as plain text