gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/unsafe/goarch/goarch.go (about)

     1  // Copyright 2021 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 goarch contains GOARCH-specific constants.
     6  package goarch
     7  
     8  // The next line makes 'go generate' write the zgoarch*.go files with
     9  // per-arch information, including constants named $GOARCH for every
    10  // GOARCH. The constant is 1 on the current system, 0 otherwise; multiplying
    11  // by them is useful for defining GOARCH-specific constants.
    12  //go:generate go run gengoarch.go
    13  
    14  type ArchFamilyType int
    15  
    16  const (
    17  	AMD64 ArchFamilyType = iota
    18  	ARM
    19  	ARM64
    20  	I386
    21  	MIPS
    22  	MIPS64
    23  	PPC64
    24  	RISCV64
    25  	S390X
    26  	WASM
    27  )
    28  
    29  // PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant.
    30  // It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
    31  const PtrSize = 4 << (^uintptr(0) >> 63)
    32  
    33  // ArchFamily is the architecture family (AMD64, ARM, ...)
    34  const ArchFamily ArchFamilyType = _ArchFamily
    35  
    36  // BigEndian reports whether the architecture is big-endian.
    37  const BigEndian = IsArmbe|IsArm64be|IsMips|IsMips64|IsPpc|IsPpc64|IsS390|IsS390x|IsSparc|IsSparc64 == 1
    38  
    39  // DefaultPhysPageSize is the default physical page size.
    40  const DefaultPhysPageSize = _DefaultPhysPageSize
    41  
    42  // PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems).
    43  // The various PC tables record PC deltas pre-divided by PCQuantum.
    44  const PCQuantum = _PCQuantum
    45  
    46  // Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit).
    47  const Int64Align = PtrSize
    48  
    49  // MinFrameSize is the size of the system-reserved words at the bottom
    50  // of a frame (just above the architectural stack pointer).
    51  // It is zero on x86 and PtrSize on most non-x86 (LR-based) systems.
    52  // On PowerPC it is larger, to cover three more reserved words:
    53  // the compiler word, the link editor word, and the TOC save word.
    54  const MinFrameSize = _MinFrameSize
    55  
    56  // StackAlign is the required alignment of the SP register.
    57  // The stack must be at least word aligned, but some architectures require more.
    58  const StackAlign = _StackAlign