//go:noescape
func sigaltstack(new, old *sigaltstackt)
+//go:noescape
+func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
+
//go:noescape
func sigaction(sig int32, new, old *sigactiont)
//go:noescape
func sigaltstack(new, old *stackt)
+//go:noescape
+func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
+
//go:noescape
func sigaction(sig int32, new, old *sigactiont)
panicmem()
}
+func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer) {
+ throw("sigfwd not implemented")
+}
+
func raiseproc(sig int32) {
}
//go:noescape
func sigaltstack(new, old *sigaltstackt)
+//go:noescape
+func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer) {
+ throw("sigfwd not implemented")
+}
+
//go:noescape
func sigprocmask(mode int32, new, old *sigset)
package runtime
+import "unsafe"
+
//go:noescape
func setitimer(mode int32, new, old *itimerval)
//go:noescape
func sigaltstack(new, old *stackt)
+//go:noescape
+func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
+
//go:noescape
func sigprocmask(mode int32, new uint32) uint32
var asmsysvicall6 libcFunc
+//go:noescape
+func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
+
//go:nosplit
func sysvicall0(fn libcFunc) uintptr {
libcall := &getg().m.libcall
package runtime
+import "unsafe"
+
type sigTabT struct {
flags int32
name string
/* 30 */ {_SigNotify, "SIGUSR1: user-defined signal 1"},
/* 31 */ {_SigNotify, "SIGUSR2: user-defined signal 2"},
}
+
+//go:noescape
+func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
+
+//go:noescape
+func sigreturn(ctx unsafe.Pointer, infostyle uint32)
+
+//go:nosplit
+func sigtrampgo(fn uintptr, infostyle, sig uint32, info *siginfo, ctx unsafe.Pointer) {
+ if sigfwdgo(sig, info, ctx) {
+ sigreturn(ctx, infostyle)
+ return
+ }
+ g := getg()
+ if g == nil {
+ badsignal(uintptr(sig))
+ sigreturn(ctx, infostyle)
+ return
+ }
+ setg(g.m.gsignal)
+ sighandler(sig, info, ctx, g)
+ setg(g)
+ sigreturn(ctx, infostyle)
+}
/* 64 */ {_SigNotify, "signal 64"},
}
-// Determines if the signal should be handled by Go and if not, forwards the
-// signal to the handler that was installed before Go's. Returns whether the
-// signal was forwarded.
-//go:nosplit
-func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool {
- g := getg()
- c := &sigctxt{info, ctx}
- if sig >= uint32(len(sigtable)) {
- return false
- }
- fwdFn := fwdSig[sig]
- flags := sigtable[sig].flags
-
- // If there is no handler to forward to, no need to forward.
- if fwdFn == _SIG_DFL {
- return false
- }
- // Only forward synchronous signals.
- if c.sigcode() == _SI_USER || flags&_SigPanic == 0 {
- return false
- }
- // Determine if the signal occurred inside Go code. We test that:
- // (1) we were in a goroutine (i.e., m.curg != nil), and
- // (2) we weren't in CGO (i.e., m.curg.syscallsp == 0).
- if g != nil && g.m != nil && g.m.curg != nil && g.m.curg.syscallsp == 0 {
- return false
- }
- // Signal not handled by Go, forward it.
- if fwdFn != _SIG_IGN {
- sigfwd(fwdFn, sig, info, ctx)
- }
- return true
-}
-
// Continuation of the (assembly) sigtramp() logic.
//go:nosplit
func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
package runtime
-import _ "unsafe" // for go:linkname
+import "unsafe"
//go:linkname os_sigpipe os.sigpipe
func os_sigpipe() {
systemstack(sigpipe)
}
+
+// Determines if the signal should be handled by Go and if not, forwards the
+// signal to the handler that was installed before Go's. Returns whether the
+// signal was forwarded.
+//go:nosplit
+func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool {
+ g := getg()
+ c := &sigctxt{info, ctx}
+ if sig >= uint32(len(sigtable)) {
+ return false
+ }
+ fwdFn := fwdSig[sig]
+ flags := sigtable[sig].flags
+
+ // If there is no handler to forward to, no need to forward.
+ if fwdFn == _SIG_DFL {
+ return false
+ }
+ // Only forward synchronous signals.
+ if c.sigcode() == _SI_USER || flags&_SigPanic == 0 {
+ return false
+ }
+ // Determine if the signal occurred inside Go code. We test that:
+ // (1) we were in a goroutine (i.e., m.curg != nil), and
+ // (2) we weren't in CGO (i.e., m.curg.syscallsp == 0).
+ if g != nil && g.m != nil && g.m.curg != nil && g.m.curg.syscallsp == 0 {
+ return false
+ }
+ // Signal not handled by Go, forward it.
+ if fwdFn != _SIG_IGN {
+ sigfwd(fwdFn, sig, info, ctx)
+ }
+ return true
+}
MOVL $0xf1, 0xf1 // crash
RET
-TEXT runtime·sigaction(SB),NOSPLIT,$0
+TEXT runtime·sigaction(SB),NOSPLIT,$0-24
MOVL mode+0(FP), DI // arg 1 sig
MOVQ new+8(FP), SI // arg 2 act
MOVQ old+16(FP), DX // arg 3 oact
MOVL $0xf1, 0xf1 // crash
RET
-TEXT runtime·sigtramp(SB),NOSPLIT,$64
- get_tls(BX)
-
- MOVQ R8, 32(SP) // save ucontext
- MOVQ SI, 40(SP) // save infostyle
-
- // check that g exists
- MOVQ g(BX), R10
- CMPQ R10, $0
- JNE 5(PC)
- MOVL DX, 0(SP)
- MOVQ $runtime·badsignal(SB), AX
- CALL AX
- JMP ret
-
- // save g
- MOVQ R10, 48(SP)
-
- // g = m->gsignal
- MOVQ g_m(R10), BP
- MOVQ m_gsignal(BP), BP
- MOVQ BP, g(BX)
-
- MOVL DX, 0(SP)
- MOVQ CX, 8(SP)
- MOVQ R8, 16(SP)
- MOVQ R10, 24(SP)
-
- CALL DI
-
- // restore g
- get_tls(BX)
- MOVQ 48(SP), R10
- MOVQ R10, g(BX)
+TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
+ MOVQ fn+0(FP), AX
+ MOVQ sig+8(FP), DI
+ MOVQ info+16(FP), SI
+ MOVQ ctx+24(FP), DX
+ CALL AX
+ RET
-ret:
- // call sigreturn
- MOVL $(0x2000000+184), AX // sigreturn(ucontext, infostyle)
- MOVQ 32(SP), DI // saved ucontext
- MOVQ 40(SP), SI // saved infostyle
+TEXT runtime·sigreturn(SB),NOSPLIT,$0-12
+ MOVQ ctx+0(FP), DI
+ MOVL infostyle+8(FP), SI
+ MOVL $(0x2000000+184), AX
SYSCALL
- INT $3 // not reached
+ INT $3 // not reached
+
+TEXT runtime·sigtramp(SB),NOSPLIT,$32
+ MOVQ DI, 0(SP) // fn
+ MOVL SI, 8(SP) // infostyle
+ MOVL DX, 12(SP) // sig
+ MOVQ CX, 16(SP) // info
+ MOVQ R8, 24(SP) // ctx
+ MOVQ $runtime·sigtrampgo(SB), AX
+ CALL AX
TEXT runtime·mmap(SB),NOSPLIT,$0
MOVQ addr+0(FP), DI // arg 1 addr