Skip to content

Commit

Permalink
internal/runtime/maps: support big endian architectures
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
prattmic authored and gopherbot committed Oct 9, 2024
1 parent 3aa71c1 commit 3352db1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/internal/runtime/maps/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package maps

import (
"internal/goarch"
"internal/runtime/maps/internal/abi"
"internal/runtime/sys"
"unsafe"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 3352db1

Please sign in to comment.