From 097a581dc0d97efac1dfbe5d79819bbf6bf681a7 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 27 Sep 2016 07:20:10 -0700 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/runtime/os_netbsd.go | 3 ++- src/runtime/signal_unix.go | 14 ++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/runtime/os_netbsd.go b/src/runtime/os_netbsd.go index e9c0490455..38deb26e91 100644 --- a/src/runtime/os_netbsd.go +++ b/src/runtime/os_netbsd.go @@ -192,7 +192,8 @@ func newosproc(mp *m, stk unsafe.Pointer) { // At this point all signals are blocked, so there is no race. //go:nosplit func netbsdMstart() { - signalstack(nil) + st := stackt{ss_flags: _SS_DISABLE} + sigaltstack(&st, nil) mstart() } diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 3a26245221..d74cb3bf3a 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -624,7 +624,8 @@ func minitSignalMask() { //go:nosplit func unminitSignals() { if getg().m.newSigstack { - signalstack(nil) + st := stackt{ss_flags: _SS_DISABLE} + sigaltstack(&st, nil) } } @@ -645,17 +646,10 @@ func setGsignalStack(st *stackt) { } // signalstack sets the current thread's alternate signal stack to s. -// If s is nil, the current thread's alternate signal stack is disabled. //go:nosplit func signalstack(s *stack) { - var st stackt - if s == nil { - st.ss_flags = _SS_DISABLE - } else { - setSignalstackSP(&st, s.lo) - st.ss_size = s.hi - s.lo - st.ss_flags = 0 - } + st := stackt{ss_size: s.hi - s.lo} + setSignalstackSP(&st, s.lo) sigaltstack(&st, nil) }