diff --git a/src/runtime/os1_darwin.go b/src/runtime/os1_darwin.go index 1b74e3e653..06bc2c79a5 100644 --- a/src/runtime/os1_darwin.go +++ b/src/runtime/os1_darwin.go @@ -138,7 +138,7 @@ func msigsave(mp *m) { func minit() { // Initialize signal handling. _g_ := getg() - signalstack((*byte)(unsafe.Pointer(_g_.m.gsignal.stack.lo)), 32*1024) + signalstack(&_g_.m.gsignal.stack) // restore signal mask from m.sigmask and unblock essential signals nmask := *(*uint32)(unsafe.Pointer(&_g_.m.sigmask)) @@ -155,7 +155,7 @@ func unminit() { _g_ := getg() smask := (*uint32)(unsafe.Pointer(&_g_.m.sigmask)) sigprocmask(_SIG_SETMASK, smask, nil) - signalstack(nil, 0) + signalstack(nil) } // Mach IPC, to get at semaphores @@ -454,13 +454,14 @@ func getsig(i int32) uintptr { return *(*uintptr)(unsafe.Pointer(&sa.__sigaction_u)) } -func signalstack(p *byte, n int32) { +func signalstack(s *stack) { var st stackt - st.ss_sp = p - st.ss_size = uintptr(n) - st.ss_flags = 0 - if p == nil { + if s == nil { st.ss_flags = _SS_DISABLE + } else { + st.ss_sp = (*byte)(unsafe.Pointer(s.lo)) + st.ss_size = s.hi - s.lo + st.ss_flags = 0 } sigaltstack(&st, nil) } diff --git a/src/runtime/os1_dragonfly.go b/src/runtime/os1_dragonfly.go index eb42b54e2b..a4c11d4fbf 100644 --- a/src/runtime/os1_dragonfly.go +++ b/src/runtime/os1_dragonfly.go @@ -136,7 +136,7 @@ func minit() { _g_.m.procid = uint64(*(*int32)(unsafe.Pointer(&_g_.m.procid))) // Initialize signal handling - signalstack((*byte)(unsafe.Pointer(_g_.m.gsignal.stack.lo)), 32*1024) + signalstack(&_g_.m.gsignal.stack) // restore signal mask from m.sigmask and unblock essential signals nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask)) @@ -153,7 +153,7 @@ func unminit() { _g_ := getg() smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask)) sigprocmask(smask, nil) - signalstack(nil, 0) + signalstack(nil) } func memlimit() uintptr { @@ -222,13 +222,14 @@ func getsig(i int32) uintptr { return sa.sa_sigaction } -func signalstack(p *byte, n int32) { +func signalstack(s *stack) { var st sigaltstackt - st.ss_sp = uintptr(unsafe.Pointer(p)) - st.ss_size = uintptr(n) - st.ss_flags = 0 - if p == nil { + if s == nil { st.ss_flags = _SS_DISABLE + } else { + st.ss_sp = s.lo + st.ss_size = s.hi - s.lo + st.ss_flags = 0 } sigaltstack(&st, nil) } diff --git a/src/runtime/os1_freebsd.go b/src/runtime/os1_freebsd.go index f7f34bd386..6dbf8299b4 100644 --- a/src/runtime/os1_freebsd.go +++ b/src/runtime/os1_freebsd.go @@ -138,7 +138,7 @@ func minit() { } // Initialize signal handling. - signalstack((*byte)(unsafe.Pointer(_g_.m.gsignal.stack.lo)), 32*1024) + signalstack(&_g_.m.gsignal.stack) // restore signal mask from m.sigmask and unblock essential signals nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask)) @@ -155,7 +155,7 @@ func unminit() { _g_ := getg() smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask)) sigprocmask(smask, nil) - signalstack(nil, 0) + signalstack(nil) } func memlimit() uintptr { @@ -224,13 +224,14 @@ func getsig(i int32) uintptr { return sa.sa_handler } -func signalstack(p *byte, n int32) { +func signalstack(s *stack) { var st stackt - st.ss_sp = uintptr(unsafe.Pointer(p)) - st.ss_size = uintptr(n) - st.ss_flags = 0 - if p == nil { + if s == nil { st.ss_flags = _SS_DISABLE + } else { + st.ss_sp = s.lo + st.ss_size = s.hi - s.lo + st.ss_flags = 0 } sigaltstack(&st, nil) } diff --git a/src/runtime/os1_linux.go b/src/runtime/os1_linux.go index 02f98d7c5f..8aa0804860 100644 --- a/src/runtime/os1_linux.go +++ b/src/runtime/os1_linux.go @@ -202,7 +202,7 @@ func msigsave(mp *m) { func minit() { // Initialize signal handling. _g_ := getg() - signalstack((*byte)(unsafe.Pointer(_g_.m.gsignal.stack.lo)), 32*1024) + signalstack(&_g_.m.gsignal.stack) // restore signal mask from m.sigmask and unblock essential signals nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask)) @@ -219,7 +219,7 @@ func unminit() { _g_ := getg() smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask)) rtsigprocmask(_SIG_SETMASK, smask, nil, int32(unsafe.Sizeof(*smask))) - signalstack(nil, 0) + signalstack(nil) } func memlimit() uintptr { @@ -311,13 +311,14 @@ func getsig(i int32) uintptr { return sa.sa_handler } -func signalstack(p *byte, n int32) { +func signalstack(s *stack) { var st sigaltstackt - st.ss_sp = p - st.ss_size = uintptr(n) - st.ss_flags = 0 - if p == nil { + if s == nil { st.ss_flags = _SS_DISABLE + } else { + st.ss_sp = (*byte)(unsafe.Pointer(s.lo)) + st.ss_size = s.hi - s.lo + st.ss_flags = 0 } sigaltstack(&st, nil) } diff --git a/src/runtime/os1_netbsd.go b/src/runtime/os1_netbsd.go index 3fb05989e7..2a579b8694 100644 --- a/src/runtime/os1_netbsd.go +++ b/src/runtime/os1_netbsd.go @@ -153,7 +153,7 @@ func minit() { _g_.m.procid = uint64(lwp_self()) // Initialize signal handling - signalstack((*byte)(unsafe.Pointer(_g_.m.gsignal.stack.lo)), 32*1024) + signalstack(&_g_.m.gsignal.stack) // restore signal mask from m.sigmask and unblock essential signals nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask)) @@ -171,7 +171,7 @@ func unminit() { smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask)) sigprocmask(_SIG_SETMASK, smask, nil) - signalstack(nil, 0) + signalstack(nil) } func memlimit() uintptr { @@ -213,14 +213,14 @@ func getsig(i int32) uintptr { return sa.sa_sigaction } -func signalstack(p *byte, n int32) { +func signalstack(s *stack) { var st sigaltstackt - - st.ss_sp = uintptr(unsafe.Pointer(p)) - st.ss_size = uintptr(n) - st.ss_flags = 0 - if p == nil { + if s == nil { st.ss_flags = _SS_DISABLE + } else { + st.ss_sp = s.lo + st.ss_size = s.hi - s.lo + st.ss_flags = 0 } sigaltstack(&st, nil) } diff --git a/src/runtime/os1_openbsd.go b/src/runtime/os1_openbsd.go index 5ccf642468..c07cd243be 100644 --- a/src/runtime/os1_openbsd.go +++ b/src/runtime/os1_openbsd.go @@ -165,7 +165,7 @@ func minit() { _g_.m.procid = uint64(*(*int32)(unsafe.Pointer(&_g_.m.procid))) // Initialize signal handling - signalstack((*byte)(unsafe.Pointer(_g_.m.gsignal.stack.lo)), 32*1024) + signalstack(&_g_.m.gsignal.stack) // restore signal mask from m.sigmask and unblock essential signals nmask := *(*uint32)(unsafe.Pointer(&_g_.m.sigmask)) @@ -182,7 +182,7 @@ func unminit() { _g_ := getg() smask := *(*uint32)(unsafe.Pointer(&_g_.m.sigmask)) sigprocmask(_SIG_SETMASK, smask) - signalstack(nil, 0) + signalstack(nil) } func memlimit() uintptr { @@ -224,14 +224,14 @@ func getsig(i int32) uintptr { return sa.sa_sigaction } -func signalstack(p *byte, n int32) { +func signalstack(s *stack) { var st stackt - - st.ss_sp = uintptr(unsafe.Pointer(p)) - st.ss_size = uintptr(n) - st.ss_flags = 0 - if p == nil { + if s == nil { st.ss_flags = _SS_DISABLE + } else { + st.ss_sp = s.lo + st.ss_size = s.hi - s.lo + st.ss_flags = 0 } sigaltstack(&st, nil) } diff --git a/src/runtime/os3_solaris.go b/src/runtime/os3_solaris.go index e4fe92de41..53d7b96b0f 100644 --- a/src/runtime/os3_solaris.go +++ b/src/runtime/os3_solaris.go @@ -203,7 +203,7 @@ func minit() { _g_ := getg() asmcgocall(unsafe.Pointer(funcPC(miniterrno)), unsafe.Pointer(&libc____errno)) // Initialize signal handling - signalstack((*byte)(unsafe.Pointer(_g_.m.gsignal.stack.lo)), 32*1024) + signalstack(&_g_.m.gsignal.stack) // restore signal mask from m.sigmask and unblock essential signals nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask)) @@ -221,7 +221,7 @@ func unminit() { smask := (*sigset)(unsafe.Pointer(&_g_.m.sigmask)) sigprocmask(_SIG_SETMASK, smask, nil) - signalstack(nil, 0) + signalstack(nil) } func memlimit() uintptr { @@ -286,13 +286,14 @@ func getsig(i int32) uintptr { return *((*uintptr)(unsafe.Pointer(&sa._funcptr))) } -func signalstack(p *byte, n int32) { +func signalstack(s *stack) { var st sigaltstackt - st.ss_sp = (*byte)(unsafe.Pointer(p)) - st.ss_size = uint64(n) - st.ss_flags = 0 - if p == nil { + if s == nil { st.ss_flags = _SS_DISABLE + } else { + st.ss_sp = (*byte)(unsafe.Pointer(s.lo)) + st.ss_size = uint64(s.hi - s.lo) + st.ss_flags = 0 } sigaltstack(&st, nil) }