[dev.typeparams] runtime/internal/sys: replace BigEndian with goarch.BigEndian [generated]

[git-generate]
cd src/runtime/internal/atomic
gofmt -w -r "sys.BigEndian -> goarch.BigEndian" .
goimports -w *.go
cd ../..
gofmt -w -r "sys.BigEndian -> goarch.BigEndian" .
goimports -w *.go

Change-Id: Iad35d2b367d8defb081a77ca837e7a7c805c2b7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/329190
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Michael Anthony Knyszek 2021-06-17 19:01:08 +00:00 committed by Michael Knyszek
parent 9c58e399a4
commit 9a93072a07
6 changed files with 10 additions and 12 deletions

View file

@ -7,7 +7,6 @@ package runtime
import ( import (
"internal/cpu" "internal/cpu"
"internal/goarch" "internal/goarch"
"runtime/internal/sys"
"unsafe" "unsafe"
) )
@ -338,7 +337,7 @@ func initAlgAES() {
// Note: These routines perform the read with a native endianness. // Note: These routines perform the read with a native endianness.
func readUnaligned32(p unsafe.Pointer) uint32 { func readUnaligned32(p unsafe.Pointer) uint32 {
q := (*[4]byte)(p) q := (*[4]byte)(p)
if sys.BigEndian { if goarch.BigEndian {
return uint32(q[3]) | uint32(q[2])<<8 | uint32(q[1])<<16 | uint32(q[0])<<24 return uint32(q[3]) | uint32(q[2])<<8 | uint32(q[1])<<16 | uint32(q[0])<<24
} }
return uint32(q[0]) | uint32(q[1])<<8 | uint32(q[2])<<16 | uint32(q[3])<<24 return uint32(q[0]) | uint32(q[1])<<8 | uint32(q[2])<<16 | uint32(q[3])<<24
@ -346,7 +345,7 @@ func readUnaligned32(p unsafe.Pointer) uint32 {
func readUnaligned64(p unsafe.Pointer) uint64 { func readUnaligned64(p unsafe.Pointer) uint64 {
q := (*[8]byte)(p) q := (*[8]byte)(p)
if sys.BigEndian { if goarch.BigEndian {
return uint64(q[7]) | uint64(q[6])<<8 | uint64(q[5])<<16 | uint64(q[4])<<24 | return uint64(q[7]) | uint64(q[6])<<8 | uint64(q[5])<<16 | uint64(q[4])<<24 |
uint64(q[3])<<32 | uint64(q[2])<<40 | uint64(q[1])<<48 | uint64(q[0])<<56 uint64(q[3])<<32 | uint64(q[2])<<40 | uint64(q[1])<<48 | uint64(q[0])<<56
} }

View file

@ -215,7 +215,7 @@ var Write = write
func Envs() []string { return envs } func Envs() []string { return envs }
func SetEnvs(e []string) { envs = e } func SetEnvs(e []string) { envs = e }
var BigEndian = sys.BigEndian var BigEndian = goarch.BigEndian
// For benchmarking. // For benchmarking.

View file

@ -8,7 +8,6 @@ import (
"internal/abi" "internal/abi"
"internal/goarch" "internal/goarch"
"runtime/internal/atomic" "runtime/internal/atomic"
"runtime/internal/sys"
"unsafe" "unsafe"
) )
@ -336,7 +335,7 @@ func convT2E(t *_type, elem unsafe.Pointer) (e eface) {
func convT16(val uint16) (x unsafe.Pointer) { func convT16(val uint16) (x unsafe.Pointer) {
if val < uint16(len(staticuint64s)) { if val < uint16(len(staticuint64s)) {
x = unsafe.Pointer(&staticuint64s[val]) x = unsafe.Pointer(&staticuint64s[val])
if sys.BigEndian { if goarch.BigEndian {
x = add(x, 6) x = add(x, 6)
} }
} else { } else {
@ -349,7 +348,7 @@ func convT16(val uint16) (x unsafe.Pointer) {
func convT32(val uint32) (x unsafe.Pointer) { func convT32(val uint32) (x unsafe.Pointer) {
if val < uint32(len(staticuint64s)) { if val < uint32(len(staticuint64s)) {
x = unsafe.Pointer(&staticuint64s[val]) x = unsafe.Pointer(&staticuint64s[val])
if sys.BigEndian { if goarch.BigEndian {
x = add(x, 4) x = add(x, 4)
} }
} else { } else {

View file

@ -5,9 +5,9 @@
package atomic_test package atomic_test
import ( import (
"internal/goarch"
"runtime" "runtime"
"runtime/internal/atomic" "runtime/internal/atomic"
"runtime/internal/sys"
"testing" "testing"
"unsafe" "unsafe"
) )
@ -56,7 +56,7 @@ func TestXadduintptr(t *testing.T) {
// Tests that xadduintptr correctly updates 64-bit values. The place where // Tests that xadduintptr correctly updates 64-bit values. The place where
// we actually do so is mstats.go, functions mSysStat{Inc,Dec}. // we actually do so is mstats.go, functions mSysStat{Inc,Dec}.
func TestXadduintptrOnUint64(t *testing.T) { func TestXadduintptrOnUint64(t *testing.T) {
if sys.BigEndian { if goarch.BigEndian {
// On big endian architectures, we never use xadduintptr to update // On big endian architectures, we never use xadduintptr to update
// 64-bit values and hence we skip the test. (Note that functions // 64-bit values and hence we skip the test. (Note that functions
// mSysStat{Inc,Dec} in mstats.go have explicit checks for // mSysStat{Inc,Dec} in mstats.go have explicit checks for

View file

@ -7,7 +7,7 @@ package runtime
import ( import (
"internal/abi" "internal/abi"
"internal/bytealg" "internal/bytealg"
"runtime/internal/sys" "internal/goarch"
"unsafe" "unsafe"
) )
@ -96,7 +96,7 @@ func slicebytetostring(buf *tmpBuf, ptr *byte, n int) (str string) {
} }
if n == 1 { if n == 1 {
p := unsafe.Pointer(&staticuint64s[*ptr]) p := unsafe.Pointer(&staticuint64s[*ptr])
if sys.BigEndian { if goarch.BigEndian {
p = add(p, 7) p = add(p, 7)
} }
stringStructOf(&str).str = p stringStructOf(&str).str = p

View file

@ -569,7 +569,7 @@ func printArgs(f funcInfo, argp unsafe.Pointer) {
// mask out irrelavant bits // mask out irrelavant bits
if sz < 8 { if sz < 8 {
shift := 64 - sz*8 shift := 64 - sz*8
if sys.BigEndian { if goarch.BigEndian {
x = x >> shift x = x >> shift
} else { } else {
x = x << shift >> shift x = x << shift >> shift