From: Michael Pratt Date: Wed, 9 Oct 2024 16:03:33 +0000 (-0400) Subject: internal/runtime/maps: support big endian architectures X-Git-Tag: go1.24rc1~720 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3352db152b8347650e1fd3c9f26c335586577b21;p=gostls13.git 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 --- 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 }