github.com/primecitizens/pcz/std@v0.2.1/core/arch/goarch.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2021 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  // Package arch contains GOARCH-specific constants.
     9  package arch
    10  
    11  type ArchFamilyType int
    12  
    13  const (
    14  	AMD64 ArchFamilyType = iota
    15  	ARM
    16  	ARM64
    17  	I386
    18  	MIPS
    19  	MIPS64
    20  	PPC64
    21  	RISCV64
    22  	S390X
    23  	WASM
    24  )
    25  
    26  const (
    27  	// Is64bit = 1 on 64-bit systems, 0 on 32-bit systems
    28  	Is64bit = 1 << (^uintptr(0) >> 63) / 2
    29  
    30  	// PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant.
    31  	// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
    32  	PtrSize = 4 << (^uintptr(0) >> 63)
    33  
    34  	// 32 on 32-bit systems, 64 on 64-bit.
    35  	UintBits = 32 << (^uint(0) >> 63)
    36  
    37  	// ArchFamily is the architecture family (AMD64, ARM, ...)
    38  	ArchFamily ArchFamilyType = _ArchFamily
    39  
    40  	// DefaultPhysPageSize is the default physical page size.
    41  	DefaultPhysPageSize = _DefaultPhysPageSize
    42  
    43  	// PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems).
    44  	// The various PC tables record PC deltas pre-divided by PCQuantum.
    45  	PCQuantum = _PCQuantum
    46  
    47  	// Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit).
    48  	Int64Align = PtrSize
    49  
    50  	// MinFrameSize is the size of the system-reserved words at the bottom
    51  	// of a frame (just above the architectural stack pointer).
    52  	// It is zero on x86 and PtrSize on most non-x86 (LR-based) systems.
    53  	// On PowerPC it is larger, to cover three more reserved words:
    54  	// the compiler word, the link editor word, and the TOC save word.
    55  	MinFrameSize = _MinFrameSize
    56  
    57  	// StackAlign is the required alignment of the SP register.
    58  	// The stack must be at least word aligned, but some architectures require more.
    59  	StackAlign = _StackAlign
    60  )
    61  
    62  const (
    63  	PageShift = 13
    64  	PageSize  = 1 << PageShift
    65  )
    66  
    67  const (
    68  	// BigEndian reports whether the architecture is big-endian.
    69  	BigEndian    = IsArmbe|IsArm64be|IsMips|IsMips64|IsMips64p32|IsPpc|IsPpc64|IsS390|IsS390x|IsSparc|IsSparc64 != 0
    70  	LittleEndian = !BigEndian
    71  )
    72  
    73  const (
    74  	FramePointerEnabled = IsAmd64|IsArm64 != 0
    75  )