zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 8fe6d5a48e97ec1b3260c86832baa707271d0f8b (tree)
parent 8b220cd746384c43e8406b70e93f76afe7a6db48
Author: xtex <xtex@astrafall.org>
Date:   Sat, 25 Apr 2026 21:49:21 +0800

std.os.linux: move HWCAP bits to linux.zig

Change-Id: Ic06feeeec9d04b540cf4efc931df4f4b7e327c5f

Diffstat:
Mlib/std/os/linux.zig | 48+++++++++++++++++++++++++++++++++++++++++++++++-
Mlib/std/os/linux/arm.zig | 26--------------------------
Mlib/std/os/linux/loongarch32.zig | 19-------------------
Mlib/std/os/linux/loongarch64.zig | 19-------------------
4 files changed, 47 insertions(+), 65 deletions(-)

diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig @@ -96,7 +96,6 @@ pub fn clone( } pub const ARCH = arch_bits.ARCH; -pub const HWCAP = arch_bits.HWCAP; pub const SC = arch_bits.SC; pub const VDSO = arch_bits.VDSO; pub const user_desc = arch_bits.user_desc; @@ -524,6 +523,53 @@ pub const O = switch (native_arch) { else => @compileError("missing std.os.linux.O constants for this architecture"), }; +pub const HWCAP = switch (native_arch) { + .arm, .armeb, .thumb, .thumbeb => struct { + pub const SWP = 1 << 0; + pub const HALF = 1 << 1; + pub const THUMB = 1 << 2; + pub const @"26BIT" = 1 << 3; + pub const FAST_MULT = 1 << 4; + pub const FPA = 1 << 5; + pub const VFP = 1 << 6; + pub const EDSP = 1 << 7; + pub const JAVA = 1 << 8; + pub const IWMMXT = 1 << 9; + pub const CRUNCH = 1 << 10; + pub const THUMBEE = 1 << 11; + pub const NEON = 1 << 12; + pub const VFPv3 = 1 << 13; + pub const VFPv3D16 = 1 << 14; + pub const TLS = 1 << 15; + pub const VFPv4 = 1 << 16; + pub const IDIVA = 1 << 17; + pub const IDIVT = 1 << 18; + pub const VFPD32 = 1 << 19; + pub const IDIV = IDIVA | IDIVT; + pub const LPAE = 1 << 20; + pub const EVTSTRM = 1 << 21; + }, + .loongarch32, .loongarch64 => struct { + pub const CPUCFG = 1 << 0; + pub const LAM = 1 << 1; + pub const UAL = 1 << 2; + pub const FPU = 1 << 3; + pub const LSX = 1 << 4; + pub const LASX = 1 << 5; + pub const CRC32 = 1 << 6; + pub const COMPLEX = 1 << 7; + pub const CRYPTO = 1 << 8; + pub const LVZ = 1 << 9; + pub const LBT_X86 = 1 << 10; + pub const LBT_ARM = 1 << 11; + pub const LBT_MIPS = 1 << 12; + pub const PTW = 1 << 13; + pub const LSPW = 1 << 14; + pub const SCQ = 1 << 15; + }, + else => struct {}, +}; + pub const RENAME = packed struct(u32) { /// Cannot be set together with `EXCHANGE`. NOREPLACE: bool = false, diff --git a/lib/std/os/linux/arm.zig b/lib/std/os/linux/arm.zig @@ -182,30 +182,4 @@ pub const VDSO = struct { pub const CGT_VER = "LINUX_2.6"; }; -pub const HWCAP = struct { - pub const SWP = 1 << 0; - pub const HALF = 1 << 1; - pub const THUMB = 1 << 2; - pub const @"26BIT" = 1 << 3; - pub const FAST_MULT = 1 << 4; - pub const FPA = 1 << 5; - pub const VFP = 1 << 6; - pub const EDSP = 1 << 7; - pub const JAVA = 1 << 8; - pub const IWMMXT = 1 << 9; - pub const CRUNCH = 1 << 10; - pub const THUMBEE = 1 << 11; - pub const NEON = 1 << 12; - pub const VFPv3 = 1 << 13; - pub const VFPv3D16 = 1 << 14; - pub const TLS = 1 << 15; - pub const VFPv4 = 1 << 16; - pub const IDIVA = 1 << 17; - pub const IDIVT = 1 << 18; - pub const VFPD32 = 1 << 19; - pub const IDIV = IDIVA | IDIVT; - pub const LPAE = 1 << 20; - pub const EVTSTRM = 1 << 21; -}; - pub const time_t = i32; diff --git a/lib/std/os/linux/loongarch32.zig b/lib/std/os/linux/loongarch32.zig @@ -161,22 +161,3 @@ pub const VDSO = struct { pub const CGT_SYM = "__vdso_clock_gettime"; pub const CGT_VER = "LINUX_5.10"; }; - -pub const HWCAP = struct { - pub const CPUCFG = 1 << 0; - pub const LAM = 1 << 1; - pub const UAL = 1 << 2; - pub const FPU = 1 << 3; - pub const LSX = 1 << 4; - pub const LASX = 1 << 5; - pub const CRC32 = 1 << 6; - pub const COMPLEX = 1 << 7; - pub const CRYPTO = 1 << 8; - pub const LVZ = 1 << 9; - pub const LBT_X86 = 1 << 10; - pub const LBT_ARM = 1 << 11; - pub const LBT_MIPS = 1 << 12; - pub const PTW = 1 << 13; - pub const LSPW = 1 << 14; - pub const SCQ = 1 << 15; -}; diff --git a/lib/std/os/linux/loongarch64.zig b/lib/std/os/linux/loongarch64.zig @@ -160,22 +160,3 @@ pub const VDSO = struct { pub const CGT_SYM = "__vdso_clock_gettime"; pub const CGT_VER = "LINUX_5.10"; }; - -pub const HWCAP = struct { - pub const CPUCFG = 1 << 0; - pub const LAM = 1 << 1; - pub const UAL = 1 << 2; - pub const FPU = 1 << 3; - pub const LSX = 1 << 4; - pub const LASX = 1 << 5; - pub const CRC32 = 1 << 6; - pub const COMPLEX = 1 << 7; - pub const CRYPTO = 1 << 8; - pub const LVZ = 1 << 9; - pub const LBT_X86 = 1 << 10; - pub const LBT_ARM = 1 << 11; - pub const LBT_MIPS = 1 << 12; - pub const PTW = 1 << 13; - pub const LSPW = 1 << 14; - pub const SCQ = 1 << 15; -};