Skip to content

Commit 097a581

Browse files
runtime: simplify signalstack by dropping nil as argument
Change the two calls to signalstack(nil) to inline the code instead (it's two lines). Change-Id: Ie92a05494f924f279e40ac159f1b677fda18f281 Reviewed-on: https://go-review.googlesource.com/29854 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 60482d8 commit 097a581

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/runtime/os_netbsd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ func newosproc(mp *m, stk unsafe.Pointer) {
192192
// At this point all signals are blocked, so there is no race.
193193
//go:nosplit
194194
func netbsdMstart() {
195-
signalstack(nil)
195+
st := stackt{ss_flags: _SS_DISABLE}
196+
sigaltstack(&st, nil)
196197
mstart()
197198
}
198199

src/runtime/signal_unix.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,8 @@ func minitSignalMask() {
624624
//go:nosplit
625625
func unminitSignals() {
626626
if getg().m.newSigstack {
627-
signalstack(nil)
627+
st := stackt{ss_flags: _SS_DISABLE}
628+
sigaltstack(&st, nil)
628629
}
629630
}
630631

@@ -645,17 +646,10 @@ func setGsignalStack(st *stackt) {
645646
}
646647

647648
// signalstack sets the current thread's alternate signal stack to s.
648-
// If s is nil, the current thread's alternate signal stack is disabled.
649649
//go:nosplit
650650
func signalstack(s *stack) {
651-
var st stackt
652-
if s == nil {
653-
st.ss_flags = _SS_DISABLE
654-
} else {
655-
setSignalstackSP(&st, s.lo)
656-
st.ss_size = s.hi - s.lo
657-
st.ss_flags = 0
658-
}
651+
st := stackt{ss_size: s.hi - s.lo}
652+
setSignalstackSP(&st, s.lo)
659653
sigaltstack(&st, nil)
660654
}
661655

0 commit comments

Comments
 (0)