aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_darwin.go
diff options
context:
space:
mode:
authorElias Naur <elias.naur@gmail.com>2018-05-01 01:21:02 +0200
committerElias Naur <elias.naur@gmail.com>2018-05-01 00:37:36 +0000
commitc2fdb42b1632b054d382b05ebfb6cb903dbb9531 (patch)
tree0c166c4b0a09c848e4e0b50fac8d537d66c834e0 /src/runtime/sys_darwin.go
parent21656d09b710799806aee182856b2a02068609bd (diff)
downloadgo-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.go24
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