From 3352db152b8347650e1fd3c9f26c335586577b21 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 9 Oct 2024 12:03:33 -0400 Subject: [PATCH] internal/runtime/maps: support big endian architectures 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 LUCI-TryBot-Result: Go LUCI Auto-Submit: Michael Pratt --- src/internal/runtime/maps/group.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/internal/runtime/maps/group.go b/src/internal/runtime/maps/group.go index d6e06300ab..822e3773ea 100644 --- a/src/internal/runtime/maps/group.go +++ b/src/internal/runtime/maps/group.go @@ -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 } -- 2.48.1