mirror of
https://github.com/golang/go
synced 2024-11-18 04:04:49 -07:00
runtime: clean up signalstack API
Currently signalstack takes a lower limit and a length and all calls hard-code the passed length. Change the API to take a *stack and compute the lower limit and length from the passed stack. This will make it easier for the runtime to steal some space from the top of the stack since it eliminates the hard-coded stack sizes. Change-Id: I7d2a9f45894b221f4e521628c2165530bbc57d53 Reviewed-on: https://go-review.googlesource.com/10311 Reviewed-by: Rick Hudson <rlh@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
cc6a7fce53
commit
c02b8911d8
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user