]> Cypherpunks repositories - gostls13.git/commitdiff
runtime, os/signal: use //go:linkname instead of assembly stubs to get access to...
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Thu, 15 Oct 2015 20:56:07 +0000 (09:56 +1300)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Fri, 16 Oct 2015 07:11:04 +0000 (07:11 +0000)
os/signal depends on a few unexported runtime functions. This removes the
assembly stubs it used to get access to these in favour of using
//go:linkname in runtime to make the functions accessible to os/signal.

This is motivated by ppc64le shared libraries, where you cannot BR to a symbol
defined in a shared library (only BL), but it seems like an improvment anyway.

Change-Id: I09361203ce38070bd3f132f6dc5ac212f2dc6f58
Reviewed-on: https://go-review.googlesource.com/15871
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
src/os/signal/sig.s
src/os/signal/signal_unix.go
src/runtime/sigqueue.go
src/runtime/sigqueue_plan9.go

index 7fa6c9224effbd246e1319aee2217127e24bea77..2e94c915786c06d549f725405b3141839d11b62a 100644 (file)
@@ -2,31 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Assembly to get into package runtime without using exported symbols.
-
-// +build amd64 amd64p32 arm arm64 386 ppc64 ppc64le
-
-#include "textflag.h"
-
-#ifdef GOARCH_arm
-#define JMP B
-#endif
-#ifdef GOARCH_ppc64
-#define JMP BR
-#endif
-#ifdef GOARCH_ppc64le
-#define JMP BR
-#endif
-
-TEXT ·signal_disable(SB),NOSPLIT,$0
-       JMP runtime·signal_disable(SB)
-
-TEXT ·signal_enable(SB),NOSPLIT,$0
-       JMP runtime·signal_enable(SB)
-
-TEXT ·signal_ignore(SB),NOSPLIT,$0
-       JMP runtime·signal_ignore(SB)
-
-TEXT ·signal_recv(SB),NOSPLIT,$0
-       JMP runtime·signal_recv(SB)
-
+// The runtime package uses //go:linkname to push a few functions into this
+// package but we still need a .s file so the Go tool does not pass -complete
+// to the go tool compile so the latter does not complain about Go functions
+// with no bodies.
index 1bdf1d7271808b30bbbf06e7aee0448725e94ad1..01b1b14fd19548d1b091c6d1c9eae05f4f31a4a0 100644 (file)
@@ -11,7 +11,7 @@ import (
        "syscall"
 )
 
-// In assembly.
+// Defined by the runtime package.
 func signal_disable(uint32)
 func signal_enable(uint32)
 func signal_ignore(uint32)
index e6e1a84063dd5adae2af705ff643d7bd2e323f26..f28067f3f9c80958f5dbb25403f26994b312a1e2 100644 (file)
@@ -90,6 +90,7 @@ Send:
 
 // Called to receive the next queued signal.
 // Must only be called from a single goroutine at a time.
+//go:linkname signal_recv os/signal.signal_recv
 func signal_recv() uint32 {
        for {
                // Serve any signals from local copy.
@@ -127,6 +128,7 @@ func signal_recv() uint32 {
 }
 
 // Must only be called from a single goroutine at a time.
+//go:linkname signal_enable os/signal.signal_enable
 func signal_enable(s uint32) {
        if !sig.inuse {
                // The first call to signal_enable is for us
@@ -145,6 +147,7 @@ func signal_enable(s uint32) {
 }
 
 // Must only be called from a single goroutine at a time.
+//go:linkname signal_disable os/signal.signal_disable
 func signal_disable(s uint32) {
        if s >= uint32(len(sig.wanted)*32) {
                return
@@ -154,6 +157,7 @@ func signal_disable(s uint32) {
 }
 
 // Must only be called from a single goroutine at a time.
+//go:linkname signal_ignore os/signal.signal_ignore
 func signal_ignore(s uint32) {
        if s >= uint32(len(sig.wanted)*32) {
                return
index f000fabd1acccd400b94a0347516f193597967de..89f96be2e9806f41138cf6bfba3da0b946ec8b78 100644 (file)
@@ -6,6 +6,8 @@
 
 package runtime
 
+import _ "unsafe"
+
 const qsize = 64
 
 var sig struct {
@@ -92,6 +94,7 @@ func sendNote(s *byte) bool {
 
 // Called to receive the next queued signal.
 // Must only be called from a single goroutine at a time.
+//go:linkname signal_recv os/signal.signal_recv
 func signal_recv() string {
        for {
                note := sig.q.pop()
@@ -108,6 +111,7 @@ func signal_recv() string {
 }
 
 // Must only be called from a single goroutine at a time.
+//go:linkname signal_enable os/signal.signal_enable
 func signal_enable(s uint32) {
        if !sig.inuse {
                // The first call to signal_enable is for us
@@ -120,9 +124,11 @@ func signal_enable(s uint32) {
 }
 
 // Must only be called from a single goroutine at a time.
+//go:linkname signal_disable os/signal.signal_disable
 func signal_disable(s uint32) {
 }
 
 // Must only be called from a single goroutine at a time.
+//go:linkname signal_ignore os/signal.signal_ignore
 func signal_ignore(s uint32) {
 }