@@ -29,6 +29,8 @@ import (
2929//go:cgo_import_dynamic libc_pthread_attr_setdetachstate pthread_attr_setdetachstate "libc.so"
3030//go:cgo_import_dynamic libc_pthread_attr_setstack pthread_attr_setstack "libc.so"
3131//go:cgo_import_dynamic libc_pthread_create pthread_create "libc.so"
32+ //go:cgo_import_dynamic libc_pthread_self pthread_self "libc.so"
33+ //go:cgo_import_dynamic libc_pthread_kill pthread_kill "libc.so"
3234//go:cgo_import_dynamic libc_raise raise "libc.so"
3335//go:cgo_import_dynamic libc_read read "libc.so"
3436//go:cgo_import_dynamic libc_select select "libc.so"
@@ -61,6 +63,8 @@ import (
6163//go:linkname libc_pthread_attr_setdetachstate libc_pthread_attr_setdetachstate
6264//go:linkname libc_pthread_attr_setstack libc_pthread_attr_setstack
6365//go:linkname libc_pthread_create libc_pthread_create
66+ //go:linkname libc_pthread_self libc_pthread_self
67+ //go:linkname libc_pthread_kill libc_pthread_kill
6468//go:linkname libc_raise libc_raise
6569//go:linkname libc_read libc_read
6670//go:linkname libc_select libc_select
9498 libc_pthread_attr_setdetachstate ,
9599 libc_pthread_attr_setstack ,
96100 libc_pthread_create ,
101+ libc_pthread_self ,
102+ libc_pthread_kill ,
97103 libc_raise ,
98104 libc_read ,
99105 libc_sched_yield ,
@@ -214,6 +220,8 @@ func minit() {
214220 asmcgocall (unsafe .Pointer (funcPC (miniterrno )), unsafe .Pointer (& libc____errno ))
215221
216222 minitSignals ()
223+
224+ getg ().m .procid = uint64 (pthread_self ())
217225}
218226
219227// 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
434442 return int32 (sysvicall4 (& libc_pthread_create , uintptr (unsafe .Pointer (thread )), uintptr (unsafe .Pointer (attr )), uintptr (fn ), uintptr (arg )))
435443}
436444
445+ func pthread_self () pthread {
446+ return pthread (sysvicall0 (& libc_pthread_self ))
447+ }
448+
449+ func signalM (mp * m , sig int ) {
450+ sysvicall2 (& libc_pthread_kill , uintptr (pthread (mp .procid )), uintptr (sig ))
451+ }
452+
437453//go:nosplit
438454//go:nowritebarrierrec
439455func raise (sig uint32 ) /* int32 */ {
0 commit comments