diff options
author | Austin Clements <austin@google.com> | 2019-10-14 15:49:27 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2019-10-26 02:52:30 +0000 |
commit | 42aab4b0af5e50071fa8901a038bdc6f1f42b2ed (patch) | |
tree | c2f38eaeefc0d3ae4164a6adb64c229879e3ebf4 /src/runtime/os3_solaris.go | |
parent | 8714e39497dba141ce7ed83c6a18c3c0def66e77 (diff) | |
download | go-42aab4b0af5e50071fa8901a038bdc6f1f42b2ed.tar.gz go-42aab4b0af5e50071fa8901a038bdc6f1f42b2ed.zip |
runtime: M-targeted signals for libc-based OSes
For #10958, #24543.
Change-Id: I82bee63b49e15bd5a53228eb85179814c80437ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/201403
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/os3_solaris.go')
-rw-r--r-- | src/runtime/os3_solaris.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/runtime/os3_solaris.go b/src/runtime/os3_solaris.go index 4ac191fab8..563e981d0f 100644 --- a/src/runtime/os3_solaris.go +++ b/src/runtime/os3_solaris.go @@ -29,6 +29,8 @@ import ( //go:cgo_import_dynamic libc_pthread_attr_setdetachstate pthread_attr_setdetachstate "libc.so" //go:cgo_import_dynamic libc_pthread_attr_setstack pthread_attr_setstack "libc.so" //go:cgo_import_dynamic libc_pthread_create pthread_create "libc.so" +//go:cgo_import_dynamic libc_pthread_self pthread_self "libc.so" +//go:cgo_import_dynamic libc_pthread_kill pthread_kill "libc.so" //go:cgo_import_dynamic libc_raise raise "libc.so" //go:cgo_import_dynamic libc_read read "libc.so" //go:cgo_import_dynamic libc_select select "libc.so" @@ -61,6 +63,8 @@ import ( //go:linkname libc_pthread_attr_setdetachstate libc_pthread_attr_setdetachstate //go:linkname libc_pthread_attr_setstack libc_pthread_attr_setstack //go:linkname libc_pthread_create libc_pthread_create +//go:linkname libc_pthread_self libc_pthread_self +//go:linkname libc_pthread_kill libc_pthread_kill //go:linkname libc_raise libc_raise //go:linkname libc_read libc_read //go:linkname libc_select libc_select @@ -94,6 +98,8 @@ var ( libc_pthread_attr_setdetachstate, libc_pthread_attr_setstack, libc_pthread_create, + libc_pthread_self, + libc_pthread_kill, libc_raise, libc_read, libc_sched_yield, @@ -214,6 +220,8 @@ func minit() { asmcgocall(unsafe.Pointer(funcPC(miniterrno)), unsafe.Pointer(&libc____errno)) minitSignals() + + getg().m.procid = uint64(pthread_self()) } // Called from dropm to undo the effect of an minit. @@ -434,6 +442,14 @@ func pthread_create(thread *pthread, attr *pthreadattr, fn uintptr, arg unsafe.P return int32(sysvicall4(&libc_pthread_create, uintptr(unsafe.Pointer(thread)), uintptr(unsafe.Pointer(attr)), uintptr(fn), uintptr(arg))) } +func pthread_self() pthread { + return pthread(sysvicall0(&libc_pthread_self)) +} + +func signalM(mp *m, sig int) { + sysvicall2(&libc_pthread_kill, uintptr(pthread(mp.procid)), uintptr(sig)) +} + //go:nosplit //go:nowritebarrierrec func raise(sig uint32) /* int32 */ { |