Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

S390xCpuinfoImpl

linux.S390xCpuinfoImpl
const S390xCpuinfoImpl = struct

File

lib/std/zig/system/linux.zig:195

Code

const S390xCpuinfoImpl = struct {
    model: ?*const Target.Cpu.Model = null,

    const cpu_names = .{
        // z900: 2064, 2066
        // z990: 2084, 2086
        // z9: 2094, 2096

        .{ "2097", &Target.s390x.cpu.z10 },
        .{ "2098", &Target.s390x.cpu.z10 },
        .{ "2817", &Target.s390x.cpu.z196 },
        .{ "2818", &Target.s390x.cpu.z196 },
        .{ "2827", &Target.s390x.cpu.zEC12 },
        .{ "2828", &Target.s390x.cpu.zEC12 },
        .{ "2964", &Target.s390x.cpu.z13 },
        .{ "2965", &Target.s390x.cpu.z13 },
        .{ "3906", &Target.s390x.cpu.z14 },
        .{ "3907", &Target.s390x.cpu.z14 },
        .{ "8561", &Target.s390x.cpu.z15 },
        .{ "8562", &Target.s390x.cpu.z15 },
        .{ "3931", &Target.s390x.cpu.z16 },
        .{ "3932", &Target.s390x.cpu.z16 },
        .{ "9175", &Target.s390x.cpu.z17 },
        .{ "9176", &Target.s390x.cpu.z17 },
    };

    fn line_hook(self: *S390xCpuinfoImpl, key: []const u8, value: []const u8) !bool {
        if (mem.eql(u8, key, "machine")) {
            inline for (cpu_names) |pair| {
                if (mem.eql(u8, value, pair[0])) {
                    self.model = pair[1];
                    break;
                }
            }

            return false;
        }

        return true;
    }

    fn finalize(self: *const S390xCpuinfoImpl, arch: Target.Cpu.Arch) ?Target.Cpu {
        const model = self.model orelse return null;
        return Target.Cpu{
            .arch = arch,
            .model = model,
            .features = model.features,
        };
    }
}