Commit 5af2be86 authored by Russ Cox's avatar Russ Cox

Revert "runtime: use a proper type, sigset, for m.sigmask"

This reverts commit 7db77271.

Change-Id: I6d8855eb05ca331025dc49a5533c6da4d1fa4e84
Reviewed-on: https://go-review.googlesource.com/17030Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent 53c21df1
......@@ -8,9 +8,7 @@ import "unsafe"
//extern SigTabTT runtime·sigtab[];
type sigset uint32
var sigset_all = ^sigset(0)
var sigset_all = ^uint32(0)
func unimplemented(name string) {
println(name, "not implemented")
......@@ -85,7 +83,7 @@ func newosproc(mp *m, stk unsafe.Pointer) {
print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " id=", mp.id, " ostk=", &mp, "\n")
}
var oset sigset
var oset uint32
sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
errno := bsdthread_create(stk, unsafe.Pointer(mp), funcPC(mstart))
sigprocmask(_SIG_SETMASK, &oset, nil)
......@@ -111,7 +109,7 @@ func newosproc0(stacksize uintptr, fn unsafe.Pointer, fnarg uintptr) {
}
stk := unsafe.Pointer(uintptr(stack) + stacksize)
var oset sigset
var oset uint32
sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
errno := bsdthread_create(stk, fn, fnarg)
sigprocmask(_SIG_SETMASK, &oset, nil)
......@@ -133,7 +131,11 @@ func mpreinit(mp *m) {
}
func msigsave(mp *m) {
sigprocmask(_SIG_SETMASK, nil, &mp.sigmask)
smask := (*uint32)(unsafe.Pointer(&mp.sigmask))
if unsafe.Sizeof(*smask) > unsafe.Sizeof(mp.sigmask) {
throw("insufficient storage for signal mask")
}
sigprocmask(_SIG_SETMASK, nil, smask)
}
// Called to initialize a new m (including the bootstrap m).
......@@ -144,7 +146,7 @@ func minit() {
signalstack(&_g_.m.gsignal.stack)
// restore signal mask from m.sigmask and unblock essential signals
nmask := _g_.m.sigmask
nmask := *(*uint32)(unsafe.Pointer(&_g_.m.sigmask))
for i := range sigtable {
if sigtable[i].flags&_SigUnblock != 0 {
nmask &^= 1 << (uint32(i) - 1)
......@@ -156,7 +158,8 @@ func minit() {
// Called from dropm to undo the effect of an minit.
func unminit() {
_g_ := getg()
sigprocmask(_SIG_SETMASK, &_g_.m.sigmask, nil)
smask := (*uint32)(unsafe.Pointer(&_g_.m.sigmask))
sigprocmask(_SIG_SETMASK, smask, nil)
signalstack(nil)
}
......@@ -469,11 +472,10 @@ func signalstack(s *stack) {
}
func updatesigmask(m sigmask) {
s := sigset(m[0])
sigprocmask(_SIG_SETMASK, &s, nil)
sigprocmask(_SIG_SETMASK, &m[0], nil)
}
func unblocksig(sig int32) {
mask := sigset(1) << (uint32(sig) - 1)
mask := uint32(1) << (uint32(sig) - 1)
sigprocmask(_SIG_UNBLOCK, &mask, nil)
}
......@@ -118,7 +118,11 @@ func mpreinit(mp *m) {
}
func msigsave(mp *m) {
sigprocmask(_SIG_SETMASK, nil, &mp.sigmask)
smask := (*sigset)(unsafe.Pointer(&mp.sigmask))
if unsafe.Sizeof(*smask) > unsafe.Sizeof(mp.sigmask) {
throw("insufficient storage for signal mask")
}
sigprocmask(_SIG_SETMASK, nil, smask)
}
// Called to initialize a new m (including the bootstrap m).
......@@ -133,7 +137,7 @@ func minit() {
signalstack(&_g_.m.gsignal.stack)
// restore signal mask from m.sigmask and unblock essential signals
nmask := _g_.m.sigmask
nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask))
for i := range sigtable {
if sigtable[i].flags&_SigUnblock != 0 {
nmask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
......@@ -145,7 +149,8 @@ func minit() {
// Called from dropm to undo the effect of an minit.
func unminit() {
_g_ := getg()
sigprocmask(_SIG_SETMASK, &_g_.m.sigmask, nil)
smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask))
sigprocmask(_SIG_SETMASK, smask, nil)
signalstack(nil)
}
......
......@@ -121,7 +121,11 @@ func mpreinit(mp *m) {
}
func msigsave(mp *m) {
sigprocmask(_SIG_SETMASK, nil, &mp.sigmask)
smask := (*sigset)(unsafe.Pointer(&mp.sigmask))
if unsafe.Sizeof(*smask) > unsafe.Sizeof(mp.sigmask) {
throw("insufficient storage for signal mask")
}
sigprocmask(_SIG_SETMASK, nil, smask)
}
// Called to initialize a new m (including the bootstrap m).
......@@ -139,7 +143,7 @@ func minit() {
signalstack(&_g_.m.gsignal.stack)
// restore signal mask from m.sigmask and unblock essential signals
nmask := _g_.m.sigmask
nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask))
for i := range sigtable {
if sigtable[i].flags&_SigUnblock != 0 {
nmask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
......@@ -151,7 +155,8 @@ func minit() {
// Called from dropm to undo the effect of an minit.
func unminit() {
_g_ := getg()
sigprocmask(_SIG_SETMASK, &_g_.m.sigmask, nil)
smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask))
sigprocmask(_SIG_SETMASK, smask, nil)
signalstack(nil)
}
......
......@@ -198,7 +198,10 @@ func mpreinit(mp *m) {
}
func msigsave(mp *m) {
smask := &mp.sigmask
smask := (*sigset)(unsafe.Pointer(&mp.sigmask))
if unsafe.Sizeof(*smask) > unsafe.Sizeof(mp.sigmask) {
throw("insufficient storage for signal mask")
}
rtsigprocmask(_SIG_SETMASK, nil, smask, int32(unsafe.Sizeof(*smask)))
}
......@@ -215,7 +218,7 @@ func minit() {
_g_.m.procid = uint64(gettid())
// restore signal mask from m.sigmask and unblock essential signals
nmask := _g_.m.sigmask
nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask))
for i := range sigtable {
if sigtable[i].flags&_SigUnblock != 0 {
sigdelset(&nmask, i)
......@@ -227,7 +230,7 @@ func minit() {
// Called from dropm to undo the effect of an minit.
func unminit() {
_g_ := getg()
smask := &_g_.m.sigmask
smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask))
rtsigprocmask(_SIG_SETMASK, smask, nil, int32(unsafe.Sizeof(*smask)))
signalstack(nil)
}
......
......@@ -6,8 +6,6 @@ package runtime
import "unsafe"
type sigset struct{}
// Called to initialize a new m (including the bootstrap m).
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
func mpreinit(mp *m) {
......
......@@ -139,7 +139,11 @@ func mpreinit(mp *m) {
}
func msigsave(mp *m) {
sigprocmask(_SIG_SETMASK, nil, &mp.sigmask)
smask := (*sigset)(unsafe.Pointer(&mp.sigmask))
if unsafe.Sizeof(*smask) > unsafe.Sizeof(mp.sigmask) {
throw("insufficient storage for signal mask")
}
sigprocmask(_SIG_SETMASK, nil, smask)
}
// Called to initialize a new m (including the bootstrap m).
......@@ -152,7 +156,7 @@ func minit() {
signalstack(&_g_.m.gsignal.stack)
// restore signal mask from m.sigmask and unblock essential signals
nmask := _g_.m.sigmask
nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask))
for i := range sigtable {
if sigtable[i].flags&_SigUnblock != 0 {
nmask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
......@@ -164,7 +168,8 @@ func minit() {
// Called from dropm to undo the effect of an minit.
func unminit() {
_g_ := getg()
sigprocmask(_SIG_SETMASK, &_g_.m.sigmask, nil)
smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask))
sigprocmask(_SIG_SETMASK, smask, nil)
signalstack(nil)
}
......
......@@ -22,11 +22,9 @@ const (
_CLOCK_MONOTONIC = 3
)
type sigset uint32
const (
sigset_none = sigset(0)
sigset_all = ^sigset(0)
sigset_none = uint32(0)
sigset_all = ^uint32(0)
)
// From OpenBSD's <sys/sysctl.h>
......@@ -151,7 +149,11 @@ func mpreinit(mp *m) {
}
func msigsave(mp *m) {
mp.sigmask = sigprocmask(_SIG_BLOCK, 0)
smask := (*uint32)(unsafe.Pointer(&mp.sigmask))
if unsafe.Sizeof(*smask) > unsafe.Sizeof(mp.sigmask) {
throw("insufficient storage for signal mask")
}
*smask = sigprocmask(_SIG_BLOCK, 0)
}
// Called to initialize a new m (including the bootstrap m).
......@@ -166,7 +168,7 @@ func minit() {
signalstack(&_g_.m.gsignal.stack)
// restore signal mask from m.sigmask and unblock essential signals
nmask := _g_.m.sigmask
nmask := *(*uint32)(unsafe.Pointer(&_g_.m.sigmask))
for i := range sigtable {
if sigtable[i].flags&_SigUnblock != 0 {
nmask &^= 1 << (uint32(i) - 1)
......@@ -178,7 +180,8 @@ func minit() {
// Called from dropm to undo the effect of an minit.
func unminit() {
_g_ := getg()
sigprocmask(_SIG_SETMASK, _g_.m.sigmask)
smask := *(*uint32)(unsafe.Pointer(&_g_.m.sigmask))
sigprocmask(_SIG_SETMASK, smask)
signalstack(nil)
}
......@@ -200,7 +203,7 @@ func setsig(i int32, fn uintptr, restart bool) {
if restart {
sa.sa_flags |= _SA_RESTART
}
sa.sa_mask = uint32(sigset_all)
sa.sa_mask = sigset_all
if fn == funcPC(sighandler) {
fn = funcPC(sigtramp)
}
......@@ -234,10 +237,10 @@ func signalstack(s *stack) {
}
func updatesigmask(m sigmask) {
sigprocmask(_SIG_SETMASK, sigset(m[0]))
sigprocmask(_SIG_SETMASK, m[0])
}
func unblocksig(sig int32) {
mask := sigset(1) << (uint32(sig) - 1)
mask := uint32(1) << (uint32(sig) - 1)
sigprocmask(_SIG_UNBLOCK, mask)
}
......@@ -9,8 +9,6 @@ import (
"unsafe"
)
type sigset struct{}
// Called to initialize a new m (including the bootstrap m).
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
func mpreinit(mp *m) {
......
......@@ -99,8 +99,6 @@ var (
_GetQueuedCompletionStatusEx stdFunction
)
type sigset struct{}
// Call a Windows function with stdcall conventions,
// and switch to os stack during the call.
func asmstdcall(fn unsafe.Pointer)
......
......@@ -193,7 +193,11 @@ func mpreinit(mp *m) {
func miniterrno()
func msigsave(mp *m) {
sigprocmask(_SIG_SETMASK, nil, &mp.sigmask)
smask := (*sigset)(unsafe.Pointer(&mp.sigmask))
if unsafe.Sizeof(*smask) > unsafe.Sizeof(mp.sigmask) {
throw("insufficient storage for signal mask")
}
sigprocmask(_SIG_SETMASK, nil, smask)
}
// Called to initialize a new m (including the bootstrap m).
......@@ -205,7 +209,7 @@ func minit() {
signalstack(&_g_.m.gsignal.stack)
// restore signal mask from m.sigmask and unblock essential signals
nmask := _g_.m.sigmask
nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask))
for i := range sigtable {
if sigtable[i].flags&_SigUnblock != 0 {
nmask.__sigbits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
......@@ -217,7 +221,8 @@ func minit() {
// Called from dropm to undo the effect of an minit.
func unminit() {
_g_ := getg()
sigprocmask(_SIG_SETMASK, &_g_.m.sigmask, nil)
smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask))
sigprocmask(_SIG_SETMASK, smask, nil)
signalstack(nil)
}
......
......@@ -24,7 +24,7 @@ func mach_thread_self() uint32
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
//go:noescape
func sigprocmask(how uint32, new, old *sigset)
func sigprocmask(how uint32, new, old *uint32)
//go:noescape
func sigaction(mode uint32, new, old *sigactiont)
......
......@@ -18,7 +18,7 @@ func sigaction(sig int32, new, old *sigactiont)
func sigaltstack(new, old *stackt)
//go:noescape
func sigprocmask(mode int32, new sigset) sigset
func sigprocmask(mode int32, new uint32) uint32
//go:noescape
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
......
......@@ -273,7 +273,7 @@ type m struct {
// Fields not known to debuggers.
procid uint64 // for debuggers, but offset not hard-coded
gsignal *g // signal-handling g
sigmask sigset // storage for saved signal mask
sigmask [4]uintptr // storage for saved signal mask
tls [6]uintptr // thread-local storage (for x86 extern register)
mstartfn func()
curg *g // current running goroutine
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment