authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-09 20:53:37+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-15 10:55:46+02:00
logac9ca7d30c03f3111b6bb0a0bacade97d1f6f6df
tree7aca7bd412b8ed9e823c74332e174e4bc1fad980
parent65affb1c225a034058fb2cbe32c289019b463ebf
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.coff: Remove MachineType.fromTargetCpuArch().

This does the same thing as std.Target.Cpu.Arch.toCoffMachine(). Just use that.

2 files changed, 1 insertions(+), 18 deletions(-)

lib/std/coff.zig-17
......@@ -1061,23 +1061,6 @@ pub const MachineType = enum(u16) {
10611061
10621062 _,
10631063
1064 pub fn fromTargetCpuArch(arch: std.Target.Cpu.Arch) MachineType {
1065 return switch (arch) {
1066 .arm => .ARM,
1067 .powerpc => .POWERPC,
1068 .riscv32 => .RISCV32,
1069 .thumb => .Thumb,
1070 .x86 => .I386,
1071 .aarch64 => .ARM64,
1072 .riscv64 => .RISCV64,
1073 .x86_64 => .X64,
1074 .loongarch32 => .LOONGARCH32,
1075 .loongarch64 => .LOONGARCH64,
1076 // there's cases we don't (yet) handle
1077 else => unreachable,
1078 };
1079 }
1080
10811064 pub fn toTargetCpuArch(machine_type: MachineType) ?std.Target.Cpu.Arch {
10821065 return switch (machine_type) {
10831066 .ARM => .arm,
src/link/Coff.zig+1-1
......@@ -2259,7 +2259,7 @@ fn writeHeader(self: *Coff) !void {
22592259 const timestamp = if (self.repro) 0 else std.time.timestamp();
22602260 const size_of_optional_header = @as(u16, @intCast(self.getOptionalHeaderSize() + self.getDataDirectoryHeadersSize()));
22612261 var coff_header = coff.CoffHeader{
2262 .machine = coff.MachineType.fromTargetCpuArch(target.cpu.arch),
2262 .machine = target.cpu.arch.toCoffMachine(),
22632263 .number_of_sections = @as(u16, @intCast(self.sections.slice().len)), // TODO what if we prune a section
22642264 .time_date_stamp = @as(u32, @truncate(@as(u64, @bitCast(timestamp)))),
22652265 .pointer_to_symbol_table = self.strtab_offset orelse 0,