feature. See also
. The project being documented here (as the example) is the Zig library itself.
linux.PowerpcCpuinfoImpl
const PowerpcCpuinfoImpl = struct
File
Code
const PowerpcCpuinfoImpl = struct {
model: ?*const Target.Cpu.Model = null,
const cpu_names = .{
.{ "604e", &Target.powerpc.cpu.@"604e" },
.{ "604", &Target.powerpc.cpu.@"604" },
.{ "7400", &Target.powerpc.cpu.@"7400" },
.{ "7410", &Target.powerpc.cpu.@"7400" },
.{ "7447", &Target.powerpc.cpu.@"7400" },
.{ "7455", &Target.powerpc.cpu.@"7450" },
.{ "G4", &Target.powerpc.cpu.g4 },
.{ "POWER4", &Target.powerpc.cpu.@"970" },
.{ "PPC970FX", &Target.powerpc.cpu.@"970" },
.{ "PPC970MP", &Target.powerpc.cpu.@"970" },
.{ "G5", &Target.powerpc.cpu.g5 },
.{ "POWER5", &Target.powerpc.cpu.g5 },
.{ "A2", &Target.powerpc.cpu.a2 },
.{ "POWER6", &Target.powerpc.cpu.pwr6 },
.{ "POWER7", &Target.powerpc.cpu.pwr7 },
.{ "POWER8", &Target.powerpc.cpu.pwr8 },
.{ "POWER8E", &Target.powerpc.cpu.pwr8 },
.{ "POWER8NVL", &Target.powerpc.cpu.pwr8 },
.{ "POWER9", &Target.powerpc.cpu.pwr9 },
.{ "POWER10", &Target.powerpc.cpu.pwr10 },
.{ "POWER11", &Target.powerpc.cpu.pwr11 },
};
fn line_hook(self: *PowerpcCpuinfoImpl, key: []const u8, value: []const u8) !bool {
if (mem.eql(u8, key, "cpu")) {
// info.
inline for (cpu_names) |pair| {
const end_index = mem.findAny(u8, value, ", ") orelse value.len;
if (mem.eql(u8, value[0..end_index], pair[0])) {
self.model = pair[1];
break;
}
}
return false;
}
return true;
}
fn finalize(self: *const PowerpcCpuinfoImpl, arch: Target.Cpu.Arch) ?Target.Cpu {
const model = self.model orelse return null;
return Target.Cpu{
.arch = arch,
.model = model,
.features = model.features,
};
}
}