diff options
author | Elias Naur <elias.naur@gmail.com> | 2018-05-01 01:21:02 +0200 |
---|---|---|
committer | Elias Naur <elias.naur@gmail.com> | 2018-05-01 00:37:36 +0000 |
commit | c2fdb42b1632b054d382b05ebfb6cb903dbb9531 (patch) | |
tree | 0c166c4b0a09c848e4e0b50fac8d537d66c834e0 /src/runtime/sys_darwin.go | |
parent | 21656d09b710799806aee182856b2a02068609bd (diff) | |
download | go-c2fdb42b1632b054d382b05ebfb6cb903dbb9531.tar.gz go-c2fdb42b1632b054d382b05ebfb6cb903dbb9531.zip |
runtime: implement darwin raise with pthread_self and pthread_kill
Convert raise from raw syscalls to using the system pthread library.
As a bonus, raise will now target the current thread instead of the
process.
Updates #17490
Change-Id: I2e44f2000bf870e99a5b4dc5ff5e0799fba91bde
Reviewed-on: https://go-review.googlesource.com/110475
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/sys_darwin.go')
-rw-r--r-- | src/runtime/sys_darwin.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go index afb2afccca..35a9bd6f30 100644 --- a/src/runtime/sys_darwin.go +++ b/src/runtime/sys_darwin.go @@ -53,6 +53,28 @@ func pthread_create(attr *pthreadattr, start uintptr, arg unsafe.Pointer) (t pth //go:noescape func pthread_create_trampoline(t *pthread, attr *pthreadattr, start uintptr, arg unsafe.Pointer) int32 +//go:nowritebarrier +func pthread_kill(thread pthread, sig int) (errno int32) { + systemstack(func() { + errno = pthread_kill_trampoline(thread, sig) + }) + return +} + +//go:noescape +func pthread_kill_trampoline(thread pthread, sig int) int32 + +//go:nowritebarrier +func pthread_self() (t pthread) { + systemstack(func() { + t = pthread_self_trampoline() + }) + return +} + +//go:noescape +func pthread_self_trampoline() pthread + // Tell the linker that the libc_* functions are to be found // in a system library, with the libc_ prefix missing. @@ -61,6 +83,8 @@ func pthread_create_trampoline(t *pthread, attr *pthreadattr, start uintptr, arg //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" //go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic libc_pthread_kill pthread_kill "/usr/lib/libSystem.B.dylib" +//go:cgo_import_dynamic libc_pthread_self pthread_self "/usr/lib/libSystem.B.dylib" // Magic incantation to get libSystem actually dynamically linked. // TODO: Why does the code require this? See cmd/compile/internal/ld/go.go:210 |