aboutsummaryrefslogtreecommitdiff
path: root/src/internal/bytealg/compare_native.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-10-31 15:04:04 -0400
committerAustin Clements <austin@google.com>2018-11-12 20:27:16 +0000
commitef7ce57ac2da02aeceada27761c282e0718c6e14 (patch)
treebfde4649e9e2d40fd66b9c1138552e3a32488996 /src/internal/bytealg/compare_native.go
parent4f3604d3f2b25905907742f48cd0feeec5b458e1 (diff)
downloadgo-ef7ce57ac2da02aeceada27761c282e0718c6e14.tar.xz
internal/bytealg, runtime: provide linknames for pushed symbols
The internal/bytealg package defines several symbols in the runtime, bytes, and strings packages in assembly, and the runtime package defines symbols in reflect and sync/atomic. Currently, there's no corresponding Go prototype for these symbols in the defining package. We're going to start depending on Go prototypes in the same package as their assembly definitions in order to provide ABI wrappers. Plus, these are good documentation and colocate type information with definitions, which could be useful for vet if it learned a little about linkname. This CL adds linknamed Go prototypes for all pushed symbols in internal/bytealg and runtime. For #27539. Change-Id: I9b0c12d935a75bb6af46b6761180d451c00f11b8 Reviewed-on: https://go-review.googlesource.com/c/146820 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/internal/bytealg/compare_native.go')
-rw-r--r--src/internal/bytealg/compare_native.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/internal/bytealg/compare_native.go b/src/internal/bytealg/compare_native.go
index d4ff61938c..b14aa8c72c 100644
--- a/src/internal/bytealg/compare_native.go
+++ b/src/internal/bytealg/compare_native.go
@@ -6,5 +6,14 @@
package bytealg
+import _ "unsafe" // For go:linkname
+
//go:noescape
func Compare(a, b []byte) int
+
+// The declaration below generates ABI wrappers for functions
+// implemented in assembly in this package but declared in another
+// package.
+
+//go:linkname abigen_runtime_cmpstring runtime.cmpstring
+func abigen_runtime_cmpstring(a, b string) int