Skip to content

Commit

Permalink
compiler_rt: Update x86_cpu_model.zig to latest zig master
Browse files Browse the repository at this point in the history
- Use pointers in export builtin
- Update names for Type enum tag
  • Loading branch information
lacc97 committed Jan 19, 2025
1 parent 96480a5 commit d4b8c7d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/compiler_rt/x86_cpu_model.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ comptime {
const linkage: std.builtin.GlobalLinkage = common.linkage;
const visibility: std.builtin.SymbolVisibility = if (linkage != .internal) .hidden else .default;

@export(cpu, .{ .name = "__cpu_model", .linkage = linkage, .visibility = visibility });
@export(cpu_extra_features, .{ .name = "__cpu_features2", .linkage = linkage, .visibility = visibility });
@export(init, .{ .name = "__cpu_indicator_init", .linkage = linkage, .visibility = visibility });
@export(&cpu, .{ .name = "__cpu_model", .linkage = linkage, .visibility = visibility });
@export(&cpu_extra_features, .{ .name = "__cpu_features2", .linkage = linkage, .visibility = visibility });
@export(&init, .{ .name = "__cpu_indicator_init", .linkage = linkage, .visibility = visibility });
}

var cpu: Model = .{};
Expand All @@ -55,7 +55,7 @@ fn init() callconv(.C) c_int {
x86.detectNativeFeatures(&detected, builtin.os.tag);

var features = std.mem.zeroes(FeatureSet);
inline for (@typeInfo(Target.x86.Feature).Enum.fields) |f| {
inline for (@typeInfo(Target.x86.Feature).@"enum".fields) |f| {
const index: Target.Cpu.Feature.Set.Index = f.value;
if (comptime !@hasField(Feature, f.name)) continue;
if (detected.isEnabled(index)) setFeature(&features, @field(Feature, f.name));
Expand Down Expand Up @@ -120,7 +120,7 @@ const Model = extern struct {

const FeatureSet = [feature_set_size]u32;
comptime {
for (@typeInfo(Feature).Enum.fields) |f| {
for (@typeInfo(Feature).@"enum".fields) |f| {
if (f.value >= @bitSizeOf(FeatureSet))
@compileError(@import("std").fmt.comptimePrint("Feature.{s} ({}) bitindex too large", .{ f.name, f.value }));
}
Expand All @@ -143,7 +143,7 @@ const Feature = @import("cpu_model/x86.zig").Feature;

const feature_set_size = blk: {
var max_index: comptime_int = 0;
for (@typeInfo(Feature).Enum.fields) |f| {
for (@typeInfo(Feature).@"enum".fields) |f| {
if (f.value > max_index) max_index = f.value;
}
break :blk (max_index + 32) / 32;
Expand All @@ -169,7 +169,7 @@ comptime {

var errors: []const u8 = "";

for (@typeInfo(Feature).Enum.fields) |field| {
for (@typeInfo(Feature).@"enum".fields) |field| {
if (ignored.has(field.name)) {
if (@hasField(Target.x86.Feature, field.name)) errors = errors ++ std.fmt.comptimePrint(
"\n feature `{s}' present in std.Target.x86.Feature but marked for ignore in compiler-rt",
Expand Down

0 comments on commit d4b8c7d

Please sign in to comment.