mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-01 05:09:01 +00:00
The previous runtime_detect.zig called std.zig.system.resolveTargetQuery which pulled in the entire Zig target/CPU model table infrastructure for every architecture (~4,000 symbols, ~175 KB of data tables, ~130 KB of code). This bloated the binary by ~500 KB and shifted code layout enough to cause a measurable icache/branch-predictor regression in unrelated hot paths like the terminal parser (~20% more cycles for identical instruction counts). Replace with minimal, direct CPU feature detection per architecture: CPUID + XGETBV inline assembly on x86, sysctlbyname on Darwin AArch64, and getauxval/prctl via std.os.linux (direct syscalls, no libc) on Linux for AArch64, PPC, S390x, RISC-V, and LoongArch. Split into per-architecture files under src/detect/ for maintainability.
11 lines
399 B
Zig
11 lines
399 B
Zig
/// Reads from the ELF auxiliary vector (set by the kernel at process
|
|
/// start). Does not call into libc.
|
|
pub inline fn getauxval(key: usize) usize {
|
|
return @import("std").os.linux.getauxval(key);
|
|
}
|
|
|
|
/// Direct syscall wrapper for prctl(2).
|
|
pub inline fn prctl(option: i32, a2: usize, a3: usize, a4: usize, a5: usize) usize {
|
|
return @import("std").os.linux.prctl(option, a2, a3, a4, a5);
|
|
}
|