2018-04-23 08:30:32 -06:00
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package runtime
|
|
|
|
|
|
|
|
import "unsafe"
|
|
|
|
|
|
|
|
// The *_trampoline functions convert from the Go calling convention to the C calling convention
|
|
|
|
// and then call the underlying libc function. They are defined in sys_darwin_$ARCH.s.
|
|
|
|
|
|
|
|
//go:nowritebarrier
|
|
|
|
func pthread_attr_init(attr *pthreadattr) (errno int32) {
|
|
|
|
systemstack(func() {
|
|
|
|
errno = pthread_attr_init_trampoline(attr)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:noescape
|
|
|
|
func pthread_attr_init_trampoline(attr *pthreadattr) int32
|
|
|
|
|
|
|
|
//go:nowritebarrier
|
2018-04-30 08:50:10 -06:00
|
|
|
func pthread_attr_setstacksize(attr *pthreadattr, size uintptr) (errno int32) {
|
2018-04-23 08:30:32 -06:00
|
|
|
systemstack(func() {
|
2018-04-30 08:50:10 -06:00
|
|
|
errno = pthread_attr_setstacksize_trampoline(attr, size)
|
2018-04-23 08:30:32 -06:00
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:noescape
|
2018-04-30 08:50:10 -06:00
|
|
|
func pthread_attr_setstacksize_trampoline(attr *pthreadattr, size uintptr) int32
|
2018-04-23 08:30:32 -06:00
|
|
|
|
|
|
|
//go:nowritebarrier
|
|
|
|
func pthread_attr_setdetachstate(attr *pthreadattr, state int) (errno int32) {
|
|
|
|
systemstack(func() {
|
|
|
|
errno = pthread_attr_setdetachstate_trampoline(attr, state)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:noescape
|
|
|
|
func pthread_attr_setdetachstate_trampoline(attr *pthreadattr, state int) int32
|
|
|
|
|
|
|
|
//go:nowritebarrier
|
|
|
|
func pthread_create(attr *pthreadattr, start uintptr, arg unsafe.Pointer) (t pthread, errno int32) {
|
|
|
|
systemstack(func() {
|
|
|
|
errno = pthread_create_trampoline(&t, attr, start, arg)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:noescape
|
|
|
|
func pthread_create_trampoline(t *pthread, attr *pthreadattr, start uintptr, arg unsafe.Pointer) int32
|
|
|
|
|
|
|
|
// Tell the linker that the libc_* functions are to be found
|
|
|
|
// in a system library, with the libc_ prefix missing.
|
|
|
|
|
|
|
|
//go:cgo_import_dynamic libc_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib"
|
2018-04-30 08:50:10 -06:00
|
|
|
//go:cgo_import_dynamic libc_pthread_attr_setstacksize pthread_attr_setstacksize "/usr/lib/libSystem.B.dylib"
|
2018-04-23 08:30:32 -06:00
|
|
|
//go:cgo_import_dynamic libc_pthread_attr_setdetachstate pthread_attr_setdetachstate "/usr/lib/libSystem.B.dylib"
|
|
|
|
//go:cgo_import_dynamic libc_pthread_create pthread_create "/usr/lib/libSystem.B.dylib"
|
2018-04-30 08:50:10 -06:00
|
|
|
//go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib"
|
2018-04-23 08:30:32 -06:00
|
|
|
|
|
|
|
// Magic incantation to get libSystem actually dynamically linked.
|
|
|
|
// TODO: Why does the code require this? See cmd/compile/internal/ld/go.go:210
|
|
|
|
//go:cgo_import_dynamic _ _ "/usr/lib/libSystem.B.dylib"
|