// Called to initialize a new m (including the bootstrap m).
// Called on the new thread, cannot allocate memory.
func minit() {
- _g_ := getg()
asmcgocall(unsafe.Pointer(funcPC(miniterrno)), unsafe.Pointer(&libc____errno))
- minitSignalStack()
-
- // restore signal mask from m.sigmask and unblock essential signals
- nmask := _g_.m.sigmask
- for i := range sigtable {
- if sigtable[i].flags&_SigUnblock != 0 {
- nmask.__sigbits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
- }
- }
- sigprocmask(_SIG_SETMASK, &nmask, nil)
+ minitSignals()
}
// Called from dropm to undo the effect of an minit.
return set
}
+func sigdelset(mask *sigset, i int) {
+ mask.__sigbits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
+}
+
func (c *sigctxt) fixsigcode(sig uint32) {
}
// Called to initialize a new m (including the bootstrap m).
// Called on the new thread, cannot allocate memory.
func minit() {
- // Initialize signal handling.
- _g_ := getg()
-
// The alternate signal stack is buggy on arm and arm64.
// The signal handler handles it directly.
// The sigaltstack assembly function does nothing.
if GOARCH != "arm" && GOARCH != "arm64" {
minitSignalStack()
}
-
- // restore signal mask from m.sigmask and unblock essential signals
- nmask := _g_.m.sigmask
- for i := range sigtable {
- if sigtable[i].flags&_SigUnblock != 0 {
- nmask &^= 1 << (uint32(i) - 1)
- }
- }
- sigprocmask(_SIG_SETMASK, &nmask, nil)
+ minitSignalMask()
}
// Called from dropm to undo the effect of an minit.
func sigmaskToSigset(m sigmask) sigset {
return sigset(m[0])
}
+
+func sigdelset(mask *sigset, i int) {
+ *mask &^= 1 << (uint32(i) - 1)
+}
// Called to initialize a new m (including the bootstrap m).
// Called on the new thread, cannot allocate memory.
func minit() {
- _g_ := getg()
-
// m.procid is a uint64, but lwp_start writes an int32. Fix it up.
+ _g_ := getg()
_g_.m.procid = uint64(*(*int32)(unsafe.Pointer(&_g_.m.procid)))
- minitSignalStack()
-
- // restore signal mask from m.sigmask and unblock essential signals
- nmask := _g_.m.sigmask
- for i := range sigtable {
- if sigtable[i].flags&_SigUnblock != 0 {
- nmask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
- }
- }
- sigprocmask(_SIG_SETMASK, &nmask, nil)
+ minitSignals()
}
// Called from dropm to undo the effect of an minit.
return set
}
+func sigdelset(mask *sigset, i int) {
+ mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
+}
+
func (c *sigctxt) fixsigcode(sig uint32) {
}
// Called to initialize a new m (including the bootstrap m).
// Called on the new thread, cannot allocate memory.
func minit() {
- _g_ := getg()
-
// m.procid is a uint64, but thr_new writes a uint32 on 32-bit systems.
// Fix it up. (Only matters on big-endian, but be clean anyway.)
if sys.PtrSize == 4 {
+ _g_ := getg()
_g_.m.procid = uint64(*(*uint32)(unsafe.Pointer(&_g_.m.procid)))
}
- minitSignalStack()
-
- // restore signal mask from m.sigmask and unblock essential signals
- nmask := _g_.m.sigmask
- for i := range sigtable {
- if sigtable[i].flags&_SigUnblock != 0 {
- nmask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
- }
- }
- sigprocmask(_SIG_SETMASK, &nmask, nil)
+ minitSignals()
}
// Called from dropm to undo the effect of an minit.
return set
}
+func sigdelset(mask *sigset, i int) {
+ mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
+}
+
func (c *sigctxt) fixsigcode(sig uint32) {
}
// Called to initialize a new m (including the bootstrap m).
// Called on the new thread, cannot allocate memory.
func minit() {
- // Initialize signal handling.
- _g_ := getg()
-
- minitSignalStack()
+ minitSignals()
// for debuggers, in case cgo created the thread
- _g_.m.procid = uint64(gettid())
-
- // restore signal mask from m.sigmask and unblock essential signals
- nmask := _g_.m.sigmask
- for i := range sigtable {
- if sigtable[i].flags&_SigUnblock != 0 {
- sigdelset(&nmask, i)
- }
- }
- sigprocmask(_SIG_SETMASK, &nmask, nil)
+ getg().m.procid = uint64(gettid())
}
// Called from dropm to undo the effect of an minit.
_g_ := getg()
_g_.m.procid = uint64(lwp_self())
- // Initialize signal handling.
-
// On NetBSD a thread created by pthread_create inherits the
// signal stack of the creating thread. We always create a
// new signal stack here, to avoid having two Go threads using
signalstack(&_g_.m.gsignal.stack)
_g_.m.newSigstack = true
- // restore signal mask from m.sigmask and unblock essential signals
- nmask := _g_.m.sigmask
- for i := range sigtable {
- if sigtable[i].flags&_SigUnblock != 0 {
- nmask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
- }
- }
- sigprocmask(_SIG_SETMASK, &nmask, nil)
+ minitSignalMask()
}
// Called from dropm to undo the effect of an minit.
return set
}
+func sigdelset(mask *sigset, i int) {
+ mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
+}
+
func (c *sigctxt) fixsigcode(sig uint32) {
}
// Called to initialize a new m (including the bootstrap m).
// Called on the new thread, can not allocate memory.
func minit() {
- _g_ := getg()
-
// m.procid is a uint64, but tfork writes an int32. Fix it up.
+ _g_ := getg()
_g_.m.procid = uint64(*(*int32)(unsafe.Pointer(&_g_.m.procid)))
- minitSignalStack()
-
- // restore signal mask from m.sigmask and unblock essential signals
- nmask := _g_.m.sigmask
- for i := range sigtable {
- if sigtable[i].flags&_SigUnblock != 0 {
- nmask &^= 1 << (uint32(i) - 1)
- }
- }
- sigprocmask(_SIG_SETMASK, &nmask, nil)
+ minitSignals()
}
// Called from dropm to undo the effect of an minit.
return sigset(m[0])
}
+func sigdelset(mask *sigset, i int) {
+ *mask &^= 1 << (uint32(i) - 1)
+}
+
func (c *sigctxt) fixsigcode(sig uint32) {
}
sigprocmask(_SIG_UNBLOCK, &set, nil)
}
+// minitSignals is called when initializing a new m to set the
+// thread's alternate signal stack and signal mask.
+func minitSignals() {
+ minitSignalStack()
+ minitSignalMask()
+}
+
// minitSignalStack is called when initializing a new m to set the
// alternate signal stack. If the alternate signal stack is not set
// for the thread (the normal case) then set the alternate signal
}
}
+// minitSignalMask is called when initializing a new m to set the
+// thread's signal mask. When this is called all signals have been
+// blocked for the thread. This starts with m.sigmask, which was set
+// either from initSigmask for a newly created thread or by calling
+// msigsave if this is a non-Go thread calling a Go function. It
+// removes all essential signals from the mask, thus causing those
+// signals to not be blocked. Then it sets the thread's signal mask.
+// After this is called the thread can receive signals.
+func minitSignalMask() {
+ nmask := getg().m.sigmask
+ for i := range sigtable {
+ if sigtable[i].flags&_SigUnblock != 0 {
+ sigdelset(&nmask, i)
+ }
+ }
+ sigprocmask(_SIG_SETMASK, &nmask, nil)
+}
+
// setGsignalStack sets the gsignal stack of the current m to an
// alternate signal stack returned from the sigaltstack system call.
// This is used when handling a signal if non-Go code has set the