aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2024-05-22 15:03:13 -0400
committerGopher Robot <gobot@golang.org>2024-05-23 01:16:53 +0000
commit05cbbf985fed823a174bf95cc78a7d44f948fdab (patch)
treeffdb52c7ce57360323e22a68e20f45d10771a004 /src/internal
parent1d3d6ae725697c5b224b26cb3aa1325ac37f72d7 (diff)
downloadgo-05cbbf985fed823a174bf95cc78a7d44f948fdab.tar.xz
all: document legacy //go:linkname for modules with ≥500 dependents
For #67401. Change-Id: I7dd28c3b01a1a647f84929d15412aa43ab0089ee Reviewed-on: https://go-review.googlesource.com/c/go/+/587575 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/bytealg/compare_generic.go10
-rw-r--r--src/internal/cpu/cpu_arm64_darwin.go11
2 files changed, 21 insertions, 0 deletions
diff --git a/src/internal/bytealg/compare_generic.go b/src/internal/bytealg/compare_generic.go
index 8c08b7e6f5..74126ae805 100644
--- a/src/internal/bytealg/compare_generic.go
+++ b/src/internal/bytealg/compare_generic.go
@@ -39,6 +39,16 @@ func CompareString(a, b string) int {
return runtime_cmpstring(a, b)
}
+// runtime.cmpstring calls are emitted by the compiler.
+//
+// runtime.cmpstring should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/bytedance/gopkg
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
//go:linkname runtime_cmpstring runtime.cmpstring
func runtime_cmpstring(a, b string) int {
l := len(a)
diff --git a/src/internal/cpu/cpu_arm64_darwin.go b/src/internal/cpu/cpu_arm64_darwin.go
index 60beadddbb..fad66c6c90 100644
--- a/src/internal/cpu/cpu_arm64_darwin.go
+++ b/src/internal/cpu/cpu_arm64_darwin.go
@@ -6,6 +6,8 @@
package cpu
+import _ "unsafe" // for linkname
+
func osInit() {
ARM64.HasATOMICS = sysctlEnabled([]byte("hw.optional.armv8_1_atomics\x00"))
ARM64.HasCRC32 = sysctlEnabled([]byte("hw.optional.armv8_crc32\x00"))
@@ -24,6 +26,15 @@ func osInit() {
//go:noescape
func getsysctlbyname(name []byte) (int32, int32)
+// sysctlEnabled should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+// - github.com/bytedance/gopkg
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname sysctlEnabled
func sysctlEnabled(name []byte) bool {
ret, value := getsysctlbyname(name)
if ret < 0 {