1
0
mirror of https://github.com/golang/go synced 2024-11-14 13:40:30 -07:00

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 <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
This commit is contained in:
Michael Pratt 2024-10-09 12:03:33 -04:00 committed by Gopher Robot
parent 3aa71c12ea
commit 3352db152b

View 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
}