Cpuid: check x86 cpu features at runtime

Simple wrapper.

Usage:

build.zig:

exe.addImport("cpuid", b.dependency("cpuid", .{}).module("cpuid"));

your source file:

const std = @import("std");
const cpuid = @import("cpuid");

pub fn main() !void {
    // get current CPU features
    const f = cpuid.Features.get();

    // check whether SSE is available
    const has_sse = f.has(.sse);
    _ = has_sse;

    // print all features to stderr
    std.debug.print("{}\n", .{f});
}
7 Likes