]> Cypherpunks repositories - gostls13.git/commitdiff
internal/runtime/maps: support big endian architectures
authorMichael Pratt <mpratt@google.com>
Wed, 9 Oct 2024 16:03:33 +0000 (12:03 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 9 Oct 2024 16:36:29 +0000 (16:36 +0000)
For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10
Change-Id: I0a928c4b1e90056c50d2abca8982bdb540c33a34
Reviewed-on: https://go-review.googlesource.com/c/go/+/619035
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

src/internal/runtime/maps/group.go

index d6e06300abd3deb4a557c47fce15e3d2d20170a6..822e3773eaa82563d6e9339619b8670d37fffe7e 100644 (file)
@@ -5,6 +5,7 @@
 package maps
 
 import (
+       "internal/goarch"
        "internal/runtime/maps/internal/abi"
        "internal/runtime/sys"
        "unsafe"
@@ -64,11 +65,18 @@ type ctrlGroup uint64
 
 // get returns the i-th control byte.
 func (g *ctrlGroup) get(i uint32) ctrl {
+       if goarch.BigEndian {
+               return *(*ctrl)(unsafe.Add(unsafe.Pointer(g), 7-i))
+       }
        return *(*ctrl)(unsafe.Add(unsafe.Pointer(g), i))
 }
 
 // set sets the i-th control byte.
 func (g *ctrlGroup) set(i uint32, c ctrl) {
+       if goarch.BigEndian {
+               *(*ctrl)(unsafe.Add(unsafe.Pointer(g), 7-i)) = c
+               return
+       }
        *(*ctrl)(unsafe.Add(unsafe.Pointer(g), i)) = c
 }