-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
os-linuxLinuxLinuxstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Lines 7271 to 7331 in eac7fd4
| // TODO: Add the rest of the AUDIT defines? | |
| pub const AUDIT = struct { | |
| pub const ARCH = enum(u32) { | |
| const @"64BIT" = 0x80000000; | |
| const LE = 0x40000000; | |
| pub const current: AUDIT.ARCH = switch (native_arch) { | |
| .x86 => .X86, | |
| .x86_64 => .X86_64, | |
| .aarch64 => .AARCH64, | |
| .arm, .thumb => .ARM, | |
| .riscv64 => .RISCV64, | |
| .sparc64 => .SPARC64, | |
| .mips => .MIPS, | |
| .mipsel => .MIPSEL, | |
| .powerpc => .PPC, | |
| .powerpc64 => .PPC64, | |
| .powerpc64le => .PPC64LE, | |
| else => @compileError("unsupported architecture"), | |
| }; | |
| AARCH64 = toAudit(.aarch64), | |
| ARM = toAudit(.arm), | |
| ARMEB = toAudit(.armeb), | |
| CSKY = toAudit(.csky), | |
| HEXAGON = @intFromEnum(std.elf.EM.HEXAGON), | |
| X86 = toAudit(.x86), | |
| M68K = toAudit(.m68k), | |
| MIPS = toAudit(.mips), | |
| MIPSEL = toAudit(.mips) | LE, | |
| MIPS64 = toAudit(.mips64), | |
| MIPSEL64 = toAudit(.mips64) | LE, | |
| PPC = toAudit(.powerpc), | |
| PPC64 = toAudit(.powerpc64), | |
| PPC64LE = toAudit(.powerpc64le), | |
| RISCV32 = toAudit(.riscv32), | |
| RISCV64 = toAudit(.riscv64), | |
| S390X = toAudit(.s390x), | |
| SPARC = toAudit(.sparc), | |
| SPARC64 = toAudit(.sparc64), | |
| X86_64 = toAudit(.x86_64), | |
| fn toAudit(arch: std.Target.Cpu.Arch) u32 { | |
| var res: u32 = @intFromEnum(arch.toElfMachine()); | |
| if (arch.endian() == .little) res |= LE; | |
| switch (arch) { | |
| .aarch64, | |
| .mips64, | |
| .mips64el, | |
| .powerpc64, | |
| .powerpc64le, | |
| .riscv64, | |
| .sparc64, | |
| .x86_64, | |
| => res |= @"64BIT", | |
| else => {}, | |
| } | |
| return res; | |
| } | |
| }; | |
| }; |
There are two problems with this code:
- Implementing the bindings in terms of
std.Target.Cpu.Archmapped tostd.elf.EMis too clever. There is not a 1:1 mapping here; it would at least need to take anstd.Target.Abitoo. But really, just usestd.elf.EM. - Detection for
currentis broken for cases where the ABI affects the decision. It's also missing some architectures.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
os-linuxLinuxLinuxstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.