diff options
| author | Elias Naur <elias.naur@gmail.com> | 2018-05-21 15:33:20 +0200 |
|---|---|---|
| committer | Elias Naur <elias.naur@gmail.com> | 2018-05-21 19:42:49 +0000 |
| commit | 467e15accc95d4e080a8088eaff0aaa28f572c7e (patch) | |
| tree | fea470fddf70186c13884670b078c488d1f1ea73 /src/runtime/sys_darwin.go | |
| parent | b88276da6626102801a3621839d8f198176816ce (diff) | |
| download | go-467e15accc95d4e080a8088eaff0aaa28f572c7e.tar.xz | |
runtime: use raise instead of pthread_self and pthread_kill
pthread_self and pthread_kill are not safe to call from a signal
handler. In particular, pthread_self fails in iOS when called from
a signal handler context.
Use raise instead; it is signal handler safe and simpler.
Change-Id: I0cbfe25151aed245f55d7b76719ce06dc78c6a75
Reviewed-on: https://go-review.googlesource.com/113877
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 | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go index 3bdd1f2b16..c2df8a6f1a 100644 --- a/src/runtime/sys_darwin.go +++ b/src/runtime/sys_darwin.go @@ -41,10 +41,10 @@ func pthread_create_trampoline() //go:nosplit //go:cgo_unsafe_args -func pthread_kill(thread pthread, sig int) (errno int32) { - return asmcgocall(unsafe.Pointer(funcPC(pthread_kill_trampoline)), unsafe.Pointer(&thread)) +func raise(sig uint32) { + asmcgocall(unsafe.Pointer(funcPC(raise_trampoline)), unsafe.Pointer(&sig)) } -func pthread_kill_trampoline() +func raise_trampoline() //go:nosplit //go:cgo_unsafe_args @@ -158,8 +158,7 @@ func exitThread(wait *uint32) { //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" +//go:cgo_import_dynamic libc_raise raise "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib" //go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib" |
