]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: drop sigfwd from signal forwarding unsupported platforms
authorMikio Hara <mikioh.mikioh@gmail.com>
Sun, 12 Jul 2015 00:23:37 +0000 (09:23 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Fri, 2 Oct 2015 01:07:44 +0000 (01:07 +0000)
This change splits signal_unix.go into signal_unix.go and
signal2_unix.go and removes the fake symbol sigfwd from signal
forwarding unsupported platforms for clarification purpose.

Change-Id: I205eab5cf1930fda8a68659b35cfa9f3a0e67ca6
Reviewed-on: https://go-review.googlesource.com/12062
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/os_dragonfly.go
src/runtime/os_freebsd.go
src/runtime/os_linux.go
src/runtime/os_nacl.go
src/runtime/os_netbsd.go
src/runtime/os_openbsd.go
src/runtime/os_solaris.go
src/runtime/signal1_unix.go
src/runtime/signal2_unix.go [new file with mode: 0644]
src/runtime/signal_darwin.go
src/runtime/signal_unix.go

index b19270a18dbd9f07957c91636bf073fd628c4177..62fc56a1f1fed92a11fbf0ed6febdb8b9b3ddb11 100644 (file)
@@ -12,9 +12,6 @@ func lwp_create(param *lwpparams) int32
 //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)
 
index 8c8a10661d584b3970433a106b238432f4454a48..bc3394c9ac650e94637c8930f4421508d9523b89 100644 (file)
@@ -12,9 +12,6 @@ func thr_new(param *thrparam, size int32)
 //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)
 
index bd492f5e3bbd423671e43541a2c381da76130dad..dc932dbaa0fa57ada433d4af99b1448afad74165 100644 (file)
@@ -18,9 +18,6 @@ func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32
 //go:noescape
 func sigaltstack(new, old *sigaltstackt)
 
-//go:noescape
-func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
-
 //go:noescape
 func setitimer(mode int32, new, old *itimerval)
 
index 3b4c13606fb90ac435a17d1c586c5be1729f1c93..efa8fa12b911fdf7db82b866223a2a8b8c64799f 100644 (file)
@@ -50,10 +50,6 @@ func sigpanic() {
        panicmem()
 }
 
-func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer) {
-       throw("sigfwd not implemented")
-}
-
 func raiseproc(sig int32) {
 }
 
index af52099079125244802aa4aac153f83632dc614b..4fa4a416bdc70aab9d9c3754e7fc052264343181 100644 (file)
@@ -15,10 +15,6 @@ func sigaction(sig int32, new, old *sigactiont)
 //go:noescape
 func sigaltstack(new, old *sigaltstackt)
 
-func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer) {
-       throw("sigfwd not implemented")
-}
-
 //go:noescape
 func sigprocmask(mode int32, new, old *sigset)
 
index f94b490285d89d01ea64384ab6d3fcf6988c0c71..8a97a738f770ece34a450391e7a5af36609bd519 100644 (file)
@@ -4,8 +4,6 @@
 
 package runtime
 
-import "unsafe"
-
 //go:noescape
 func setitimer(mode int32, new, old *itimerval)
 
@@ -15,9 +13,6 @@ 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 sigprocmask(mode int32, new uint32) uint32
 
index fd20a5cd119a5afacb1639b8b744ddb2c3485202..634e4cf914a07bb1559da7227bfff14bb09f87f5 100644 (file)
@@ -10,9 +10,6 @@ type libcFunc uintptr
 
 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
index e351d57b779492751373d4123f0f4ed069f53938..8cabbc20e21efcb220a2f153b3a75987df919d16 100644 (file)
@@ -16,7 +16,7 @@ const (
 // handle a particular signal (e.g., signal occurred on a non-Go thread).
 // See sigfwdgo() for more information on when the signals are forwarded.
 //
-// Signal forwarding is currently available only on Linux.
+// Signal forwarding is currently available only on Darwin and Linux.
 var fwdSig [_NSIG]uintptr
 
 // sigmask represents a general signal mask compatible with the GOOS
diff --git a/src/runtime/signal2_unix.go b/src/runtime/signal2_unix.go
new file mode 100644 (file)
index 0000000..8b0bd42
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright 2012 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin linux
+
+package runtime
+
+import "unsafe"
+
+//go:noescape
+func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer)
+
+// 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
+}
index 6cd18653d5f0c88509ee4f486c1002b729ae5853..e8ec162fda51297c7b24ca007a518242c93f08e4 100644 (file)
@@ -46,9 +46,6 @@ var sigtable = [...]sigTabT{
        /* 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)
 
index ad3ab31c01c2c66ed57deccdc6ef08d3fd5cb361..8834e51f4b41b4b1d7ec818afc2c0fccf44be7b4 100644 (file)
@@ -6,43 +6,9 @@
 
 package runtime
 
-import "unsafe"
+import _ "unsafe" // for go:linkname
 
 //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
-}