| 1 | // Copyright 2019 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package cpuscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/ |
| 6 | |
| 7 | import ( |
| 8 | "runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/" |
| 9 | ) |
| 10 | |
| 11 | // byteOrder is a subset of encoding/binary.ByteOrder. |
| 12 | type byteOrderscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/byteOrder# interface { |
| 13 | Uint32scip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/byteOrder#Uint32.([]byte) uint32 |
| 14 | Uint64scip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/byteOrder#Uint64.([]byte) uint64 |
| 15 | } |
| 16 | |
| 17 | type littleEndianscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/littleEndian# struct{} |
| 18 | type bigEndianscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/bigEndian# struct{} |
| 19 | |
| 20 | func (littleEndianscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/littleEndian#) Uint32scip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/littleEndian#Uint32().(b []byte) uint32 { |
| 21 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 |
| 22 | return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 |
| 23 | } |
| 24 | |
| 25 | func (littleEndianscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/littleEndian#) Uint64scip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/littleEndian#Uint64().(b []byte) uint64 { |
| 26 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 |
| 27 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | |
| 28 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 |
| 29 | } |
| 30 | |
| 31 | func (bigEndianscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/bigEndian#) Uint32scip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/bigEndian#Uint32().(b []byte) uint32 { |
| 32 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 |
| 33 | return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 |
| 34 | } |
| 35 | |
| 36 | func (bigEndianscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/bigEndian#) Uint64scip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/bigEndian#Uint64().(b []byte) uint64 { |
| 37 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 |
| 38 | return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | |
| 39 | uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 |
| 40 | } |
| 41 | |
| 42 | // hostByteOrder returns littleEndian on little-endian machines and |
| 43 | // bigEndian on big-endian machines. |
| 44 | func hostByteOrderscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/hostByteOrder().() byteOrderscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/byteOrder# { |
| 45 | switch runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/.GOARCHscip-go gomod github.com/golang/go/src go1.25.0 runtime/GOARCH. { |
| 46 | case "386", "amd64", "amd64p32", |
| 47 | "alpha", |
| 48 | "arm", "arm64", |
| 49 | "loong64", |
| 50 | "mipsle", "mips64le", "mips64p32le", |
| 51 | "nios2", |
| 52 | "ppc64le", |
| 53 | "riscv", "riscv64", |
| 54 | "sh": |
| 55 | return littleEndianscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/littleEndian#{} |
| 56 | case "armbe", "arm64be", |
| 57 | "m68k", |
| 58 | "mips", "mips64", "mips64p32", |
| 59 | "ppc", "ppc64", |
| 60 | "s390", "s390x", |
| 61 | "shbe", |
| 62 | "sparc", "sparc64": |
| 63 | return bigEndianscip-go gomod golang.org/x/sys . `golang.org/x/sys/cpu`/bigEndian#{} |
| 64 | } |
| 65 | panic("unknown architecture") |
| 66 | } |