diff options
Diffstat (limited to 'lib')
377 files changed, 3408 insertions, 3043 deletions
@@ -26,27 +26,27 @@ const is_freestanding = switch (native_os) { comptime { if (is_freestanding and is_wasm and builtin.link_libc) { - @export(wasm_start, .{ .name = "_start", .linkage = .strong }); + @export(&wasm_start, .{ .name = "_start", .linkage = .strong }); } if (builtin.link_libc) { - @export(strcmp, .{ .name = "strcmp", .linkage = .strong }); - @export(strncmp, .{ .name = "strncmp", .linkage = .strong }); - @export(strerror, .{ .name = "strerror", .linkage = .strong }); - @export(strlen, .{ .name = "strlen", .linkage = .strong }); - @export(strcpy, .{ .name = "strcpy", .linkage = .strong }); - @export(strncpy, .{ .name = "strncpy", .linkage = .strong }); - @export(strcat, .{ .name = "strcat", .linkage = .strong }); - @export(strncat, .{ .name = "strncat", .linkage = .strong }); + @export(&strcmp, .{ .name = "strcmp", .linkage = .strong }); + @export(&strncmp, .{ .name = "strncmp", .linkage = .strong }); + @export(&strerror, .{ .name = "strerror", .linkage = .strong }); + @export(&strlen, .{ .name = "strlen", .linkage = .strong }); + @export(&strcpy, .{ .name = "strcpy", .linkage = .strong }); + @export(&strncpy, .{ .name = "strncpy", .linkage = .strong }); + @export(&strcat, .{ .name = "strcat", .linkage = .strong }); + @export(&strncat, .{ .name = "strncat", .linkage = .strong }); } else if (is_msvc) { - @export(_fltused, .{ .name = "_fltused", .linkage = .strong }); + @export(&_fltused, .{ .name = "_fltused", .linkage = .strong }); } } // Avoid dragging in the runtime safety mechanisms into this .o file, // unless we're trying to test this file. pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { - @setCold(true); + @branchHint(.cold); _ = error_return_trace; if (builtin.is_test) { std.debug.panic("{s}", .{msg}); diff --git a/lib/compiler/aro/aro/Attribute.zig b/lib/compiler/aro/aro/Attribute.zig index e6fcb8e8cf..4671028b8f 100644 --- a/lib/compiler/aro/aro/Attribute.zig +++ b/lib/compiler/aro/aro/Attribute.zig @@ -67,7 +67,7 @@ pub fn requiredArgCount(attr: Tag) u32 { comptime { const fields = std.meta.fields(@field(attributes, @tagName(tag))); for (fields) |arg_field| { - if (!mem.eql(u8, arg_field.name, "__name_tok") and @typeInfo(arg_field.type) != .Optional) needed += 1; + if (!mem.eql(u8, arg_field.name, "__name_tok") and @typeInfo(arg_field.type) != .optional) needed += 1; } } return needed; @@ -93,7 +93,7 @@ pub fn maxArgCount(attr: Tag) u32 { fn UnwrapOptional(comptime T: type) type { return switch (@typeInfo(T)) { - .Optional => |optional| optional.child, + .optional => |optional| optional.child, else => T, }; } @@ -110,7 +110,7 @@ pub const Formatting = struct { if (fields.len == 0) unreachable; const Unwrapped = UnwrapOptional(fields[0].type); - if (@typeInfo(Unwrapped) != .Enum) unreachable; + if (@typeInfo(Unwrapped) != .@"enum") unreachable; return if (Unwrapped.opts.enum_kind == .identifier) "'" else "\""; }, @@ -127,9 +127,9 @@ pub const Formatting = struct { if (fields.len == 0) unreachable; const Unwrapped = UnwrapOptional(fields[0].type); - if (@typeInfo(Unwrapped) != .Enum) unreachable; + if (@typeInfo(Unwrapped) != .@"enum") unreachable; - const enum_fields = @typeInfo(Unwrapped).Enum.fields; + const enum_fields = @typeInfo(Unwrapped).@"enum".fields; @setEvalBranchQuota(3000); const quote = comptime quoteChar(@enumFromInt(@intFromEnum(tag))); comptime var values: []const u8 = quote ++ enum_fields[0].name ++ quote; @@ -152,7 +152,7 @@ pub fn wantsIdentEnum(attr: Tag) bool { if (fields.len == 0) return false; const Unwrapped = UnwrapOptional(fields[0].type); - if (@typeInfo(Unwrapped) != .Enum) return false; + if (@typeInfo(Unwrapped) != .@"enum") return false; return Unwrapped.opts.enum_kind == .identifier; }, @@ -165,7 +165,7 @@ pub fn diagnoseIdent(attr: Tag, arguments: *Arguments, ident: []const u8) ?Diagn const fields = std.meta.fields(@field(attributes, @tagName(tag))); if (fields.len == 0) unreachable; const Unwrapped = UnwrapOptional(fields[0].type); - if (@typeInfo(Unwrapped) != .Enum) unreachable; + if (@typeInfo(Unwrapped) != .@"enum") unreachable; if (std.meta.stringToEnum(Unwrapped, normalize(ident))) |enum_val| { @field(@field(arguments, @tagName(tag)), fields[0].name) = enum_val; return null; @@ -239,7 +239,7 @@ fn diagnoseField( const key = p.comp.interner.get(res.val.ref()); switch (key) { .int => { - if (@typeInfo(Wanted) == .Int) { + if (@typeInfo(Wanted) == .int) { @field(@field(arguments, decl.name), field.name) = res.val.toInt(Wanted, p.comp) orelse return .{ .tag = .attribute_int_out_of_range, .extra = .{ .str = try res.str(p) }, @@ -258,7 +258,7 @@ fn diagnoseField( } @field(@field(arguments, decl.name), field.name) = try p.removeNull(res.val); return null; - } else if (@typeInfo(Wanted) == .Enum and @hasDecl(Wanted, "opts") and Wanted.opts.enum_kind == .string) { + } else if (@typeInfo(Wanted) == .@"enum" and @hasDecl(Wanted, "opts") and Wanted.opts.enum_kind == .string) { const str = bytes[0 .. bytes.len - 1]; if (std.meta.stringToEnum(Wanted, str)) |enum_val| { @field(@field(arguments, decl.name), field.name) = enum_val; @@ -293,7 +293,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess Alignment => .alignment, CallingConvention => .identifier, else => switch (@typeInfo(Expected)) { - .Enum => if (Expected.opts.enum_kind == .string) .string else .identifier, + .@"enum" => if (Expected.opts.enum_kind == .string) .string else .identifier, else => unreachable, }, }, .actual = actual } }, @@ -303,7 +303,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess pub fn diagnose(attr: Tag, arguments: *Arguments, arg_idx: u32, res: Parser.Result, node: Tree.Node, p: *Parser) !?Diagnostics.Message { switch (attr) { inline else => |tag| { - const decl = @typeInfo(attributes).Struct.decls[@intFromEnum(tag)]; + const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)]; const max_arg_count = comptime maxArgCount(tag); if (arg_idx >= max_arg_count) return Diagnostics.Message{ .tag = .attribute_too_many_args, @@ -641,7 +641,7 @@ const attributes = struct { pub const Tag = std.meta.DeclEnum(attributes); pub const Arguments = blk: { - const decls = @typeInfo(attributes).Struct.decls; + const decls = @typeInfo(attributes).@"struct".decls; var union_fields: [decls.len]ZigType.UnionField = undefined; for (decls, &union_fields) |decl, *field| { field.* = .{ @@ -652,7 +652,7 @@ pub const Arguments = blk: { } break :blk @Type(.{ - .Union = .{ + .@"union" = .{ .layout = .auto, .tag_type = null, .fields = &union_fields, @@ -662,7 +662,7 @@ pub const Arguments = blk: { }; pub fn ArgumentsForTag(comptime tag: Tag) type { - const decl = @typeInfo(attributes).Struct.decls[@intFromEnum(tag)]; + const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)]; return @field(attributes, decl.name); } diff --git a/lib/compiler/aro/aro/Compilation.zig b/lib/compiler/aro/aro/Compilation.zig index d361f42c90..f04df5001e 100644 --- a/lib/compiler/aro/aro/Compilation.zig +++ b/lib/compiler/aro/aro/Compilation.zig @@ -61,7 +61,7 @@ pub const Environment = struct { var env: Environment = .{}; errdefer env.deinit(allocator); - inline for (@typeInfo(@TypeOf(env)).Struct.fields) |field| { + inline for (@typeInfo(@TypeOf(env)).@"struct".fields) |field| { std.debug.assert(@field(env, field.name) == null); var env_var_buf: [field.name.len]u8 = undefined; @@ -78,7 +78,7 @@ pub const Environment = struct { /// Use this only if environment slices were allocated with `allocator` (such as via `loadAll`) pub fn deinit(self: *Environment, allocator: std.mem.Allocator) void { - inline for (@typeInfo(@TypeOf(self.*)).Struct.fields) |field| { + inline for (@typeInfo(@TypeOf(self.*)).@"struct".fields) |field| { if (@field(self, field.name)) |slice| { allocator.free(slice); } diff --git a/lib/compiler/aro/aro/Driver/Filesystem.zig b/lib/compiler/aro/aro/Driver/Filesystem.zig index 3889ec73b3..a81f313753 100644 --- a/lib/compiler/aro/aro/Driver/Filesystem.zig +++ b/lib/compiler/aro/aro/Driver/Filesystem.zig @@ -4,7 +4,7 @@ const builtin = @import("builtin"); const is_windows = builtin.os.tag == .windows; fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8) ?[]const u8 { - @setCold(true); + @branchHint(.cold); for (entries) |entry| { if (mem.eql(u8, entry.path, path)) { const len = @min(entry.contents.len, buf.len); @@ -16,7 +16,7 @@ fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8) } fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, path: ?[]const u8, buf: []u8) ?[]const u8 { - @setCold(true); + @branchHint(.cold); if (mem.indexOfScalar(u8, name, '/') != null) { @memcpy(buf[0..name.len], name); return buf[0..name.len]; @@ -35,7 +35,7 @@ fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, pa } fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool { - @setCold(true); + @branchHint(.cold); for (entries) |entry| { if (mem.eql(u8, entry.path, path)) { return entry.executable; @@ -45,7 +45,7 @@ fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool { } fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool { - @setCold(true); + @branchHint(.cold); var buf: [std.fs.max_path_bytes]u8 = undefined; var fib = std.heap.FixedBufferAllocator.init(&buf); const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false; diff --git a/lib/compiler/aro/aro/Parser.zig b/lib/compiler/aro/aro/Parser.zig index 1cb5e18934..d8d6f9d71c 100644 --- a/lib/compiler/aro/aro/Parser.zig +++ b/lib/compiler/aro/aro/Parser.zig @@ -385,12 +385,12 @@ fn errExpectedToken(p: *Parser, expected: Token.Id, actual: Token.Id) Error { } pub fn errStr(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, str: []const u8) Compilation.Error!void { - @setCold(true); + @branchHint(.cold); return p.errExtra(tag, tok_i, .{ .str = str }); } pub fn errExtra(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, extra: Diagnostics.Message.Extra) Compilation.Error!void { - @setCold(true); + @branchHint(.cold); const tok = p.pp.tokens.get(tok_i); var loc = tok.loc; if (tok_i != 0 and tok.id == .eof) { @@ -407,12 +407,12 @@ pub fn errExtra(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, extra: Diag } pub fn errTok(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex) Compilation.Error!void { - @setCold(true); + @branchHint(.cold); return p.errExtra(tag, tok_i, .{ .none = {} }); } pub fn err(p: *Parser, tag: Diagnostics.Tag) Compilation.Error!void { - @setCold(true); + @branchHint(.cold); return p.errExtra(tag, p.tok_i, .{ .none = {} }); } @@ -638,7 +638,7 @@ fn pragma(p: *Parser) Compilation.Error!bool { /// Issue errors for top-level definitions whose type was never completed. fn diagnoseIncompleteDefinitions(p: *Parser) !void { - @setCold(true); + @branchHint(.cold); const node_slices = p.nodes.slice(); const tags = node_slices.items(.tag); diff --git a/lib/compiler/aro/aro/Tree.zig b/lib/compiler/aro/aro/Tree.zig index efd5a8b56d..e353beaebc 100644 --- a/lib/compiler/aro/aro/Tree.zig +++ b/lib/compiler/aro/aro/Tree.zig @@ -707,7 +707,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void { switch (attr.tag) { inline else => |tag| { const args = @field(attr.args, @tagName(tag)); - const fields = @typeInfo(@TypeOf(args)).Struct.fields; + const fields = @typeInfo(@TypeOf(args)).@"struct".fields; if (fields.len == 0) { try writer.writeByte('\n'); return; @@ -724,7 +724,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void { Interner.Ref => try writer.print("\"{s}\"", .{tree.interner.get(@field(args, f.name)).bytes}), ?Interner.Ref => try writer.print("\"{?s}\"", .{if (@field(args, f.name)) |str| tree.interner.get(str).bytes else null}), else => switch (@typeInfo(f.type)) { - .Enum => try writer.writeAll(@tagName(@field(args, f.name))), + .@"enum" => try writer.writeAll(@tagName(@field(args, f.name))), else => try writer.print("{any}", .{@field(args, f.name)}), }, } diff --git a/lib/compiler/aro/aro/Value.zig b/lib/compiler/aro/aro/Value.zig index 45d49c99ff..2dd9a86abe 100644 --- a/lib/compiler/aro/aro/Value.zig +++ b/lib/compiler/aro/aro/Value.zig @@ -24,7 +24,7 @@ pub fn intern(comp: *Compilation, k: Interner.Key) !Value { pub fn int(i: anytype, comp: *Compilation) !Value { const info = @typeInfo(@TypeOf(i)); - if (info == .ComptimeInt or info.Int.signedness == .unsigned) { + if (info == .comptime_int or info.int.signedness == .unsigned) { return intern(comp, .{ .int = .{ .u64 = i } }); } else { return intern(comp, .{ .int = .{ .i64 = i } }); diff --git a/lib/compiler/aro/backend/Interner.zig b/lib/compiler/aro/backend/Interner.zig index 028b45fa9e..45b6e51fd9 100644 --- a/lib/compiler/aro/backend/Interner.zig +++ b/lib/compiler/aro/backend/Interner.zig @@ -505,7 +505,7 @@ pub fn put(i: *Interner, gpa: Allocator, key: Key) !Ref { }); }, .record_ty => |elems| { - try i.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.Record).Struct.fields.len + + try i.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.Record).@"struct".fields.len + elems.len); i.items.appendAssumeCapacity(.{ .tag = .record_ty, @@ -527,14 +527,14 @@ pub fn put(i: *Interner, gpa: Allocator, key: Key) !Ref { } fn addExtra(i: *Interner, gpa: Allocator, extra: anytype) Allocator.Error!u32 { - const fields = @typeInfo(@TypeOf(extra)).Struct.fields; + const fields = @typeInfo(@TypeOf(extra)).@"struct".fields; try i.extra.ensureUnusedCapacity(gpa, fields.len); return i.addExtraAssumeCapacity(extra); } fn addExtraAssumeCapacity(i: *Interner, extra: anytype) u32 { const result = @as(u32, @intCast(i.extra.items.len)); - inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { + inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| { i.extra.appendAssumeCapacity(switch (field.type) { Ref => @intFromEnum(@field(extra, field.name)), u32 => @field(extra, field.name), @@ -631,7 +631,7 @@ fn extraData(i: *const Interner, comptime T: type, index: usize) T { fn extraDataTrail(i: *const Interner, comptime T: type, index: usize) struct { data: T, end: u32 } { var result: T = undefined; - const fields = @typeInfo(T).Struct.fields; + const fields = @typeInfo(T).@"struct".fields; inline for (fields, 0..) |field, field_i| { const int32 = i.extra.items[field_i + index]; @field(result, field.name) = switch (field.type) { diff --git a/lib/compiler/aro_translate_c.zig b/lib/compiler/aro_translate_c.zig index ad7584c726..692786c2be 100644 --- a/lib/compiler/aro_translate_c.zig +++ b/lib/compiler/aro_translate_c.zig @@ -168,7 +168,7 @@ pub fn translate( context.pattern_list.deinit(gpa); } - inline for (@typeInfo(std.zig.c_builtins).Struct.decls) |decl| { + inline for (@typeInfo(std.zig.c_builtins).@"struct".decls) |decl| { const builtin_fn = try ZigTag.pub_var_simple.create(arena, .{ .name = decl.name, .init = try ZigTag.import_c_builtin.create(arena, decl.name), diff --git a/lib/compiler/resinator/bmp.zig b/lib/compiler/resinator/bmp.zig index 134ee81966..03a8638ad7 100644 --- a/lib/compiler/resinator/bmp.zig +++ b/lib/compiler/resinator/bmp.zig @@ -224,7 +224,7 @@ pub const Compression = enum(u32) { }; fn structFieldsLittleToNative(comptime T: type, x: *T) void { - inline for (@typeInfo(T).Struct.fields) |field| { + inline for (@typeInfo(T).@"struct".fields) |field| { @field(x, field.name) = std.mem.littleToNative(field.type, @field(x, field.name)); } } diff --git a/lib/compiler/resinator/code_pages.zig b/lib/compiler/resinator/code_pages.zig index cacd5acded..4813167811 100644 --- a/lib/compiler/resinator/code_pages.zig +++ b/lib/compiler/resinator/code_pages.zig @@ -259,7 +259,7 @@ pub const CodePage = enum(u16) { pub fn getByIdentifier(identifier: u16) !CodePage { // There's probably a more efficient way to do this (e.g. ComptimeHashMap?) but // this should be fine, especially since this function likely won't be called much. - inline for (@typeInfo(CodePage).Enum.fields) |enumField| { + inline for (@typeInfo(CodePage).@"enum".fields) |enumField| { if (identifier == enumField.value) { return @field(CodePage, enumField.name); } diff --git a/lib/compiler/resinator/errors.zig b/lib/compiler/resinator/errors.zig index 5cfa766ac1..90744e9934 100644 --- a/lib/compiler/resinator/errors.zig +++ b/lib/compiler/resinator/errors.zig @@ -250,7 +250,7 @@ pub const ErrorDetails = struct { }); pub fn writeCommaSeparated(self: ExpectedTypes, writer: anytype) !void { - const struct_info = @typeInfo(ExpectedTypes).Struct; + const struct_info = @typeInfo(ExpectedTypes).@"struct"; const num_real_fields = struct_info.fields.len - 1; const num_padding_bits = @bitSizeOf(ExpectedTypes) - num_real_fields; const mask = std.math.maxInt(struct_info.backing_integer.?) >> num_padding_bits; diff --git a/lib/compiler/resinator/ico.zig b/lib/compiler/resinator/ico.zig index 664def038b..e6de1d469e 100644 --- a/lib/compiler/resinator/ico.zig +++ b/lib/compiler/resinator/ico.zig @@ -14,7 +14,7 @@ pub fn read(allocator: std.mem.Allocator, reader: anytype, max_size: u64) ReadEr // Some Reader implementations have an empty ReadError error set which would // cause 'unreachable else' if we tried to use an else in the switch, so we // need to detect this case and not try to translate to ReadError - const empty_reader_errorset = @typeInfo(@TypeOf(reader).Error).ErrorSet == null or @typeInfo(@TypeOf(reader).Error).ErrorSet.?.len == 0; + const empty_reader_errorset = @typeInfo(@TypeOf(reader).Error).error_set == null or @typeInfo(@TypeOf(reader).Error).error_set.?.len == 0; if (empty_reader_errorset) { return readAnyError(allocator, reader, max_size) catch |err| switch (err) { error.EndOfStream => error.UnexpectedEOF, diff --git a/lib/compiler/resinator/lang.zig b/lib/compiler/resinator/lang.zig index 51843cff87..bf36680710 100644 --- a/lib/compiler/resinator/lang.zig +++ b/lib/compiler/resinator/lang.zig @@ -87,7 +87,7 @@ pub fn tagToId(tag: []const u8) error{InvalidLanguageTag}!?LanguageId { if (parsed.multiple_suffixes) return null; const longest_known_tag = comptime blk: { var len = 0; - for (@typeInfo(LanguageId).Enum.fields) |field| { + for (@typeInfo(LanguageId).@"enum".fields) |field| { if (field.name.len > len) len = field.name.len; } break :blk len; diff --git a/lib/compiler/resinator/main.zig b/lib/compiler/resinator/main.zig index e056e80252..c09801096c 100644 --- a/lib/compiler/resinator/main.zig +++ b/lib/compiler/resinator/main.zig @@ -421,7 +421,7 @@ fn cliDiagnosticsToErrorBundle( gpa: std.mem.Allocator, diagnostics: *cli.Diagnostics, ) !ErrorBundle { - @setCold(true); + @branchHint(.cold); var bundle: ErrorBundle.Wip = undefined; try bundle.init(gpa); @@ -468,7 +468,7 @@ fn diagnosticsToErrorBundle( diagnostics: *Diagnostics, mappings: SourceMappings, ) !ErrorBundle { - @setCold(true); + @branchHint(.cold); var bundle: ErrorBundle.Wip = undefined; try bundle.init(gpa); @@ -559,7 +559,7 @@ fn flushErrorMessageIntoBundle(wip: *ErrorBundle.Wip, msg: ErrorBundle.ErrorMess } fn errorStringToErrorBundle(allocator: std.mem.Allocator, comptime format: []const u8, args: anytype) !ErrorBundle { - @setCold(true); + @branchHint(.cold); var bundle: ErrorBundle.Wip = undefined; try bundle.init(allocator); errdefer bundle.deinit(); @@ -574,7 +574,7 @@ fn aroDiagnosticsToErrorBundle( fail_msg: []const u8, comp: *aro.Compilation, ) !ErrorBundle { - @setCold(true); + @branchHint(.cold); var bundle: ErrorBundle.Wip = undefined; try bundle.init(gpa); diff --git a/lib/compiler/std-docs.zig b/lib/compiler/std-docs.zig index 4cfdf9b1e3..0382bbf971 100644 --- a/lib/compiler/std-docs.zig +++ b/lib/compiler/std-docs.zig @@ -4,6 +4,7 @@ const mem = std.mem; const io = std.io; const Allocator = std.mem.Allocator; const assert = std.debug.assert; +const Cache = std.Build.Cache; fn usage() noreturn { io.getStdOut().writeAll( @@ -232,9 +233,18 @@ fn serveWasm( // Do the compilation every request, so that the user can edit the files // and see the changes without restarting the server. - const wasm_binary_path = try buildWasmBinary(arena, context, optimize_mode); + const wasm_base_path = try buildWasmBinary(arena, context, optimize_mode); + const bin_name = try std.zig.binNameAlloc(arena, .{ + .root_name = autodoc_root_name, + .target = std.zig.system.resolveTargetQuery(std.Build.parseTargetQuery(.{ + .arch_os_abi = autodoc_arch_os_abi, + .cpu_features = autodoc_cpu_features, + }) catch unreachable) catch unreachable, + .output_mode = .Exe, + }); // std.http.Server does not have a sendfile API yet. - const file_contents = try std.fs.cwd().readFileAlloc(gpa, wasm_binary_path, 10 * 1024 * 1024); + const bin_path = try wasm_base_path.join(arena, bin_name); + const file_contents = try bin_path.root_dir.handle.readFileAlloc(gpa, bin_path.sub_path, 10 * 1024 * 1024); defer gpa.free(file_contents); try request.respond(file_contents, .{ .extra_headers = &.{ @@ -244,37 +254,42 @@ fn serveWasm( }); } +const autodoc_root_name = "autodoc"; +const autodoc_arch_os_abi = "wasm32-freestanding"; +const autodoc_cpu_features = "baseline+atomics+bulk_memory+multivalue+mutable_globals+nontrapping_fptoint+reference_types+sign_ext"; + fn buildWasmBinary( arena: Allocator, context: *Context, optimize_mode: std.builtin.OptimizeMode, -) ![]const u8 { +) !Cache.Path { const gpa = context.gpa; var argv: std.ArrayListUnmanaged([]const u8) = .{}; try argv.appendSlice(arena, &.{ - context.zig_exe_path, - "build-exe", - "-fno-entry", - "-O", - @tagName(optimize_mode), - "-target", - "wasm32-freestanding", - "-mcpu", - "baseline+atomics+bulk_memory+multivalue+mutable_globals+nontrapping_fptoint+reference_types+sign_ext", - "--cache-dir", - context.global_cache_path, - "--global-cache-dir", - context.global_cache_path, - "--name", - "autodoc", - "-rdynamic", - "--dep", - "Walk", - try std.fmt.allocPrint(arena, "-Mroot={s}/docs/wasm/main.zig", .{context.zig_lib_directory}), - try std.fmt.allocPrint(arena, "-MWalk={s}/docs/wasm/Walk.zig", .{context.zig_lib_directory}), - "--listen=-", + context.zig_exe_path, // + "build-exe", // + "-fno-entry", // + "-O", @tagName(optimize_mode), // + "-target", autodoc_arch_os_abi, // + "-mcpu", autodoc_cpu_features, // + "--cache-dir", context.global_cache_path, // + "--global-cache-dir", context.global_cache_path, // + "--name", autodoc_root_name, // + "-rdynamic", // + "--dep", "Walk", // + try std.fmt.allocPrint( + arena, + "-Mroot={s}/docs/wasm/main.zig", + .{context.zig_lib_directory}, + ), + try std.fmt.allocPrint( + arena, + "-MWalk={s}/docs/wasm/Walk.zig", + .{context.zig_lib_directory}, + ), + "--listen=-", // }); var child = std.process.Child.init(argv.items, gpa); @@ -293,7 +308,7 @@ fn buildWasmBinary( try sendMessage(child.stdin.?, .exit); const Header = std.zig.Server.Message.Header; - var result: ?[]const u8 = null; + var result: ?Cache.Path = null; var result_error_bundle = std.zig.ErrorBundle.empty; const stdout = poller.fifo(.stdout); @@ -330,13 +345,19 @@ fn buildWasmBinary( .extra = extra_array, }; }, - .emit_bin_path => { - const EbpHdr = std.zig.Server.Message.EmitBinPath; - const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body)); - if (!ebp_hdr.flags.cache_hit) { + .emit_digest => { + const EmitDigest = std.zig.Server.Message.EmitDigest; + const emit_digest = @as(*align(1) const EmitDigest, @ptrCast(body)); + if (!emit_digest.flags.cache_hit) { std.log.info("source changes detected; rebuilt wasm component", .{}); } - result = try arena.dupe(u8, body[@sizeOf(EbpHdr)..]); + const digest = body[@sizeOf(EmitDigest)..][0..Cache.bin_digest_len]; + result = .{ + .root_dir = Cache.Directory.cwd(), + .sub_path = try std.fs.path.join(arena, &.{ + context.global_cache_path, "o" ++ std.fs.path.sep_str ++ Cache.binToHex(digest.*), + }), + }; }, else => {}, // ignore other messages } diff --git a/lib/compiler/test_runner.zig b/lib/compiler/test_runner.zig index 4be261912c..ac9629a57d 100644 --- a/lib/compiler/test_runner.zig +++ b/lib/compiler/test_runner.zig @@ -166,6 +166,7 @@ fn mainServer() !void { if (log_err_count != 0) @panic("error logs detected"); if (first) { first = false; + const entry_addr = @intFromPtr(test_fn.func); try server.serveU64Message(.fuzz_start_addr, entry_addr); } } @@ -265,7 +266,7 @@ fn mainTerminal() void { pub fn log( comptime message_level: std.log.Level, - comptime scope: @Type(.EnumLiteral), + comptime scope: @Type(.enum_literal), comptime format: []const u8, args: anytype, ) void { @@ -347,7 +348,6 @@ const FuzzerSlice = extern struct { }; var is_fuzz_test: bool = undefined; -var entry_addr: usize = 0; extern fn fuzzer_next() FuzzerSlice; extern fn fuzzer_init(cache_dir: FuzzerSlice) void; @@ -358,7 +358,6 @@ pub fn fuzzInput(options: testing.FuzzInputOptions) []const u8 { if (crippled) return ""; is_fuzz_test = true; if (builtin.fuzz) { - if (entry_addr == 0) entry_addr = @returnAddress(); return fuzzer_next().toSlice(); } if (options.corpus.len == 0) return ""; diff --git a/lib/compiler_rt/aarch64_outline_atomics.zig b/lib/compiler_rt/aarch64_outline_atomics.zig index c70fd81fc4..e920dbb4b9 100644 --- a/lib/compiler_rt/aarch64_outline_atomics.zig +++ b/lib/compiler_rt/aarch64_outline_atomics.zig @@ -2124,104 +2124,104 @@ fn __aarch64_cas16_acq_rel() align(16) callconv(.Naked) void { } comptime { - @export(__aarch64_cas1_relax, .{ .name = "__aarch64_cas1_relax", .linkage = linkage }); - @export(__aarch64_swp1_relax, .{ .name = "__aarch64_swp1_relax", .linkage = linkage }); - @export(__aarch64_ldadd1_relax, .{ .name = "__aarch64_ldadd1_relax", .linkage = linkage }); - @export(__aarch64_ldclr1_relax, .{ .name = "__aarch64_ldclr1_relax", .linkage = linkage }); - @export(__aarch64_ldeor1_relax, .{ .name = "__aarch64_ldeor1_relax", .linkage = linkage }); - @export(__aarch64_ldset1_relax, .{ .name = "__aarch64_ldset1_relax", .linkage = linkage }); - @export(__aarch64_cas1_acq, .{ .name = "__aarch64_cas1_acq", .linkage = linkage }); - @export(__aarch64_swp1_acq, .{ .name = "__aarch64_swp1_acq", .linkage = linkage }); - @export(__aarch64_ldadd1_acq, .{ .name = "__aarch64_ldadd1_acq", .linkage = linkage }); - @export(__aarch64_ldclr1_acq, .{ .name = "__aarch64_ldclr1_acq", .linkage = linkage }); - @export(__aarch64_ldeor1_acq, .{ .name = "__aarch64_ldeor1_acq", .linkage = linkage }); - @export(__aarch64_ldset1_acq, .{ .name = "__aarch64_ldset1_acq", .linkage = linkage }); - @export(__aarch64_cas1_rel, .{ .name = "__aarch64_cas1_rel", .linkage = linkage }); - @export(__aarch64_swp1_rel, .{ .name = "__aarch64_swp1_rel", .linkage = linkage }); - @export(__aarch64_ldadd1_rel, .{ .name = "__aarch64_ldadd1_rel", .linkage = linkage }); - @export(__aarch64_ldclr1_rel, .{ .name = "__aarch64_ldclr1_rel", .linkage = linkage }); - @export(__aarch64_ldeor1_rel, .{ .name = "__aarch64_ldeor1_rel", .linkage = linkage }); - @export(__aarch64_ldset1_rel, .{ .name = "__aarch64_ldset1_rel", .linkage = linkage }); - @export(__aarch64_cas1_acq_rel, .{ .name = "__aarch64_cas1_acq_rel", .linkage = linkage }); - @export(__aarch64_swp1_acq_rel, .{ .name = "__aarch64_swp1_acq_rel", .linkage = linkage }); - @export(__aarch64_ldadd1_acq_rel, .{ .name = "__aarch64_ldadd1_acq_rel", .linkage = linkage }); - @export(__aarch64_ldclr1_acq_rel, .{ .name = "__aarch64_ldclr1_acq_rel", .linkage = linkage }); - @export(__aarch64_ldeor1_acq_rel, .{ .name = "__aarch64_ldeor1_acq_rel", .linkage = linkage }); - @export(__aarch64_ldset1_acq_rel, .{ .name = "__aarch64_ldset1_acq_rel", .linkage = linkage }); - @export(__aarch64_cas2_relax, .{ .name = "__aarch64_cas2_relax", .linkage = linkage }); - @export(__aarch64_swp2_relax, .{ .name = "__aarch64_swp2_relax", .linkage = linkage }); - @export(__aarch64_ldadd2_relax, .{ .name = "__aarch64_ldadd2_relax", .linkage = linkage }); - @export(__aarch64_ldclr2_relax, .{ .name = "__aarch64_ldclr2_relax", .linkage = linkage }); - @export(__aarch64_ldeor2_relax, .{ .name = "__aarch64_ldeor2_relax", .linkage = linkage }); - @export(__aarch64_ldset2_relax, .{ .name = "__aarch64_ldset2_relax", .linkage = linkage }); - @export(__aarch64_cas2_acq, .{ .name = "__aarch64_cas2_acq", .linkage = linkage }); - @export(__aarch64_swp2_acq, .{ .name = "__aarch64_swp2_acq", .linkage = linkage }); - @export(__aarch64_ldadd2_acq, .{ .name = "__aarch64_ldadd2_acq", .linkage = linkage }); - @export(__aarch64_ldclr2_acq, .{ .name = "__aarch64_ldclr2_acq", .linkage = linkage }); - @export(__aarch64_ldeor2_acq, .{ .name = "__aarch64_ldeor2_acq", .linkage = linkage }); - @export(__aarch64_ldset2_acq, .{ .name = "__aarch64_ldset2_acq", .linkage = linkage }); - @export(__aarch64_cas2_rel, .{ .name = "__aarch64_cas2_rel", .linkage = linkage }); - @export(__aarch64_swp2_rel, .{ .name = "__aarch64_swp2_rel", .linkage = linkage }); - @export(__aarch64_ldadd2_rel, .{ .name = "__aarch64_ldadd2_rel", .linkage = linkage }); - @export(__aarch64_ldclr2_rel, .{ .name = "__aarch64_ldclr2_rel", .linkage = linkage }); - @export(__aarch64_ldeor2_rel, .{ .name = "__aarch64_ldeor2_rel", .linkage = linkage }); - @export(__aarch64_ldset2_rel, .{ .name = "__aarch64_ldset2_rel", .linkage = linkage }); - @export(__aarch64_cas2_acq_rel, .{ .name = "__aarch64_cas2_acq_rel", .linkage = linkage }); - @export(__aarch64_swp2_acq_rel, .{ .name = "__aarch64_swp2_acq_rel", .linkage = linkage }); - @export(__aarch64_ldadd2_acq_rel, .{ .name = "__aarch64_ldadd2_acq_rel", .linkage = linkage }); - @export(__aarch64_ldclr2_acq_rel, .{ .name = "__aarch64_ldclr2_acq_rel", .linkage = linkage }); - @export(__aarch64_ldeor2_acq_rel, .{ .name = "__aarch64_ldeor2_acq_rel", .linkage = linkage }); - @export(__aarch64_ldset2_acq_rel, .{ .name = "__aarch64_ldset2_acq_rel", .linkage = linkage }); - @export(__aarch64_cas4_relax, .{ .name = "__aarch64_cas4_relax", .linkage = linkage }); - @export(__aarch64_swp4_relax, .{ .name = "__aarch64_swp4_relax", .linkage = linkage }); - @export(__aarch64_ldadd4_relax, .{ .name = "__aarch64_ldadd4_relax", .linkage = linkage }); - @export(__aarch64_ldclr4_relax, .{ .name = "__aarch64_ldclr4_relax", .linkage = linkage }); - @export(__aarch64_ldeor4_relax, .{ .name = "__aarch64_ldeor4_relax", .linkage = linkage }); - @export(__aarch64_ldset4_relax, .{ .name = "__aarch64_ldset4_relax", .linkage = linkage }); - @export(__aarch64_cas4_acq, .{ .name = "__aarch64_cas4_acq", .linkage = linkage }); - @export(__aarch64_swp4_acq, .{ .name = "__aarch64_swp4_acq", .linkage = linkage }); - @export(__aarch64_ldadd4_acq, .{ .name = "__aarch64_ldadd4_acq", .linkage = linkage }); - @export(__aarch64_ldclr4_acq, .{ .name = "__aarch64_ldclr4_acq", .linkage = linkage }); - @export(__aarch64_ldeor4_acq, .{ .name = "__aarch64_ldeor4_acq", .linkage = linkage }); - @export(__aarch64_ldset4_acq, .{ .name = "__aarch64_ldset4_acq", .linkage = linkage }); - @export(__aarch64_cas4_rel, .{ .name = "__aarch64_cas4_rel", .linkage = linkage }); - @export(__aarch64_swp4_rel, .{ .name = "__aarch64_swp4_rel", .linkage = linkage }); - @export(__aarch64_ldadd4_rel, .{ .name = "__aarch64_ldadd4_rel", .linkage = linkage }); - @export(__aarch64_ldclr4_rel, .{ .name = "__aarch64_ldclr4_rel", .linkage = linkage }); - @export(__aarch64_ldeor4_rel, .{ .name = "__aarch64_ldeor4_rel", .linkage = linkage }); - @export(__aarch64_ldset4_rel, .{ .name = "__aarch64_ldset4_rel", .linkage = linkage }); - @export(__aarch64_cas4_acq_rel, .{ .name = "__aarch64_cas4_acq_rel", .linkage = linkage }); - @export(__aarch64_swp4_acq_rel, .{ .name = "__aarch64_swp4_acq_rel", .linkage = linkage }); - @export(__aarch64_ldadd4_acq_rel, .{ .name = "__aarch64_ldadd4_acq_rel", .linkage = linkage }); - @export(__aarch64_ldclr4_acq_rel, .{ .name = "__aarch64_ldclr4_acq_rel", .linkage = linkage }); - @export(__aarch64_ldeor4_acq_rel, .{ .name = "__aarch64_ldeor4_acq_rel", .linkage = linkage }); - @export(__aarch64_ldset4_acq_rel, .{ .name = "__aarch64_ldset4_acq_rel", .linkage = linkage }); - @export(__aarch64_cas8_relax, .{ .name = "__aarch64_cas8_relax", .linkage = linkage }); - @export(__aarch64_swp8_relax, .{ .name = "__aarch64_swp8_relax", .linkage = linkage }); - @export(__aarch64_ldadd8_relax, .{ .name = "__aarch64_ldadd8_relax", .linkage = linkage }); - @export(__aarch64_ldclr8_relax, .{ .name = "__aarch64_ldclr8_relax", .linkage = linkage }); - @export(__aarch64_ldeor8_relax, .{ .name = "__aarch64_ldeor8_relax", .linkage = linkage }); - @export(__aarch64_ldset8_relax, .{ .name = "__aarch64_ldset8_relax", .linkage = linkage }); - @export(__aarch64_cas8_acq, .{ .name = "__aarch64_cas8_acq", .linkage = linkage }); - @export(__aarch64_swp8_acq, .{ .name = "__aarch64_swp8_acq", .linkage = linkage }); - @export(__aarch64_ldadd8_acq, .{ .name = "__aarch64_ldadd8_acq", .linkage = linkage }); - @export(__aarch64_ldclr8_acq, .{ .name = "__aarch64_ldclr8_acq", .linkage = linkage }); - @export(__aarch64_ldeor8_acq, .{ .name = "__aarch64_ldeor8_acq", .linkage = linkage }); - @export(__aarch64_ldset8_acq, .{ .name = "__aarch64_ldset8_acq", .linkage = linkage }); - @export(__aarch64_cas8_rel, .{ .name = "__aarch64_cas8_rel", .linkage = linkage }); - @export(__aarch64_swp8_rel, .{ .name = "__aarch64_swp8_rel", .linkage = linkage }); - @export(__aarch64_ldadd8_rel, .{ .name = "__aarch64_ldadd8_rel", .linkage = linkage }); - @export(__aarch64_ldclr8_rel, .{ .name = "__aarch64_ldclr8_rel", .linkage = linkage }); - @export(__aarch64_ldeor8_rel, .{ .name = "__aarch64_ldeor8_rel", .linkage = linkage }); - @export(__aarch64_ldset8_rel, .{ .name = "__aarch64_ldset8_rel", .linkage = linkage }); - @export(__aarch64_cas8_acq_rel, .{ .name = "__aarch64_cas8_acq_rel", .linkage = linkage }); - @export(__aarch64_swp8_acq_rel, .{ .name = "__aarch64_swp8_acq_rel", .linkage = linkage }); - @export(__aarch64_ldadd8_acq_rel, .{ .name = "__aarch64_ldadd8_acq_rel", .linkage = linkage }); - @export(__aarch64_ldclr8_acq_rel, .{ .name = "__aarch64_ldclr8_acq_rel", .linkage = linkage }); - @export(__aarch64_ldeor8_acq_rel, .{ .name = "__aarch64_ldeor8_acq_rel", .linkage = linkage }); - @export(__aarch64_ldset8_acq_rel, .{ .name = "__aarch64_ldset8_acq_rel", .linkage = linkage }); - @export(__aarch64_cas16_relax, .{ .name = "__aarch64_cas16_relax", .linkage = linkage }); - @export(__aarch64_cas16_acq, .{ .name = "__aarch64_cas16_acq", .linkage = linkage }); - @export(__aarch64_cas16_rel, .{ .name = "__aarch64_cas16_rel", .linkage = linkage }); - @export(__aarch64_cas16_acq_rel, .{ .name = "__aarch64_cas16_acq_rel", .linkage = linkage }); + @export(&__aarch64_cas1_relax, .{ .name = "__aarch64_cas1_relax", .linkage = linkage }); + @export(&__aarch64_swp1_relax, .{ .name = "__aarch64_swp1_relax", .linkage = linkage }); + @export(&__aarch64_ldadd1_relax, .{ .name = "__aarch64_ldadd1_relax", .linkage = linkage }); + @export(&__aarch64_ldclr1_relax, .{ .name = "__aarch64_ldclr1_relax", .linkage = linkage }); + @export(&__aarch64_ldeor1_relax, .{ .name = "__aarch64_ldeor1_relax", .linkage = linkage }); + @export(&__aarch64_ldset1_relax, .{ .name = "__aarch64_ldset1_relax", .linkage = linkage }); + @export(&__aarch64_cas1_acq, .{ .name = "__aarch64_cas1_acq", .linkage = linkage }); + @export(&__aarch64_swp1_acq, .{ .name = "__aarch64_swp1_acq", .linkage = linkage }); + @export(&__aarch64_ldadd1_acq, .{ .name = "__aarch64_ldadd1_acq", .linkage = linkage }); + @export(&__aarch64_ldclr1_acq, .{ .name = "__aarch64_ldclr1_acq", .linkage = linkage }); + @export(&__aarch64_ldeor1_acq, .{ .name = "__aarch64_ldeor1_acq", .linkage = linkage }); + @export(&__aarch64_ldset1_acq, .{ .name = "__aarch64_ldset1_acq", .linkage = linkage }); + @export(&__aarch64_cas1_rel, .{ .name = "__aarch64_cas1_rel", .linkage = linkage }); + @export(&__aarch64_swp1_rel, .{ .name = "__aarch64_swp1_rel", .linkage = linkage }); + @export(&__aarch64_ldadd1_rel, .{ .name = "__aarch64_ldadd1_rel", .linkage = linkage }); + @export(&__aarch64_ldclr1_rel, .{ .name = "__aarch64_ldclr1_rel", .linkage = linkage }); + @export(&__aarch64_ldeor1_rel, .{ .name = "__aarch64_ldeor1_rel", .linkage = linkage }); + @export(&__aarch64_ldset1_rel, .{ .name = "__aarch64_ldset1_rel", .linkage = linkage }); + @export(&__aarch64_cas1_acq_rel, .{ .name = "__aarch64_cas1_acq_rel", .linkage = linkage }); + @export(&__aarch64_swp1_acq_rel, .{ .name = "__aarch64_swp1_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldadd1_acq_rel, .{ .name = "__aarch64_ldadd1_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldclr1_acq_rel, .{ .name = "__aarch64_ldclr1_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldeor1_acq_rel, .{ .name = "__aarch64_ldeor1_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldset1_acq_rel, .{ .name = "__aarch64_ldset1_acq_rel", .linkage = linkage }); + @export(&__aarch64_cas2_relax, .{ .name = "__aarch64_cas2_relax", .linkage = linkage }); + @export(&__aarch64_swp2_relax, .{ .name = "__aarch64_swp2_relax", .linkage = linkage }); + @export(&__aarch64_ldadd2_relax, .{ .name = "__aarch64_ldadd2_relax", .linkage = linkage }); + @export(&__aarch64_ldclr2_relax, .{ .name = "__aarch64_ldclr2_relax", .linkage = linkage }); + @export(&__aarch64_ldeor2_relax, .{ .name = "__aarch64_ldeor2_relax", .linkage = linkage }); + @export(&__aarch64_ldset2_relax, .{ .name = "__aarch64_ldset2_relax", .linkage = linkage }); + @export(&__aarch64_cas2_acq, .{ .name = "__aarch64_cas2_acq", .linkage = linkage }); + @export(&__aarch64_swp2_acq, .{ .name = "__aarch64_swp2_acq", .linkage = linkage }); + @export(&__aarch64_ldadd2_acq, .{ .name = "__aarch64_ldadd2_acq", .linkage = linkage }); + @export(&__aarch64_ldclr2_acq, .{ .name = "__aarch64_ldclr2_acq", .linkage = linkage }); + @export(&__aarch64_ldeor2_acq, .{ .name = "__aarch64_ldeor2_acq", .linkage = linkage }); + @export(&__aarch64_ldset2_acq, .{ .name = "__aarch64_ldset2_acq", .linkage = linkage }); + @export(&__aarch64_cas2_rel, .{ .name = "__aarch64_cas2_rel", .linkage = linkage }); + @export(&__aarch64_swp2_rel, .{ .name = "__aarch64_swp2_rel", .linkage = linkage }); + @export(&__aarch64_ldadd2_rel, .{ .name = "__aarch64_ldadd2_rel", .linkage = linkage }); + @export(&__aarch64_ldclr2_rel, .{ .name = "__aarch64_ldclr2_rel", .linkage = linkage }); + @export(&__aarch64_ldeor2_rel, .{ .name = "__aarch64_ldeor2_rel", .linkage = linkage }); + @export(&__aarch64_ldset2_rel, .{ .name = "__aarch64_ldset2_rel", .linkage = linkage }); + @export(&__aarch64_cas2_acq_rel, .{ .name = "__aarch64_cas2_acq_rel", .linkage = linkage }); + @export(&__aarch64_swp2_acq_rel, .{ .name = "__aarch64_swp2_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldadd2_acq_rel, .{ .name = "__aarch64_ldadd2_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldclr2_acq_rel, .{ .name = "__aarch64_ldclr2_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldeor2_acq_rel, .{ .name = "__aarch64_ldeor2_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldset2_acq_rel, .{ .name = "__aarch64_ldset2_acq_rel", .linkage = linkage }); + @export(&__aarch64_cas4_relax, .{ .name = "__aarch64_cas4_relax", .linkage = linkage }); + @export(&__aarch64_swp4_relax, .{ .name = "__aarch64_swp4_relax", .linkage = linkage }); + @export(&__aarch64_ldadd4_relax, .{ .name = "__aarch64_ldadd4_relax", .linkage = linkage }); + @export(&__aarch64_ldclr4_relax, .{ .name = "__aarch64_ldclr4_relax", .linkage = linkage }); + @export(&__aarch64_ldeor4_relax, .{ .name = "__aarch64_ldeor4_relax", .linkage = linkage }); + @export(&__aarch64_ldset4_relax, .{ .name = "__aarch64_ldset4_relax", .linkage = linkage }); + @export(&__aarch64_cas4_acq, .{ .name = "__aarch64_cas4_acq", .linkage = linkage }); + @export(&__aarch64_swp4_acq, .{ .name = "__aarch64_swp4_acq", .linkage = linkage }); + @export(&__aarch64_ldadd4_acq, .{ .name = "__aarch64_ldadd4_acq", .linkage = linkage }); + @export(&__aarch64_ldclr4_acq, .{ .name = "__aarch64_ldclr4_acq", .linkage = linkage }); + @export(&__aarch64_ldeor4_acq, .{ .name = "__aarch64_ldeor4_acq", .linkage = linkage }); + @export(&__aarch64_ldset4_acq, .{ .name = "__aarch64_ldset4_acq", .linkage = linkage }); + @export(&__aarch64_cas4_rel, .{ .name = "__aarch64_cas4_rel", .linkage = linkage }); + @export(&__aarch64_swp4_rel, .{ .name = "__aarch64_swp4_rel", .linkage = linkage }); + @export(&__aarch64_ldadd4_rel, .{ .name = "__aarch64_ldadd4_rel", .linkage = linkage }); + @export(&__aarch64_ldclr4_rel, .{ .name = "__aarch64_ldclr4_rel", .linkage = linkage }); + @export(&__aarch64_ldeor4_rel, .{ .name = "__aarch64_ldeor4_rel", .linkage = linkage }); + @export(&__aarch64_ldset4_rel, .{ .name = "__aarch64_ldset4_rel", .linkage = linkage }); + @export(&__aarch64_cas4_acq_rel, .{ .name = "__aarch64_cas4_acq_rel", .linkage = linkage }); + @export(&__aarch64_swp4_acq_rel, .{ .name = "__aarch64_swp4_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldadd4_acq_rel, .{ .name = "__aarch64_ldadd4_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldclr4_acq_rel, .{ .name = "__aarch64_ldclr4_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldeor4_acq_rel, .{ .name = "__aarch64_ldeor4_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldset4_acq_rel, .{ .name = "__aarch64_ldset4_acq_rel", .linkage = linkage }); + @export(&__aarch64_cas8_relax, .{ .name = "__aarch64_cas8_relax", .linkage = linkage }); + @export(&__aarch64_swp8_relax, .{ .name = "__aarch64_swp8_relax", .linkage = linkage }); + @export(&__aarch64_ldadd8_relax, .{ .name = "__aarch64_ldadd8_relax", .linkage = linkage }); + @export(&__aarch64_ldclr8_relax, .{ .name = "__aarch64_ldclr8_relax", .linkage = linkage }); + @export(&__aarch64_ldeor8_relax, .{ .name = "__aarch64_ldeor8_relax", .linkage = linkage }); + @export(&__aarch64_ldset8_relax, .{ .name = "__aarch64_ldset8_relax", .linkage = linkage }); + @export(&__aarch64_cas8_acq, .{ .name = "__aarch64_cas8_acq", .linkage = linkage }); + @export(&__aarch64_swp8_acq, .{ .name = "__aarch64_swp8_acq", .linkage = linkage }); + @export(&__aarch64_ldadd8_acq, .{ .name = "__aarch64_ldadd8_acq", .linkage = linkage }); + @export(&__aarch64_ldclr8_acq, .{ .name = "__aarch64_ldclr8_acq", .linkage = linkage }); + @export(&__aarch64_ldeor8_acq, .{ .name = "__aarch64_ldeor8_acq", .linkage = linkage }); + @export(&__aarch64_ldset8_acq, .{ .name = "__aarch64_ldset8_acq", .linkage = linkage }); + @export(&__aarch64_cas8_rel, .{ .name = "__aarch64_cas8_rel", .linkage = linkage }); + @export(&__aarch64_swp8_rel, .{ .name = "__aarch64_swp8_rel", .linkage = linkage }); + @export(&__aarch64_ldadd8_rel, .{ .name = "__aarch64_ldadd8_rel", .linkage = linkage }); + @export(&__aarch64_ldclr8_rel, .{ .name = "__aarch64_ldclr8_rel", .linkage = linkage }); + @export(&__aarch64_ldeor8_rel, .{ .name = "__aarch64_ldeor8_rel", .linkage = linkage }); + @export(&__aarch64_ldset8_rel, .{ .name = "__aarch64_ldset8_rel", .linkage = linkage }); + @export(&__aarch64_cas8_acq_rel, .{ .name = "__aarch64_cas8_acq_rel", .linkage = linkage }); + @export(&__aarch64_swp8_acq_rel, .{ .name = "__aarch64_swp8_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldadd8_acq_rel, .{ .name = "__aarch64_ldadd8_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldclr8_acq_rel, .{ .name = "__aarch64_ldclr8_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldeor8_acq_rel, .{ .name = "__aarch64_ldeor8_acq_rel", .linkage = linkage }); + @export(&__aarch64_ldset8_acq_rel, .{ .name = "__aarch64_ldset8_acq_rel", .linkage = linkage }); + @export(&__aarch64_cas16_relax, .{ .name = "__aarch64_cas16_relax", .linkage = linkage }); + @export(&__aarch64_cas16_acq, .{ .name = "__aarch64_cas16_acq", .linkage = linkage }); + @export(&__aarch64_cas16_rel, .{ .name = "__aarch64_cas16_rel", .linkage = linkage }); + @export(&__aarch64_cas16_acq_rel, .{ .name = "__aarch64_cas16_acq_rel", .linkage = linkage }); } diff --git a/lib/compiler_rt/absvdi2.zig b/lib/compiler_rt/absvdi2.zig index 14cd1d8393..71f2467091 100644 --- a/lib/compiler_rt/absvdi2.zig +++ b/lib/compiler_rt/absvdi2.zig @@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv; pub const panic = common.panic; comptime { - @export(__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __absvdi2(a: i64) callconv(.C) i64 { diff --git a/lib/compiler_rt/absvsi2.zig b/lib/compiler_rt/absvsi2.zig index 9ca9297c56..83cc71bbaf 100644 --- a/lib/compiler_rt/absvsi2.zig +++ b/lib/compiler_rt/absvsi2.zig @@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv; pub const panic = common.panic; comptime { - @export(__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __absvsi2(a: i32) callconv(.C) i32 { diff --git a/lib/compiler_rt/absvti2.zig b/lib/compiler_rt/absvti2.zig index f866f4c2c1..91e2d5fe7b 100644 --- a/lib/compiler_rt/absvti2.zig +++ b/lib/compiler_rt/absvti2.zig @@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv; pub const panic = common.panic; comptime { - @export(__absvti2, .{ .name = "__absvti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__absvti2, .{ .name = "__absvti2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __absvti2(a: i128) callconv(.C) i128 { diff --git a/lib/compiler_rt/adddf3.zig b/lib/compiler_rt/adddf3.zig index 10ae9c328a..b63785a796 100644 --- a/lib/compiler_rt/adddf3.zig +++ b/lib/compiler_rt/adddf3.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__adddf3, .{ .name = "__adddf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__adddf3, .{ .name = "__adddf3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/addf3.zig b/lib/compiler_rt/addf3.zig index ee6a2b6be4..60ae0165a8 100644 --- a/lib/compiler_rt/addf3.zig +++ b/lib/compiler_rt/addf3.zig @@ -7,7 +7,7 @@ const normalize = common.normalize; /// /// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc pub inline fn addf3(comptime T: type, a: T, b: T) T { - const bits = @typeInfo(T).Float.bits; + const bits = @typeInfo(T).float.bits; const Z = std.meta.Int(.unsigned, bits); const typeWidth = bits; diff --git a/lib/compiler_rt/addhf3.zig b/lib/compiler_rt/addhf3.zig index 013c2ea714..5c337ea096 100644 --- a/lib/compiler_rt/addhf3.zig +++ b/lib/compiler_rt/addhf3.zig @@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3; pub const panic = common.panic; comptime { - @export(__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility }); } fn __addhf3(a: f16, b: f16) callconv(.C) f16 { diff --git a/lib/compiler_rt/addo.zig b/lib/compiler_rt/addo.zig index 8ce0d625da..00d0e95850 100644 --- a/lib/compiler_rt/addo.zig +++ b/lib/compiler_rt/addo.zig @@ -5,9 +5,9 @@ const common = @import("./common.zig"); pub const panic = @import("common.zig").panic; comptime { - @export(__addosi4, .{ .name = "__addosi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__addodi4, .{ .name = "__addodi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__addoti4, .{ .name = "__addoti4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__addosi4, .{ .name = "__addosi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__addodi4, .{ .name = "__addodi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__addoti4, .{ .name = "__addoti4", .linkage = common.linkage, .visibility = common.visibility }); } // addo - add overflow diff --git a/lib/compiler_rt/addsf3.zig b/lib/compiler_rt/addsf3.zig index 59e96da432..244e3f1a25 100644 --- a/lib/compiler_rt/addsf3.zig +++ b/lib/compiler_rt/addsf3.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__addsf3, .{ .name = "__addsf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__addsf3, .{ .name = "__addsf3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/addtf3.zig b/lib/compiler_rt/addtf3.zig index e9a077fad5..95bd593855 100644 --- a/lib/compiler_rt/addtf3.zig +++ b/lib/compiler_rt/addtf3.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__addtf3, .{ .name = "__addkf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__addtf3, .{ .name = "__addkf3", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__addtf3, .{ .name = "__addtf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 { diff --git a/lib/compiler_rt/addxf3.zig b/lib/compiler_rt/addxf3.zig index babb11ab80..1aaf692ef3 100644 --- a/lib/compiler_rt/addxf3.zig +++ b/lib/compiler_rt/addxf3.zig @@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3; pub const panic = common.panic; comptime { - @export(__addxf3, .{ .name = "__addxf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__addxf3, .{ .name = "__addxf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __addxf3(a: f80, b: f80) callconv(.C) f80 { diff --git a/lib/compiler_rt/arm.zig b/lib/compiler_rt/arm.zig index 217625b2f7..e42694b2bf 100644 --- a/lib/compiler_rt/arm.zig +++ b/lib/compiler_rt/arm.zig @@ -2,6 +2,7 @@ //! This file includes all ARM-only functions. const std = @import("std"); const builtin = @import("builtin"); +const target = builtin.target; const arch = builtin.cpu.arch; const common = @import("common.zig"); @@ -10,39 +11,39 @@ pub const panic = common.panic; comptime { if (!builtin.is_test) { if (arch.isArmOrThumb()) { - @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_ldivmod, .{ .name = if (target.isMinGW()) "__rt_sdiv64" else "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_uldivmod, .{ .name = if (target.isMinGW()) "__rt_udiv64" else "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_idivmod, .{ .name = if (target.isMinGW()) "__rt_sdiv" else "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_uidivmod, .{ .name = if (target.isMinGW()) "__rt_udiv" else "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility }); if (builtin.os.tag == .linux) { - @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility }); } // floating-point helper functions (single+double-precision reverse subtraction, y – x), see subdf3.zig - @export(__aeabi_frsub, .{ .name = "__aeabi_frsub", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_frsub, .{ .name = "__aeabi_frsub", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility }); } } } diff --git a/lib/compiler_rt/atomics.zig b/lib/compiler_rt/atomics.zig index 2e5989336c..db1e9b4b70 100644 --- a/lib/compiler_rt/atomics.zig +++ b/lib/compiler_rt/atomics.zig @@ -538,81 +538,81 @@ fn __atomic_fetch_umin_16(ptr: *u128, val: u128, model: i32) callconv(.C) u128 { comptime { if (supports_atomic_ops and builtin.object_format != .c) { - @export(__atomic_load, .{ .name = "__atomic_load", .linkage = linkage, .visibility = visibility }); - @export(__atomic_store, .{ .name = "__atomic_store", .linkage = linkage, .visibility = visibility }); - @export(__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage, .visibility = visibility }); - @export(__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_add_16, .{ .name = "__atomic_fetch_add_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_sub_16, .{ .name = "__atomic_fetch_sub_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_and_16, .{ .name = "__atomic_fetch_and_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_or_16, .{ .name = "__atomic_fetch_or_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_xor_16, .{ .name = "__atomic_fetch_xor_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_nand_16, .{ .name = "__atomic_fetch_nand_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_fetch_umax_1, .{ .name = "__atomic_fetch_umax_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_umax_2, .{ .name = "__atomic_fetch_umax_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_umax_4, .{ .name = "__atomic_fetch_umax_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_umax_8, .{ .name = "__atomic_fetch_umax_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_umax_16, .{ .name = "__atomic_fetch_umax_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_fetch_umin_1, .{ .name = "__atomic_fetch_umin_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_umin_2, .{ .name = "__atomic_fetch_umin_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_umin_4, .{ .name = "__atomic_fetch_umin_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_umin_8, .{ .name = "__atomic_fetch_umin_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_fetch_umin_16, .{ .name = "__atomic_fetch_umin_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_load_16, .{ .name = "__atomic_load_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_store_16, .{ .name = "__atomic_store_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_exchange_16, .{ .name = "__atomic_exchange_16", .linkage = linkage, .visibility = visibility }); - - @export(__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage, .visibility = visibility }); - @export(__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage, .visibility = visibility }); - @export(__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage, .visibility = visibility }); - @export(__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage, .visibility = visibility }); - @export(__atomic_compare_exchange_16, .{ .name = "__atomic_compare_exchange_16", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_load, .{ .name = "__atomic_load", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_store, .{ .name = "__atomic_store", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_add_16, .{ .name = "__atomic_fetch_add_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_sub_16, .{ .name = "__atomic_fetch_sub_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_and_16, .{ .name = "__atomic_fetch_and_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_or_16, .{ .name = "__atomic_fetch_or_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_xor_16, .{ .name = "__atomic_fetch_xor_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_nand_16, .{ .name = "__atomic_fetch_nand_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_fetch_umax_1, .{ .name = "__atomic_fetch_umax_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_umax_2, .{ .name = "__atomic_fetch_umax_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_umax_4, .{ .name = "__atomic_fetch_umax_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_umax_8, .{ .name = "__atomic_fetch_umax_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_umax_16, .{ .name = "__atomic_fetch_umax_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_fetch_umin_1, .{ .name = "__atomic_fetch_umin_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_umin_2, .{ .name = "__atomic_fetch_umin_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_umin_4, .{ .name = "__atomic_fetch_umin_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_umin_8, .{ .name = "__atomic_fetch_umin_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_fetch_umin_16, .{ .name = "__atomic_fetch_umin_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_load_16, .{ .name = "__atomic_load_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_store_16, .{ .name = "__atomic_store_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_exchange_16, .{ .name = "__atomic_exchange_16", .linkage = linkage, .visibility = visibility }); + + @export(&__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage, .visibility = visibility }); + @export(&__atomic_compare_exchange_16, .{ .name = "__atomic_compare_exchange_16", .linkage = linkage, .visibility = visibility }); } } diff --git a/lib/compiler_rt/aulldiv.zig b/lib/compiler_rt/aulldiv.zig index 1ce8f80c9f..21ec61722b 100644 --- a/lib/compiler_rt/aulldiv.zig +++ b/lib/compiler_rt/aulldiv.zig @@ -9,8 +9,8 @@ pub const panic = common.panic; comptime { if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) { // Don't let LLVM apply the stdcall name mangling on those MSVC builtins - @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility }); - @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/aullrem.zig b/lib/compiler_rt/aullrem.zig index a87ec26475..c1578aeb8b 100644 --- a/lib/compiler_rt/aullrem.zig +++ b/lib/compiler_rt/aullrem.zig @@ -9,8 +9,8 @@ pub const panic = common.panic; comptime { if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) { // Don't let LLVM apply the stdcall name mangling on those MSVC builtins - @export(_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility }); - @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/bcmp.zig b/lib/compiler_rt/bcmp.zig index bc8d43b48e..829dc03715 100644 --- a/lib/compiler_rt/bcmp.zig +++ b/lib/compiler_rt/bcmp.zig @@ -2,7 +2,7 @@ const std = @import("std"); const common = @import("./common.zig"); comptime { - @export(bcmp, .{ .name = "bcmp", .linkage = common.linkage, .visibility = common.visibility }); + @export(&bcmp, .{ .name = "bcmp", .linkage = common.linkage, .visibility = common.visibility }); } pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.C) c_int { diff --git a/lib/compiler_rt/bitreverse.zig b/lib/compiler_rt/bitreverse.zig index fec1a388b7..4022f8d72c 100644 --- a/lib/compiler_rt/bitreverse.zig +++ b/lib/compiler_rt/bitreverse.zig @@ -5,9 +5,9 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__bitreversesi2, .{ .name = "__bitreversesi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__bitreversedi2, .{ .name = "__bitreversedi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__bitreverseti2, .{ .name = "__bitreverseti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__bitreversesi2, .{ .name = "__bitreversesi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__bitreversedi2, .{ .name = "__bitreversedi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__bitreverseti2, .{ .name = "__bitreverseti2", .linkage = common.linkage, .visibility = common.visibility }); } inline fn bitreverseXi2(comptime T: type, a: T) T { diff --git a/lib/compiler_rt/bswap.zig b/lib/compiler_rt/bswap.zig index ed330810f0..4bd8ff688c 100644 --- a/lib/compiler_rt/bswap.zig +++ b/lib/compiler_rt/bswap.zig @@ -5,9 +5,9 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage, .visibility = common.visibility }); } // bswap - byteswap diff --git a/lib/compiler_rt/ceil.zig b/lib/compiler_rt/ceil.zig index ff78f47839..e1139ff9f4 100644 --- a/lib/compiler_rt/ceil.zig +++ b/lib/compiler_rt/ceil.zig @@ -15,15 +15,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__ceilh, .{ .name = "__ceilh", .linkage = common.linkage, .visibility = common.visibility }); - @export(ceilf, .{ .name = "ceilf", .linkage = common.linkage, .visibility = common.visibility }); - @export(ceil, .{ .name = "ceil", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ceilx, .{ .name = "__ceilx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ceilh, .{ .name = "__ceilh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&ceilf, .{ .name = "ceilf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&ceil, .{ .name = "ceil", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ceilx, .{ .name = "__ceilx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(ceilq, .{ .name = "ceilf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&ceilq, .{ .name = "ceilf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(ceilq, .{ .name = "ceilq", .linkage = common.linkage, .visibility = common.visibility }); - @export(ceill, .{ .name = "ceill", .linkage = common.linkage, .visibility = common.visibility }); + @export(&ceilq, .{ .name = "ceilq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&ceill, .{ .name = "ceill", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __ceilh(x: f16) callconv(.C) f16 { @@ -130,7 +130,7 @@ pub fn ceilq(x: f128) callconv(.C) f128 { } pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __ceilh(x), 32 => return ceilf(x), 64 => return ceil(x), diff --git a/lib/compiler_rt/clear_cache.zig b/lib/compiler_rt/clear_cache.zig index 0ec36c5eb9..0c7847388c 100644 --- a/lib/compiler_rt/clear_cache.zig +++ b/lib/compiler_rt/clear_cache.zig @@ -175,7 +175,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void { const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.internal else std.builtin.GlobalLinkage.weak; fn exportIt() void { - @export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage }); + @export(&clear_cache, .{ .name = "__clear_cache", .linkage = linkage }); } // Darwin-only diff --git a/lib/compiler_rt/cmp.zig b/lib/compiler_rt/cmp.zig index cebc38c2ae..6ae608fcb0 100644 --- a/lib/compiler_rt/cmp.zig +++ b/lib/compiler_rt/cmp.zig @@ -6,12 +6,12 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage, .visibility = common.visibility }); } // cmp - signed compare diff --git a/lib/compiler_rt/cmpdf2.zig b/lib/compiler_rt/cmpdf2.zig index c01b1c1538..47641145de 100644 --- a/lib/compiler_rt/cmpdf2.zig +++ b/lib/compiler_rt/cmpdf2.zig @@ -7,15 +7,15 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__eqdf2, .{ .name = "__eqdf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__nedf2, .{ .name = "__nedf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ledf2, .{ .name = "__ledf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__cmpdf2, .{ .name = "__cmpdf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ltdf2, .{ .name = "__ltdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__eqdf2, .{ .name = "__eqdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__nedf2, .{ .name = "__nedf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ledf2, .{ .name = "__ledf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cmpdf2, .{ .name = "__cmpdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ltdf2, .{ .name = "__ltdf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/cmphf2.zig b/lib/compiler_rt/cmphf2.zig index 67ad7a74b6..15b9ad610f 100644 --- a/lib/compiler_rt/cmphf2.zig +++ b/lib/compiler_rt/cmphf2.zig @@ -6,11 +6,11 @@ const comparef = @import("./comparef.zig"); pub const panic = common.panic; comptime { - @export(__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__nehf2, .{ .name = "__nehf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lehf2, .{ .name = "__lehf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lthf2, .{ .name = "__lthf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__nehf2, .{ .name = "__nehf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lehf2, .{ .name = "__lehf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lthf2, .{ .name = "__lthf2", .linkage = common.linkage, .visibility = common.visibility }); } /// "These functions calculate a <=> b. That is, if a is less than b, they return -1; diff --git a/lib/compiler_rt/cmpsf2.zig b/lib/compiler_rt/cmpsf2.zig index c51792254d..3f65021b89 100644 --- a/lib/compiler_rt/cmpsf2.zig +++ b/lib/compiler_rt/cmpsf2.zig @@ -7,15 +7,15 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__nesf2, .{ .name = "__nesf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lesf2, .{ .name = "__lesf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__nesf2, .{ .name = "__nesf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lesf2, .{ .name = "__lesf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/cmptf2.zig b/lib/compiler_rt/cmptf2.zig index 4f8ecc73b9..41e7f4ba08 100644 --- a/lib/compiler_rt/cmptf2.zig +++ b/lib/compiler_rt/cmptf2.zig @@ -7,24 +7,24 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__netf2, .{ .name = "__nekf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__letf2, .{ .name = "__lekf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__netf2, .{ .name = "__nekf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__letf2, .{ .name = "__lekf2", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage, .visibility = common.visibility }); - @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage, .visibility = common.visibility }); - @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage, .visibility = common.visibility }); - @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage, .visibility = common.visibility }); - @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage, .visibility = common.visibility }); - @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage, .visibility = common.visibility }); - @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__netf2, .{ .name = "__netf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__letf2, .{ .name = "__letf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lttf2, .{ .name = "__lttf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__netf2, .{ .name = "__netf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__letf2, .{ .name = "__letf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lttf2, .{ .name = "__lttf2", .linkage = common.linkage, .visibility = common.visibility }); } /// "These functions calculate a <=> b. That is, if a is less than b, they return -1; diff --git a/lib/compiler_rt/cmpxf2.zig b/lib/compiler_rt/cmpxf2.zig index cd66b1c6c8..a020f60824 100644 --- a/lib/compiler_rt/cmpxf2.zig +++ b/lib/compiler_rt/cmpxf2.zig @@ -6,11 +6,11 @@ const comparef = @import("./comparef.zig"); pub const panic = common.panic; comptime { - @export(__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__nexf2, .{ .name = "__nexf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lexf2, .{ .name = "__lexf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__nexf2, .{ .name = "__nexf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lexf2, .{ .name = "__lexf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage, .visibility = common.visibility }); } /// "These functions calculate a <=> b. That is, if a is less than b, they return -1; diff --git a/lib/compiler_rt/common.zig b/lib/compiler_rt/common.zig index 552fc07efd..1dfd4be07f 100644 --- a/lib/compiler_rt/common.zig +++ b/lib/compiler_rt/common.zig @@ -72,7 +72,7 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC(); pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = error_return_trace; if (builtin.is_test) { - @setCold(true); + @branchHint(.cold); std.debug.panic("{s}", .{msg}); } else { unreachable; @@ -219,8 +219,8 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { } } -pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { - const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); +pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).float.bits)) i32 { + const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T); const shift = @clz(significand.*) - @clz(integerBit); @@ -230,8 +230,8 @@ pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeIn pub inline fn fneg(a: anytype) @TypeOf(a) { const F = @TypeOf(a); - const bits = @typeInfo(F).Float.bits; - const U = @Type(.{ .Int = .{ + const bits = @typeInfo(F).float.bits; + const U = @Type(.{ .int = .{ .signedness = .unsigned, .bits = bits, } }); @@ -244,7 +244,7 @@ pub inline fn fneg(a: anytype) @TypeOf(a) { /// signed or unsigned integers. pub fn HalveInt(comptime T: type, comptime signed_half: bool) type { return extern union { - pub const bits = @divExact(@typeInfo(T).Int.bits, 2); + pub const bits = @divExact(@typeInfo(T).int.bits, 2); pub const HalfTU = std.meta.Int(.unsigned, bits); pub const HalfTS = std.meta.Int(.signed, bits); pub const HalfT = if (signed_half) HalfTS else HalfTU; diff --git a/lib/compiler_rt/comparef.zig b/lib/compiler_rt/comparef.zig index 25b5401911..512eba0594 100644 --- a/lib/compiler_rt/comparef.zig +++ b/lib/compiler_rt/comparef.zig @@ -17,7 +17,7 @@ pub const GE = enum(i32) { }; pub inline fn cmpf2(comptime T: type, comptime RT: type, a: T, b: T) RT { - const bits = @typeInfo(T).Float.bits; + const bits = @typeInfo(T).float.bits; const srep_t = std.meta.Int(.signed, bits); const rep_t = std.meta.Int(.unsigned, bits); @@ -109,7 +109,7 @@ test "cmp_f80" { } pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 { - const rep_t = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const rep_t = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const significandBits = std.math.floatMantissaBits(T); const exponentBits = std.math.floatExponentBits(T); diff --git a/lib/compiler_rt/cos.zig b/lib/compiler_rt/cos.zig index 62d6320d1b..5cbe5af6e8 100644 --- a/lib/compiler_rt/cos.zig +++ b/lib/compiler_rt/cos.zig @@ -11,15 +11,15 @@ const rem_pio2 = @import("rem_pio2.zig").rem_pio2; const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; comptime { - @export(__cosh, .{ .name = "__cosh", .linkage = common.linkage, .visibility = common.visibility }); - @export(cosf, .{ .name = "cosf", .linkage = common.linkage, .visibility = common.visibility }); - @export(cos, .{ .name = "cos", .linkage = common.linkage, .visibility = common.visibility }); - @export(__cosx, .{ .name = "__cosx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cosh, .{ .name = "__cosh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&cosf, .{ .name = "cosf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&cos, .{ .name = "cos", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__cosx, .{ .name = "__cosx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(cosq, .{ .name = "cosf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&cosq, .{ .name = "cosf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(cosq, .{ .name = "cosq", .linkage = common.linkage, .visibility = common.visibility }); - @export(cosl, .{ .name = "cosl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&cosq, .{ .name = "cosq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&cosl, .{ .name = "cosl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __cosh(a: f16) callconv(.C) f16 { @@ -124,7 +124,7 @@ pub fn cosq(a: f128) callconv(.C) f128 { } pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __cosh(x), 32 => return cosf(x), 64 => return cos(x), diff --git a/lib/compiler_rt/count0bits.zig b/lib/compiler_rt/count0bits.zig index 478ad0eb57..60da0390da 100644 --- a/lib/compiler_rt/count0bits.zig +++ b/lib/compiler_rt/count0bits.zig @@ -6,15 +6,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__clzti2, .{ .name = "__clzti2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__clzti2, .{ .name = "__clzti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage, .visibility = common.visibility }); } // clz - count leading zeroes @@ -203,7 +203,7 @@ pub fn __ctzti2(a: i128) callconv(.C) i32 { } inline fn ffsXi2(comptime T: type, a: T) i32 { - var x: std.meta.Int(.unsigned, @typeInfo(T).Int.bits) = @bitCast(a); + var x: std.meta.Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a); var n: T = 1; // adapted from Number of trailing zeroes (see ctzXi2) var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x)); diff --git a/lib/compiler_rt/divdc3.zig b/lib/compiler_rt/divdc3.zig index ddcb0b83ea..6a555b78db 100644 --- a/lib/compiler_rt/divdc3.zig +++ b/lib/compiler_rt/divdc3.zig @@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__divdc3, .{ .name = "__divdc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divdc3, .{ .name = "__divdc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/divdf3.zig b/lib/compiler_rt/divdf3.zig index 128eb2500d..29b82d360d 100644 --- a/lib/compiler_rt/divdf3.zig +++ b/lib/compiler_rt/divdf3.zig @@ -15,9 +15,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__divdf3, .{ .name = "__divdf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divdf3, .{ .name = "__divdf3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/divhc3.zig b/lib/compiler_rt/divhc3.zig index 7e9bfeb0ff..0a5053bfa8 100644 --- a/lib/compiler_rt/divhc3.zig +++ b/lib/compiler_rt/divhc3.zig @@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__divhc3, .{ .name = "__divhc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divhc3, .{ .name = "__divhc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/divhf3.zig b/lib/compiler_rt/divhf3.zig index 19c30d1221..23c6d60191 100644 --- a/lib/compiler_rt/divhf3.zig +++ b/lib/compiler_rt/divhf3.zig @@ -2,7 +2,7 @@ const common = @import("common.zig"); const divsf3 = @import("./divsf3.zig"); comptime { - @export(__divhf3, .{ .name = "__divhf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divhf3, .{ .name = "__divhf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __divhf3(a: f16, b: f16) callconv(.C) f16 { diff --git a/lib/compiler_rt/divsc3.zig b/lib/compiler_rt/divsc3.zig index 20cdc56a09..d1af430508 100644 --- a/lib/compiler_rt/divsc3.zig +++ b/lib/compiler_rt/divsc3.zig @@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__divsc3, .{ .name = "__divsc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divsc3, .{ .name = "__divsc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/divsf3.zig b/lib/compiler_rt/divsf3.zig index 7240bacc80..181f95cef6 100644 --- a/lib/compiler_rt/divsf3.zig +++ b/lib/compiler_rt/divsf3.zig @@ -13,9 +13,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__divsf3, .{ .name = "__divsf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divsf3, .{ .name = "__divsf3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/divtc3.zig b/lib/compiler_rt/divtc3.zig index fccce3459c..bfc8a4badf 100644 --- a/lib/compiler_rt/divtc3.zig +++ b/lib/compiler_rt/divtc3.zig @@ -5,8 +5,8 @@ const Complex = @import("./mulc3.zig").Complex; comptime { if (@import("builtin").zig_backend != .stage2_c) { if (common.want_ppc_abi) - @export(__divtc3, .{ .name = "__divkc3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__divtc3, .{ .name = "__divtc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divtc3, .{ .name = "__divkc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divtc3, .{ .name = "__divtc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/divtf3.zig b/lib/compiler_rt/divtf3.zig index 1fcdae442e..b6067e73d3 100644 --- a/lib/compiler_rt/divtf3.zig +++ b/lib/compiler_rt/divtf3.zig @@ -9,11 +9,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__divtf3, .{ .name = "__divkf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divtf3, .{ .name = "__divkf3", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__divtf3, .{ .name = "__divtf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divtf3, .{ .name = "__divtf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 { diff --git a/lib/compiler_rt/divti3.zig b/lib/compiler_rt/divti3.zig index 1efc09ce3c..0468175db1 100644 --- a/lib/compiler_rt/divti3.zig +++ b/lib/compiler_rt/divti3.zig @@ -8,9 +8,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/divxc3.zig b/lib/compiler_rt/divxc3.zig index 177e26cfd8..86ef5cbb73 100644 --- a/lib/compiler_rt/divxc3.zig +++ b/lib/compiler_rt/divxc3.zig @@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__divxc3, .{ .name = "__divxc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divxc3, .{ .name = "__divxc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/divxf3.zig b/lib/compiler_rt/divxf3.zig index 84a7da0fc3..0f50233546 100644 --- a/lib/compiler_rt/divxf3.zig +++ b/lib/compiler_rt/divxf3.zig @@ -9,7 +9,7 @@ const wideMultiply = common.wideMultiply; pub const panic = common.panic; comptime { - @export(__divxf3, .{ .name = "__divxf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divxf3, .{ .name = "__divxf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 { diff --git a/lib/compiler_rt/emutls.zig b/lib/compiler_rt/emutls.zig index 111193934a..55927b8b37 100644 --- a/lib/compiler_rt/emutls.zig +++ b/lib/compiler_rt/emutls.zig @@ -19,7 +19,7 @@ pub const panic = common.panic; comptime { if (builtin.link_libc and (builtin.abi == .android or builtin.os.tag == .openbsd)) { - @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/exp.zig b/lib/compiler_rt/exp.zig index 282ee5db9a..7245abe191 100644 --- a/lib/compiler_rt/exp.zig +++ b/lib/compiler_rt/exp.zig @@ -15,15 +15,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__exph, .{ .name = "__exph", .linkage = common.linkage, .visibility = common.visibility }); - @export(expf, .{ .name = "expf", .linkage = common.linkage, .visibility = common.visibility }); - @export(exp, .{ .name = "exp", .linkage = common.linkage, .visibility = common.visibility }); - @export(__expx, .{ .name = "__expx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__exph, .{ .name = "__exph", .linkage = common.linkage, .visibility = common.visibility }); + @export(&expf, .{ .name = "expf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&exp, .{ .name = "exp", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__expx, .{ .name = "__expx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(expq, .{ .name = "expf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&expq, .{ .name = "expf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(expq, .{ .name = "expq", .linkage = common.linkage, .visibility = common.visibility }); - @export(expl, .{ .name = "expl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&expq, .{ .name = "expq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&expl, .{ .name = "expl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __exph(a: f16) callconv(.C) f16 { @@ -201,7 +201,7 @@ pub fn expq(a: f128) callconv(.C) f128 { } pub fn expl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __exph(x), 32 => return expf(x), 64 => return exp(x), diff --git a/lib/compiler_rt/exp2.zig b/lib/compiler_rt/exp2.zig index 450eab201f..5aa43a6543 100644 --- a/lib/compiler_rt/exp2.zig +++ b/lib/compiler_rt/exp2.zig @@ -15,15 +15,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__exp2h, .{ .name = "__exp2h", .linkage = common.linkage, .visibility = common.visibility }); - @export(exp2f, .{ .name = "exp2f", .linkage = common.linkage, .visibility = common.visibility }); - @export(exp2, .{ .name = "exp2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__exp2x, .{ .name = "__exp2x", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__exp2h, .{ .name = "__exp2h", .linkage = common.linkage, .visibility = common.visibility }); + @export(&exp2f, .{ .name = "exp2f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&exp2, .{ .name = "exp2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__exp2x, .{ .name = "__exp2x", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(exp2q, .{ .name = "exp2f128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&exp2q, .{ .name = "exp2f128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(exp2q, .{ .name = "exp2q", .linkage = common.linkage, .visibility = common.visibility }); - @export(exp2l, .{ .name = "exp2l", .linkage = common.linkage, .visibility = common.visibility }); + @export(&exp2q, .{ .name = "exp2q", .linkage = common.linkage, .visibility = common.visibility }); + @export(&exp2l, .{ .name = "exp2l", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __exp2h(x: f16) callconv(.C) f16 { @@ -168,7 +168,7 @@ pub fn exp2q(x: f128) callconv(.C) f128 { } pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __exp2h(x), 32 => return exp2f(x), 64 => return exp2(x), diff --git a/lib/compiler_rt/extenddftf2.zig b/lib/compiler_rt/extenddftf2.zig index af293b5ea2..8c4ed97f76 100644 --- a/lib/compiler_rt/extenddftf2.zig +++ b/lib/compiler_rt/extenddftf2.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__extenddftf2, .{ .name = "__extenddfkf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extenddftf2, .{ .name = "__extenddfkf2", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __extenddftf2(a: f64) callconv(.C) f128 { diff --git a/lib/compiler_rt/extenddfxf2.zig b/lib/compiler_rt/extenddfxf2.zig index 54232d0b70..3e36e86b70 100644 --- a/lib/compiler_rt/extenddfxf2.zig +++ b/lib/compiler_rt/extenddfxf2.zig @@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80; pub const panic = common.panic; comptime { - @export(__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __extenddfxf2(a: f64) callconv(.C) f80 { diff --git a/lib/compiler_rt/extendf.zig b/lib/compiler_rt/extendf.zig index b4e3f37f38..5c7c2fecde 100644 --- a/lib/compiler_rt/extendf.zig +++ b/lib/compiler_rt/extendf.zig @@ -3,10 +3,10 @@ const std = @import("std"); pub inline fn extendf( comptime dst_t: type, comptime src_t: type, - a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits), + a: std.meta.Int(.unsigned, @typeInfo(src_t).float.bits), ) dst_t { - const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits); - const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits); + const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); + const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); const srcSigBits = std.math.floatMantissaBits(src_t); const dstSigBits = std.math.floatMantissaBits(dst_t); @@ -70,8 +70,8 @@ pub inline fn extendf( return @bitCast(result); } -pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits)) f80 { - const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits); +pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).float.bits)) f80 { + const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); const src_sig_bits = std.math.floatMantissaBits(src_t); const dst_int_bit = 0x8000000000000000; const dst_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit diff --git a/lib/compiler_rt/extendhfdf2.zig b/lib/compiler_rt/extendhfdf2.zig index 92aa3591ff..d4e693cc72 100644 --- a/lib/compiler_rt/extendhfdf2.zig +++ b/lib/compiler_rt/extendhfdf2.zig @@ -4,7 +4,7 @@ const extendf = @import("./extendf.zig").extendf; pub const panic = common.panic; comptime { - @export(__extendhfdf2, .{ .name = "__extendhfdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendhfdf2, .{ .name = "__extendhfdf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __extendhfdf2(a: common.F16T(f64)) callconv(.C) f64 { diff --git a/lib/compiler_rt/extendhfsf2.zig b/lib/compiler_rt/extendhfsf2.zig index eb144cc79a..0047f878ba 100644 --- a/lib/compiler_rt/extendhfsf2.zig +++ b/lib/compiler_rt/extendhfsf2.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.gnu_f16_abi) { - @export(__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_aeabi) { - @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __extendhfsf2(a: common.F16T(f32)) callconv(.C) f32 { diff --git a/lib/compiler_rt/extendhftf2.zig b/lib/compiler_rt/extendhftf2.zig index 3e63b94e42..ea82372a04 100644 --- a/lib/compiler_rt/extendhftf2.zig +++ b/lib/compiler_rt/extendhftf2.zig @@ -4,7 +4,7 @@ const extendf = @import("./extendf.zig").extendf; pub const panic = common.panic; comptime { - @export(__extendhftf2, .{ .name = "__extendhftf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendhftf2, .{ .name = "__extendhftf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __extendhftf2(a: common.F16T(f128)) callconv(.C) f128 { diff --git a/lib/compiler_rt/extendhfxf2.zig b/lib/compiler_rt/extendhfxf2.zig index 2858641d43..c48fa9d90a 100644 --- a/lib/compiler_rt/extendhfxf2.zig +++ b/lib/compiler_rt/extendhfxf2.zig @@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80; pub const panic = common.panic; comptime { - @export(__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __extendhfxf2(a: common.F16T(f80)) callconv(.C) f80 { diff --git a/lib/compiler_rt/extendsfdf2.zig b/lib/compiler_rt/extendsfdf2.zig index 4ab9288818..4fc0b83338 100644 --- a/lib/compiler_rt/extendsfdf2.zig +++ b/lib/compiler_rt/extendsfdf2.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/extendsftf2.zig b/lib/compiler_rt/extendsftf2.zig index 3783438771..ce1af6d91e 100644 --- a/lib/compiler_rt/extendsftf2.zig +++ b/lib/compiler_rt/extendsftf2.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __extendsftf2(a: f32) callconv(.C) f128 { diff --git a/lib/compiler_rt/extendsfxf2.zig b/lib/compiler_rt/extendsfxf2.zig index f41a921f9e..4263b4663e 100644 --- a/lib/compiler_rt/extendsfxf2.zig +++ b/lib/compiler_rt/extendsfxf2.zig @@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80; pub const panic = common.panic; comptime { - @export(__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __extendsfxf2(a: f32) callconv(.C) f80 { diff --git a/lib/compiler_rt/extendxftf2.zig b/lib/compiler_rt/extendxftf2.zig index a47f4479f6..53de08e686 100644 --- a/lib/compiler_rt/extendxftf2.zig +++ b/lib/compiler_rt/extendxftf2.zig @@ -4,7 +4,7 @@ const common = @import("./common.zig"); pub const panic = common.panic; comptime { - @export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__extendxftf2, .{ .name = "__extendxftf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __extendxftf2(a: f80) callconv(.C) f128 { diff --git a/lib/compiler_rt/fabs.zig b/lib/compiler_rt/fabs.zig index e107291543..2ab6db5913 100644 --- a/lib/compiler_rt/fabs.zig +++ b/lib/compiler_rt/fabs.zig @@ -6,15 +6,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__fabsh, .{ .name = "__fabsh", .linkage = common.linkage, .visibility = common.visibility }); - @export(fabsf, .{ .name = "fabsf", .linkage = common.linkage, .visibility = common.visibility }); - @export(fabs, .{ .name = "fabs", .linkage = common.linkage, .visibility = common.visibility }); - @export(__fabsx, .{ .name = "__fabsx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fabsh, .{ .name = "__fabsh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fabsf, .{ .name = "fabsf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fabs, .{ .name = "fabs", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fabsx, .{ .name = "__fabsx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(fabsq, .{ .name = "fabsf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fabsq, .{ .name = "fabsf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(fabsq, .{ .name = "fabsq", .linkage = common.linkage, .visibility = common.visibility }); - @export(fabsl, .{ .name = "fabsl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fabsq, .{ .name = "fabsq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fabsl, .{ .name = "fabsl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fabsh(a: f16) callconv(.C) f16 { @@ -38,7 +38,7 @@ pub fn fabsq(a: f128) callconv(.C) f128 { } pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __fabsh(x), 32 => return fabsf(x), 64 => return fabs(x), @@ -50,7 +50,7 @@ pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble { inline fn generic_fabs(x: anytype) @TypeOf(x) { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const float_bits: TBits = @bitCast(x); const remove_sign = ~@as(TBits, 0) >> 1; return @bitCast(float_bits & remove_sign); diff --git a/lib/compiler_rt/fixdfdi.zig b/lib/compiler_rt/fixdfdi.zig index 23b3876b91..78744b145d 100644 --- a/lib/compiler_rt/fixdfdi.zig +++ b/lib/compiler_rt/fixdfdi.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixdfsi.zig b/lib/compiler_rt/fixdfsi.zig index 09b9533254..611810dfc7 100644 --- a/lib/compiler_rt/fixdfsi.zig +++ b/lib/compiler_rt/fixdfsi.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixdfsi, .{ .name = "__fixdfsi", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixdfti.zig b/lib/compiler_rt/fixdfti.zig index 7dced515f1..196750d4a8 100644 --- a/lib/compiler_rt/fixdfti.zig +++ b/lib/compiler_rt/fixdfti.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixdfti_windows_x86_64, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixdfti_windows_x86_64, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixdfti, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixdfti, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixhfdi.zig b/lib/compiler_rt/fixhfdi.zig index 21736e2d9a..4582b4b7e1 100644 --- a/lib/compiler_rt/fixhfdi.zig +++ b/lib/compiler_rt/fixhfdi.zig @@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; comptime { - @export(__fixhfdi, .{ .name = "__fixhfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixhfdi, .{ .name = "__fixhfdi", .linkage = common.linkage, .visibility = common.visibility }); } fn __fixhfdi(a: f16) callconv(.C) i64 { diff --git a/lib/compiler_rt/fixhfsi.zig b/lib/compiler_rt/fixhfsi.zig index cd1ae208f8..4a8ac2cfea 100644 --- a/lib/compiler_rt/fixhfsi.zig +++ b/lib/compiler_rt/fixhfsi.zig @@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; comptime { - @export(__fixhfsi, .{ .name = "__fixhfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixhfsi, .{ .name = "__fixhfsi", .linkage = common.linkage, .visibility = common.visibility }); } fn __fixhfsi(a: f16) callconv(.C) i32 { diff --git a/lib/compiler_rt/fixhfti.zig b/lib/compiler_rt/fixhfti.zig index bcc30ec763..1810ec6612 100644 --- a/lib/compiler_rt/fixhfti.zig +++ b/lib/compiler_rt/fixhfti.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixsfdi.zig b/lib/compiler_rt/fixsfdi.zig index bbb31f6233..c75e401475 100644 --- a/lib/compiler_rt/fixsfdi.zig +++ b/lib/compiler_rt/fixsfdi.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixsfdi, .{ .name = "__fixsfdi", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixsfsi.zig b/lib/compiler_rt/fixsfsi.zig index 7aa352bbf9..8bc18e93b4 100644 --- a/lib/compiler_rt/fixsfsi.zig +++ b/lib/compiler_rt/fixsfsi.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixsfsi, .{ .name = "__fixsfsi", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixsfti.zig b/lib/compiler_rt/fixsfti.zig index 058d20f0b3..439310d0b6 100644 --- a/lib/compiler_rt/fixsfti.zig +++ b/lib/compiler_rt/fixsfti.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixsfti_windows_x86_64, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixsfti_windows_x86_64, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixsfti, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixsfti, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixtfdi.zig b/lib/compiler_rt/fixtfdi.zig index f65c9eaed1..acf23a78dc 100644 --- a/lib/compiler_rt/fixtfdi.zig +++ b/lib/compiler_rt/fixtfdi.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__fixtfdi, .{ .name = "__fixkfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixtfdi, .{ .name = "__fixkfdi", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fixtfdi(a: f128) callconv(.C) i64 { diff --git a/lib/compiler_rt/fixtfsi.zig b/lib/compiler_rt/fixtfsi.zig index 2667b1f626..89e0308d06 100644 --- a/lib/compiler_rt/fixtfsi.zig +++ b/lib/compiler_rt/fixtfsi.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__fixtfsi, .{ .name = "__fixkfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixtfsi, .{ .name = "__fixkfsi", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fixtfsi(a: f128) callconv(.C) i32 { diff --git a/lib/compiler_rt/fixtfti.zig b/lib/compiler_rt/fixtfti.zig index d38b092498..1c826d865c 100644 --- a/lib/compiler_rt/fixtfti.zig +++ b/lib/compiler_rt/fixtfti.zig @@ -6,11 +6,11 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixtfti_windows_x86_64, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixtfti_windows_x86_64, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility }); } else { if (common.want_ppc_abi) - @export(__fixtfti, .{ .name = "__fixkfti", .linkage = common.linkage, .visibility = common.visibility }); - @export(__fixtfti, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixtfti, .{ .name = "__fixkfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixtfti, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunsdfdi.zig b/lib/compiler_rt/fixunsdfdi.zig index a43ad91ac8..68a0c44ff9 100644 --- a/lib/compiler_rt/fixunsdfdi.zig +++ b/lib/compiler_rt/fixunsdfdi.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunsdfsi.zig b/lib/compiler_rt/fixunsdfsi.zig index 8af2c5af7e..908f60d615 100644 --- a/lib/compiler_rt/fixunsdfsi.zig +++ b/lib/compiler_rt/fixunsdfsi.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunsdfti.zig b/lib/compiler_rt/fixunsdfti.zig index f4e1b84b87..f8164d8185 100644 --- a/lib/compiler_rt/fixunsdfti.zig +++ b/lib/compiler_rt/fixunsdfti.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixunsdfti_windows_x86_64, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunsdfti_windows_x86_64, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunshfdi.zig b/lib/compiler_rt/fixunshfdi.zig index cd68cab757..262ba24bd7 100644 --- a/lib/compiler_rt/fixunshfdi.zig +++ b/lib/compiler_rt/fixunshfdi.zig @@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; comptime { - @export(__fixunshfdi, .{ .name = "__fixunshfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunshfdi, .{ .name = "__fixunshfdi", .linkage = common.linkage, .visibility = common.visibility }); } fn __fixunshfdi(a: f16) callconv(.C) u64 { diff --git a/lib/compiler_rt/fixunshfsi.zig b/lib/compiler_rt/fixunshfsi.zig index aa47d7edf7..06fae61d8a 100644 --- a/lib/compiler_rt/fixunshfsi.zig +++ b/lib/compiler_rt/fixunshfsi.zig @@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; comptime { - @export(__fixunshfsi, .{ .name = "__fixunshfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunshfsi, .{ .name = "__fixunshfsi", .linkage = common.linkage, .visibility = common.visibility }); } fn __fixunshfsi(a: f16) callconv(.C) u32 { diff --git a/lib/compiler_rt/fixunshfti.zig b/lib/compiler_rt/fixunshfti.zig index c35e6c7f94..cd76694e5b 100644 --- a/lib/compiler_rt/fixunshfti.zig +++ b/lib/compiler_rt/fixunshfti.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixunshfti_windows_x86_64, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunshfti_windows_x86_64, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixunshfti, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunshfti, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunssfdi.zig b/lib/compiler_rt/fixunssfdi.zig index dda6e80c65..9157a71e2f 100644 --- a/lib/compiler_rt/fixunssfdi.zig +++ b/lib/compiler_rt/fixunssfdi.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunssfsi.zig b/lib/compiler_rt/fixunssfsi.zig index 7c935c2731..4ee183b3f2 100644 --- a/lib/compiler_rt/fixunssfsi.zig +++ b/lib/compiler_rt/fixunssfsi.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunssfti.zig b/lib/compiler_rt/fixunssfti.zig index f65083413a..05919e996e 100644 --- a/lib/compiler_rt/fixunssfti.zig +++ b/lib/compiler_rt/fixunssfti.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixunssfti_windows_x86_64, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunssfti_windows_x86_64, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunssfti, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunstfdi.zig b/lib/compiler_rt/fixunstfdi.zig index 778388a05c..5e71a8e8cb 100644 --- a/lib/compiler_rt/fixunstfdi.zig +++ b/lib/compiler_rt/fixunstfdi.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fixunstfdi(a: f128) callconv(.C) u64 { diff --git a/lib/compiler_rt/fixunstfsi.zig b/lib/compiler_rt/fixunstfsi.zig index aabebccb99..cdaeaccd5d 100644 --- a/lib/compiler_rt/fixunstfsi.zig +++ b/lib/compiler_rt/fixunstfsi.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fixunstfsi(a: f128) callconv(.C) u32 { diff --git a/lib/compiler_rt/fixunstfti.zig b/lib/compiler_rt/fixunstfti.zig index 327f5209ce..3aa9f41c2f 100644 --- a/lib/compiler_rt/fixunstfti.zig +++ b/lib/compiler_rt/fixunstfti.zig @@ -6,11 +6,11 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility }); } else { if (common.want_ppc_abi) - @export(__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility }); - @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixunsxfdi.zig b/lib/compiler_rt/fixunsxfdi.zig index d83cc123f4..0d346365ae 100644 --- a/lib/compiler_rt/fixunsxfdi.zig +++ b/lib/compiler_rt/fixunsxfdi.zig @@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; comptime { - @export(__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = common.linkage, .visibility = common.visibility }); } fn __fixunsxfdi(a: f80) callconv(.C) u64 { diff --git a/lib/compiler_rt/fixunsxfsi.zig b/lib/compiler_rt/fixunsxfsi.zig index 8212b5b2c3..cfc91845f3 100644 --- a/lib/compiler_rt/fixunsxfsi.zig +++ b/lib/compiler_rt/fixunsxfsi.zig @@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; comptime { - @export(__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = common.linkage, .visibility = common.visibility }); } fn __fixunsxfsi(a: f80) callconv(.C) u32 { diff --git a/lib/compiler_rt/fixunsxfti.zig b/lib/compiler_rt/fixunsxfti.zig index 9b98522f51..4d8d46f939 100644 --- a/lib/compiler_rt/fixunsxfti.zig +++ b/lib/compiler_rt/fixunsxfti.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixunsxfti_windows_x86_64, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunsxfti_windows_x86_64, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/fixxfdi.zig b/lib/compiler_rt/fixxfdi.zig index c7510323d6..c6dd6ece68 100644 --- a/lib/compiler_rt/fixxfdi.zig +++ b/lib/compiler_rt/fixxfdi.zig @@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; comptime { - @export(__fixxfdi, .{ .name = "__fixxfdi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixxfdi, .{ .name = "__fixxfdi", .linkage = common.linkage, .visibility = common.visibility }); } fn __fixxfdi(a: f80) callconv(.C) i64 { diff --git a/lib/compiler_rt/fixxfsi.zig b/lib/compiler_rt/fixxfsi.zig index afcf06e4c9..9d348d6f00 100644 --- a/lib/compiler_rt/fixxfsi.zig +++ b/lib/compiler_rt/fixxfsi.zig @@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat; pub const panic = common.panic; comptime { - @export(__fixxfsi, .{ .name = "__fixxfsi", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixxfsi, .{ .name = "__fixxfsi", .linkage = common.linkage, .visibility = common.visibility }); } fn __fixxfsi(a: f80) callconv(.C) i32 { diff --git a/lib/compiler_rt/fixxfti.zig b/lib/compiler_rt/fixxfti.zig index 78cd10dfa5..2f57f5c222 100644 --- a/lib/compiler_rt/fixxfti.zig +++ b/lib/compiler_rt/fixxfti.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__fixxfti_windows_x86_64, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixxfti_windows_x86_64, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__fixxfti, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fixxfti, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/float_from_int.zig b/lib/compiler_rt/float_from_int.zig index 66f5eb0587..f552a3ae5c 100644 --- a/lib/compiler_rt/float_from_int.zig +++ b/lib/compiler_rt/float_from_int.zig @@ -18,7 +18,7 @@ pub fn floatFromInt(comptime T: type, x: anytype) T { const max_exp = exp_bias; // Sign - const abs_val = if (@TypeOf(x) == comptime_int or @typeInfo(@TypeOf(x)).Int.signedness == .signed) @abs(x) else x; + const abs_val = if (@TypeOf(x) == comptime_int or @typeInfo(@TypeOf(x)).int.signedness == .signed) @abs(x) else x; const sign_bit = if (x < 0) @as(uT, 1) << (float_bits - 1) else 0; var result: uT = sign_bit; diff --git a/lib/compiler_rt/floatdidf.zig b/lib/compiler_rt/floatdidf.zig index 3615e89035..393fa95c19 100644 --- a/lib/compiler_rt/floatdidf.zig +++ b/lib/compiler_rt/floatdidf.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatdihf.zig b/lib/compiler_rt/floatdihf.zig index 4d01d5c2e0..eb568c9ff2 100644 --- a/lib/compiler_rt/floatdihf.zig +++ b/lib/compiler_rt/floatdihf.zig @@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; comptime { - @export(__floatdihf, .{ .name = "__floatdihf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatdihf, .{ .name = "__floatdihf", .linkage = common.linkage, .visibility = common.visibility }); } fn __floatdihf(a: i64) callconv(.C) f16 { diff --git a/lib/compiler_rt/floatdisf.zig b/lib/compiler_rt/floatdisf.zig index 1a1b5fc6d7..4f3b42ef79 100644 --- a/lib/compiler_rt/floatdisf.zig +++ b/lib/compiler_rt/floatdisf.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatdisf, .{ .name = "__floatdisf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatdisf, .{ .name = "__floatdisf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatditf.zig b/lib/compiler_rt/floatditf.zig index 5f0c49c129..7294c16802 100644 --- a/lib/compiler_rt/floatditf.zig +++ b/lib/compiler_rt/floatditf.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__floatditf, .{ .name = "__floatdikf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatditf, .{ .name = "__floatdikf", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__floatditf, .{ .name = "__floatditf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatditf, .{ .name = "__floatditf", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __floatditf(a: i64) callconv(.C) f128 { diff --git a/lib/compiler_rt/floatdixf.zig b/lib/compiler_rt/floatdixf.zig index b4d250b277..ccd5e5bd4d 100644 --- a/lib/compiler_rt/floatdixf.zig +++ b/lib/compiler_rt/floatdixf.zig @@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; comptime { - @export(__floatdixf, .{ .name = "__floatdixf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatdixf, .{ .name = "__floatdixf", .linkage = common.linkage, .visibility = common.visibility }); } fn __floatdixf(a: i64) callconv(.C) f80 { diff --git a/lib/compiler_rt/floatsidf.zig b/lib/compiler_rt/floatsidf.zig index 8402c5726b..183e886721 100644 --- a/lib/compiler_rt/floatsidf.zig +++ b/lib/compiler_rt/floatsidf.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatsidf, .{ .name = "__floatsidf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatsidf, .{ .name = "__floatsidf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatsihf.zig b/lib/compiler_rt/floatsihf.zig index 889fa3c33f..4b27e9d00e 100644 --- a/lib/compiler_rt/floatsihf.zig +++ b/lib/compiler_rt/floatsihf.zig @@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; comptime { - @export(__floatsihf, .{ .name = "__floatsihf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatsihf, .{ .name = "__floatsihf", .linkage = common.linkage, .visibility = common.visibility }); } fn __floatsihf(a: i32) callconv(.C) f16 { diff --git a/lib/compiler_rt/floatsisf.zig b/lib/compiler_rt/floatsisf.zig index 907c7a554d..5839d20a0a 100644 --- a/lib/compiler_rt/floatsisf.zig +++ b/lib/compiler_rt/floatsisf.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatsisf, .{ .name = "__floatsisf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatsisf, .{ .name = "__floatsisf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatsitf.zig b/lib/compiler_rt/floatsitf.zig index 2553de5f18..4619019ea0 100644 --- a/lib/compiler_rt/floatsitf.zig +++ b/lib/compiler_rt/floatsitf.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __floatsitf(a: i32) callconv(.C) f128 { diff --git a/lib/compiler_rt/floatsixf.zig b/lib/compiler_rt/floatsixf.zig index fe63f1c0a8..0a22f5cd0c 100644 --- a/lib/compiler_rt/floatsixf.zig +++ b/lib/compiler_rt/floatsixf.zig @@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; comptime { - @export(__floatsixf, .{ .name = "__floatsixf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatsixf, .{ .name = "__floatsixf", .linkage = common.linkage, .visibility = common.visibility }); } fn __floatsixf(a: i32) callconv(.C) f80 { diff --git a/lib/compiler_rt/floattidf.zig b/lib/compiler_rt/floattidf.zig index fa213d4d80..b13a450aa5 100644 --- a/lib/compiler_rt/floattidf.zig +++ b/lib/compiler_rt/floattidf.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floattidf_windows_x86_64, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattidf_windows_x86_64, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floattidf, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattidf, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floattihf.zig b/lib/compiler_rt/floattihf.zig index 752e5b8663..4d0dfa1802 100644 --- a/lib/compiler_rt/floattihf.zig +++ b/lib/compiler_rt/floattihf.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floattihf_windows_x86_64, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattihf_windows_x86_64, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floattihf, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattihf, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floattisf.zig b/lib/compiler_rt/floattisf.zig index 0f81bfbb85..c609f87abb 100644 --- a/lib/compiler_rt/floattisf.zig +++ b/lib/compiler_rt/floattisf.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floattisf_windows_x86_64, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattisf_windows_x86_64, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floattisf, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattisf, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floattitf.zig b/lib/compiler_rt/floattitf.zig index 49397d34a3..d7aa35f0c3 100644 --- a/lib/compiler_rt/floattitf.zig +++ b/lib/compiler_rt/floattitf.zig @@ -6,11 +6,11 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floattitf_windows_x86_64, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattitf_windows_x86_64, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility }); } else { if (common.want_ppc_abi) - @export(__floattitf, .{ .name = "__floattikf", .linkage = common.linkage, .visibility = common.visibility }); - @export(__floattitf, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattitf, .{ .name = "__floattikf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattitf, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floattixf.zig b/lib/compiler_rt/floattixf.zig index a8fd2d6ae6..3dcdac3a21 100644 --- a/lib/compiler_rt/floattixf.zig +++ b/lib/compiler_rt/floattixf.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floattixf_windows_x86_64, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattixf_windows_x86_64, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floattixf, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floattixf, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatundidf.zig b/lib/compiler_rt/floatundidf.zig index b158fb546d..5cb1de0d35 100644 --- a/lib/compiler_rt/floatundidf.zig +++ b/lib/compiler_rt/floatundidf.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatundidf, .{ .name = "__floatundidf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatundidf, .{ .name = "__floatundidf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatundihf.zig b/lib/compiler_rt/floatundihf.zig index 1c534c9175..d05eb0a25e 100644 --- a/lib/compiler_rt/floatundihf.zig +++ b/lib/compiler_rt/floatundihf.zig @@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; comptime { - @export(__floatundihf, .{ .name = "__floatundihf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatundihf, .{ .name = "__floatundihf", .linkage = common.linkage, .visibility = common.visibility }); } fn __floatundihf(a: u64) callconv(.C) f16 { diff --git a/lib/compiler_rt/floatundisf.zig b/lib/compiler_rt/floatundisf.zig index c9dffa7e36..17f9148575 100644 --- a/lib/compiler_rt/floatundisf.zig +++ b/lib/compiler_rt/floatundisf.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatunditf.zig b/lib/compiler_rt/floatunditf.zig index d573d095bc..8f42107ba7 100644 --- a/lib/compiler_rt/floatunditf.zig +++ b/lib/compiler_rt/floatunditf.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __floatunditf(a: u64) callconv(.C) f128 { diff --git a/lib/compiler_rt/floatundixf.zig b/lib/compiler_rt/floatundixf.zig index 33836f3ccb..ed58f943d4 100644 --- a/lib/compiler_rt/floatundixf.zig +++ b/lib/compiler_rt/floatundixf.zig @@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; comptime { - @export(__floatundixf, .{ .name = "__floatundixf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatundixf, .{ .name = "__floatundixf", .linkage = common.linkage, .visibility = common.visibility }); } fn __floatundixf(a: u64) callconv(.C) f80 { diff --git a/lib/compiler_rt/floatunsidf.zig b/lib/compiler_rt/floatunsidf.zig index 3ffd79655a..a988d80c07 100644 --- a/lib/compiler_rt/floatunsidf.zig +++ b/lib/compiler_rt/floatunsidf.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatunsidf, .{ .name = "__floatunsidf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatunsihf.zig b/lib/compiler_rt/floatunsihf.zig index fcfbbaf646..9f64e0e9a8 100644 --- a/lib/compiler_rt/floatunsihf.zig +++ b/lib/compiler_rt/floatunsihf.zig @@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; comptime { - @export(__floatunsihf, .{ .name = "__floatunsihf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatunsihf, .{ .name = "__floatunsihf", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __floatunsihf(a: u32) callconv(.C) f16 { diff --git a/lib/compiler_rt/floatunsisf.zig b/lib/compiler_rt/floatunsisf.zig index b7cc567ff0..7519ab77c7 100644 --- a/lib/compiler_rt/floatunsisf.zig +++ b/lib/compiler_rt/floatunsisf.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatunsisf, .{ .name = "__floatunsisf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatunsitf.zig b/lib/compiler_rt/floatunsitf.zig index 0414784b83..c6f0bea610 100644 --- a/lib/compiler_rt/floatunsitf.zig +++ b/lib/compiler_rt/floatunsitf.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__floatunsitf, .{ .name = "__floatunsikf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatunsitf, .{ .name = "__floatunsikf", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __floatunsitf(a: u32) callconv(.C) f128 { diff --git a/lib/compiler_rt/floatunsixf.zig b/lib/compiler_rt/floatunsixf.zig index 866f3f8c47..cb4f77d73c 100644 --- a/lib/compiler_rt/floatunsixf.zig +++ b/lib/compiler_rt/floatunsixf.zig @@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt; pub const panic = common.panic; comptime { - @export(__floatunsixf, .{ .name = "__floatunsixf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatunsixf, .{ .name = "__floatunsixf", .linkage = common.linkage, .visibility = common.visibility }); } fn __floatunsixf(a: u32) callconv(.C) f80 { diff --git a/lib/compiler_rt/floatuntidf.zig b/lib/compiler_rt/floatuntidf.zig index f036ffd7fe..52fdbfd930 100644 --- a/lib/compiler_rt/floatuntidf.zig +++ b/lib/compiler_rt/floatuntidf.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floatuntidf_windows_x86_64, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntidf_windows_x86_64, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntidf, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatuntihf.zig b/lib/compiler_rt/floatuntihf.zig index 97ccf7f5fe..caa64d3a40 100644 --- a/lib/compiler_rt/floatuntihf.zig +++ b/lib/compiler_rt/floatuntihf.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floatuntihf_windows_x86_64, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntihf_windows_x86_64, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatuntihf, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntihf, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatuntisf.zig b/lib/compiler_rt/floatuntisf.zig index 8d8f771e7d..6db67b737d 100644 --- a/lib/compiler_rt/floatuntisf.zig +++ b/lib/compiler_rt/floatuntisf.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floatuntisf_windows_x86_64, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntisf_windows_x86_64, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntisf, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatuntitf.zig b/lib/compiler_rt/floatuntitf.zig index e828f12d8b..c5152cee02 100644 --- a/lib/compiler_rt/floatuntitf.zig +++ b/lib/compiler_rt/floatuntitf.zig @@ -6,11 +6,11 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floatuntitf_windows_x86_64, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntitf_windows_x86_64, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility }); } else { if (common.want_ppc_abi) - @export(__floatuntitf, .{ .name = "__floatuntikf", .linkage = common.linkage, .visibility = common.visibility }); - @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntitf, .{ .name = "__floatuntikf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntitf, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floatuntixf.zig b/lib/compiler_rt/floatuntixf.zig index c9016bfa06..d7592c1c75 100644 --- a/lib/compiler_rt/floatuntixf.zig +++ b/lib/compiler_rt/floatuntixf.zig @@ -6,9 +6,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__floatuntixf_windows_x86_64, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntixf_windows_x86_64, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__floatuntixf, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floatuntixf, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/floor.zig b/lib/compiler_rt/floor.zig index f9d8075be9..b9eb4e3251 100644 --- a/lib/compiler_rt/floor.zig +++ b/lib/compiler_rt/floor.zig @@ -15,15 +15,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__floorh, .{ .name = "__floorh", .linkage = common.linkage, .visibility = common.visibility }); - @export(floorf, .{ .name = "floorf", .linkage = common.linkage, .visibility = common.visibility }); - @export(floor, .{ .name = "floor", .linkage = common.linkage, .visibility = common.visibility }); - @export(__floorx, .{ .name = "__floorx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floorh, .{ .name = "__floorh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&floorf, .{ .name = "floorf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&floor, .{ .name = "floor", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__floorx, .{ .name = "__floorx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(floorq, .{ .name = "floorf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&floorq, .{ .name = "floorf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(floorq, .{ .name = "floorq", .linkage = common.linkage, .visibility = common.visibility }); - @export(floorl, .{ .name = "floorl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&floorq, .{ .name = "floorq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&floorl, .{ .name = "floorl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __floorh(x: f16) callconv(.C) f16 { @@ -160,7 +160,7 @@ pub fn floorq(x: f128) callconv(.C) f128 { } pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __floorh(x), 32 => return floorf(x), 64 => return floor(x), diff --git a/lib/compiler_rt/fma.zig b/lib/compiler_rt/fma.zig index ad775db5dd..46377bdc2e 100644 --- a/lib/compiler_rt/fma.zig +++ b/lib/compiler_rt/fma.zig @@ -13,15 +13,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__fmah, .{ .name = "__fmah", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmaf, .{ .name = "fmaf", .linkage = common.linkage, .visibility = common.visibility }); - @export(fma, .{ .name = "fma", .linkage = common.linkage, .visibility = common.visibility }); - @export(__fmax, .{ .name = "__fmax", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fmah, .{ .name = "__fmah", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmaf, .{ .name = "fmaf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fma, .{ .name = "fma", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fmax, .{ .name = "__fmax", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(fmaq, .{ .name = "fmaf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmaq, .{ .name = "fmaf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(fmaq, .{ .name = "fmaq", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmal, .{ .name = "fmal", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmaq, .{ .name = "fmaq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmal, .{ .name = "fmal", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 { @@ -151,7 +151,7 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 { } pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __fmah(x, y, z), 32 => return fmaf(x, y, z), 64 => return fma(x, y, z), diff --git a/lib/compiler_rt/fmax.zig b/lib/compiler_rt/fmax.zig index 9645b665f3..a26d41a2b3 100644 --- a/lib/compiler_rt/fmax.zig +++ b/lib/compiler_rt/fmax.zig @@ -7,15 +7,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmaxf, .{ .name = "fmaxf", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmax, .{ .name = "fmax", .linkage = common.linkage, .visibility = common.visibility }); - @export(__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmaxf, .{ .name = "fmaxf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmax, .{ .name = "fmax", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(fmaxq, .{ .name = "fmaxq", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmaxl, .{ .name = "fmaxl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmaxq, .{ .name = "fmaxq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmaxl, .{ .name = "fmaxl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 { @@ -39,7 +39,7 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 { } pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __fmaxh(x, y), 32 => return fmaxf(x, y), 64 => return fmax(x, y), diff --git a/lib/compiler_rt/fmin.zig b/lib/compiler_rt/fmin.zig index 6cb7f8544e..079e503218 100644 --- a/lib/compiler_rt/fmin.zig +++ b/lib/compiler_rt/fmin.zig @@ -7,15 +7,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__fminh, .{ .name = "__fminh", .linkage = common.linkage, .visibility = common.visibility }); - @export(fminf, .{ .name = "fminf", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmin, .{ .name = "fmin", .linkage = common.linkage, .visibility = common.visibility }); - @export(__fminx, .{ .name = "__fminx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fminh, .{ .name = "__fminh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fminf, .{ .name = "fminf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmin, .{ .name = "fmin", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fminx, .{ .name = "__fminx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(fminq, .{ .name = "fminf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fminq, .{ .name = "fminf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(fminq, .{ .name = "fminq", .linkage = common.linkage, .visibility = common.visibility }); - @export(fminl, .{ .name = "fminl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fminq, .{ .name = "fminq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fminl, .{ .name = "fminl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fminh(x: f16, y: f16) callconv(.C) f16 { @@ -39,7 +39,7 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 { } pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __fminh(x, y), 32 => return fminf(x, y), 64 => return fmin(x, y), diff --git a/lib/compiler_rt/fmod.zig b/lib/compiler_rt/fmod.zig index 465d46e7f1..592a563e7e 100644 --- a/lib/compiler_rt/fmod.zig +++ b/lib/compiler_rt/fmod.zig @@ -9,15 +9,15 @@ const normalize = common.normalize; pub const panic = common.panic; comptime { - @export(__fmodh, .{ .name = "__fmodh", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmodf, .{ .name = "fmodf", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmod, .{ .name = "fmod", .linkage = common.linkage, .visibility = common.visibility }); - @export(__fmodx, .{ .name = "__fmodx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fmodh, .{ .name = "__fmodh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmodf, .{ .name = "fmodf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmod, .{ .name = "fmod", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__fmodx, .{ .name = "__fmodx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(fmodq, .{ .name = "fmodf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmodq, .{ .name = "fmodf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(fmodq, .{ .name = "fmodq", .linkage = common.linkage, .visibility = common.visibility }); - @export(fmodl, .{ .name = "fmodl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmodq, .{ .name = "fmodq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&fmodl, .{ .name = "fmodl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 { @@ -251,7 +251,7 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 { } pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __fmodh(a, b), 32 => return fmodf(a, b), 64 => return fmod(a, b), @@ -262,7 +262,7 @@ pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { } inline fn generic_fmod(comptime T: type, x: T, y: T) T { - const bits = @typeInfo(T).Float.bits; + const bits = @typeInfo(T).float.bits; const uint = std.meta.Int(.unsigned, bits); comptime assert(T == f32 or T == f64); const digits = if (T == f32) 23 else 52; diff --git a/lib/compiler_rt/gedf2.zig b/lib/compiler_rt/gedf2.zig index 0ade0cf46a..967278f324 100644 --- a/lib/compiler_rt/gedf2.zig +++ b/lib/compiler_rt/gedf2.zig @@ -7,11 +7,11 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__gedf2, .{ .name = "__gedf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__gtdf2, .{ .name = "__gtdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gedf2, .{ .name = "__gedf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gtdf2, .{ .name = "__gtdf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/gehf2.zig b/lib/compiler_rt/gehf2.zig index c6e7b90a65..edf45d9553 100644 --- a/lib/compiler_rt/gehf2.zig +++ b/lib/compiler_rt/gehf2.zig @@ -6,8 +6,8 @@ const comparef = @import("./comparef.zig"); pub const panic = common.panic; comptime { - @export(__gehf2, .{ .name = "__gehf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__gthf2, .{ .name = "__gthf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gehf2, .{ .name = "__gehf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gthf2, .{ .name = "__gthf2", .linkage = common.linkage, .visibility = common.visibility }); } /// "These functions return a value greater than or equal to zero if neither diff --git a/lib/compiler_rt/gesf2.zig b/lib/compiler_rt/gesf2.zig index 44d8b5cc75..569f66425d 100644 --- a/lib/compiler_rt/gesf2.zig +++ b/lib/compiler_rt/gesf2.zig @@ -7,11 +7,11 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/getf2.zig b/lib/compiler_rt/getf2.zig index 07e87ed55c..c5aebdd2b9 100644 --- a/lib/compiler_rt/getf2.zig +++ b/lib/compiler_rt/getf2.zig @@ -7,14 +7,14 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { // These exports are handled in cmptf2.zig because gt and ge on sparc // are based on calling _Qp_cmp. } - @export(__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility }); } /// "These functions return a value greater than or equal to zero if neither diff --git a/lib/compiler_rt/gexf2.zig b/lib/compiler_rt/gexf2.zig index 94f735b8c2..8aee88cbc2 100644 --- a/lib/compiler_rt/gexf2.zig +++ b/lib/compiler_rt/gexf2.zig @@ -4,8 +4,8 @@ const comparef = @import("./comparef.zig"); pub const panic = common.panic; comptime { - @export(__gexf2, .{ .name = "__gexf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__gtxf2, .{ .name = "__gtxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gexf2, .{ .name = "__gexf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gtxf2, .{ .name = "__gtxf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __gexf2(a: f80, b: f80) callconv(.C) i32 { diff --git a/lib/compiler_rt/int.zig b/lib/compiler_rt/int.zig index c100b815a5..49891ac5e3 100644 --- a/lib/compiler_rt/int.zig +++ b/lib/compiler_rt/int.zig @@ -15,24 +15,24 @@ const arm = @import("arm.zig"); pub const panic = common.panic; comptime { - @export(__divmodti4, .{ .name = "__divmodti4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divmodti4, .{ .name = "__divmodti4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divmoddi4, .{ .name = "__divmoddi4", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_aeabi) { - @export(__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__divsi3, .{ .name = "__divsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__udivsi3, .{ .name = "__udivsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divsi3, .{ .name = "__divsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivsi3, .{ .name = "__udivsi3", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__divdi3, .{ .name = "__divdi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__udivdi3, .{ .name = "__udivdi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__modsi3, .{ .name = "__modsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__moddi3, .{ .name = "__moddi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__umodsi3, .{ .name = "__umodsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__umoddi3, .{ .name = "__umoddi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divdi3, .{ .name = "__divdi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivdi3, .{ .name = "__udivdi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__modsi3, .{ .name = "__modsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__moddi3, .{ .name = "__moddi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__umodsi3, .{ .name = "__umodsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__umoddi3, .{ .name = "__umoddi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__divmodsi4, .{ .name = "__divmodsi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __divmodti4(a: i128, b: i128, rem: *i128) callconv(.C) i128 { diff --git a/lib/compiler_rt/int_from_float.zig b/lib/compiler_rt/int_from_float.zig index 7149bf53bf..f0624ebb59 100644 --- a/lib/compiler_rt/int_from_float.zig +++ b/lib/compiler_rt/int_from_float.zig @@ -4,8 +4,8 @@ const Log2Int = math.Log2Int; pub inline fn intFromFloat(comptime I: type, a: anytype) I { const F = @TypeOf(a); - const float_bits = @typeInfo(F).Float.bits; - const int_bits = @typeInfo(I).Int.bits; + const float_bits = @typeInfo(F).float.bits; + const int_bits = @typeInfo(I).int.bits; const rep_t = Int(.unsigned, float_bits); const sig_bits = math.floatMantissaBits(F); const exp_bits = math.floatExponentBits(F); @@ -26,7 +26,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I { if (exponent < 0) return 0; // If the value is too large for the integer type, saturate. - switch (@typeInfo(I).Int.signedness) { + switch (@typeInfo(I).int.signedness) { .unsigned => { if (negative) return 0; if (@as(c_uint, @intCast(exponent)) >= @min(int_bits, max_exp)) return math.maxInt(I); @@ -45,7 +45,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I { result = @as(I, @intCast(significand)) << @intCast(exponent - fractional_bits); } - if ((@typeInfo(I).Int.signedness == .signed) and negative) + if ((@typeInfo(I).int.signedness == .signed) and negative) return ~result +% 1; return result; } diff --git a/lib/compiler_rt/log.zig b/lib/compiler_rt/log.zig index 6753c0c77f..6b179fd199 100644 --- a/lib/compiler_rt/log.zig +++ b/lib/compiler_rt/log.zig @@ -14,15 +14,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__logh, .{ .name = "__logh", .linkage = common.linkage, .visibility = common.visibility }); - @export(logf, .{ .name = "logf", .linkage = common.linkage, .visibility = common.visibility }); - @export(log, .{ .name = "log", .linkage = common.linkage, .visibility = common.visibility }); - @export(__logx, .{ .name = "__logx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__logh, .{ .name = "__logh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&logf, .{ .name = "logf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log, .{ .name = "log", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__logx, .{ .name = "__logx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(logq, .{ .name = "logf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&logq, .{ .name = "logf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(logq, .{ .name = "logq", .linkage = common.linkage, .visibility = common.visibility }); - @export(logl, .{ .name = "logl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&logq, .{ .name = "logq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&logl, .{ .name = "logl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __logh(a: f16) callconv(.C) f16 { @@ -149,7 +149,7 @@ pub fn logq(a: f128) callconv(.C) f128 { } pub fn logl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __logh(x), 32 => return logf(x), 64 => return log(x), diff --git a/lib/compiler_rt/log10.zig b/lib/compiler_rt/log10.zig index 917a200123..7b32362534 100644 --- a/lib/compiler_rt/log10.zig +++ b/lib/compiler_rt/log10.zig @@ -15,15 +15,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__log10h, .{ .name = "__log10h", .linkage = common.linkage, .visibility = common.visibility }); - @export(log10f, .{ .name = "log10f", .linkage = common.linkage, .visibility = common.visibility }); - @export(log10, .{ .name = "log10", .linkage = common.linkage, .visibility = common.visibility }); - @export(__log10x, .{ .name = "__log10x", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__log10h, .{ .name = "__log10h", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log10f, .{ .name = "log10f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log10, .{ .name = "log10", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__log10x, .{ .name = "__log10x", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(log10q, .{ .name = "log10f128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log10q, .{ .name = "log10f128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(log10q, .{ .name = "log10q", .linkage = common.linkage, .visibility = common.visibility }); - @export(log10l, .{ .name = "log10l", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log10q, .{ .name = "log10q", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log10l, .{ .name = "log10l", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __log10h(a: f16) callconv(.C) f16 { @@ -177,7 +177,7 @@ pub fn log10q(a: f128) callconv(.C) f128 { } pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __log10h(x), 32 => return log10f(x), 64 => return log10(x), diff --git a/lib/compiler_rt/log2.zig b/lib/compiler_rt/log2.zig index 41027c3df1..e152d5a6b4 100644 --- a/lib/compiler_rt/log2.zig +++ b/lib/compiler_rt/log2.zig @@ -15,15 +15,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__log2h, .{ .name = "__log2h", .linkage = common.linkage, .visibility = common.visibility }); - @export(log2f, .{ .name = "log2f", .linkage = common.linkage, .visibility = common.visibility }); - @export(log2, .{ .name = "log2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__log2x, .{ .name = "__log2x", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__log2h, .{ .name = "__log2h", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log2f, .{ .name = "log2f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log2, .{ .name = "log2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__log2x, .{ .name = "__log2x", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(log2q, .{ .name = "log2f128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log2q, .{ .name = "log2f128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(log2q, .{ .name = "log2q", .linkage = common.linkage, .visibility = common.visibility }); - @export(log2l, .{ .name = "log2l", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log2q, .{ .name = "log2q", .linkage = common.linkage, .visibility = common.visibility }); + @export(&log2l, .{ .name = "log2l", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __log2h(a: f16) callconv(.C) f16 { @@ -169,7 +169,7 @@ pub fn log2q(a: f128) callconv(.C) f128 { } pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __log2h(x), 32 => return log2f(x), 64 => return log2(x), diff --git a/lib/compiler_rt/memcmp.zig b/lib/compiler_rt/memcmp.zig index b337e6f29e..b0e822e2dc 100644 --- a/lib/compiler_rt/memcmp.zig +++ b/lib/compiler_rt/memcmp.zig @@ -2,7 +2,7 @@ const std = @import("std"); const common = @import("./common.zig"); comptime { - @export(memcmp, .{ .name = "memcmp", .linkage = common.linkage, .visibility = common.visibility }); + @export(&memcmp, .{ .name = "memcmp", .linkage = common.linkage, .visibility = common.visibility }); } pub fn memcmp(vl: [*]const u8, vr: [*]const u8, n: usize) callconv(.C) c_int { diff --git a/lib/compiler_rt/memcpy.zig b/lib/compiler_rt/memcpy.zig index 410117b6c3..4609f25576 100644 --- a/lib/compiler_rt/memcpy.zig +++ b/lib/compiler_rt/memcpy.zig @@ -4,7 +4,7 @@ const builtin = @import("builtin"); comptime { if (builtin.object_format != .c) { - @export(memcpy, .{ .name = "memcpy", .linkage = common.linkage, .visibility = common.visibility }); + @export(&memcpy, .{ .name = "memcpy", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/memmove.zig b/lib/compiler_rt/memmove.zig index bb772b3217..75f9e46d16 100644 --- a/lib/compiler_rt/memmove.zig +++ b/lib/compiler_rt/memmove.zig @@ -2,7 +2,7 @@ const std = @import("std"); const common = @import("./common.zig"); comptime { - @export(memmove, .{ .name = "memmove", .linkage = common.linkage, .visibility = common.visibility }); + @export(&memmove, .{ .name = "memmove", .linkage = common.linkage, .visibility = common.visibility }); } pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 { diff --git a/lib/compiler_rt/memset.zig b/lib/compiler_rt/memset.zig index 25c5493607..31c01f0948 100644 --- a/lib/compiler_rt/memset.zig +++ b/lib/compiler_rt/memset.zig @@ -4,8 +4,8 @@ const builtin = @import("builtin"); comptime { if (builtin.object_format != .c) { - @export(memset, .{ .name = "memset", .linkage = common.linkage, .visibility = common.visibility }); - @export(__memset, .{ .name = "__memset", .linkage = common.linkage, .visibility = common.visibility }); + @export(&memset, .{ .name = "memset", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__memset, .{ .name = "__memset", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/modti3.zig b/lib/compiler_rt/modti3.zig index bdeb7151da..0c13660d3a 100644 --- a/lib/compiler_rt/modti3.zig +++ b/lib/compiler_rt/modti3.zig @@ -11,9 +11,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__modti3, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__modti3, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/mulXi3.zig b/lib/compiler_rt/mulXi3.zig index 0b0782fdce..d8b3c91914 100644 --- a/lib/compiler_rt/mulXi3.zig +++ b/lib/compiler_rt/mulXi3.zig @@ -7,16 +7,16 @@ const native_endian = builtin.cpu.arch.endian(); pub const panic = common.panic; comptime { - @export(__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_aeabi) { - @export(__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__muldi3, .{ .name = "__muldi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__muldi3, .{ .name = "__muldi3", .linkage = common.linkage, .visibility = common.visibility }); } if (common.want_windows_v2u64_abi) { - @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__multi3, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__multi3, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/muldc3.zig b/lib/compiler_rt/muldc3.zig index 3a497fdedc..d23addeac5 100644 --- a/lib/compiler_rt/muldc3.zig +++ b/lib/compiler_rt/muldc3.zig @@ -5,7 +5,7 @@ pub const panic = common.panic; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__muldc3, .{ .name = "__muldc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__muldc3, .{ .name = "__muldc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/muldf3.zig b/lib/compiler_rt/muldf3.zig index 81c6989381..d5af6d06c4 100644 --- a/lib/compiler_rt/muldf3.zig +++ b/lib/compiler_rt/muldf3.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__muldf3, .{ .name = "__muldf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__muldf3, .{ .name = "__muldf3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/mulf3.zig b/lib/compiler_rt/mulf3.zig index c61ade8e55..ad60ec41a5 100644 --- a/lib/compiler_rt/mulf3.zig +++ b/lib/compiler_rt/mulf3.zig @@ -7,7 +7,7 @@ const common = @import("./common.zig"); /// https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/fp_mul_impl.inc pub inline fn mulf3(comptime T: type, a: T, b: T) T { @setRuntimeSafety(builtin.is_test); - const typeWidth = @typeInfo(T).Float.bits; + const typeWidth = @typeInfo(T).float.bits; const significandBits = math.floatMantissaBits(T); const fractionalBits = math.floatFractionalBits(T); const exponentBits = math.floatExponentBits(T); @@ -16,7 +16,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T { // ZSignificand is large enough to contain the significand, including an explicit integer bit const ZSignificand = PowerOfTwoSignificandZ(T); - const ZSignificandBits = @typeInfo(ZSignificand).Int.bits; + const ZSignificandBits = @typeInfo(ZSignificand).int.bits; const roundBit = (1 << (ZSignificandBits - 1)); const signBit = (@as(Z, 1) << (significandBits + exponentBits)); @@ -164,7 +164,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T { /// This is analogous to an shr version of `@shlWithOverflow` fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool { @setRuntimeSafety(builtin.is_test); - const typeWidth = @typeInfo(Z).Int.bits; + const typeWidth = @typeInfo(Z).int.bits; var inexact = false; if (count < typeWidth) { inexact = (lo.* << @intCast(typeWidth -% count)) != 0; diff --git a/lib/compiler_rt/mulhc3.zig b/lib/compiler_rt/mulhc3.zig index cf44f1cc14..4d0fa1459d 100644 --- a/lib/compiler_rt/mulhc3.zig +++ b/lib/compiler_rt/mulhc3.zig @@ -5,7 +5,7 @@ pub const panic = common.panic; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__mulhc3, .{ .name = "__mulhc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulhc3, .{ .name = "__mulhc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/mulhf3.zig b/lib/compiler_rt/mulhf3.zig index c38c659092..0eaf35e18f 100644 --- a/lib/compiler_rt/mulhf3.zig +++ b/lib/compiler_rt/mulhf3.zig @@ -4,7 +4,7 @@ const mulf3 = @import("./mulf3.zig").mulf3; pub const panic = common.panic; comptime { - @export(__mulhf3, .{ .name = "__mulhf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulhf3, .{ .name = "__mulhf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __mulhf3(a: f16, b: f16) callconv(.C) f16 { diff --git a/lib/compiler_rt/mulo.zig b/lib/compiler_rt/mulo.zig index ec77068fc6..44937cfa18 100644 --- a/lib/compiler_rt/mulo.zig +++ b/lib/compiler_rt/mulo.zig @@ -6,9 +6,9 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__muloti4, .{ .name = "__muloti4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__muloti4, .{ .name = "__muloti4", .linkage = common.linkage, .visibility = common.visibility }); } // mulo - multiplication overflow diff --git a/lib/compiler_rt/mulsc3.zig b/lib/compiler_rt/mulsc3.zig index add389a598..9fb86d1bf4 100644 --- a/lib/compiler_rt/mulsc3.zig +++ b/lib/compiler_rt/mulsc3.zig @@ -5,7 +5,7 @@ pub const panic = common.panic; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__mulsc3, .{ .name = "__mulsc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulsc3, .{ .name = "__mulsc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/mulsf3.zig b/lib/compiler_rt/mulsf3.zig index 27d0e09f34..4c529cb2d8 100644 --- a/lib/compiler_rt/mulsf3.zig +++ b/lib/compiler_rt/mulsf3.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__mulsf3, .{ .name = "__mulsf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulsf3, .{ .name = "__mulsf3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/multc3.zig b/lib/compiler_rt/multc3.zig index ae46bdeed8..cc69e0b5fa 100644 --- a/lib/compiler_rt/multc3.zig +++ b/lib/compiler_rt/multc3.zig @@ -6,8 +6,8 @@ pub const panic = common.panic; comptime { if (@import("builtin").zig_backend != .stage2_c) { if (common.want_ppc_abi) - @export(__multc3, .{ .name = "__mulkc3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__multc3, .{ .name = "__multc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__multc3, .{ .name = "__mulkc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__multc3, .{ .name = "__multc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/multf3.zig b/lib/compiler_rt/multf3.zig index 453a869a83..8ed84d0587 100644 --- a/lib/compiler_rt/multf3.zig +++ b/lib/compiler_rt/multf3.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__multf3, .{ .name = "__mulkf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__multf3, .{ .name = "__mulkf3", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__multf3, .{ .name = "__multf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__multf3, .{ .name = "__multf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __multf3(a: f128, b: f128) callconv(.C) f128 { diff --git a/lib/compiler_rt/mulxc3.zig b/lib/compiler_rt/mulxc3.zig index 8d836ef04d..27bcc0796d 100644 --- a/lib/compiler_rt/mulxc3.zig +++ b/lib/compiler_rt/mulxc3.zig @@ -5,7 +5,7 @@ pub const panic = common.panic; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__mulxc3, .{ .name = "__mulxc3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulxc3, .{ .name = "__mulxc3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/mulxf3.zig b/lib/compiler_rt/mulxf3.zig index 04213b3a9b..f225ed1439 100644 --- a/lib/compiler_rt/mulxf3.zig +++ b/lib/compiler_rt/mulxf3.zig @@ -4,7 +4,7 @@ const mulf3 = @import("./mulf3.zig").mulf3; pub const panic = common.panic; comptime { - @export(__mulxf3, .{ .name = "__mulxf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__mulxf3, .{ .name = "__mulxf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __mulxf3(a: f80, b: f80) callconv(.C) f80 { diff --git a/lib/compiler_rt/negXi2.zig b/lib/compiler_rt/negXi2.zig index df0ddf9409..c49df08428 100644 --- a/lib/compiler_rt/negXi2.zig +++ b/lib/compiler_rt/negXi2.zig @@ -13,9 +13,9 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__negsi2, .{ .name = "__negsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__negdi2, .{ .name = "__negdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__negti2, .{ .name = "__negti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negsi2, .{ .name = "__negsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negdi2, .{ .name = "__negdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negti2, .{ .name = "__negti2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __negsi2(a: i32) callconv(.C) i32 { diff --git a/lib/compiler_rt/negdf2.zig b/lib/compiler_rt/negdf2.zig index 25f27a0a1e..afc9e31ffe 100644 --- a/lib/compiler_rt/negdf2.zig +++ b/lib/compiler_rt/negdf2.zig @@ -4,9 +4,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__negdf2, .{ .name = "__negdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negdf2, .{ .name = "__negdf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/neghf2.zig b/lib/compiler_rt/neghf2.zig index feee02afb0..455c3c7fc3 100644 --- a/lib/compiler_rt/neghf2.zig +++ b/lib/compiler_rt/neghf2.zig @@ -3,7 +3,7 @@ const common = @import("./common.zig"); pub const panic = common.panic; comptime { - @export(__neghf2, .{ .name = "__neghf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__neghf2, .{ .name = "__neghf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __neghf2(a: f16) callconv(.C) f16 { diff --git a/lib/compiler_rt/negsf2.zig b/lib/compiler_rt/negsf2.zig index 1b9e10e12c..27c2eef5ce 100644 --- a/lib/compiler_rt/negsf2.zig +++ b/lib/compiler_rt/negsf2.zig @@ -4,9 +4,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__negsf2, .{ .name = "__negsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negsf2, .{ .name = "__negsf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/negtf2.zig b/lib/compiler_rt/negtf2.zig index 25462ed64d..2c576c32f2 100644 --- a/lib/compiler_rt/negtf2.zig +++ b/lib/compiler_rt/negtf2.zig @@ -4,8 +4,8 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) - @export(__negtf2, .{ .name = "__negkf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__negtf2, .{ .name = "__negtf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negtf2, .{ .name = "__negkf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negtf2, .{ .name = "__negtf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __negtf2(a: f128) callconv(.C) f128 { diff --git a/lib/compiler_rt/negv.zig b/lib/compiler_rt/negv.zig index 64961255c3..28122faca5 100644 --- a/lib/compiler_rt/negv.zig +++ b/lib/compiler_rt/negv.zig @@ -8,9 +8,9 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__negvti2, .{ .name = "__negvti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negvti2, .{ .name = "__negvti2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __negvsi2(a: i32) callconv(.C) i32 { diff --git a/lib/compiler_rt/negxf2.zig b/lib/compiler_rt/negxf2.zig index 13a6ef2cab..9bcd98463f 100644 --- a/lib/compiler_rt/negxf2.zig +++ b/lib/compiler_rt/negxf2.zig @@ -3,7 +3,7 @@ const common = @import("./common.zig"); pub const panic = common.panic; comptime { - @export(__negxf2, .{ .name = "__negxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__negxf2, .{ .name = "__negxf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __negxf2(a: f80) callconv(.C) f80 { diff --git a/lib/compiler_rt/os_version_check.zig b/lib/compiler_rt/os_version_check.zig index 80353d5e5f..f61b9a71ba 100644 --- a/lib/compiler_rt/os_version_check.zig +++ b/lib/compiler_rt/os_version_check.zig @@ -9,7 +9,7 @@ const have_availability_version_check = builtin.os.tag.isDarwin() and comptime { if (have_availability_version_check) { - @export(__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage }); + @export(&__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage }); } } diff --git a/lib/compiler_rt/parity.zig b/lib/compiler_rt/parity.zig index 219102c226..37faa1a4b1 100644 --- a/lib/compiler_rt/parity.zig +++ b/lib/compiler_rt/parity.zig @@ -8,9 +8,9 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__paritysi2, .{ .name = "__paritysi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__paritydi2, .{ .name = "__paritydi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__parityti2, .{ .name = "__parityti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__paritysi2, .{ .name = "__paritysi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__paritydi2, .{ .name = "__paritydi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__parityti2, .{ .name = "__parityti2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __paritysi2(a: i32) callconv(.C) i32 { @@ -26,7 +26,7 @@ pub fn __parityti2(a: i128) callconv(.C) i32 { } inline fn parityXi2(comptime T: type, a: T) i32 { - var x: std.meta.Int(.unsigned, @typeInfo(T).Int.bits) = @bitCast(a); + var x: std.meta.Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a); // Bit Twiddling Hacks: Compute parity in parallel comptime var shift: u8 = @bitSizeOf(T) / 2; inline while (shift > 2) { diff --git a/lib/compiler_rt/popcount.zig b/lib/compiler_rt/popcount.zig index 64a73b804f..d54a4aab42 100644 --- a/lib/compiler_rt/popcount.zig +++ b/lib/compiler_rt/popcount.zig @@ -13,9 +13,9 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__popcountti2, .{ .name = "__popcountti2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__popcountsi2, .{ .name = "__popcountsi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__popcountdi2, .{ .name = "__popcountdi2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__popcountti2, .{ .name = "__popcountti2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __popcountsi2(a: i32) callconv(.C) i32 { diff --git a/lib/compiler_rt/powiXf2.zig b/lib/compiler_rt/powiXf2.zig index 97dc1b77d1..4cf59950f0 100644 --- a/lib/compiler_rt/powiXf2.zig +++ b/lib/compiler_rt/powiXf2.zig @@ -10,13 +10,13 @@ const std = @import("std"); pub const panic = common.panic; comptime { - @export(__powihf2, .{ .name = "__powihf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__powisf2, .{ .name = "__powisf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__powidf2, .{ .name = "__powidf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__powihf2, .{ .name = "__powihf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__powisf2, .{ .name = "__powisf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__powidf2, .{ .name = "__powidf2", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) - @export(__powitf2, .{ .name = "__powikf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__powitf2, .{ .name = "__powitf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__powixf2, .{ .name = "__powixf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__powitf2, .{ .name = "__powikf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__powitf2, .{ .name = "__powitf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__powixf2, .{ .name = "__powixf2", .linkage = common.linkage, .visibility = common.visibility }); } inline fn powiXf2(comptime FT: type, a: FT, b: i32) FT { diff --git a/lib/compiler_rt/round.zig b/lib/compiler_rt/round.zig index 3062ff76e9..f0745feb49 100644 --- a/lib/compiler_rt/round.zig +++ b/lib/compiler_rt/round.zig @@ -15,15 +15,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__roundh, .{ .name = "__roundh", .linkage = common.linkage, .visibility = common.visibility }); - @export(roundf, .{ .name = "roundf", .linkage = common.linkage, .visibility = common.visibility }); - @export(round, .{ .name = "round", .linkage = common.linkage, .visibility = common.visibility }); - @export(__roundx, .{ .name = "__roundx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__roundh, .{ .name = "__roundh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&roundf, .{ .name = "roundf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&round, .{ .name = "round", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__roundx, .{ .name = "__roundx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(roundq, .{ .name = "roundf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&roundq, .{ .name = "roundf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(roundq, .{ .name = "roundq", .linkage = common.linkage, .visibility = common.visibility }); - @export(roundl, .{ .name = "roundl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&roundq, .{ .name = "roundq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&roundl, .{ .name = "roundl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __roundh(x: f16) callconv(.C) f16 { @@ -142,7 +142,7 @@ pub fn roundq(x_: f128) callconv(.C) f128 { } pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __roundh(x), 32 => return roundf(x), 64 => return round(x), diff --git a/lib/compiler_rt/shift.zig b/lib/compiler_rt/shift.zig index 59701f747d..5b46e8ec00 100644 --- a/lib/compiler_rt/shift.zig +++ b/lib/compiler_rt/shift.zig @@ -7,22 +7,22 @@ pub const panic = common.panic; comptime { // symbol compatibility with libgcc - @export(__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_aeabi) { - @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage, .visibility = common.visibility }); - @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage, .visibility = common.visibility }); - @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/sin.zig b/lib/compiler_rt/sin.zig index e1e019512f..505bf59fd4 100644 --- a/lib/compiler_rt/sin.zig +++ b/lib/compiler_rt/sin.zig @@ -19,15 +19,15 @@ const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; pub const panic = common.panic; comptime { - @export(__sinh, .{ .name = "__sinh", .linkage = common.linkage, .visibility = common.visibility }); - @export(sinf, .{ .name = "sinf", .linkage = common.linkage, .visibility = common.visibility }); - @export(sin, .{ .name = "sin", .linkage = common.linkage, .visibility = common.visibility }); - @export(__sinx, .{ .name = "__sinx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__sinh, .{ .name = "__sinh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sinf, .{ .name = "sinf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sin, .{ .name = "sin", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__sinx, .{ .name = "__sinx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(sinq, .{ .name = "sinf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sinq, .{ .name = "sinf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(sinq, .{ .name = "sinq", .linkage = common.linkage, .visibility = common.visibility }); - @export(sinl, .{ .name = "sinl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sinq, .{ .name = "sinq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sinl, .{ .name = "sinl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __sinh(x: f16) callconv(.C) f16 { @@ -130,7 +130,7 @@ pub fn sinq(x: f128) callconv(.C) f128 { } pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __sinh(x), 32 => return sinf(x), 64 => return sin(x), diff --git a/lib/compiler_rt/sincos.zig b/lib/compiler_rt/sincos.zig index 5d8a9a6feb..7763be42db 100644 --- a/lib/compiler_rt/sincos.zig +++ b/lib/compiler_rt/sincos.zig @@ -11,15 +11,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__sincosh, .{ .name = "__sincosh", .linkage = common.linkage, .visibility = common.visibility }); - @export(sincosf, .{ .name = "sincosf", .linkage = common.linkage, .visibility = common.visibility }); - @export(sincos, .{ .name = "sincos", .linkage = common.linkage, .visibility = common.visibility }); - @export(__sincosx, .{ .name = "__sincosx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__sincosh, .{ .name = "__sincosh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sincosf, .{ .name = "sincosf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sincos, .{ .name = "sincos", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__sincosx, .{ .name = "__sincosx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(sincosq, .{ .name = "sincosf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sincosq, .{ .name = "sincosf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(sincosq, .{ .name = "sincosq", .linkage = common.linkage, .visibility = common.visibility }); - @export(sincosl, .{ .name = "sincosl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sincosq, .{ .name = "sincosq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sincosl, .{ .name = "sincosl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void { @@ -198,7 +198,7 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void { } pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __sincosh(x, r_sin, r_cos), 32 => return sincosf(x, r_sin, r_cos), 64 => return sincos(x, r_sin, r_cos), @@ -216,7 +216,7 @@ pub const rem_pio2_generic = @compileError("TODO"); /// * trig.cos_generic ported from __cosl.c inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void { const sc1pio4: F = 1.0 * math.pi / 4.0; - const bits = @typeInfo(F).Float.bits; + const bits = @typeInfo(F).float.bits; const I = std.meta.Int(.unsigned, bits); const ix = @as(I, @bitCast(x)) & (math.maxInt(I) >> 1); const se: u16 = @truncate(ix >> (bits - 16)); diff --git a/lib/compiler_rt/sqrt.zig b/lib/compiler_rt/sqrt.zig index cb686a2d62..b804ff9359 100644 --- a/lib/compiler_rt/sqrt.zig +++ b/lib/compiler_rt/sqrt.zig @@ -7,15 +7,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__sqrth, .{ .name = "__sqrth", .linkage = common.linkage, .visibility = common.visibility }); - @export(sqrtf, .{ .name = "sqrtf", .linkage = common.linkage, .visibility = common.visibility }); - @export(sqrt, .{ .name = "sqrt", .linkage = common.linkage, .visibility = common.visibility }); - @export(__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__sqrth, .{ .name = "__sqrth", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sqrtf, .{ .name = "sqrtf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sqrt, .{ .name = "sqrt", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(sqrtq, .{ .name = "sqrtq", .linkage = common.linkage, .visibility = common.visibility }); - @export(sqrtl, .{ .name = "sqrtl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sqrtq, .{ .name = "sqrtq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&sqrtl, .{ .name = "sqrtl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __sqrth(x: f16) callconv(.C) f16 { @@ -243,7 +243,7 @@ pub fn sqrtq(x: f128) callconv(.C) f128 { } pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __sqrth(x), 32 => return sqrtf(x), 64 => return sqrt(x), diff --git a/lib/compiler_rt/ssp.zig b/lib/compiler_rt/ssp.zig index 236428e1ca..d32895ea52 100644 --- a/lib/compiler_rt/ssp.zig +++ b/lib/compiler_rt/ssp.zig @@ -21,16 +21,16 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8; comptime { - @export(__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = common.linkage, .visibility = common.visibility }); - @export(__chk_fail, .{ .name = "__chk_fail", .linkage = common.linkage, .visibility = common.visibility }); - @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = common.linkage, .visibility = common.visibility }); - @export(__strcpy_chk, .{ .name = "__strcpy_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(__strncpy_chk, .{ .name = "__strncpy_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(__strcat_chk, .{ .name = "__strcat_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(__strncat_chk, .{ .name = "__strncat_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(__memcpy_chk, .{ .name = "__memcpy_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(__memmove_chk, .{ .name = "__memmove_chk", .linkage = common.linkage, .visibility = common.visibility }); - @export(__memset_chk, .{ .name = "__memset_chk", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__chk_fail, .{ .name = "__chk_fail", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__strcpy_chk, .{ .name = "__strcpy_chk", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__strncpy_chk, .{ .name = "__strncpy_chk", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__strcat_chk, .{ .name = "__strcat_chk", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__strncat_chk, .{ .name = "__strncat_chk", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__memcpy_chk, .{ .name = "__memcpy_chk", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__memmove_chk, .{ .name = "__memmove_chk", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__memset_chk, .{ .name = "__memset_chk", .linkage = common.linkage, .visibility = common.visibility }); } fn __stack_chk_fail() callconv(.C) noreturn { diff --git a/lib/compiler_rt/stack_probe.zig b/lib/compiler_rt/stack_probe.zig index 21e41574cc..69de4c8575 100644 --- a/lib/compiler_rt/stack_probe.zig +++ b/lib/compiler_rt/stack_probe.zig @@ -5,9 +5,6 @@ const arch = builtin.cpu.arch; const abi = builtin.abi; const is_test = builtin.is_test; -const is_gnu = abi.isGnu(); -const is_mingw = os_tag == .windows and is_gnu; - const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak; const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .strong; pub const panic = @import("common.zig").panic; @@ -15,17 +12,17 @@ pub const panic = @import("common.zig").panic; comptime { if (builtin.os.tag == .windows) { // Default stack-probe functions emitted by LLVM - if (is_mingw) { - @export(_chkstk, .{ .name = "_alloca", .linkage = linkage }); - @export(___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = linkage }); + if (builtin.target.isMinGW()) { + @export(&_chkstk, .{ .name = "_alloca", .linkage = linkage }); + @export(&___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = linkage }); - if (arch.isAARCH64()) { - @export(__chkstk, .{ .name = "__chkstk", .linkage = linkage }); + if (arch == .thumb or arch == .aarch64) { + @export(&__chkstk, .{ .name = "__chkstk", .linkage = linkage }); } } else if (!builtin.link_libc) { // This symbols are otherwise exported by MSVCRT.lib - @export(_chkstk, .{ .name = "_chkstk", .linkage = linkage }); - @export(__chkstk, .{ .name = "__chkstk", .linkage = linkage }); + @export(&_chkstk, .{ .name = "_chkstk", .linkage = linkage }); + @export(&__chkstk, .{ .name = "__chkstk", .linkage = linkage }); } } @@ -33,7 +30,7 @@ comptime { .x86, .x86_64, => { - @export(zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage }); + @export(&zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage }); }, else => {}, } @@ -100,6 +97,35 @@ fn win_probe_stack_only() void { @setRuntimeSafety(false); switch (arch) { + .thumb => { + asm volatile ( + \\ lsl r4, r4, #2 + \\ mov r12, sp + \\ push {r5, r6} + \\ mov r5, r4 + \\1: + \\ sub r12, r12, #4096 + \\ subs r5, r5, #4096 + \\ ldr r6, [r12] + \\ bgt 1b + \\ pop {r5, r6} + \\ bx lr + ); + }, + .aarch64 => { + asm volatile ( + \\ lsl x16, x15, #4 + \\ mov x17, sp + \\1: + \\ + \\ sub x17, x17, 4096 + \\ subs x16, x16, 4096 + \\ ldr xzr, [x17] + \\ b.gt 1b + \\ + \\ ret + ); + }, .x86_64 => { asm volatile ( \\ push %%rcx @@ -144,21 +170,6 @@ fn win_probe_stack_only() void { }, else => {}, } - if (comptime arch.isAARCH64()) { - // NOTE: page size hardcoded to 4096 for now - asm volatile ( - \\ lsl x16, x15, #4 - \\ mov x17, sp - \\1: - \\ - \\ sub x17, x17, 4096 - \\ subs x16, x16, 4096 - \\ ldr xzr, [x17] - \\ b.gt 1b - \\ - \\ ret - ); - } unreachable; } @@ -240,7 +251,7 @@ pub fn _chkstk() callconv(.Naked) void { } pub fn __chkstk() callconv(.Naked) void { @setRuntimeSafety(false); - if (comptime arch.isAARCH64()) { + if (arch == .thumb or arch == .aarch64) { @call(.always_inline, win_probe_stack_only, .{}); } else switch (arch) { .x86 => @call(.always_inline, win_probe_stack_adjust_sp, .{}), diff --git a/lib/compiler_rt/subdf3.zig b/lib/compiler_rt/subdf3.zig index a67eb9de57..8970c63b23 100644 --- a/lib/compiler_rt/subdf3.zig +++ b/lib/compiler_rt/subdf3.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__subdf3, .{ .name = "__subdf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__subdf3, .{ .name = "__subdf3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/subhf3.zig b/lib/compiler_rt/subhf3.zig index 51602851b2..f116a97d43 100644 --- a/lib/compiler_rt/subhf3.zig +++ b/lib/compiler_rt/subhf3.zig @@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3; pub const panic = common.panic; comptime { - @export(__subhf3, .{ .name = "__subhf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__subhf3, .{ .name = "__subhf3", .linkage = common.linkage, .visibility = common.visibility }); } fn __subhf3(a: f16, b: f16) callconv(.C) f16 { diff --git a/lib/compiler_rt/subo.zig b/lib/compiler_rt/subo.zig index 7b0fd8086c..a03e2158f5 100644 --- a/lib/compiler_rt/subo.zig +++ b/lib/compiler_rt/subo.zig @@ -10,9 +10,9 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__subosi4, .{ .name = "__subosi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__subodi4, .{ .name = "__subodi4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__suboti4, .{ .name = "__suboti4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__subosi4, .{ .name = "__subosi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__subodi4, .{ .name = "__subodi4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__suboti4, .{ .name = "__suboti4", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __subosi4(a: i32, b: i32, overflow: *c_int) callconv(.C) i32 { diff --git a/lib/compiler_rt/subsf3.zig b/lib/compiler_rt/subsf3.zig index 40c7a44ddd..84b5e5341e 100644 --- a/lib/compiler_rt/subsf3.zig +++ b/lib/compiler_rt/subsf3.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__subsf3, .{ .name = "__subsf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__subsf3, .{ .name = "__subsf3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/subtf3.zig b/lib/compiler_rt/subtf3.zig index bda7cb0e31..8c6626e882 100644 --- a/lib/compiler_rt/subtf3.zig +++ b/lib/compiler_rt/subtf3.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__subtf3, .{ .name = "__subkf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__subtf3, .{ .name = "__subkf3", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__subtf3, .{ .name = "__subtf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__subtf3, .{ .name = "__subtf3", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 { diff --git a/lib/compiler_rt/subxf3.zig b/lib/compiler_rt/subxf3.zig index 5b3680c2c5..815bc1f78f 100644 --- a/lib/compiler_rt/subxf3.zig +++ b/lib/compiler_rt/subxf3.zig @@ -4,7 +4,7 @@ const common = @import("./common.zig"); pub const panic = common.panic; comptime { - @export(__subxf3, .{ .name = "__subxf3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__subxf3, .{ .name = "__subxf3", .linkage = common.linkage, .visibility = common.visibility }); } fn __subxf3(a: f80, b: f80) callconv(.C) f80 { diff --git a/lib/compiler_rt/tan.zig b/lib/compiler_rt/tan.zig index 9f1d3f82c7..067164a3a7 100644 --- a/lib/compiler_rt/tan.zig +++ b/lib/compiler_rt/tan.zig @@ -21,15 +21,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__tanh, .{ .name = "__tanh", .linkage = common.linkage, .visibility = common.visibility }); - @export(tanf, .{ .name = "tanf", .linkage = common.linkage, .visibility = common.visibility }); - @export(tan, .{ .name = "tan", .linkage = common.linkage, .visibility = common.visibility }); - @export(__tanx, .{ .name = "__tanx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__tanh, .{ .name = "__tanh", .linkage = common.linkage, .visibility = common.visibility }); + @export(&tanf, .{ .name = "tanf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&tan, .{ .name = "tan", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__tanx, .{ .name = "__tanx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(tanq, .{ .name = "tanf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&tanq, .{ .name = "tanf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(tanq, .{ .name = "tanq", .linkage = common.linkage, .visibility = common.visibility }); - @export(tanl, .{ .name = "tanl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&tanq, .{ .name = "tanq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&tanl, .{ .name = "tanl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __tanh(x: f16) callconv(.C) f16 { @@ -116,7 +116,7 @@ pub fn tanq(x: f128) callconv(.C) f128 { } pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __tanh(x), 32 => return tanf(x), 64 => return tan(x), diff --git a/lib/compiler_rt/trunc.zig b/lib/compiler_rt/trunc.zig index 3036fdaef4..ea655fbb18 100644 --- a/lib/compiler_rt/trunc.zig +++ b/lib/compiler_rt/trunc.zig @@ -15,15 +15,15 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - @export(__trunch, .{ .name = "__trunch", .linkage = common.linkage, .visibility = common.visibility }); - @export(truncf, .{ .name = "truncf", .linkage = common.linkage, .visibility = common.visibility }); - @export(trunc, .{ .name = "trunc", .linkage = common.linkage, .visibility = common.visibility }); - @export(__truncx, .{ .name = "__truncx", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__trunch, .{ .name = "__trunch", .linkage = common.linkage, .visibility = common.visibility }); + @export(&truncf, .{ .name = "truncf", .linkage = common.linkage, .visibility = common.visibility }); + @export(&trunc, .{ .name = "trunc", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__truncx, .{ .name = "__truncx", .linkage = common.linkage, .visibility = common.visibility }); if (common.want_ppc_abi) { - @export(truncq, .{ .name = "truncf128", .linkage = common.linkage, .visibility = common.visibility }); + @export(&truncq, .{ .name = "truncf128", .linkage = common.linkage, .visibility = common.visibility }); } - @export(truncq, .{ .name = "truncq", .linkage = common.linkage, .visibility = common.visibility }); - @export(truncl, .{ .name = "truncl", .linkage = common.linkage, .visibility = common.visibility }); + @export(&truncq, .{ .name = "truncq", .linkage = common.linkage, .visibility = common.visibility }); + @export(&truncl, .{ .name = "truncl", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __trunch(x: f16) callconv(.C) f16 { @@ -100,7 +100,7 @@ pub fn truncq(x: f128) callconv(.C) f128 { } pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble { - switch (@typeInfo(c_longdouble).Float.bits) { + switch (@typeInfo(c_longdouble).float.bits) { 16 => return __trunch(x), 32 => return truncf(x), 64 => return trunc(x), diff --git a/lib/compiler_rt/truncdfhf2.zig b/lib/compiler_rt/truncdfhf2.zig index 29e57f6685..e15a2202a1 100644 --- a/lib/compiler_rt/truncdfhf2.zig +++ b/lib/compiler_rt/truncdfhf2.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/truncdfsf2.zig b/lib/compiler_rt/truncdfsf2.zig index 85a19988af..160df412d6 100644 --- a/lib/compiler_rt/truncdfsf2.zig +++ b/lib/compiler_rt/truncdfsf2.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/truncf.zig b/lib/compiler_rt/truncf.zig index 02b6c7d4bd..d8b7c6b682 100644 --- a/lib/compiler_rt/truncf.zig +++ b/lib/compiler_rt/truncf.zig @@ -1,14 +1,14 @@ const std = @import("std"); pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t { - const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits); - const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits); + const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits); + const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); const srcSigBits = std.math.floatMantissaBits(src_t); const dstSigBits = std.math.floatMantissaBits(dst_t); // Various constants whose values follow from the type parameters. // Any reasonable optimizer will fold and propagate all of these. - const srcBits = @typeInfo(src_t).Float.bits; + const srcBits = @typeInfo(src_t).float.bits; const srcExpBits = srcBits - srcSigBits - 1; const srcInfExp = (1 << srcExpBits) - 1; const srcExpBias = srcInfExp >> 1; @@ -23,7 +23,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t const srcQNaN = 1 << (srcSigBits - 1); const srcNaNCode = srcQNaN - 1; - const dstBits = @typeInfo(dst_t).Float.bits; + const dstBits = @typeInfo(dst_t).float.bits; const dstExpBits = dstBits - dstSigBits - 1; const dstInfExp = (1 << dstExpBits) - 1; const dstExpBias = dstInfExp >> 1; @@ -100,7 +100,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t } pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { - const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits); + const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits); const src_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit const dst_sig_bits = std.math.floatMantissaBits(dst_t); @@ -109,7 +109,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { const round_mask = (1 << (src_sig_bits - dst_sig_bits)) - 1; const halfway = 1 << (src_sig_bits - dst_sig_bits - 1); - const dst_bits = @typeInfo(dst_t).Float.bits; + const dst_bits = @typeInfo(dst_t).float.bits; const dst_exp_bits = dst_bits - dst_sig_bits - 1; const dst_inf_exp = (1 << dst_exp_bits) - 1; const dst_exp_bias = dst_inf_exp >> 1; diff --git a/lib/compiler_rt/truncsfhf2.zig b/lib/compiler_rt/truncsfhf2.zig index ffc74b75e9..9de9cecd4b 100644 --- a/lib/compiler_rt/truncsfhf2.zig +++ b/lib/compiler_rt/truncsfhf2.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.gnu_f16_abi) { - @export(__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_aeabi) { - @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __truncsfhf2(a: f32) callconv(.C) common.F16T(f32) { diff --git a/lib/compiler_rt/trunctfdf2.zig b/lib/compiler_rt/trunctfdf2.zig index 6fa089cd41..2dc3242b12 100644 --- a/lib/compiler_rt/trunctfdf2.zig +++ b/lib/compiler_rt/trunctfdf2.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __trunctfdf2(a: f128) callconv(.C) f64 { diff --git a/lib/compiler_rt/trunctfhf2.zig b/lib/compiler_rt/trunctfhf2.zig index 6107b6ba49..d4dbc5b44b 100644 --- a/lib/compiler_rt/trunctfhf2.zig +++ b/lib/compiler_rt/trunctfhf2.zig @@ -4,7 +4,7 @@ const truncf = @import("./truncf.zig").truncf; pub const panic = common.panic; comptime { - @export(__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __trunctfhf2(a: f128) callconv(.C) common.F16T(f128) { diff --git a/lib/compiler_rt/trunctfsf2.zig b/lib/compiler_rt/trunctfsf2.zig index 62c00a81aa..42228d4690 100644 --- a/lib/compiler_rt/trunctfsf2.zig +++ b/lib/compiler_rt/trunctfsf2.zig @@ -5,11 +5,11 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { - @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = common.linkage, .visibility = common.visibility }); + @export(&_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = common.linkage, .visibility = common.visibility }); } - @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __trunctfsf2(a: f128) callconv(.C) f32 { diff --git a/lib/compiler_rt/trunctfxf2.zig b/lib/compiler_rt/trunctfxf2.zig index a594c8e6e9..b7c2b1cb1d 100644 --- a/lib/compiler_rt/trunctfxf2.zig +++ b/lib/compiler_rt/trunctfxf2.zig @@ -5,7 +5,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80; pub const panic = common.panic; comptime { - @export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __trunctfxf2(a: f128) callconv(.C) f80 { @@ -14,7 +14,7 @@ pub fn __trunctfxf2(a: f128) callconv(.C) f80 { // Various constants whose values follow from the type parameters. // Any reasonable optimizer will fold and propagate all of these. - const src_bits = @typeInfo(f128).Float.bits; + const src_bits = @typeInfo(f128).float.bits; const src_exp_bits = src_bits - src_sig_bits - 1; const src_inf_exp = 0x7FFF; diff --git a/lib/compiler_rt/truncxfdf2.zig b/lib/compiler_rt/truncxfdf2.zig index 059db73ef6..90170db6a9 100644 --- a/lib/compiler_rt/truncxfdf2.zig +++ b/lib/compiler_rt/truncxfdf2.zig @@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80; pub const panic = common.panic; comptime { - @export(__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __truncxfdf2(a: f80) callconv(.C) f64 { diff --git a/lib/compiler_rt/truncxfhf2.zig b/lib/compiler_rt/truncxfhf2.zig index 5dbd161b84..276de030f8 100644 --- a/lib/compiler_rt/truncxfhf2.zig +++ b/lib/compiler_rt/truncxfhf2.zig @@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80; pub const panic = common.panic; comptime { - @export(__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __truncxfhf2(a: f80) callconv(.C) common.F16T(f80) { diff --git a/lib/compiler_rt/truncxfsf2.zig b/lib/compiler_rt/truncxfsf2.zig index 8185c5089a..0a11e06655 100644 --- a/lib/compiler_rt/truncxfsf2.zig +++ b/lib/compiler_rt/truncxfsf2.zig @@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80; pub const panic = common.panic; comptime { - @export(__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __truncxfsf2(a: f80) callconv(.C) f32 { diff --git a/lib/compiler_rt/udivmodei4.zig b/lib/compiler_rt/udivmodei4.zig index 890ced4360..cff4212f93 100644 --- a/lib/compiler_rt/udivmodei4.zig +++ b/lib/compiler_rt/udivmodei4.zig @@ -7,8 +7,8 @@ const shl = std.math.shl; const max_limbs = std.math.divCeil(usize, 65535, 32) catch unreachable; // max supported type is u65535 comptime { - @export(__udivei4, .{ .name = "__udivei4", .linkage = common.linkage, .visibility = common.visibility }); - @export(__umodei4, .{ .name = "__umodei4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivei4, .{ .name = "__udivei4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__umodei4, .{ .name = "__umodei4", .linkage = common.linkage, .visibility = common.visibility }); } const endian = builtin.cpu.arch.endian(); diff --git a/lib/compiler_rt/udivmodti4.zig b/lib/compiler_rt/udivmodti4.zig index bb98819dcc..20cd916693 100644 --- a/lib/compiler_rt/udivmodti4.zig +++ b/lib/compiler_rt/udivmodti4.zig @@ -7,9 +7,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/udivti3.zig b/lib/compiler_rt/udivti3.zig index f89868dc48..0fb193352c 100644 --- a/lib/compiler_rt/udivti3.zig +++ b/lib/compiler_rt/udivti3.zig @@ -7,9 +7,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__udivti3, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__udivti3, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/umodti3.zig b/lib/compiler_rt/umodti3.zig index ea2db7ee0b..9b17f60c6b 100644 --- a/lib/compiler_rt/umodti3.zig +++ b/lib/compiler_rt/umodti3.zig @@ -7,9 +7,9 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { - @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__umodti3, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__umodti3, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/unorddf2.zig b/lib/compiler_rt/unorddf2.zig index a185b43155..6f0a1344dd 100644 --- a/lib/compiler_rt/unorddf2.zig +++ b/lib/compiler_rt/unorddf2.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__unorddf2, .{ .name = "__unorddf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__unorddf2, .{ .name = "__unorddf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/unordhf2.zig b/lib/compiler_rt/unordhf2.zig index 65d6ed7617..0c2ad16c8e 100644 --- a/lib/compiler_rt/unordhf2.zig +++ b/lib/compiler_rt/unordhf2.zig @@ -4,7 +4,7 @@ const comparef = @import("./comparef.zig"); pub const panic = common.panic; comptime { - @export(__unordhf2, .{ .name = "__unordhf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__unordhf2, .{ .name = "__unordhf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __unordhf2(a: f16, b: f16) callconv(.C) i32 { diff --git a/lib/compiler_rt/unordsf2.zig b/lib/compiler_rt/unordsf2.zig index e28ad0091c..c3209fe5fb 100644 --- a/lib/compiler_rt/unordsf2.zig +++ b/lib/compiler_rt/unordsf2.zig @@ -5,9 +5,9 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { - @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = common.linkage, .visibility = common.visibility }); } else { - @export(__unordsf2, .{ .name = "__unordsf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__unordsf2, .{ .name = "__unordsf2", .linkage = common.linkage, .visibility = common.visibility }); } } diff --git a/lib/compiler_rt/unordtf2.zig b/lib/compiler_rt/unordtf2.zig index 2f98982683..6e80ba3d4b 100644 --- a/lib/compiler_rt/unordtf2.zig +++ b/lib/compiler_rt/unordtf2.zig @@ -5,12 +5,12 @@ pub const panic = common.panic; comptime { if (common.want_ppc_abi) { - @export(__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage, .visibility = common.visibility }); } else if (common.want_sparc_abi) { // These exports are handled in cmptf2.zig because unordered comparisons // are based on calling _Qp_cmp. } - @export(__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage, .visibility = common.visibility }); } fn __unordtf2(a: f128, b: f128) callconv(.C) i32 { diff --git a/lib/compiler_rt/unordxf2.zig b/lib/compiler_rt/unordxf2.zig index d0932f253d..c985f9cd98 100644 --- a/lib/compiler_rt/unordxf2.zig +++ b/lib/compiler_rt/unordxf2.zig @@ -4,7 +4,7 @@ const comparef = @import("./comparef.zig"); pub const panic = common.panic; comptime { - @export(__unordxf2, .{ .name = "__unordxf2", .linkage = common.linkage, .visibility = common.visibility }); + @export(&__unordxf2, .{ .name = "__unordxf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __unordxf2(a: f80, b: f80) callconv(.C) i32 { diff --git a/lib/docs/wasm/Walk.zig b/lib/docs/wasm/Walk.zig index ae924b8c38..611830fcb8 100644 --- a/lib/docs/wasm/Walk.zig +++ b/lib/docs/wasm/Walk.zig @@ -36,7 +36,7 @@ pub const Category = union(enum(u8)) { /// A function that returns a type. type_function: Ast.Node.Index, - pub const Tag = @typeInfo(Category).Union.tag_type.?; + pub const Tag = @typeInfo(Category).@"union".tag_type.?; }; pub const File = struct { diff --git a/lib/docs/wasm/markdown/Document.zig b/lib/docs/wasm/markdown/Document.zig index 8eec97415c..59a40135d6 100644 --- a/lib/docs/wasm/markdown/Document.zig +++ b/lib/docs/wasm/markdown/Document.zig @@ -170,7 +170,7 @@ pub fn ExtraData(comptime T: type) type { } pub fn extraData(doc: Document, comptime T: type, index: ExtraIndex) ExtraData(T) { - const fields = @typeInfo(T).Struct.fields; + const fields = @typeInfo(T).@"struct".fields; var i: usize = @intFromEnum(index); var result: T = undefined; inline for (fields) |field| { diff --git a/lib/docs/wasm/markdown/Parser.zig b/lib/docs/wasm/markdown/Parser.zig index fe4fc2f9b0..024a16a2d7 100644 --- a/lib/docs/wasm/markdown/Parser.zig +++ b/lib/docs/wasm/markdown/Parser.zig @@ -1564,7 +1564,7 @@ fn parseInlines(p: *Parser, content: []const u8) !ExtraIndex { } pub fn extraData(p: Parser, comptime T: type, index: ExtraIndex) ExtraData(T) { - const fields = @typeInfo(T).Struct.fields; + const fields = @typeInfo(T).@"struct".fields; var i: usize = @intFromEnum(index); var result: T = undefined; inline for (fields) |field| { diff --git a/lib/fuzzer.zig b/lib/fuzzer.zig index 2a6794235e..9c67756a6d 100644 --- a/lib/fuzzer.zig +++ b/lib/fuzzer.zig @@ -13,7 +13,7 @@ var log_file: ?std.fs.File = null; fn logOverride( comptime level: std.log.Level, - comptime scope: @TypeOf(.EnumLiteral), + comptime scope: @Type(.enum_literal), comptime format: []const u8, args: anytype, ) void { @@ -30,19 +30,6 @@ fn logOverride( export threadlocal var __sancov_lowest_stack: usize = std.math.maxInt(usize); -var module_count_8bc: usize = 0; -var module_count_pcs: usize = 0; - -export fn __sanitizer_cov_8bit_counters_init(start: [*]u8, end: [*]u8) void { - assert(@atomicRmw(usize, &module_count_8bc, .Add, 1, .monotonic) == 0); - fuzzer.pc_counters = start[0 .. end - start]; -} - -export fn __sanitizer_cov_pcs_init(start: [*]const Fuzzer.FlaggedPc, end: [*]const Fuzzer.FlaggedPc) void { - assert(@atomicRmw(usize, &module_count_pcs, .Add, 1, .monotonic) == 0); - fuzzer.flagged_pcs = start[0 .. end - start]; -} - export fn __sanitizer_cov_trace_const_cmp1(arg1: u8, arg2: u8) void { handleCmp(@returnAddress(), arg1, arg2); } @@ -105,7 +92,7 @@ const Fuzzer = struct { gpa: Allocator, rng: std.Random.DefaultPrng, input: std.ArrayListUnmanaged(u8), - flagged_pcs: []const FlaggedPc, + pcs: []const usize, pc_counters: []u8, n_runs: usize, recent_cases: RunMap, @@ -174,32 +161,18 @@ const Fuzzer = struct { } }; - const FlaggedPc = extern struct { - addr: usize, - flags: packed struct(usize) { - entry: bool, - _: @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(usize) - 1 } }), - }, - }; - const Analysis = struct { score: usize, id: Run.Id, }; - fn init(f: *Fuzzer, cache_dir: std.fs.Dir) !void { - const flagged_pcs = f.flagged_pcs; - + fn init(f: *Fuzzer, cache_dir: std.fs.Dir, pc_counters: []u8, pcs: []const usize) !void { f.cache_dir = cache_dir; + f.pc_counters = pc_counters; + f.pcs = pcs; // Choose a file name for the coverage based on a hash of the PCs that will be stored within. - const pc_digest = d: { - var hasher = std.hash.Wyhash.init(0); - for (flagged_pcs) |flagged_pc| { - hasher.update(std.mem.asBytes(&flagged_pc.addr)); - } - break :d f.coverage.run_id_hasher.final(); - }; + const pc_digest = std.hash.Wyhash.hash(0, std.mem.sliceAsBytes(pcs)); f.coverage_id = pc_digest; const hex_digest = std.fmt.hex(pc_digest); const coverage_file_path = "v/" ++ hex_digest; @@ -213,12 +186,12 @@ const Fuzzer = struct { .truncate = false, }); defer coverage_file.close(); - const n_bitset_elems = (flagged_pcs.len + @bitSizeOf(usize) - 1) / @bitSizeOf(usize); + const n_bitset_elems = (pcs.len + @bitSizeOf(usize) - 1) / @bitSizeOf(usize); comptime assert(SeenPcsHeader.trailing[0] == .pc_bits_usize); comptime assert(SeenPcsHeader.trailing[1] == .pc_addr); const bytes_len = @sizeOf(SeenPcsHeader) + n_bitset_elems * @sizeOf(usize) + - flagged_pcs.len * @sizeOf(usize); + pcs.len * @sizeOf(usize); const existing_len = coverage_file.getEndPos() catch |err| { fatal("unable to check len of coverage file: {s}", .{@errorName(err)}); }; @@ -233,12 +206,12 @@ const Fuzzer = struct { fatal("unable to init coverage memory map: {s}", .{@errorName(err)}); }; if (existing_len != 0) { - const existing_pcs_bytes = f.seen_pcs.items[@sizeOf(SeenPcsHeader) + @sizeOf(usize) * n_bitset_elems ..][0 .. flagged_pcs.len * @sizeOf(usize)]; + const existing_pcs_bytes = f.seen_pcs.items[@sizeOf(SeenPcsHeader) + @sizeOf(usize) * n_bitset_elems ..][0 .. pcs.len * @sizeOf(usize)]; const existing_pcs = std.mem.bytesAsSlice(usize, existing_pcs_bytes); - for (existing_pcs, flagged_pcs, 0..) |old, new, i| { - if (old != new.addr) { + for (existing_pcs, pcs, 0..) |old, new, i| { + if (old != new) { fatal("incompatible existing coverage file (differing PC at index {d}: {x} != {x})", .{ - i, old, new.addr, + i, old, new, }); } } @@ -246,14 +219,12 @@ const Fuzzer = struct { const header: SeenPcsHeader = .{ .n_runs = 0, .unique_runs = 0, - .pcs_len = flagged_pcs.len, + .pcs_len = pcs.len, .lowest_stack = std.math.maxInt(usize), }; f.seen_pcs.appendSliceAssumeCapacity(std.mem.asBytes(&header)); f.seen_pcs.appendNTimesAssumeCapacity(0, n_bitset_elems * @sizeOf(usize)); - for (flagged_pcs) |flagged_pc| { - f.seen_pcs.appendSliceAssumeCapacity(std.mem.asBytes(&flagged_pc.addr)); - } + f.seen_pcs.appendSliceAssumeCapacity(std.mem.sliceAsBytes(pcs)); } } @@ -307,8 +278,8 @@ const Fuzzer = struct { // Track code coverage from all runs. comptime assert(SeenPcsHeader.trailing[0] == .pc_bits_usize); const header_end_ptr: [*]volatile usize = @ptrCast(f.seen_pcs.items[@sizeOf(SeenPcsHeader)..]); - const remainder = f.flagged_pcs.len % @bitSizeOf(usize); - const aligned_len = f.flagged_pcs.len - remainder; + const remainder = f.pcs.len % @bitSizeOf(usize); + const aligned_len = f.pcs.len - remainder; const seen_pcs = header_end_ptr[0..aligned_len]; const pc_counters = std.mem.bytesAsSlice([@bitSizeOf(usize)]u8, f.pc_counters[0..aligned_len]); const V = @Vector(@bitSizeOf(usize), u8); @@ -433,7 +404,7 @@ var fuzzer: Fuzzer = .{ .gpa = general_purpose_allocator.allocator(), .rng = std.Random.DefaultPrng.init(0), .input = .{}, - .flagged_pcs = undefined, + .pcs = undefined, .pc_counters = undefined, .n_runs = 0, .recent_cases = .{}, @@ -455,8 +426,32 @@ export fn fuzzer_next() Fuzzer.Slice { } export fn fuzzer_init(cache_dir_struct: Fuzzer.Slice) void { - if (module_count_8bc == 0) fatal("__sanitizer_cov_8bit_counters_init was never called", .{}); - if (module_count_pcs == 0) fatal("__sanitizer_cov_pcs_init was never called", .{}); + // Linkers are expected to automatically add `__start_<section>` and + // `__stop_<section>` symbols when section names are valid C identifiers. + + const pc_counters_start = @extern([*]u8, .{ + .name = "__start___sancov_cntrs", + .linkage = .weak, + }) orelse fatal("missing __start___sancov_cntrs symbol"); + + const pc_counters_end = @extern([*]u8, .{ + .name = "__stop___sancov_cntrs", + .linkage = .weak, + }) orelse fatal("missing __stop___sancov_cntrs symbol"); + + const pc_counters = pc_counters_start[0 .. pc_counters_end - pc_counters_start]; + + const pcs_start = @extern([*]usize, .{ + .name = "__start___sancov_pcs1", + .linkage = .weak, + }) orelse fatal("missing __start___sancov_pcs1 symbol"); + + const pcs_end = @extern([*]usize, .{ + .name = "__stop___sancov_pcs1", + .linkage = .weak, + }) orelse fatal("missing __stop___sancov_pcs1 symbol"); + + const pcs = pcs_start[0 .. pcs_end - pcs_start]; const cache_dir_path = cache_dir_struct.toZig(); const cache_dir = if (cache_dir_path.len == 0) @@ -466,7 +461,8 @@ export fn fuzzer_init(cache_dir_struct: Fuzzer.Slice) void { fatal("unable to open fuzz directory '{s}': {s}", .{ cache_dir_path, @errorName(err) }); }; - fuzzer.init(cache_dir) catch |err| fatal("unable to init fuzzer: {s}", .{@errorName(err)}); + fuzzer.init(cache_dir, pc_counters, pcs) catch |err| + fatal("unable to init fuzzer: {s}", .{@errorName(err)}); } /// Like `std.ArrayListUnmanaged(u8)` but backed by memory mapping. diff --git a/lib/libc/glibc/csu/init.c b/lib/libc/glibc/csu/init.c new file mode 100644 index 0000000000..3ee6148898 --- /dev/null +++ b/lib/libc/glibc/csu/init.c @@ -0,0 +1,23 @@ +/* Special startup support. + Copyright (C) 1997-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +/* Vestigial libio version number. Some code in libio checks whether + this symbol exists in the executable, but nothing looks at its + value anymore; the value it was historically set to has been + preserved out of an abundance of caution. */ +const int _IO_stdin_used = 0x20001; diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/xstatver.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/xstatver.h new file mode 100644 index 0000000000..1cb5d26bb1 --- /dev/null +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/xstatver.h @@ -0,0 +1,14 @@ +/* Versions of the 'struct stat' data structure used in compatibility xstat + functions. */ +#define _STAT_VER_KERNEL 0 +#define _STAT_VER_GLIBC2 1 +#define _STAT_VER_GLIBC2_1 2 +#define _STAT_VER_KERNEL64 3 +#define _STAT_VER_GLIBC2_3_4 3 +#define _STAT_VER_LINUX 3 +#define _STAT_VER _STAT_VER_LINUX + +/* Versions of the 'xmknod' interface used in compatibility xmknod + functions. */ +#define _MKNOD_VER_LINUX 0 +#define _MKNOD_VER _MKNOD_VER_LINUX diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/xstatver.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/xstatver.h new file mode 100644 index 0000000000..8e1801b603 --- /dev/null +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/xstatver.h @@ -0,0 +1,13 @@ +/* Versions of the 'struct stat' data structure used in compatibility xstat + functions. */ +#define _STAT_VER_LINUX_OLD 1 +#define _STAT_VER_KERNEL 1 +#define _STAT_VER_SVR4 2 +#define _STAT_VER_LINUX 3 +#define _STAT_VER _STAT_VER_LINUX + +/* Versions of the 'xmknod' interface used in compatibility xmknod + functions. */ +#define _MKNOD_VER_LINUX 1 +#define _MKNOD_VER_SVR4 2 +#define _MKNOD_VER _MKNOD_VER_LINUX diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/xstatver.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/xstatver.h new file mode 100644 index 0000000000..8e1801b603 --- /dev/null +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/xstatver.h @@ -0,0 +1,13 @@ +/* Versions of the 'struct stat' data structure used in compatibility xstat + functions. */ +#define _STAT_VER_LINUX_OLD 1 +#define _STAT_VER_KERNEL 1 +#define _STAT_VER_SVR4 2 +#define _STAT_VER_LINUX 3 +#define _STAT_VER _STAT_VER_LINUX + +/* Versions of the 'xmknod' interface used in compatibility xmknod + functions. */ +#define _MKNOD_VER_LINUX 1 +#define _MKNOD_VER_SVR4 2 +#define _MKNOD_VER _MKNOD_VER_LINUX diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/xstatver.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/xstatver.h new file mode 100644 index 0000000000..790cc834d2 --- /dev/null +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/xstatver.h @@ -0,0 +1,13 @@ +/* Versions of the 'struct stat' data structure used in compatibility xstat + functions. */ +#define _STAT_VER_LINUX_OLD 1 +#define _STAT_VER_KERNEL 1 +#define _STAT_VER_SVR4 2 +#define _STAT_VER_LINUX 3 +#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */ + +/* Versions of the 'xmknod' interface used in compatibility xmknod + functions. */ +#define _MKNOD_VER_LINUX 1 +#define _MKNOD_VER_SVR4 2 +#define _MKNOD_VER _MKNOD_VER_LINUX diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/sh/xstatver.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/sh/xstatver.h new file mode 100644 index 0000000000..8e1801b603 --- /dev/null +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/sh/xstatver.h @@ -0,0 +1,13 @@ +/* Versions of the 'struct stat' data structure used in compatibility xstat + functions. */ +#define _STAT_VER_LINUX_OLD 1 +#define _STAT_VER_KERNEL 1 +#define _STAT_VER_SVR4 2 +#define _STAT_VER_LINUX 3 +#define _STAT_VER _STAT_VER_LINUX + +/* Versions of the 'xmknod' interface used in compatibility xmknod + functions. */ +#define _MKNOD_VER_LINUX 1 +#define _MKNOD_VER_SVR4 2 +#define _MKNOD_VER _MKNOD_VER_LINUX diff --git a/lib/std/Build.zig b/lib/std/Build.zig index 82810bb02f..109ebc8be2 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -408,7 +408,7 @@ fn createChildOnly( fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOptionsMap { var user_input_options = UserInputOptionsMap.init(allocator); - inline for (@typeInfo(@TypeOf(args)).Struct.fields) |field| { + inline for (@typeInfo(@TypeOf(args)).@"struct".fields) |field| { const v = @field(args, field.name); const T = @TypeOf(v); switch (T) { @@ -454,28 +454,28 @@ fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOption }) catch @panic("OOM"); }, else => switch (@typeInfo(T)) { - .Bool => { + .bool => { user_input_options.put(field.name, .{ .name = field.name, .value = .{ .scalar = if (v) "true" else "false" }, .used = false, }) catch @panic("OOM"); }, - .Enum, .EnumLiteral => { + .@"enum", .enum_literal => { user_input_options.put(field.name, .{ .name = field.name, .value = .{ .scalar = @tagName(v) }, .used = false, }) catch @panic("OOM"); }, - .ComptimeInt, .Int => { + .comptime_int, .int => { user_input_options.put(field.name, .{ .name = field.name, .value = .{ .scalar = std.fmt.allocPrint(allocator, "{d}", .{v}) catch @panic("OOM") }, .used = false, }) catch @panic("OOM"); }, - .ComptimeFloat, .Float => { + .comptime_float, .float => { user_input_options.put(field.name, .{ .name = field.name, .value = .{ .scalar = std.fmt.allocPrint(allocator, "{e}", .{v}) catch @panic("OOM") }, @@ -1111,7 +1111,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw const description = b.dupe(description_raw); const type_id = comptime typeToEnum(T); const enum_options = if (type_id == .@"enum" or type_id == .enum_list) blk: { - const EnumType = if (type_id == .enum_list) @typeInfo(T).Pointer.child else T; + const EnumType = if (type_id == .enum_list) @typeInfo(T).pointer.child else T; const fields = comptime std.meta.fields(EnumType); var options = ArrayList([]const u8).initCapacity(b.allocator, fields.len) catch @panic("OOM"); @@ -1265,7 +1265,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw return null; }, .scalar => |s| { - const Child = @typeInfo(T).Pointer.child; + const Child = @typeInfo(T).pointer.child; const value = std.meta.stringToEnum(Child, s) orelse { log.err("Expected -D{s} to be of type {s}.", .{ name, @typeName(Child) }); b.markInvalidUserInput(); @@ -1274,7 +1274,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw return b.allocator.dupe(Child, &[_]Child{value}) catch @panic("OOM"); }, .list => |lst| { - const Child = @typeInfo(T).Pointer.child; + const Child = @typeInfo(T).pointer.child; var new_list = b.allocator.alloc(Child, lst.items.len) catch @panic("OOM"); for (lst.items, 0..) |str, i| { const value = std.meta.stringToEnum(Child, str) orelse { @@ -1542,15 +1542,15 @@ fn typeToEnum(comptime T: type) TypeId { return switch (T) { std.zig.BuildId => .build_id, else => return switch (@typeInfo(T)) { - .Int => .int, - .Float => .float, - .Bool => .bool, - .Enum => .@"enum", - .Pointer => |pointer| switch (pointer.child) { + .int => .int, + .float => .float, + .bool => .bool, + .@"enum" => .@"enum", + .pointer => |pointer| switch (pointer.child) { u8 => .string, []const u8 => .list, else => switch (@typeInfo(pointer.child)) { - .Enum => .enum_list, + .@"enum" => .enum_list, else => @compileError("Unsupported type: " ++ @typeName(T)), }, }, @@ -1726,7 +1726,7 @@ pub fn fmt(b: *Build, comptime format: []const u8, args: anytype) []u8 { } fn supportedWindowsProgramExtension(ext: []const u8) bool { - inline for (@typeInfo(std.process.Child.WindowsExtension).Enum.fields) |field| { + inline for (@typeInfo(std.process.Child.WindowsExtension).@"enum".fields) |field| { if (std.ascii.eqlIgnoreCase(ext, "." ++ field.name)) return true; } return false; @@ -1808,6 +1808,7 @@ pub fn runAllowFail( child.stderr_behavior = stderr_behavior; child.env_map = &b.graph.env_map; + try Step.handleVerbose2(b, null, child.env_map, argv); try child.spawn(); const stdout = child.stdout.?.reader().readAllAlloc(b.allocator, max_output_size) catch { @@ -1924,7 +1925,7 @@ inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, c const build_runner = @import("root"); const deps = build_runner.dependencies; - const b_pkg_hash, const b_pkg_deps = comptime for (@typeInfo(deps.packages).Struct.decls) |decl| { + const b_pkg_hash, const b_pkg_deps = comptime for (@typeInfo(deps.packages).@"struct".decls) |decl| { const pkg_hash = decl.name; const pkg = @field(deps.packages, pkg_hash); if (@hasDecl(pkg, "build_zig") and pkg.build_zig == asking_build_zig) break .{ pkg_hash, pkg.deps }; @@ -1962,7 +1963,7 @@ pub fn lazyDependency(b: *Build, name: []const u8, args: anytype) ?*Dependency { const deps = build_runner.dependencies; const pkg_hash = findPkgHashOrFatal(b, name); - inline for (@typeInfo(deps.packages).Struct.decls) |decl| { + inline for (@typeInfo(deps.packages).@"struct".decls) |decl| { if (mem.eql(u8, decl.name, pkg_hash)) { const pkg = @field(deps.packages, decl.name); const available = !@hasDecl(pkg, "available") or pkg.available; @@ -1982,7 +1983,7 @@ pub fn dependency(b: *Build, name: []const u8, args: anytype) *Dependency { const deps = build_runner.dependencies; const pkg_hash = findPkgHashOrFatal(b, name); - inline for (@typeInfo(deps.packages).Struct.decls) |decl| { + inline for (@typeInfo(deps.packages).@"struct".decls) |decl| { if (mem.eql(u8, decl.name, pkg_hash)) { const pkg = @field(deps.packages, decl.name); if (@hasDecl(pkg, "available")) { @@ -2012,7 +2013,7 @@ pub inline fn lazyImport( const deps = build_runner.dependencies; const pkg_hash = findImportPkgHashOrFatal(b, asking_build_zig, dep_name); - inline for (@typeInfo(deps.packages).Struct.decls) |decl| { + inline for (@typeInfo(deps.packages).@"struct".decls) |decl| { if (comptime mem.eql(u8, decl.name, pkg_hash)) { const pkg = @field(deps.packages, decl.name); const available = !@hasDecl(pkg, "available") or pkg.available; @@ -2041,7 +2042,7 @@ pub fn dependencyFromBuildZig( const deps = build_runner.dependencies; find_dep: { - const pkg, const pkg_hash = inline for (@typeInfo(deps.packages).Struct.decls) |decl| { + const pkg, const pkg_hash = inline for (@typeInfo(deps.packages).@"struct".decls) |decl| { const pkg_hash = decl.name; const pkg = @field(deps.packages, pkg_hash); if (@hasDecl(pkg, "build_zig") and pkg.build_zig == build_zig) break .{ pkg, pkg_hash }; @@ -2149,9 +2150,9 @@ fn dependencyInner( } pub fn runBuild(b: *Build, build_zig: anytype) anyerror!void { - switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).Fn.return_type.?)) { - .Void => build_zig.build(b), - .ErrorUnion => try build_zig.build(b), + switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).@"fn".return_type.?)) { + .void => build_zig.build(b), + .error_union => try build_zig.build(b), else => @compileError("expected return type of build to be 'void' or '!void'"), } } diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig index 1eabdd54e6..93908807eb 100644 --- a/lib/std/Build/Cache.zig +++ b/lib/std/Build/Cache.zig @@ -222,7 +222,7 @@ pub const HashHelper = struct { .hexstring => |hex_string| hh.addBytes(hex_string.toSlice()), }, else => switch (@typeInfo(@TypeOf(x))) { - .Bool, .Int, .Enum, .Array => hh.addBytes(mem.asBytes(&x)), + .bool, .int, .@"enum", .array => hh.addBytes(mem.asBytes(&x)), else => @compileError("unable to hash type " ++ @typeName(@TypeOf(x))), }, } @@ -1014,7 +1014,7 @@ pub const Manifest = struct { } pub fn populateFileSystemInputs(man: *Manifest, buf: *std.ArrayListUnmanaged(u8)) Allocator.Error!void { - assert(@typeInfo(std.zig.Server.Message.PathPrefix).Enum.fields.len == man.cache.prefixes_len); + assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".fields.len == man.cache.prefixes_len); buf.clearRetainingCapacity(); const gpa = man.cache.gpa; const files = man.files.keys(); @@ -1032,7 +1032,7 @@ pub const Manifest = struct { pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [4]u8) Allocator.Error!void { const gpa = other.cache.gpa; - assert(@typeInfo(std.zig.Server.Message.PathPrefix).Enum.fields.len == man.cache.prefixes_len); + assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".fields.len == man.cache.prefixes_len); assert(man.cache.prefixes_len == 4); for (man.files.keys()) |file| { const prefixed_path: PrefixedPath = .{ diff --git a/lib/std/Build/Cache/Path.zig b/lib/std/Build/Cache/Path.zig index 65c6f6a9bc..ee0666b70a 100644 --- a/lib/std/Build/Cache/Path.zig +++ b/lib/std/Build/Cache/Path.zig @@ -189,8 +189,8 @@ pub const TableAdapter = struct { pub fn hash(self: TableAdapter, a: Cache.Path) u32 { _ = self; const seed = switch (@typeInfo(@TypeOf(a.root_dir.handle.fd))) { - .Pointer => @intFromPtr(a.root_dir.handle.fd), - .Int => @as(u32, @bitCast(a.root_dir.handle.fd)), + .pointer => @intFromPtr(a.root_dir.handle.fd), + .int => @as(u32, @bitCast(a.root_dir.handle.fd)), else => @compileError("unimplemented hash function"), }; return @truncate(Hash.hash(seed, a.sub_path)); diff --git a/lib/std/Build/Fuzz/WebServer.zig b/lib/std/Build/Fuzz/WebServer.zig index fbf6b8dbce..a0ab018cf5 100644 --- a/lib/std/Build/Fuzz/WebServer.zig +++ b/lib/std/Build/Fuzz/WebServer.zig @@ -304,13 +304,13 @@ fn buildWasmBinary( }; }, .emit_digest => { - const EbpHdr = std.zig.Server.Message.EmitDigest; - const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body)); + const EmitDigest = std.zig.Server.Message.EmitDigest; + const ebp_hdr = @as(*align(1) const EmitDigest, @ptrCast(body)); if (!ebp_hdr.flags.cache_hit) { log.info("source changes detected; rebuilt wasm component", .{}); } - const digest = body[@sizeOf(EbpHdr)..][0..Cache.bin_digest_len]; - result = Path{ + const digest = body[@sizeOf(EmitDigest)..][0..Cache.bin_digest_len]; + result = .{ .root_dir = ws.global_cache_directory, .sub_path = try arena.dupe(u8, "o" ++ std.fs.path.sep_str ++ Cache.binToHex(digest.*)), }; @@ -664,11 +664,16 @@ fn addEntryPoint(ws: *WebServer, coverage_id: u64, addr: u64) error{ AlreadyRepo const coverage_map = ws.coverage_files.getPtr(coverage_id).?; const header: *const abi.SeenPcsHeader = @ptrCast(coverage_map.mapped_memory[0..@sizeOf(abi.SeenPcsHeader)]); const pcs = header.pcAddrs(); - const index = std.sort.upperBound(usize, pcs, addr, struct { - fn order(context: usize, item: usize) std.math.Order { - return std.math.order(item, context); + // Since this pcs list is unsorted, we must linear scan for the best index. + const index = i: { + var best: usize = 0; + for (pcs[1..], 1..) |elem_addr, i| { + if (elem_addr == addr) break :i i; + if (elem_addr > addr) continue; + if (elem_addr > pcs[best]) best = i; } - }.order); + break :i best; + }; if (index >= pcs.len) { log.err("unable to find unit test entry address 0x{x} in source locations (range: 0x{x} to 0x{x})", .{ addr, pcs[0], pcs[pcs.len - 1], @@ -678,8 +683,8 @@ fn addEntryPoint(ws: *WebServer, coverage_id: u64, addr: u64) error{ AlreadyRepo if (false) { const sl = coverage_map.source_locations[index]; const file_name = coverage_map.coverage.stringAt(coverage_map.coverage.fileAt(sl.file).basename); - log.debug("server found entry point for 0x{x} at {s}:{d}:{d}", .{ - addr, file_name, sl.line, sl.column, + log.debug("server found entry point for 0x{x} at {s}:{d}:{d} - index {d} between {x} and {x}", .{ + addr, file_name, sl.line, sl.column, index, pcs[index - 1], pcs[index + 1], }); } const gpa = ws.gpa; diff --git a/lib/std/Build/Step.zig b/lib/std/Build/Step.zig index d9729a47cb..b8fb42a959 100644 --- a/lib/std/Build/Step.zig +++ b/lib/std/Build/Step.zig @@ -533,11 +533,11 @@ fn zigProcessUpdate(s: *Step, zp: *ZigProcess, watch: bool) !?Path { } }, .emit_digest => { - const EbpHdr = std.zig.Server.Message.EmitDigest; - const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body)); - s.result_cached = ebp_hdr.flags.cache_hit; - const digest = body[@sizeOf(EbpHdr)..][0..Cache.bin_digest_len]; - result = Path{ + const EmitDigest = std.zig.Server.Message.EmitDigest; + const emit_digest = @as(*align(1) const EmitDigest, @ptrCast(body)); + s.result_cached = emit_digest.flags.cache_hit; + const digest = body[@sizeOf(EmitDigest)..][0..Cache.bin_digest_len]; + result = .{ .root_dir = b.cache_root, .sub_path = try arena.dupe(u8, "o" ++ std.fs.path.sep_str ++ Cache.binToHex(digest.*)), }; diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index 1aeebbb55b..922d64c728 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -218,12 +218,18 @@ no_builtin: bool = false, /// Managed by the build runner, not user build script. zig_process: ?*Step.ZigProcess, -/// Enables deprecated coverage instrumentation that is only useful if you -/// are using third party fuzzers that depend on it. Otherwise, slows down -/// the instrumented binary with unnecessary function calls. +/// Enables coverage instrumentation that is only useful if you are using third +/// party fuzzers that depend on it. Otherwise, slows down the instrumented +/// binary with unnecessary function calls. /// -/// To enable fuzz testing instrumentation on a compilation, see the `fuzz` -/// flag in `Module`. +/// This kind of coverage instrumentation is used by AFLplusplus v4.21c, +/// however, modern fuzzers - including Zig - have switched to using "inline +/// 8-bit counters" or "inline bool flag" which incurs only a single +/// instruction for coverage, along with "trace cmp" which instruments +/// comparisons and reports the operands. +/// +/// To instead enable fuzz testing instrumentation on a compilation using Zig's +/// builtin fuzzer, see the `fuzz` flag in `Module`. sanitize_coverage_trace_pc_guard: ?bool = null, pub const ExpectedCompileErrors = union(enum) { diff --git a/lib/std/Build/Step/ConfigHeader.zig b/lib/std/Build/Step/ConfigHeader.zig index 512460a532..895f50f5d0 100644 --- a/lib/std/Build/Step/ConfigHeader.zig +++ b/lib/std/Build/Step/ConfigHeader.zig @@ -109,47 +109,47 @@ pub fn getOutput(config_header: *ConfigHeader) std.Build.LazyPath { } fn addValuesInner(config_header: *ConfigHeader, values: anytype) !void { - inline for (@typeInfo(@TypeOf(values)).Struct.fields) |field| { + inline for (@typeInfo(@TypeOf(values)).@"struct".fields) |field| { try putValue(config_header, field.name, field.type, @field(values, field.name)); } } fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: type, v: T) !void { switch (@typeInfo(T)) { - .Null => { + .null => { try config_header.values.put(field_name, .undef); }, - .Void => { + .void => { try config_header.values.put(field_name, .defined); }, - .Bool => { + .bool => { try config_header.values.put(field_name, .{ .boolean = v }); }, - .Int => { + .int => { try config_header.values.put(field_name, .{ .int = v }); }, - .ComptimeInt => { + .comptime_int => { try config_header.values.put(field_name, .{ .int = v }); }, - .EnumLiteral => { + .enum_literal => { try config_header.values.put(field_name, .{ .ident = @tagName(v) }); }, - .Optional => { + .optional => { if (v) |x| { return putValue(config_header, field_name, @TypeOf(x), x); } else { try config_header.values.put(field_name, .undef); } }, - .Pointer => |ptr| { + .pointer => |ptr| { switch (@typeInfo(ptr.child)) { - .Array => |array| { + .array => |array| { if (ptr.size == .One and array.child == u8) { try config_header.values.put(field_name, .{ .string = v }); return; } }, - .Int => { + .int => { if (ptr.size == .Slice and ptr.child == u8) { try config_header.values.put(field_name, .{ .string = v }); return; diff --git a/lib/std/Build/Step/Options.zig b/lib/std/Build/Step/Options.zig index 6131912b1b..41739dba47 100644 --- a/lib/std/Build/Step/Options.zig +++ b/lib/std/Build/Step/Options.zig @@ -151,7 +151,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent } switch (@typeInfo(T)) { - .Array => { + .array => { if (name) |some| { try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) }); } @@ -171,7 +171,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent } return; }, - .Pointer => |p| { + .pointer => |p| { if (p.size != .Slice) { @compileError("Non-slice pointers are not yet supported in build options"); } @@ -195,7 +195,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent } return; }, - .Optional => { + .optional => { if (name) |some| { try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) }); } @@ -216,12 +216,12 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent } return; }, - .Void, - .Bool, - .Int, - .ComptimeInt, - .Float, - .Null, + .void, + .bool, + .int, + .comptime_int, + .float, + .null, => { if (name) |some| { try out.print("pub const {}: {s} = {any};\n", .{ std.zig.fmtId(some), @typeName(T), value }); @@ -230,7 +230,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent } return; }, - .Enum => |info| { + .@"enum" => |info| { try printEnum(options, out, T, info, indent); if (name) |some| { @@ -242,7 +242,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent } return; }, - .Struct => |info| { + .@"struct" => |info| { try printStruct(options, out, T, info, indent); if (name) |some| { @@ -260,10 +260,10 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent fn printUserDefinedType(options: *Options, out: anytype, comptime T: type, indent: u8) !void { switch (@typeInfo(T)) { - .Enum => |info| { + .@"enum" => |info| { return try printEnum(options, out, T, info, indent); }, - .Struct => |info| { + .@"struct" => |info| { return try printStruct(options, out, T, info, indent); }, else => {}, @@ -323,8 +323,8 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val: try out.writeAll(" = "); switch (@typeInfo(@TypeOf(default_value))) { - .Enum => try out.print(".{s},\n", .{@tagName(default_value)}), - .Struct => |info| { + .@"enum" => try out.print(".{s},\n", .{@tagName(default_value)}), + .@"struct" => |info| { try printStructValue(options, out, info, default_value, indent + 4); }, else => try printType(options, out, @TypeOf(default_value), default_value, indent, null), @@ -359,8 +359,8 @@ fn printStructValue(options: *Options, out: anytype, comptime struct_val: std.bu const field_name = @field(val, field.name); switch (@typeInfo(@TypeOf(field_name))) { - .Enum => try out.print(".{s},\n", .{@tagName(field_name)}), - .Struct => |struct_info| { + .@"enum" => try out.print(".{s},\n", .{@tagName(field_name)}), + .@"struct" => |struct_info| { try printStructValue(options, out, struct_info, field_name, indent + 4); }, else => try printType(options, out, @TypeOf(field_name), field_name, indent, null), diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 0c011e25ed..e37b97ddb3 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -614,7 +614,7 @@ fn checksContainStderr(checks: []const StdIo.Check) bool { const IndexedOutput = struct { index: usize, - tag: @typeInfo(Arg).Union.tag_type.?, + tag: @typeInfo(Arg).@"union".tag_type.?, output: *Output, }; fn make(step: *Step, options: Step.MakeOptions) !void { diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index 9c34cbbec9..7e24f25c73 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -95,8 +95,8 @@ pub const Node = struct { /// Not thread-safe. fn getIpcFd(s: Storage) ?posix.fd_t { return if (s.estimated_total_count == std.math.maxInt(u32)) switch (@typeInfo(posix.fd_t)) { - .Int => @bitCast(s.completed_count), - .Pointer => @ptrFromInt(s.completed_count), + .int => @bitCast(s.completed_count), + .pointer => @ptrFromInt(s.completed_count), else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), } else null; } @@ -104,8 +104,8 @@ pub const Node = struct { /// Thread-safe. fn setIpcFd(s: *Storage, fd: posix.fd_t) void { const integer: u32 = switch (@typeInfo(posix.fd_t)) { - .Int => @bitCast(fd), - .Pointer => @intFromPtr(fd), + .int => @bitCast(fd), + .pointer => @intFromPtr(fd), else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), }; // `estimated_total_count` max int indicates the special state that @@ -276,8 +276,8 @@ pub const Node = struct { const storage = storageByIndex(index); const int = @atomicLoad(u32, &storage.completed_count, .monotonic); return switch (@typeInfo(posix.fd_t)) { - .Int => @bitCast(int), - .Pointer => @ptrFromInt(int), + .int => @bitCast(int), + .pointer => @ptrFromInt(int), else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), }; } @@ -381,8 +381,8 @@ pub fn start(options: Options) Node { if (std.process.parseEnvVarInt("ZIG_PROGRESS", u31, 10)) |ipc_fd| { global_progress.update_thread = std.Thread.spawn(.{}, ipcThreadRun, .{ @as(posix.fd_t, switch (@typeInfo(posix.fd_t)) { - .Int => ipc_fd, - .Pointer => @ptrFromInt(ipc_fd), + .int => ipc_fd, + .pointer => @ptrFromInt(ipc_fd), else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), }), }) catch |err| { @@ -633,7 +633,7 @@ const TreeSymbol = enum { fn maxByteLen(symbol: TreeSymbol) usize { var max: usize = 0; - inline for (@typeInfo(Encoding).Enum.fields) |field| { + inline for (@typeInfo(Encoding).@"enum".fields) |field| { const len = symbol.bytes(@field(Encoding, field.name)).len; max = @max(max, len); } diff --git a/lib/std/Random.zig b/lib/std/Random.zig index 0ba048eb0c..3de754c6de 100644 --- a/lib/std/Random.zig +++ b/lib/std/Random.zig @@ -34,9 +34,9 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void, pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random { const Ptr = @TypeOf(pointer); - assert(@typeInfo(Ptr) == .Pointer); // Must be a pointer - assert(@typeInfo(Ptr).Pointer.size == .One); // Must be a single-item pointer - assert(@typeInfo(@typeInfo(Ptr).Pointer.child) == .Struct); // Must point to a struct + assert(@typeInfo(Ptr) == .pointer); // Must be a pointer + assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer + assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct const gen = struct { fn fill(ptr: *anyopaque, buf: []u8) void { const self: Ptr = @ptrCast(@alignCast(ptr)); @@ -79,7 +79,7 @@ pub inline fn enumValue(r: Random, comptime EnumType: type) EnumType { /// See `uintLessThan`, which this function uses in most cases, /// for commentary on the runtime of this function. pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: type) EnumType { - comptime assert(@typeInfo(EnumType) == .Enum); + comptime assert(@typeInfo(EnumType) == .@"enum"); // We won't use int -> enum casting because enum elements can have // arbitrary values. Instead we'll randomly pick one of the type's values. @@ -100,7 +100,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty /// Returns a random int `i` such that `minInt(T) <= i <= maxInt(T)`. /// `i` is evenly distributed. pub fn int(r: Random, comptime T: type) T { - const bits = @typeInfo(T).Int.bits; + const bits = @typeInfo(T).int.bits; const UnsignedT = std.meta.Int(.unsigned, bits); const ceil_bytes = comptime std.math.divCeil(u16, bits, 8) catch unreachable; const ByteAlignedT = std.meta.Int(.unsigned, ceil_bytes * 8); @@ -119,7 +119,7 @@ pub fn int(r: Random, comptime T: type) T { /// Constant-time implementation off `uintLessThan`. /// The results of this function may be biased. pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T { - comptime assert(@typeInfo(T).Int.signedness == .unsigned); + comptime assert(@typeInfo(T).int.signedness == .unsigned); assert(0 < less_than); return limitRangeBiased(T, r.int(T), less_than); } @@ -133,8 +133,8 @@ pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T { /// this function is guaranteed to return. /// If you need deterministic runtime bounds, use `uintLessThanBiased`. pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T { - comptime assert(@typeInfo(T).Int.signedness == .unsigned); - const bits = @typeInfo(T).Int.bits; + comptime assert(@typeInfo(T).int.signedness == .unsigned); + const bits = @typeInfo(T).int.bits; assert(0 < less_than); // adapted from: @@ -164,7 +164,7 @@ pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T { /// Constant-time implementation off `uintAtMost`. /// The results of this function may be biased. pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T { - assert(@typeInfo(T).Int.signedness == .unsigned); + assert(@typeInfo(T).int.signedness == .unsigned); if (at_most == maxInt(T)) { // have the full range return r.int(T); @@ -176,7 +176,7 @@ pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T { /// See `uintLessThan`, which this function uses in most cases, /// for commentary on the runtime of this function. pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T { - assert(@typeInfo(T).Int.signedness == .unsigned); + assert(@typeInfo(T).int.signedness == .unsigned); if (at_most == maxInt(T)) { // have the full range return r.int(T); @@ -188,7 +188,7 @@ pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T { /// The results of this function may be biased. pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_than: T) T { assert(at_least < less_than); - const info = @typeInfo(T).Int; + const info = @typeInfo(T).int; if (info.signedness == .signed) { // Two's complement makes this math pretty easy. const UnsignedT = std.meta.Int(.unsigned, info.bits); @@ -207,7 +207,7 @@ pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_tha /// for commentary on the runtime of this function. pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) T { assert(at_least < less_than); - const info = @typeInfo(T).Int; + const info = @typeInfo(T).int; if (info.signedness == .signed) { // Two's complement makes this math pretty easy. const UnsignedT = std.meta.Int(.unsigned, info.bits); @@ -225,7 +225,7 @@ pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) /// The results of this function may be biased. pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T) T { assert(at_least <= at_most); - const info = @typeInfo(T).Int; + const info = @typeInfo(T).int; if (info.signedness == .signed) { // Two's complement makes this math pretty easy. const UnsignedT = std.meta.Int(.unsigned, info.bits); @@ -244,7 +244,7 @@ pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T /// for commentary on the runtime of this function. pub fn intRangeAtMost(r: Random, comptime T: type, at_least: T, at_most: T) T { assert(at_least <= at_most); - const info = @typeInfo(T).Int; + const info = @typeInfo(T).int; if (info.signedness == .signed) { // Two's complement makes this math pretty easy. const UnsignedT = std.meta.Int(.unsigned, info.bits); @@ -392,12 +392,12 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize }; const point = switch (@typeInfo(T)) { - .Int => |int_info| switch (int_info.signedness) { + .int => |int_info| switch (int_info.signedness) { .signed => r.intRangeLessThan(T, 0, sum), .unsigned => r.uintLessThan(T, sum), }, // take care that imprecision doesn't lead to a value slightly greater than sum - .Float => @min(r.float(T) * sum, sum - std.math.floatEps(T)), + .float => @min(r.float(T) * sum, sum - std.math.floatEps(T)), else => @compileError("weightedIndex does not support proportions of type " ++ @typeName(T)), }; @@ -415,8 +415,8 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize /// into an integer 0 <= result < less_than. /// This function introduces a minor bias. pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { - comptime assert(@typeInfo(T).Int.signedness == .unsigned); - const bits = @typeInfo(T).Int.bits; + comptime assert(@typeInfo(T).int.signedness == .unsigned); + const bits = @typeInfo(T).int.bits; // adapted from: // http://www.pcg-random.org/posts/bounded-rands.html @@ -427,9 +427,9 @@ pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { /// Returns the smallest of `Index` and `usize`. fn MinArrayIndex(comptime Index: type) type { - const index_info = @typeInfo(Index).Int; + const index_info = @typeInfo(Index).int; assert(index_info.signedness == .unsigned); - return if (index_info.bits >= @typeInfo(usize).Int.bits) usize else Index; + return if (index_info.bits >= @typeInfo(usize).int.bits) usize else Index; } test { diff --git a/lib/std/Target.zig b/lib/std/Target.zig index a231892e6e..3580813aec 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -154,7 +154,7 @@ pub const Os = struct { }; } - pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).Union.tag_type.? { + pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? { return switch (tag) { .freestanding, .fuchsia, @@ -1458,7 +1458,7 @@ pub const Cpu = struct { fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model { @setEvalBranchQuota(2000); - const decls = @typeInfo(cpus).Struct.decls; + const decls = @typeInfo(cpus).@"struct".decls; var array: [decls.len]*const Cpu.Model = undefined; for (decls, 0..) |decl, i| { array[i] = &@field(cpus, decl.name); diff --git a/lib/std/Target/Query.zig b/lib/std/Target/Query.zig index 8871e360a5..f18d211853 100644 --- a/lib/std/Target/Query.zig +++ b/lib/std/Target/Query.zig @@ -53,7 +53,7 @@ pub const CpuModel = union(enum) { explicit: *const Target.Cpu.Model, pub fn eql(a: CpuModel, b: CpuModel) bool { - const Tag = @typeInfo(CpuModel).Union.tag_type.?; + const Tag = @typeInfo(CpuModel).@"union".tag_type.?; const a_tag: Tag = a; const b_tag: Tag = b; if (a_tag != b_tag) return false; @@ -70,7 +70,7 @@ pub const OsVersion = union(enum) { windows: Target.Os.WindowsVersion, pub fn eql(a: OsVersion, b: OsVersion) bool { - const Tag = @typeInfo(OsVersion).Union.tag_type.?; + const Tag = @typeInfo(OsVersion).@"union".tag_type.?; const a_tag: Tag = a; const b_tag: Tag = b; if (a_tag != b_tag) return false; @@ -588,14 +588,7 @@ test parse { const text = try query.zigTriple(std.testing.allocator); defer std.testing.allocator.free(text); - var buf: [256]u8 = undefined; - const triple = std.fmt.bufPrint( - buf[0..], - "native-native-{s}.2.1.1", - .{@tagName(builtin.target.abi)}, - ) catch unreachable; - - try std.testing.expectEqualSlices(u8, triple, text); + try std.testing.expectEqualSlices(u8, "native-native-gnu.2.1.1", text); } { const query = try Query.parse(.{ diff --git a/lib/std/Target/aarch64.zig b/lib/std/Target/aarch64.zig index 7755f7959a..b0b895cfeb 100644 --- a/lib/std/Target/aarch64.zig +++ b/lib/std/Target/aarch64.zig @@ -242,7 +242,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { @setEvalBranchQuota(2000); - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.a510)] = .{ @@ -1660,7 +1660,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/amdgpu.zig b/lib/std/Target/amdgpu.zig index 9fe574bd85..0cc7eafe89 100644 --- a/lib/std/Target/amdgpu.zig +++ b/lib/std/Target/amdgpu.zig @@ -183,7 +183,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.@"16_bit_insts")] = .{ @@ -1284,7 +1284,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/arc.zig b/lib/std/Target/arc.zig index 37fc2243c3..4642a085aa 100644 --- a/lib/std/Target/arc.zig +++ b/lib/std/Target/arc.zig @@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.norm)] = .{ @@ -25,7 +25,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/arm.zig b/lib/std/Target/arm.zig index d8b3216a12..7bb2d6b600 100644 --- a/lib/std/Target/arm.zig +++ b/lib/std/Target/arm.zig @@ -215,7 +215,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { @setEvalBranchQuota(10000); - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.@"32bit")] = .{ @@ -1735,7 +1735,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/avr.zig b/lib/std/Target/avr.zig index 0512bd8718..3183aa4f4d 100644 --- a/lib/std/Target/avr.zig +++ b/lib/std/Target/avr.zig @@ -49,7 +49,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.addsubiw)] = .{ @@ -340,7 +340,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/bpf.zig b/lib/std/Target/bpf.zig index 2d17805fbc..5f314a5455 100644 --- a/lib/std/Target/bpf.zig +++ b/lib/std/Target/bpf.zig @@ -16,7 +16,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.alu32)] = .{ @@ -37,7 +37,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/csky.zig b/lib/std/Target/csky.zig index bdb8637709..9ea4c3f41e 100644 --- a/lib/std/Target/csky.zig +++ b/lib/std/Target/csky.zig @@ -76,7 +76,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.@"10e60")] = .{ @@ -418,7 +418,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/hexagon.zig b/lib/std/Target/hexagon.zig index c1cfc777e5..7b1d619e87 100644 --- a/lib/std/Target/hexagon.zig +++ b/lib/std/Target/hexagon.zig @@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.audio)] = .{ @@ -298,7 +298,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/loongarch.zig b/lib/std/Target/loongarch.zig index 999c33f9c2..c5a905dc11 100644 --- a/lib/std/Target/loongarch.zig +++ b/lib/std/Target/loongarch.zig @@ -28,7 +28,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.@"32bit")] = .{ @@ -115,7 +115,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/m68k.zig b/lib/std/Target/m68k.zig index 549ecd4668..a9fcf9e231 100644 --- a/lib/std/Target/m68k.zig +++ b/lib/std/Target/m68k.zig @@ -36,7 +36,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.isa_68000)] = .{ @@ -170,7 +170,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/mips.zig b/lib/std/Target/mips.zig index 0d3f587683..9638cb3907 100644 --- a/lib/std/Target/mips.zig +++ b/lib/std/Target/mips.zig @@ -65,7 +65,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.abs2008)] = .{ @@ -389,7 +389,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/msp430.zig b/lib/std/Target/msp430.zig index 1fb473420d..9ee76ca894 100644 --- a/lib/std/Target/msp430.zig +++ b/lib/std/Target/msp430.zig @@ -17,7 +17,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.ext)] = .{ @@ -43,7 +43,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/nvptx.zig b/lib/std/Target/nvptx.zig index a97994a0d1..bcdf91027b 100644 --- a/lib/std/Target/nvptx.zig +++ b/lib/std/Target/nvptx.zig @@ -58,7 +58,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.ptx32)] = .{ @@ -289,7 +289,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/powerpc.zig b/lib/std/Target/powerpc.zig index 3397446bd1..19c8735bb3 100644 --- a/lib/std/Target/powerpc.zig +++ b/lib/std/Target/powerpc.zig @@ -95,7 +95,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.@"64bit")] = .{ @@ -606,7 +606,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/riscv.zig b/lib/std/Target/riscv.zig index ac31070980..9ee2ea9114 100644 --- a/lib/std/Target/riscv.zig +++ b/lib/std/Target/riscv.zig @@ -201,7 +201,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.@"32bit")] = .{ @@ -1298,7 +1298,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/s390x.zig b/lib/std/Target/s390x.zig index c9516be074..2e7dda40f4 100644 --- a/lib/std/Target/s390x.zig +++ b/lib/std/Target/s390x.zig @@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.backchain)] = .{ @@ -271,7 +271,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/sparc.zig b/lib/std/Target/sparc.zig index 7b550fd2c5..b08d5420b9 100644 --- a/lib/std/Target/sparc.zig +++ b/lib/std/Target/sparc.zig @@ -60,7 +60,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.deprecated_v8)] = .{ @@ -303,7 +303,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/spirv.zig b/lib/std/Target/spirv.zig index 8bc81e189d..6c58fd48eb 100644 --- a/lib/std/Target/spirv.zig +++ b/lib/std/Target/spirv.zig @@ -301,7 +301,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { @setEvalBranchQuota(2000); - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.v1_1)] = .{ @@ -2077,7 +2077,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/ve.zig b/lib/std/Target/ve.zig index cfd6576ff7..6c0d93d1cb 100644 --- a/lib/std/Target/ve.zig +++ b/lib/std/Target/ve.zig @@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.vpu)] = .{ @@ -25,7 +25,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/wasm.zig b/lib/std/Target/wasm.zig index 7f0ae49a78..172c3ecf79 100644 --- a/lib/std/Target/wasm.zig +++ b/lib/std/Target/wasm.zig @@ -26,7 +26,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.atomics)] = .{ @@ -97,7 +97,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/x86.zig b/lib/std/Target/x86.zig index 09ce8cd33e..50d8d48593 100644 --- a/lib/std/Target/x86.zig +++ b/lib/std/Target/x86.zig @@ -199,7 +199,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.@"16bit_mode")] = .{ @@ -1272,7 +1272,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Target/xtensa.zig b/lib/std/Target/xtensa.zig index 40143512c0..4b27e8e12f 100644 --- a/lib/std/Target/xtensa.zig +++ b/lib/std/Target/xtensa.zig @@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; pub const all_features = blk: { - const len = @typeInfo(Feature).Enum.fields.len; + const len = @typeInfo(Feature).@"enum".fields.len; std.debug.assert(len <= CpuFeature.Set.needed_bit_count); var result: [len]CpuFeature = undefined; result[@intFromEnum(Feature.density)] = .{ @@ -25,7 +25,7 @@ pub const all_features = blk: { const ti = @typeInfo(Feature); for (&result, 0..) |*elem, i| { elem.index = i; - elem.name = ti.Enum.fields[i].name; + elem.name = ti.@"enum".fields[i].name; } break :blk result; }; diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 2ed6610bc0..60021346e4 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -401,15 +401,15 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) { const default_value = if (Impl == PosixThreadImpl) null else 0; const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', '!noreturn', 'void', or '!void'"; - switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) { - .NoReturn => { + switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) { + .noreturn => { @call(.auto, f, args); }, - .Void => { + .void => { @call(.auto, f, args); return default_value; }, - .Int => |info| { + .int => |info| { if (info.bits != 8) { @compileError(bad_fn_ret); } @@ -422,7 +422,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) { // pthreads don't support exit status, ignore value return default_value; }, - .ErrorUnion => |info| { + .error_union => |info| { switch (info.payload) { void, noreturn => { @call(.auto, f, args) catch |err| { @@ -850,17 +850,17 @@ const WasiThreadImpl = struct { fn entry(ptr: usize) void { const w: *@This() = @ptrFromInt(ptr); const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'"; - switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) { - .NoReturn, .Void => { + switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) { + .noreturn, .void => { @call(.auto, f, w.args); }, - .Int => |info| { + .int => |info| { if (info.bits != 8) { @compileError(bad_fn_ret); } _ = @call(.auto, f, w.args); // WASI threads don't support exit status, ignore value }, - .ErrorUnion => |info| { + .error_union => |info| { if (info.payload != void) { @compileError(bad_fn_ret); } @@ -1130,6 +1130,19 @@ const LinuxThreadImpl = struct { [len] "r" (self.mapped.len), : "memory" ), + .hexagon => asm volatile ( + \\ r6 = #215 // SYS_munmap + \\ r0 = %[ptr] + \\ r1 = %[len] + \\ trap0(#1) + \\ r6 = #93 // SYS_exit + \\ r0 = #0 + \\ trap0(#1) + : + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), + [len] "r" (self.mapped.len), + : "memory" + ), // We set `sp` to the address of the current function as a workaround for a Linux // kernel bug that caused syscalls to return EFAULT if the stack pointer is invalid. // The bug was introduced in 46e12c07b3b9603c60fc1d421ff18618241cb081 and fixed in @@ -1188,18 +1201,51 @@ const LinuxThreadImpl = struct { [len] "r" (self.mapped.len), : "memory" ), + .s390x => asm volatile ( + \\ lgr %%r2, %[ptr] + \\ lgr %%r3, %[len] + \\ svc 91 # SYS_munmap + \\ lghi %%r2, 0 + \\ svc 1 # SYS_exit + : + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), + [len] "r" (self.mapped.len), + : "memory" + ), + .sparc => asm volatile ( + \\ # See sparc64 comments below. + \\ 1: + \\ cmp %%fp, 0 + \\ beq 2f + \\ nop + \\ ba 1b + \\ restore + \\ 2: + \\ mov 73, %%g1 # SYS_munmap + \\ mov %[ptr], %%o0 + \\ mov %[len], %%o1 + \\ t 0x3 # ST_FLUSH_WINDOWS + \\ t 0x10 + \\ mov 1, %%g1 # SYS_exit + \\ mov 0, %%o0 + \\ t 0x10 + : + : [ptr] "r" (@intFromPtr(self.mapped.ptr)), + [len] "r" (self.mapped.len), + : "memory" + ), .sparc64 => asm volatile ( \\ # SPARCs really don't like it when active stack frames \\ # is unmapped (it will result in a segfault), so we \\ # force-deactivate it by running `restore` until \\ # all frames are cleared. - \\ 1: + \\ 1: \\ cmp %%fp, 0 \\ beq 2f \\ nop \\ ba 1b \\ restore - \\ 2: + \\ 2: \\ mov 73, %%g1 # SYS_munmap \\ mov %[ptr], %%o0 \\ mov %[len], %%o1 @@ -1208,7 +1254,7 @@ const LinuxThreadImpl = struct { \\ flushw \\ t 0x6d \\ mov 1, %%g1 # SYS_exit - \\ mov 1, %%o0 + \\ mov 0, %%o0 \\ t 0x6d : : [ptr] "r" (@intFromPtr(self.mapped.ptr)), diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig index c067368041..fe22fa2011 100644 --- a/lib/std/Thread/Futex.zig +++ b/lib/std/Thread/Futex.zig @@ -27,7 +27,7 @@ const atomic = std.atomic; /// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically /// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`. pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void { - @setCold(true); + @branchHint(.cold); Impl.wait(ptr, expect, null) catch |err| switch (err) { error.Timeout => unreachable, // null timeout meant to wait forever @@ -43,7 +43,7 @@ pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void { /// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically /// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`. pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) error{Timeout}!void { - @setCold(true); + @branchHint(.cold); // Avoid calling into the OS for no-op timeouts. if (timeout_ns == 0) { @@ -56,7 +56,7 @@ pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) er /// Unblocks at most `max_waiters` callers blocked in a `wait()` call on `ptr`. pub fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { - @setCold(true); + @branchHint(.cold); // Avoid calling into the OS if there's nothing to wake up. if (max_waiters == 0) { @@ -1048,7 +1048,7 @@ pub const Deadline = struct { /// - A spurious wake occurs. /// - The deadline expires; In which case `error.Timeout` is returned. pub fn wait(self: *Deadline, ptr: *const atomic.Value(u32), expect: u32) error{Timeout}!void { - @setCold(true); + @branchHint(.cold); // Check if we actually have a timeout to wait until. // If not just wait "forever". diff --git a/lib/std/Thread/Mutex.zig b/lib/std/Thread/Mutex.zig index 032c19b7dd..be421c4c94 100644 --- a/lib/std/Thread/Mutex.zig +++ b/lib/std/Thread/Mutex.zig @@ -169,7 +169,7 @@ const FutexImpl = struct { } fn lockSlow(self: *@This()) void { - @setCold(true); + @branchHint(.cold); // Avoid doing an atomic swap below if we already know the state is contended. // An atomic swap unconditionally stores which marks the cache-line as modified unnecessarily. diff --git a/lib/std/Thread/ResetEvent.zig b/lib/std/Thread/ResetEvent.zig index b7e5758780..cbc5a2a31c 100644 --- a/lib/std/Thread/ResetEvent.zig +++ b/lib/std/Thread/ResetEvent.zig @@ -107,7 +107,7 @@ const FutexImpl = struct { } fn waitUntilSet(self: *Impl, timeout: ?u64) error{Timeout}!void { - @setCold(true); + @branchHint(.cold); // Try to set the state from `unset` to `waiting` to indicate // to the set() thread that others are blocked on the ResetEvent. diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index 62e875ff0a..eb31d1cae3 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -2584,17 +2584,17 @@ pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K pub fn autoEqlIsCheap(comptime K: type) bool { return switch (@typeInfo(K)) { - .Bool, - .Int, - .Float, - .Pointer, - .ComptimeFloat, - .ComptimeInt, - .Enum, - .Fn, - .ErrorSet, - .AnyFrame, - .EnumLiteral, + .bool, + .int, + .float, + .pointer, + .comptime_float, + .comptime_int, + .@"enum", + .@"fn", + .error_set, + .@"anyframe", + .enum_literal, => true, else => false, }; diff --git a/lib/std/bit_set.zig b/lib/std/bit_set.zig index d70f425e61..1e2a0179ef 100644 --- a/lib/std/bit_set.zig +++ b/lib/std/bit_set.zig @@ -319,10 +319,10 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { const mask_info: std.builtin.Type = @typeInfo(MaskIntType); // Make sure the mask int is indeed an int - if (mask_info != .Int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType)); + if (mask_info != .int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType)); // It must also be unsigned. - if (mask_info.Int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType)); + if (mask_info.int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType)); // And it must not be empty. if (MaskIntType == u0) diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index 85a175003d..b88ba5a907 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -39,16 +39,14 @@ pub fn BoundedArrayAligned( ) type { return struct { const Self = @This(); - const Len = std.math.IntFittingRange(0, buffer_capacity); - buffer: [buffer_capacity]T align(alignment) = undefined, - len: Len = 0, + len: usize = 0, /// Set the actual length of the slice. /// Returns error.Overflow if it exceeds the length of the backing array. pub fn init(len: usize) error{Overflow}!Self { if (len > buffer_capacity) return error.Overflow; - return Self{ .len = @intCast(len) }; + return Self{ .len = len }; } /// View the internal array as a slice whose size was previously set. @@ -69,7 +67,7 @@ pub fn BoundedArrayAligned( /// Does not initialize added items if any. pub fn resize(self: *Self, len: usize) error{Overflow}!void { if (len > buffer_capacity) return error.Overflow; - self.len = @intCast(len); + self.len = len; } /// Remove all elements from the slice. @@ -178,7 +176,7 @@ pub fn BoundedArrayAligned( /// This operation is O(N). pub fn insertSlice(self: *Self, i: usize, items: []const T) error{Overflow}!void { try self.ensureUnusedCapacity(items.len); - self.len = @intCast(self.len + items.len); + self.len += items.len; mem.copyBackwards(T, self.slice()[i + items.len .. self.len], self.constSlice()[i .. self.len - items.len]); @memcpy(self.slice()[i..][0..items.len], items); } @@ -208,7 +206,7 @@ pub fn BoundedArrayAligned( for (self.constSlice()[after_range..], 0..) |item, i| { self.slice()[after_subrange..][i] = item; } - self.len = @intCast(self.len - len + new_items.len); + self.len -= len - new_items.len; } } @@ -259,7 +257,7 @@ pub fn BoundedArrayAligned( /// enough to store the new items. pub fn appendSliceAssumeCapacity(self: *Self, items: []const T) void { const old_len = self.len; - self.len = @intCast(self.len + items.len); + self.len += items.len; @memcpy(self.slice()[old_len..][0..items.len], items); } @@ -275,8 +273,8 @@ pub fn BoundedArrayAligned( /// Asserts the capacity is enough. pub fn appendNTimesAssumeCapacity(self: *Self, value: T, n: usize) void { const old_len = self.len; - assert(self.len + n <= buffer_capacity); - self.len = @intCast(self.len + n); + self.len += n; + assert(self.len <= buffer_capacity); @memset(self.slice()[old_len..self.len], value); } @@ -406,18 +404,6 @@ test BoundedArray { try testing.expectEqualStrings(s, a.constSlice()); } -test "BoundedArray sizeOf" { - // Just sanity check size on one CPU - if (@import("builtin").cpu.arch != .x86_64) - return; - - try testing.expectEqual(@sizeOf(BoundedArray(u8, 3)), 4); - - // `len` is the minimum required size to hold the maximum capacity - try testing.expectEqual(@TypeOf(@as(BoundedArray(u8, 15), undefined).len), u4); - try testing.expectEqual(@TypeOf(@as(BoundedArray(u8, 16), undefined).len), u5); -} - test "BoundedArrayAligned" { var a = try BoundedArrayAligned(u8, 16, 4).init(0); try a.append(0); diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 69a9a47bdf..ccd46d874d 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -255,30 +255,30 @@ pub const TypeId = std.meta.Tag(Type); /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub const Type = union(enum) { - Type: void, - Void: void, - Bool: void, - NoReturn: void, - Int: Int, - Float: Float, - Pointer: Pointer, - Array: Array, - Struct: Struct, - ComptimeFloat: void, - ComptimeInt: void, - Undefined: void, - Null: void, - Optional: Optional, - ErrorUnion: ErrorUnion, - ErrorSet: ErrorSet, - Enum: Enum, - Union: Union, - Fn: Fn, - Opaque: Opaque, - Frame: Frame, - AnyFrame: AnyFrame, - Vector: Vector, - EnumLiteral: void, + type: void, + void: void, + bool: void, + noreturn: void, + int: Int, + float: Float, + pointer: Pointer, + array: Array, + @"struct": Struct, + comptime_float: void, + comptime_int: void, + undefined: void, + null: void, + optional: Optional, + error_union: ErrorUnion, + error_set: ErrorSet, + @"enum": Enum, + @"union": Union, + @"fn": Fn, + @"opaque": Opaque, + frame: Frame, + @"anyframe": AnyFrame, + vector: Vector, + enum_literal: void, /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. @@ -601,7 +601,7 @@ pub const VaList = switch (builtin.cpu.arch) { .ios, .macos, .tvos, .watchos, .visionos => *u8, else => @compileError("disabled due to miscompilations"), // VaListAarch64, }, - .arm => switch (builtin.os.tag) { + .arm, .armeb, .thumb, .thumbeb => switch (builtin.os.tag) { .ios, .macos, .tvos, .watchos, .visionos => *u8, else => *anyopaque, }, @@ -673,6 +673,25 @@ pub const ExternOptions = struct { is_thread_local: bool = false, }; +/// This data structure is used by the Zig language code generation and +/// therefore must be kept in sync with the compiler implementation. +pub const BranchHint = enum(u3) { + /// Equivalent to no hint given. + none, + /// This branch of control flow is more likely to be reached than its peers. + /// The optimizer should optimize for reaching it. + likely, + /// This branch of control flow is less likely to be reached than its peers. + /// The optimizer should optimize for not reaching it. + unlikely, + /// This branch of control flow is unlikely to *ever* be reached. + /// The optimizer may place it in a different page of memory to optimize other branches. + cold, + /// It is difficult to predict whether this branch of control flow will be reached. + /// The optimizer should avoid branching behavior with expensive mispredictions. + unpredictable, +}; + /// This enum is set by the compiler and communicates which compiler backend is /// used to produce machine code. /// Think carefully before deciding to observe this value. Nearly all code should @@ -758,7 +777,7 @@ else /// This function is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr: ?usize) noreturn { - @setCold(true); + @branchHint(.cold); // For backends that cannot handle the language features depended on by the // default panic handler, we have a simpler panic handler: @@ -875,27 +894,27 @@ pub fn checkNonScalarSentinel(expected: anytype, actual: @TypeOf(expected)) void } pub fn panicSentinelMismatch(expected: anytype, actual: @TypeOf(expected)) noreturn { - @setCold(true); + @branchHint(.cold); std.debug.panicExtra(null, @returnAddress(), "sentinel mismatch: expected {any}, found {any}", .{ expected, actual }); } pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn { - @setCold(true); + @branchHint(.cold); std.debug.panicExtra(st, @returnAddress(), "attempt to unwrap error: {s}", .{@errorName(err)}); } pub fn panicOutOfBounds(index: usize, len: usize) noreturn { - @setCold(true); + @branchHint(.cold); std.debug.panicExtra(null, @returnAddress(), "index out of bounds: index {d}, len {d}", .{ index, len }); } pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn { - @setCold(true); + @branchHint(.cold); std.debug.panicExtra(null, @returnAddress(), "start index {d} is larger than end index {d}", .{ start, end }); } pub fn panicInactiveUnionField(active: anytype, wanted: @TypeOf(active)) noreturn { - @setCold(true); + @branchHint(.cold); std.debug.panicExtra(null, @returnAddress(), "access of union field '{s}' while field '{s}' is active", .{ @tagName(wanted), @tagName(active) }); } @@ -928,7 +947,7 @@ pub const panic_messages = struct { }; pub noinline fn returnError(st: *StackTrace) void { - @setCold(true); + @branchHint(.cold); @setRuntimeSafety(false); addErrRetTraceAddr(st, @returnAddress()); } diff --git a/lib/std/c.zig b/lib/std/c.zig index d430cf6a83..2a47628306 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -40,7 +40,7 @@ pub extern var _mh_execute_header: mach_hdr; var dummy_execute_header: mach_hdr = undefined; comptime { if (native_os.isDarwin()) { - @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak }); + @export(&dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak }); } } @@ -177,7 +177,7 @@ pub const passwd = switch (native_os) { dir: ?[*:0]const u8, // home directory shell: ?[*:0]const u8, // shell program }, - .openbsd => extern struct { + .netbsd, .openbsd, .macos => extern struct { name: ?[*:0]const u8, // user name passwd: ?[*:0]const u8, // encrypted password uid: uid_t, // user uid @@ -9499,8 +9499,8 @@ pub const LC = enum(c_int) { pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8; -pub const getcontext = if (builtin.target.isAndroid()) -{} // android bionic libc does not implement getcontext +pub const getcontext = if (builtin.target.isAndroid() or builtin.target.os.tag == .openbsd) +{} // android bionic and openbsd libc does not implement getcontext else if (native_os == .linux and builtin.target.isMusl()) linux.getcontext else diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index 3e2cf53b60..60a349868e 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -54,7 +54,7 @@ pub const EXC = enum(exception_type_t) { /// Abnormal process exited to corpse state CORPSE_NOTIFY = 13, - pub const TYPES_COUNT = @typeInfo(EXC).Enum.fields.len; + pub const TYPES_COUNT = @typeInfo(EXC).@"enum".fields.len; pub const SOFT_SIGNAL = 0x10003; pub const MASK = packed struct(u32) { diff --git a/lib/std/coff.zig b/lib/std/coff.zig index ca05ce3cf9..da7dc0bcda 100644 --- a/lib/std/coff.zig +++ b/lib/std/coff.zig @@ -1060,23 +1060,6 @@ pub const MachineType = enum(u16) { WCEMIPSV2 = 0x169, _, - - pub fn toTargetCpuArch(machine_type: MachineType) ?std.Target.Cpu.Arch { - return switch (machine_type) { - .ARM => .arm, - .POWERPC => .powerpc, - .RISCV32 => .riscv32, - .THUMB => .thumb, - .I386 => .x86, - .ARM64 => .aarch64, - .RISCV64 => .riscv64, - .X64 => .x86_64, - .LOONGARCH32 => .loongarch32, - .LOONGARCH64 => .loongarch64, - // there's cases we don't (yet) handle - else => null, - }; - } }; pub const CoffError = error{ diff --git a/lib/std/compress/flate/huffman_encoder.zig b/lib/std/compress/flate/huffman_encoder.zig index 42cf9a20c2..3e92e55a63 100644 --- a/lib/std/compress/flate/huffman_encoder.zig +++ b/lib/std/compress/flate/huffman_encoder.zig @@ -455,7 +455,7 @@ test "generate a Huffman code for the 30 possible relative distances (LZ77 dista // Reverse bit-by-bit a N-bit code. fn bitReverse(comptime T: type, value: T, n: usize) T { const r = @bitReverse(value); - return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).Int.bits - n)); + return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).int.bits - n)); } test bitReverse { diff --git a/lib/std/crypto/cmac.zig b/lib/std/crypto/cmac.zig index 902bac591c..c026850ea6 100644 --- a/lib/std/crypto/cmac.zig +++ b/lib/std/crypto/cmac.zig @@ -8,7 +8,7 @@ pub const CmacAes128 = Cmac(crypto.core.aes.Aes128); /// NIST Special Publication 800-38B - The CMAC Mode for Authentication /// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38b.pdf pub fn Cmac(comptime BlockCipher: type) type { - const BlockCipherCtx = @typeInfo(@TypeOf(BlockCipher.initEnc)).Fn.return_type.?; + const BlockCipherCtx = @typeInfo(@TypeOf(BlockCipher.initEnc)).@"fn".return_type.?; const Block = [BlockCipher.block.block_length]u8; return struct { diff --git a/lib/std/crypto/ff.zig b/lib/std/crypto/ff.zig index ba37a428ad..ff018b3c9b 100644 --- a/lib/std/crypto/ff.zig +++ b/lib/std/crypto/ff.zig @@ -848,7 +848,7 @@ const ct_protected = struct { // Multiplies two limbs and returns the result as a wide limb. fn mulWide(x: Limb, y: Limb) WideLimb { - const half_bits = @typeInfo(Limb).Int.bits / 2; + const half_bits = @typeInfo(Limb).int.bits / 2; const Half = meta.Int(.unsigned, half_bits); const x0 = @as(Half, @truncate(x)); const x1 = @as(Half, @truncate(x >> half_bits)); @@ -901,7 +901,7 @@ const ct_unprotected = struct { fn mulWide(x: Limb, y: Limb) WideLimb { const wide = math.mulWide(Limb, x, y); return .{ - .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).Int.bits)), + .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).int.bits)), .lo = @as(Limb, @truncate(wide)), }; } diff --git a/lib/std/crypto/phc_encoding.zig b/lib/std/crypto/phc_encoding.zig index fecd7f1239..3442073632 100644 --- a/lib/std/crypto/phc_encoding.zig +++ b/lib/std/crypto/phc_encoding.zig @@ -91,7 +91,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult if (mem.eql(u8, opt_version.key, version_param_name)) { if (@hasField(HashResult, "alg_version")) { const value_type_info = switch (@typeInfo(@TypeOf(out.alg_version))) { - .Optional => |opt| comptime @typeInfo(opt.child), + .optional => |opt| @typeInfo(opt.child), else => |t| t, }; out.alg_version = fmt.parseUnsigned( @@ -114,16 +114,16 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult inline for (comptime meta.fields(HashResult)) |p| { if (mem.eql(u8, p.name, param.key)) { switch (@typeInfo(p.type)) { - .Int => @field(out, p.name) = fmt.parseUnsigned( + .int => @field(out, p.name) = fmt.parseUnsigned( p.type, param.value, 10, ) catch return Error.InvalidEncoding, - .Pointer => |ptr| { + .pointer => |ptr| { if (!ptr.is_const) @compileError("Value slice must be constant"); @field(out, p.name) = param.value; }, - .Struct => try @field(out, p.name).fromB64(param.value), + .@"struct" => try @field(out, p.name).fromB64(param.value), else => std.debug.panic( "Value for [{s}] must be an integer, a constant slice or a BinValue", .{p.name}, @@ -164,7 +164,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult // with default values var expected_fields: usize = 0; inline for (comptime meta.fields(HashResult)) |p| { - if (@typeInfo(p.type) != .Optional and p.default_value == null) { + if (@typeInfo(p.type) != .optional and p.default_value == null) { expected_fields += 1; } } @@ -202,7 +202,7 @@ fn serializeTo(params: anytype, out: anytype) !void { try out.writeAll(params.alg_id); if (@hasField(HashResult, "alg_version")) { - if (@typeInfo(@TypeOf(params.alg_version)) == .Optional) { + if (@typeInfo(@TypeOf(params.alg_version)) == .optional) { if (params.alg_version) |alg_version| { try out.print( "{s}{s}{s}{}", @@ -226,12 +226,12 @@ fn serializeTo(params: anytype, out: anytype) !void { { const value = @field(params, p.name); try out.writeAll(if (has_params) params_delimiter else fields_delimiter); - if (@typeInfo(p.type) == .Struct) { + if (@typeInfo(p.type) == .@"struct") { var buf: [@TypeOf(value).max_encoded_length]u8 = undefined; try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) }); } else { try out.print( - if (@typeInfo(@TypeOf(value)) == .Pointer) "{s}{s}{s}" else "{s}{s}{}", + if (@typeInfo(@TypeOf(value)) == .pointer) "{s}{s}{s}" else "{s}{s}{}", .{ p.name, kv_delimiter, value }, ); } diff --git a/lib/std/crypto/poly1305.zig b/lib/std/crypto/poly1305.zig index 254e19ae02..787f105904 100644 --- a/lib/std/crypto/poly1305.zig +++ b/lib/std/crypto/poly1305.zig @@ -12,7 +12,7 @@ pub const Poly1305 = struct { // accumulated hash h: [3]u64 = [_]u64{ 0, 0, 0 }, // random number added at the end (from the secret key) - pad: [2]u64, + end_pad: [2]u64, // how many bytes are waiting to be processed in a partial block leftover: usize = 0, // partial block buffer @@ -24,7 +24,7 @@ pub const Poly1305 = struct { mem.readInt(u64, key[0..8], .little) & 0x0ffffffc0fffffff, mem.readInt(u64, key[8..16], .little) & 0x0ffffffc0ffffffc, }, - .pad = [_]u64{ + .end_pad = [_]u64{ mem.readInt(u64, key[16..24], .little), mem.readInt(u64, key[24..32], .little), }, @@ -177,9 +177,9 @@ pub const Poly1305 = struct { h1 ^= mask & (h1 ^ h_p1); // Add the first half of the key, we intentionally don't use @addWithOverflow() here. - st.h[0] = h0 +% st.pad[0]; - const c = ((h0 & st.pad[0]) | ((h0 | st.pad[0]) & ~st.h[0])) >> 63; - st.h[1] = h1 +% st.pad[1] +% c; + st.h[0] = h0 +% st.end_pad[0]; + const c = ((h0 & st.end_pad[0]) | ((h0 | st.end_pad[0]) & ~st.h[0])) >> 63; + st.h[1] = h1 +% st.end_pad[1] +% c; mem.writeInt(u64, out[0..8], st.h[0], .little); mem.writeInt(u64, out[8..16], st.h[1], .little); diff --git a/lib/std/crypto/timing_safe.zig b/lib/std/crypto/timing_safe.zig index 4adeb9cf69..72543340c3 100644 --- a/lib/std/crypto/timing_safe.zig +++ b/lib/std/crypto/timing_safe.zig @@ -11,27 +11,27 @@ const Order = std.math.Order; /// For all other applications, use mem.eql() instead. pub fn eql(comptime T: type, a: T, b: T) bool { switch (@typeInfo(T)) { - .Array => |info| { + .array => |info| { const C = info.child; - if (@typeInfo(C) != .Int) { + if (@typeInfo(C) != .int) { @compileError("Elements to be compared must be integers"); } var acc = @as(C, 0); for (a, 0..) |x, i| { acc |= x ^ b[i]; } - const s = @typeInfo(C).Int.bits; + const s = @typeInfo(C).int.bits; const Cu = std.meta.Int(.unsigned, s); const Cext = std.meta.Int(.unsigned, s + 1); return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s)))); }, - .Vector => |info| { + .vector => |info| { const C = info.child; - if (@typeInfo(C) != .Int) { + if (@typeInfo(C) != .int) { @compileError("Elements to be compared must be integers"); } const acc = @reduce(.Or, a ^ b); - const s = @typeInfo(C).Int.bits; + const s = @typeInfo(C).int.bits; const Cu = std.meta.Int(.unsigned, s); const Cext = std.meta.Int(.unsigned, s + 1); return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s)))); @@ -47,7 +47,7 @@ pub fn eql(comptime T: type, a: T, b: T) bool { pub fn compare(comptime T: type, a: []const T, b: []const T, endian: Endian) Order { assert(a.len == b.len); const bits = switch (@typeInfo(T)) { - .Int => |cinfo| if (cinfo.signedness != .unsigned) @compileError("Elements to be compared must be unsigned") else cinfo.bits, + .int => |cinfo| if (cinfo.signedness != .unsigned) @compileError("Elements to be compared must be unsigned") else cinfo.bits, else => @compileError("Elements to be compared must be integers"), }; const Cext = std.meta.Int(.unsigned, bits + 1); diff --git a/lib/std/crypto/tls.zig b/lib/std/crypto/tls.zig index fbb41a3fd7..b3d0dcb59f 100644 --- a/lib/std/crypto/tls.zig +++ b/lib/std/crypto/tls.zig @@ -491,7 +491,7 @@ pub const Decoder = struct { /// Use this function to increase `idx`. pub fn decode(d: *Decoder, comptime T: type) T { switch (@typeInfo(T)) { - .Int => |info| switch (info.bits) { + .int => |info| switch (info.bits) { 8 => { skip(d, 1); return d.buf[d.idx - 1]; @@ -511,7 +511,7 @@ pub const Decoder = struct { }, else => @compileError("unsupported int type: " ++ @typeName(T)), }, - .Enum => |info| { + .@"enum" => |info| { const int = d.decode(info.tag_type); if (info.is_exhaustive) @compileError("exhaustive enum cannot be used"); return @as(T, @enumFromInt(int)); diff --git a/lib/std/debug.zig b/lib/std/debug.zig index b465efd12a..554788f4fd 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -409,7 +409,7 @@ pub fn assertReadable(slice: []const volatile u8) void { } pub fn panic(comptime format: []const u8, args: anytype) noreturn { - @setCold(true); + @branchHint(.cold); panicExtra(@errorReturnTrace(), @returnAddress(), format, args); } @@ -422,7 +422,7 @@ pub fn panicExtra( comptime format: []const u8, args: anytype, ) noreturn { - @setCold(true); + @branchHint(.cold); const size = 0x1000; const trunc_msg = "(msg truncated)"; @@ -450,7 +450,7 @@ threadlocal var panic_stage: usize = 0; // `panicImpl` could be useful in implementing a custom panic handler which // calls the default handler (on supported platforms) pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn { - @setCold(true); + @branchHint(.cold); if (enable_segfault_handler) { // If a segfault happens while panicking, we want it to actually segfault, not trigger @@ -545,7 +545,7 @@ pub fn writeStackTrace( } pub const UnwindError = if (have_ucontext) - @typeInfo(@typeInfo(@TypeOf(StackIterator.next_unwind)).Fn.return_type.?).ErrorUnion.error_set + @typeInfo(@typeInfo(@TypeOf(StackIterator.next_unwind)).@"fn".return_type.?).error_union.error_set else void; @@ -787,7 +787,7 @@ pub noinline fn walkStackWindows(addresses: []usize, existing_context: ?*const w } var i: usize = 0; - var image_base: usize = undefined; + var image_base: windows.DWORD64 = undefined; var history_table: windows.UNWIND_HISTORY_TABLE = std.mem.zeroes(windows.UNWIND_HISTORY_TABLE); while (i < addresses.len) : (i += 1) { @@ -807,7 +807,7 @@ pub noinline fn walkStackWindows(addresses: []usize, existing_context: ?*const w ); } else { // leaf function - context.setIp(@as(*u64, @ptrFromInt(current_regs.sp)).*); + context.setIp(@as(*usize, @ptrFromInt(current_regs.sp)).*); context.setSp(current_regs.sp + @sizeOf(usize)); } diff --git a/lib/std/debug/Dwarf.zig b/lib/std/debug/Dwarf.zig index 7cce30df38..1bc47a3e38 100644 --- a/lib/std/debug/Dwarf.zig +++ b/lib/std/debug/Dwarf.zig @@ -279,10 +279,11 @@ pub const Die = struct { }; } - fn getAttrRef(self: *const Die, id: u64) !u64 { + fn getAttrRef(self: *const Die, id: u64, unit_offset: u64, unit_len: u64) !u64 { const form_value = self.getAttr(id) orelse return error.MissingDebugInfo; return switch (form_value.*) { - .ref => |value| value, + .ref => |offset| if (offset < unit_len) unit_offset + offset else bad(), + .ref_addr => |addr| addr, else => bad(), }; } @@ -428,14 +429,14 @@ pub const ExceptionFrameHeader = struct { }; const fde_entry_header = try EntryHeader.read(&eh_frame_fbr, if (eh_frame_len == null) ma else null, .eh_frame); - if (!self.isValidPtr(u8, @intFromPtr(&fde_entry_header.entry_bytes[fde_entry_header.entry_bytes.len - 1]), ma, eh_frame_len)) return bad(); + if (fde_entry_header.entry_bytes.len > 0 and !self.isValidPtr(u8, @intFromPtr(&fde_entry_header.entry_bytes[fde_entry_header.entry_bytes.len - 1]), ma, eh_frame_len)) return bad(); if (fde_entry_header.type != .fde) return bad(); // CIEs always come before FDEs (the offset is a subtraction), so we can assume this memory is readable const cie_offset = fde_entry_header.type.fde; try eh_frame_fbr.seekTo(cie_offset); const cie_entry_header = try EntryHeader.read(&eh_frame_fbr, if (eh_frame_len == null) ma else null, .eh_frame); - if (!self.isValidPtr(u8, @intFromPtr(&cie_entry_header.entry_bytes[cie_entry_header.entry_bytes.len - 1]), ma, eh_frame_len)) return bad(); + if (cie_entry_header.entry_bytes.len > 0 and !self.isValidPtr(u8, @intFromPtr(&cie_entry_header.entry_bytes[cie_entry_header.entry_bytes.len - 1]), ma, eh_frame_len)) return bad(); if (cie_entry_header.type != .cie) return bad(); cie.* = try CommonInformationEntry.parse( @@ -942,13 +943,12 @@ fn scanAllFunctions(di: *Dwarf, allocator: Allocator) ScanError!void { defer fbr.pos = after_die_offset; // Follow the DIE it points to and repeat - const ref_offset = try this_die_obj.getAttrRef(AT.abstract_origin); - if (ref_offset > next_offset) return bad(); - try fbr.seekTo(this_unit_offset + ref_offset); + const ref_offset = try this_die_obj.getAttrRef(AT.abstract_origin, this_unit_offset, next_offset); + try fbr.seekTo(ref_offset); this_die_obj = (try parseDie( &fbr, attrs_bufs[2], - abbrev_table, + abbrev_table, // wrong abbrev table for different cu unit_header.format, )) orelse return bad(); } else if (this_die_obj.getAttr(AT.specification)) |_| { @@ -956,13 +956,12 @@ fn scanAllFunctions(di: *Dwarf, allocator: Allocator) ScanError!void { defer fbr.pos = after_die_offset; // Follow the DIE it points to and repeat - const ref_offset = try this_die_obj.getAttrRef(AT.specification); - if (ref_offset > next_offset) return bad(); - try fbr.seekTo(this_unit_offset + ref_offset); + const ref_offset = try this_die_obj.getAttrRef(AT.specification, this_unit_offset, next_offset); + try fbr.seekTo(ref_offset); this_die_obj = (try parseDie( &fbr, attrs_bufs[2], - abbrev_table, + abbrev_table, // wrong abbrev table for different cu unit_header.format, )) orelse return bad(); } else { @@ -1494,7 +1493,7 @@ fn runLineNumberProgram(d: *Dwarf, gpa: Allocator, compile_unit: *CompileUnit) ! } } else { const FileEntFmt = struct { - content_type_code: u8, + content_type_code: u16, form_code: u16, }; { @@ -1539,7 +1538,7 @@ fn runLineNumberProgram(d: *Dwarf, gpa: Allocator, compile_unit: *CompileUnit) ! if (file_name_entry_format_count > file_ent_fmt_buf.len) return bad(); for (file_ent_fmt_buf[0..file_name_entry_format_count]) |*ent_fmt| { ent_fmt.* = .{ - .content_type_code = try fbr.readUleb128(u8), + .content_type_code = try fbr.readUleb128(u16), .form_code = try fbr.readUleb128(u16), }; } @@ -2216,7 +2215,7 @@ pub const ElfModule = struct { } var section_index: ?usize = null; - inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |sect, i| { + inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |sect, i| { if (mem.eql(u8, "." ++ sect.name, name)) section_index = i; } if (section_index == null) continue; diff --git a/lib/std/debug/Dwarf/expression.zig b/lib/std/debug/Dwarf/expression.zig index 5fab56de6e..f71a4e02c1 100644 --- a/lib/std/debug/Dwarf/expression.zig +++ b/lib/std/debug/Dwarf/expression.zig @@ -164,7 +164,7 @@ pub fn StackMachine(comptime options: Options) type { } fn generic(value: anytype) Operand { - const int_info = @typeInfo(@TypeOf(value)).Int; + const int_info = @typeInfo(@TypeOf(value)).int; if (@sizeOf(@TypeOf(value)) > options.addr_size) { return .{ .generic = switch (int_info.signedness) { .signed => @bitCast(@as(addr_type_signed, @truncate(value))), @@ -843,7 +843,7 @@ pub fn Builder(comptime options: Options) type { } pub fn writeConst(writer: anytype, comptime T: type, value: T) !void { - if (@typeInfo(T) != .Int) @compileError("Constants must be integers"); + if (@typeInfo(T) != .int) @compileError("Constants must be integers"); switch (T) { u8, i8, u16, i16, u32, i32, u64, i64 => { @@ -861,7 +861,7 @@ pub fn Builder(comptime options: Options) type { try writer.writeInt(T, value, options.endian); }, - else => switch (@typeInfo(T).Int.signedness) { + else => switch (@typeInfo(T).int.signedness) { .unsigned => { try writer.writeByte(OP.constu); try leb.writeUleb128(writer, value); diff --git a/lib/std/debug/FixedBufferReader.zig b/lib/std/debug/FixedBufferReader.zig index 494245a9e9..e4aec1a9c6 100644 --- a/lib/std/debug/FixedBufferReader.zig +++ b/lib/std/debug/FixedBufferReader.zig @@ -32,7 +32,7 @@ pub fn readByteSigned(fbr: *FixedBufferReader) Error!i8 { } pub fn readInt(fbr: *FixedBufferReader, comptime T: type) Error!T { - const size = @divExact(@typeInfo(T).Int.bits, 8); + const size = @divExact(@typeInfo(T).int.bits, 8); if (fbr.buf.len - fbr.pos < size) return error.EndOfBuffer; defer fbr.pos += size; return std.mem.readInt(T, fbr.buf[fbr.pos..][0..size], fbr.endian); diff --git a/lib/std/debug/Pdb.zig b/lib/std/debug/Pdb.zig index bdcc108c1d..3b1adb3c56 100644 --- a/lib/std/debug/Pdb.zig +++ b/lib/std/debug/Pdb.zig @@ -63,18 +63,18 @@ pub fn deinit(self: *Pdb) void { } pub fn parseDbiStream(self: *Pdb) !void { - var stream = self.getStream(pdb.StreamType.Dbi) orelse + var stream = self.getStream(pdb.StreamType.dbi) orelse return error.InvalidDebugInfo; const reader = stream.reader(); const header = try reader.readStruct(std.pdb.DbiStreamHeader); - if (header.VersionHeader != 19990903) // V70, only value observed by LLVM team + if (header.version_header != 19990903) // V70, only value observed by LLVM team return error.UnknownPDBVersion; // if (header.Age != age) // return error.UnmatchingPDB; - const mod_info_size = header.ModInfoSize; - const section_contrib_size = header.SectionContributionSize; + const mod_info_size = header.mod_info_size; + const section_contrib_size = header.section_contribution_size; var modules = std.ArrayList(Module).init(self.allocator); errdefer modules.deinit(); @@ -143,7 +143,7 @@ pub fn parseDbiStream(self: *Pdb) !void { } pub fn parseInfoStream(self: *Pdb) !void { - var stream = self.getStream(pdb.StreamType.Pdb) orelse + var stream = self.getStream(pdb.StreamType.pdb) orelse return error.InvalidDebugInfo; const reader = stream.reader(); @@ -168,23 +168,23 @@ pub fn parseInfoStream(self: *Pdb) !void { try reader.readNoEof(name_bytes); const HashTableHeader = extern struct { - Size: u32, - Capacity: u32, + size: u32, + capacity: u32, fn maxLoad(cap: u32) u32 { return cap * 2 / 3 + 1; } }; const hash_tbl_hdr = try reader.readStruct(HashTableHeader); - if (hash_tbl_hdr.Capacity == 0) + if (hash_tbl_hdr.capacity == 0) return error.InvalidDebugInfo; - if (hash_tbl_hdr.Size > HashTableHeader.maxLoad(hash_tbl_hdr.Capacity)) + if (hash_tbl_hdr.size > HashTableHeader.maxLoad(hash_tbl_hdr.capacity)) return error.InvalidDebugInfo; const present = try readSparseBitVector(&reader, self.allocator); defer self.allocator.free(present); - if (present.len != hash_tbl_hdr.Size) + if (present.len != hash_tbl_hdr.size) return error.InvalidDebugInfo; const deleted = try readSparseBitVector(&reader, self.allocator); defer self.allocator.free(deleted); @@ -212,19 +212,19 @@ pub fn getSymbolName(self: *Pdb, module: *Module, address: u64) ?[]const u8 { var symbol_i: usize = 0; while (symbol_i != module.symbols.len) { - const prefix = @as(*align(1) pdb.RecordPrefix, @ptrCast(&module.symbols[symbol_i])); - if (prefix.RecordLen < 2) + const prefix: *align(1) pdb.RecordPrefix = @ptrCast(&module.symbols[symbol_i]); + if (prefix.record_len < 2) return null; - switch (prefix.RecordKind) { - .S_LPROC32, .S_GPROC32 => { - const proc_sym = @as(*align(1) pdb.ProcSym, @ptrCast(&module.symbols[symbol_i + @sizeOf(pdb.RecordPrefix)])); - if (address >= proc_sym.CodeOffset and address < proc_sym.CodeOffset + proc_sym.CodeSize) { - return std.mem.sliceTo(@as([*:0]u8, @ptrCast(&proc_sym.Name[0])), 0); + switch (prefix.record_kind) { + .lproc32, .gproc32 => { + const proc_sym: *align(1) pdb.ProcSym = @ptrCast(&module.symbols[symbol_i + @sizeOf(pdb.RecordPrefix)]); + if (address >= proc_sym.code_offset and address < proc_sym.code_offset + proc_sym.code_size) { + return std.mem.sliceTo(@as([*:0]u8, @ptrCast(&proc_sym.name[0])), 0); } }, else => {}, } - symbol_i += prefix.RecordLen + @sizeOf(u16); + symbol_i += prefix.record_len + @sizeOf(u16); } return null; @@ -238,44 +238,44 @@ pub fn getLineNumberInfo(self: *Pdb, module: *Module, address: u64) !std.debug.S var skip_len: usize = undefined; const checksum_offset = module.checksum_offset orelse return error.MissingDebugInfo; while (sect_offset != subsect_info.len) : (sect_offset += skip_len) { - const subsect_hdr = @as(*align(1) pdb.DebugSubsectionHeader, @ptrCast(&subsect_info[sect_offset])); - skip_len = subsect_hdr.Length; + const subsect_hdr: *align(1) pdb.DebugSubsectionHeader = @ptrCast(&subsect_info[sect_offset]); + skip_len = subsect_hdr.length; sect_offset += @sizeOf(pdb.DebugSubsectionHeader); - switch (subsect_hdr.Kind) { - .Lines => { + switch (subsect_hdr.kind) { + .lines => { var line_index = sect_offset; - const line_hdr = @as(*align(1) pdb.LineFragmentHeader, @ptrCast(&subsect_info[line_index])); - if (line_hdr.RelocSegment == 0) + const line_hdr: *align(1) pdb.LineFragmentHeader = @ptrCast(&subsect_info[line_index]); + if (line_hdr.reloc_segment == 0) return error.MissingDebugInfo; line_index += @sizeOf(pdb.LineFragmentHeader); - const frag_vaddr_start = line_hdr.RelocOffset; - const frag_vaddr_end = frag_vaddr_start + line_hdr.CodeSize; + const frag_vaddr_start = line_hdr.reloc_offset; + const frag_vaddr_end = frag_vaddr_start + line_hdr.code_size; if (address >= frag_vaddr_start and address < frag_vaddr_end) { // There is an unknown number of LineBlockFragmentHeaders (and their accompanying line and column records) // from now on. We will iterate through them, and eventually find a SourceLocation that we're interested in, // breaking out to :subsections. If not, we will make sure to not read anything outside of this subsection. - const subsection_end_index = sect_offset + subsect_hdr.Length; + const subsection_end_index = sect_offset + subsect_hdr.length; while (line_index < subsection_end_index) { - const block_hdr = @as(*align(1) pdb.LineBlockFragmentHeader, @ptrCast(&subsect_info[line_index])); + const block_hdr: *align(1) pdb.LineBlockFragmentHeader = @ptrCast(&subsect_info[line_index]); line_index += @sizeOf(pdb.LineBlockFragmentHeader); const start_line_index = line_index; - const has_column = line_hdr.Flags.LF_HaveColumns; + const has_column = line_hdr.flags.have_columns; // All line entries are stored inside their line block by ascending start address. // Heuristic: we want to find the last line entry // that has a vaddr_start <= address. // This is done with a simple linear search. var line_i: u32 = 0; - while (line_i < block_hdr.NumLines) : (line_i += 1) { - const line_num_entry = @as(*align(1) pdb.LineNumberEntry, @ptrCast(&subsect_info[line_index])); + while (line_i < block_hdr.num_lines) : (line_i += 1) { + const line_num_entry: *align(1) pdb.LineNumberEntry = @ptrCast(&subsect_info[line_index]); line_index += @sizeOf(pdb.LineNumberEntry); - const vaddr_start = frag_vaddr_start + line_num_entry.Offset; + const vaddr_start = frag_vaddr_start + line_num_entry.offset; if (address < vaddr_start) { break; } @@ -283,28 +283,27 @@ pub fn getLineNumberInfo(self: *Pdb, module: *Module, address: u64) !std.debug.S // line_i == 0 would mean that no matching pdb.LineNumberEntry was found. if (line_i > 0) { - const subsect_index = checksum_offset + block_hdr.NameIndex; - const chksum_hdr = @as(*align(1) pdb.FileChecksumEntryHeader, @ptrCast(&module.subsect_info[subsect_index])); - const strtab_offset = @sizeOf(pdb.StringTableHeader) + chksum_hdr.FileNameOffset; + const subsect_index = checksum_offset + block_hdr.name_index; + const chksum_hdr: *align(1) pdb.FileChecksumEntryHeader = @ptrCast(&module.subsect_info[subsect_index]); + const strtab_offset = @sizeOf(pdb.StringTableHeader) + chksum_hdr.file_name_offset; try self.string_table.?.seekTo(strtab_offset); const source_file_name = try self.string_table.?.reader().readUntilDelimiterAlloc(self.allocator, 0, 1024); const line_entry_idx = line_i - 1; const column = if (has_column) blk: { - const start_col_index = start_line_index + @sizeOf(pdb.LineNumberEntry) * block_hdr.NumLines; + const start_col_index = start_line_index + @sizeOf(pdb.LineNumberEntry) * block_hdr.num_lines; const col_index = start_col_index + @sizeOf(pdb.ColumnNumberEntry) * line_entry_idx; - const col_num_entry = @as(*align(1) pdb.ColumnNumberEntry, @ptrCast(&subsect_info[col_index])); - break :blk col_num_entry.StartColumn; + const col_num_entry: *align(1) pdb.ColumnNumberEntry = @ptrCast(&subsect_info[col_index]); + break :blk col_num_entry.start_column; } else 0; const found_line_index = start_line_index + line_entry_idx * @sizeOf(pdb.LineNumberEntry); const line_num_entry: *align(1) pdb.LineNumberEntry = @ptrCast(&subsect_info[found_line_index]); - const flags: *align(1) pdb.LineNumberEntry.Flags = @ptrCast(&line_num_entry.Flags); return .{ .file_name = source_file_name, - .line = flags.Start, + .line = line_num_entry.flags.start, .column = column, }; } @@ -335,12 +334,12 @@ pub fn getModule(self: *Pdb, index: usize) !?*Module { return mod; // At most one can be non-zero. - if (mod.mod_info.C11ByteSize != 0 and mod.mod_info.C13ByteSize != 0) + if (mod.mod_info.c11_byte_size != 0 and mod.mod_info.c13_byte_size != 0) return error.InvalidDebugInfo; - if (mod.mod_info.C13ByteSize == 0) + if (mod.mod_info.c13_byte_size == 0) return error.InvalidDebugInfo; - const stream = self.getStreamById(mod.mod_info.ModuleSymStream) orelse + const stream = self.getStreamById(mod.mod_info.module_sym_stream) orelse return error.MissingDebugInfo; const reader = stream.reader(); @@ -348,23 +347,23 @@ pub fn getModule(self: *Pdb, index: usize) !?*Module { if (signature != 4) return error.InvalidDebugInfo; - mod.symbols = try self.allocator.alloc(u8, mod.mod_info.SymByteSize - 4); + mod.symbols = try self.allocator.alloc(u8, mod.mod_info.sym_byte_size - 4); errdefer self.allocator.free(mod.symbols); try reader.readNoEof(mod.symbols); - mod.subsect_info = try self.allocator.alloc(u8, mod.mod_info.C13ByteSize); + mod.subsect_info = try self.allocator.alloc(u8, mod.mod_info.c13_byte_size); errdefer self.allocator.free(mod.subsect_info); try reader.readNoEof(mod.subsect_info); var sect_offset: usize = 0; var skip_len: usize = undefined; while (sect_offset != mod.subsect_info.len) : (sect_offset += skip_len) { - const subsect_hdr = @as(*align(1) pdb.DebugSubsectionHeader, @ptrCast(&mod.subsect_info[sect_offset])); - skip_len = subsect_hdr.Length; + const subsect_hdr: *align(1) pdb.DebugSubsectionHeader = @ptrCast(&mod.subsect_info[sect_offset]); + skip_len = subsect_hdr.length; sect_offset += @sizeOf(pdb.DebugSubsectionHeader); - switch (subsect_hdr.Kind) { - .FileChecksums => { + switch (subsect_hdr.kind) { + .file_checksums => { mod.checksum_offset = sect_offset; break; }, @@ -401,30 +400,30 @@ const Msf = struct { const superblock = try in.readStruct(pdb.SuperBlock); // Sanity checks - if (!std.mem.eql(u8, &superblock.FileMagic, pdb.SuperBlock.file_magic)) + if (!std.mem.eql(u8, &superblock.file_magic, pdb.SuperBlock.expect_magic)) return error.InvalidDebugInfo; - if (superblock.FreeBlockMapBlock != 1 and superblock.FreeBlockMapBlock != 2) + if (superblock.free_block_map_block != 1 and superblock.free_block_map_block != 2) return error.InvalidDebugInfo; const file_len = try file.getEndPos(); - if (superblock.NumBlocks * superblock.BlockSize != file_len) + if (superblock.num_blocks * superblock.block_size != file_len) return error.InvalidDebugInfo; - switch (superblock.BlockSize) { + switch (superblock.block_size) { // llvm only supports 4096 but we can handle any of these values 512, 1024, 2048, 4096 => {}, else => return error.InvalidDebugInfo, } - const dir_block_count = blockCountFromSize(superblock.NumDirectoryBytes, superblock.BlockSize); - if (dir_block_count > superblock.BlockSize / @sizeOf(u32)) + const dir_block_count = blockCountFromSize(superblock.num_directory_bytes, superblock.block_size); + if (dir_block_count > superblock.block_size / @sizeOf(u32)) return error.UnhandledBigDirectoryStream; // cf. BlockMapAddr comment. - try file.seekTo(superblock.BlockSize * superblock.BlockMapAddr); + try file.seekTo(superblock.block_size * superblock.block_map_addr); const dir_blocks = try allocator.alloc(u32, dir_block_count); for (dir_blocks) |*b| { b.* = try in.readInt(u32, .little); } var directory = MsfStream.init( - superblock.BlockSize, + superblock.block_size, file, dir_blocks, ); @@ -440,7 +439,7 @@ const Msf = struct { const Nil = 0xFFFFFFFF; for (stream_sizes) |*s| { const size = try directory.reader().readInt(u32, .little); - s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.BlockSize); + s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.block_size); } const streams = try allocator.alloc(MsfStream, stream_count); @@ -455,15 +454,15 @@ const Msf = struct { var j: u32 = 0; while (j < size) : (j += 1) { const block_id = try directory.reader().readInt(u32, .little); - const n = (block_id % superblock.BlockSize); + const n = (block_id % superblock.block_size); // 0 is for pdb.SuperBlock, 1 and 2 for FPMs. - if (block_id == 0 or n == 1 or n == 2 or block_id * superblock.BlockSize > file_len) + if (block_id == 0 or n == 1 or n == 2 or block_id * superblock.block_size > file_len) return error.InvalidBlockIndex; blocks[j] = block_id; } stream.* = MsfStream.init( - superblock.BlockSize, + superblock.block_size, file, blocks, ); @@ -471,7 +470,7 @@ const Msf = struct { } const end = directory.pos; - if (end - begin != superblock.NumDirectoryBytes) + if (end - begin != superblock.num_directory_bytes) return error.InvalidStreamDirectory; return Msf{ @@ -495,7 +494,7 @@ const MsfStream = struct { blocks: []u32 = undefined, block_size: u32 = undefined, - pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).Fn.return_type.?).ErrorUnion.error_set; + pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).@"fn".return_type.?).error_union.error_set; fn init(block_size: u32, file: File, blocks: []u32) MsfStream { const stream = MsfStream{ diff --git a/lib/std/debug/SelfInfo.zig b/lib/std/debug/SelfInfo.zig index 5d2dca960b..5e7aefef38 100644 --- a/lib/std/debug/SelfInfo.zig +++ b/lib/std/debug/SelfInfo.zig @@ -37,7 +37,7 @@ modules: if (native_os == .windows) std.ArrayListUnmanaged(WindowsModule) else v pub const OpenError = error{ MissingDebugInfo, UnsupportedOperatingSystem, -} || @typeInfo(@typeInfo(@TypeOf(SelfInfo.init)).Fn.return_type.?).ErrorUnion.error_set; +} || @typeInfo(@typeInfo(@TypeOf(SelfInfo.init)).@"fn".return_type.?).error_union.error_set; pub fn open(allocator: Allocator) OpenError!SelfInfo { nosuspend { @@ -582,7 +582,7 @@ pub const Module = switch (native_os) { if (!std.mem.eql(u8, "__DWARF", sect.segName())) continue; var section_index: ?usize = null; - inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |section, i| { + inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| { if (mem.eql(u8, "__" ++ section.name, sect.sectName())) section_index = i; } if (section_index == null) continue; @@ -732,14 +732,14 @@ pub const Module = switch (native_os) { fn getSymbolFromPdb(self: *@This(), relocated_address: usize) !?std.debug.Symbol { var coff_section: *align(1) const coff.SectionHeader = undefined; const mod_index = for (self.pdb.?.sect_contribs) |sect_contrib| { - if (sect_contrib.Section > self.coff_section_headers.len) continue; + if (sect_contrib.section > self.coff_section_headers.len) continue; // Remember that SectionContribEntry.Section is 1-based. - coff_section = &self.coff_section_headers[sect_contrib.Section - 1]; + coff_section = &self.coff_section_headers[sect_contrib.section - 1]; - const vaddr_start = coff_section.virtual_address + sect_contrib.Offset; - const vaddr_end = vaddr_start + sect_contrib.Size; + const vaddr_start = coff_section.virtual_address + sect_contrib.offset; + const vaddr_end = vaddr_start + sect_contrib.size; if (relocated_address >= vaddr_start and relocated_address < vaddr_end) { - break sect_contrib.ModuleIndex; + break sect_contrib.module_index; } } else { // we have no information to add to the address @@ -981,7 +981,7 @@ fn readCoffDebugInfo(allocator: Allocator, coff_obj: *coff.Coff) !Module { var sections: Dwarf.SectionArray = Dwarf.null_section_array; errdefer for (sections) |section| if (section) |s| if (s.owned) allocator.free(s.data); - inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |section, i| { + inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| { sections[i] = if (coff_obj.getSectionByName("." ++ section.name)) |section_header| blk: { break :blk .{ .data = try coff_obj.getSectionDataAlloc(section_header, allocator), @@ -1443,7 +1443,7 @@ pub fn unwindFrameMachO( if (ma.load(usize, new_sp) == null or ma.load(usize, min_reg_addr) == null) return error.InvalidUnwindInfo; var reg_addr = fp - @sizeOf(usize); - inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.x_reg_pairs)).Struct.fields, 0..) |field, i| { + inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.x_reg_pairs)).@"struct".fields, 0..) |field, i| { if (@field(encoding.value.arm64.frame.x_reg_pairs, field.name) != 0) { (try regValueNative(context.thread_context, 19 + i, reg_context)).* = @as(*const usize, @ptrFromInt(reg_addr)).*; reg_addr += @sizeOf(usize); @@ -1452,7 +1452,7 @@ pub fn unwindFrameMachO( } } - inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.d_reg_pairs)).Struct.fields, 0..) |field, i| { + inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.d_reg_pairs)).@"struct".fields, 0..) |field, i| { if (@field(encoding.value.arm64.frame.d_reg_pairs, field.name) != 0) { // Only the lower half of the 128-bit V registers are restored during unwinding @memcpy( diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index ad37777e43..110393d91a 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -147,9 +147,72 @@ pub const ElfDynLib = struct { pub const Error = ElfDynLibError; + fn openPath(path: []const u8) !std.fs.Dir { + if (path.len == 0) return error.NotDir; + var parts = std.mem.tokenizeScalar(u8, path, '/'); + var parent = if (path[0] == '/') try std.fs.cwd().openDir("/", .{}) else std.fs.cwd(); + while (parts.next()) |part| { + const child = try parent.openDir(part, .{}); + parent.close(); + parent = child; + } + return parent; + } + + fn resolveFromSearchPath(search_path: []const u8, file_name: []const u8, delim: u8) ?posix.fd_t { + var paths = std.mem.tokenizeScalar(u8, search_path, delim); + while (paths.next()) |p| { + var dir = openPath(p) catch continue; + defer dir.close(); + const fd = posix.openat(dir.fd, file_name, .{ + .ACCMODE = .RDONLY, + .CLOEXEC = true, + }, 0) catch continue; + return fd; + } + return null; + } + + fn resolveFromParent(dir_path: []const u8, file_name: []const u8) ?posix.fd_t { + var dir = std.fs.cwd().openDir(dir_path, .{}) catch return null; + defer dir.close(); + return posix.openat(dir.fd, file_name, .{ + .ACCMODE = .RDONLY, + .CLOEXEC = true, + }, 0) catch null; + } + + // This implements enough to be able to load system libraries in general + // Places where it differs from dlopen: + // - DT_RPATH of the calling binary is not used as a search path + // - DT_RUNPATH of the calling binary is not used as a search path + // - /etc/ld.so.cache is not read + fn resolveFromName(path_or_name: []const u8) !posix.fd_t { + // If filename contains a slash ("/"), then it is interpreted as a (relative or absolute) pathname + if (std.mem.indexOfScalarPos(u8, path_or_name, 0, '/')) |_| { + return posix.open(path_or_name, .{ .ACCMODE = .RDONLY, .CLOEXEC = true }, 0); + } + + // Only read LD_LIBRARY_PATH if the binary is not setuid/setgid + if (std.os.linux.geteuid() == std.os.linux.getuid() and + std.os.linux.getegid() == std.os.linux.getgid()) + { + if (posix.getenvZ("LD_LIBRARY_PATH")) |ld_library_path| { + if (resolveFromSearchPath(ld_library_path, path_or_name, ':')) |fd| { + return fd; + } + } + } + + // Lastly the directories /lib and /usr/lib are searched (in this exact order) + if (resolveFromParent("/lib", path_or_name)) |fd| return fd; + if (resolveFromParent("/usr/lib", path_or_name)) |fd| return fd; + return error.FileNotFound; + } + /// Trusts the file. Malicious file will be able to execute arbitrary code. pub fn open(path: []const u8) Error!ElfDynLib { - const fd = try posix.open(path, .{ .ACCMODE = .RDONLY, .CLOEXEC = true }, 0); + const fd = try resolveFromName(path); defer posix.close(fd); const stat = try posix.fstat(fd); diff --git a/lib/std/elf.zig b/lib/std/elf.zig index af3f1813e2..aefaca4bef 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -1646,44 +1646,6 @@ pub const EM = enum(u16) { FRV = 0x5441, _, - - pub fn toTargetCpuArch(em: EM) ?std.Target.Cpu.Arch { - return switch (em) { - .AVR => .avr, - .MSP430 => .msp430, - .ARC => .arc, - .ARM => .arm, - .HEXAGON => .hexagon, - .@"68K" => .m68k, - .MIPS => .mips, - .MIPS_RS3_LE => .mipsel, - .PPC => .powerpc, - .SPARC => .sparc, - .@"386" => .x86, - .XCORE => .xcore, - .CSR_KALIMBA => .kalimba, - .LANAI => .lanai, - .AARCH64 => .aarch64, - .PPC64 => .powerpc64, - .RISCV => .riscv64, - .X86_64 => .x86_64, - .BPF => .bpfel, - .SPARCV9 => .sparc64, - .S390 => .s390x, - .SPU_2 => .spu_2, - // FIXME: - // No support for .loongarch32 yet so it is safe to assume we are on .loongarch64. - // - // However, when e_machine is .LOONGARCH, we should check - // ei_class's value to decide the CPU architecture. - // - ELFCLASS32 => .loongarch32 - // - ELFCLASS64 => .loongarch64 - .LOONGARCH => .loongarch64, - // there's many cases we don't (yet) handle, or will never have a - // zig target cpu arch equivalent (such as null). - else => null, - }; - } }; pub const GRP_COMDAT = 1; diff --git a/lib/std/enums.zig b/lib/std/enums.zig index 1cc7bde8d2..aebfe2a18a 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -13,9 +13,9 @@ const eval_branch_quota_cushion = 10; /// the first name is used. Each field is of type Data and has the provided /// default, which may be undefined. pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type { - @setEvalBranchQuota(@typeInfo(E).Enum.fields.len + eval_branch_quota_cushion); - var struct_fields: [@typeInfo(E).Enum.fields.len]std.builtin.Type.StructField = undefined; - for (&struct_fields, @typeInfo(E).Enum.fields) |*struct_field, enum_field| { + @setEvalBranchQuota(@typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion); + var struct_fields: [@typeInfo(E).@"enum".fields.len]std.builtin.Type.StructField = undefined; + for (&struct_fields, @typeInfo(E).@"enum".fields) |*struct_field, enum_field| { struct_field.* = .{ .name = enum_field.name ++ "", .type = Data, @@ -24,7 +24,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0, }; } - return @Type(.{ .Struct = .{ + return @Type(.{ .@"struct" = .{ .layout = .auto, .fields = &struct_fields, .decls = &.{}, @@ -49,14 +49,14 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi /// Returns the set of all named values in the given enum, in /// declaration order. pub fn values(comptime E: type) []const E { - return comptime valuesFromFields(E, @typeInfo(E).Enum.fields); + return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields); } /// A safe alternative to @tagName() for non-exhaustive enums that doesn't /// panic when `e` has no tagged value. /// Returns the tag name for `e` or null if no tag exists. pub fn tagName(comptime E: type, e: E) ?[]const u8 { - return inline for (@typeInfo(E).Enum.fields) |f| { + return inline for (@typeInfo(E).@"enum".fields) |f| { if (@intFromEnum(e) == f.value) break f.name; } else null; } @@ -80,7 +80,7 @@ test tagName { pub fn directEnumArrayLen(comptime E: type, comptime max_unused_slots: comptime_int) comptime_int { var max_value: comptime_int = -1; const max_usize: comptime_int = ~@as(usize, 0); - const fields = @typeInfo(E).Enum.fields; + const fields = @typeInfo(E).@"enum".fields; for (fields) |f| { if (f.value < 0) { @compileError("Cannot create a direct enum array for " ++ @typeName(E) ++ ", field ." ++ f.name ++ " has a negative value."); @@ -159,7 +159,7 @@ pub fn directEnumArrayDefault( ) [directEnumArrayLen(E, max_unused_slots)]Data { const len = comptime directEnumArrayLen(E, max_unused_slots); var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined; - inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| { + inline for (@typeInfo(@TypeOf(init_values)).@"struct".fields) |f| { const enum_value = @field(E, f.name); const index = @as(usize, @intCast(@intFromEnum(enum_value))); result[index] = @field(init_values, f.name); @@ -204,8 +204,8 @@ pub fn nameCast(comptime E: type, comptime value: anytype) E { const V = @TypeOf(value); if (V == E) break :blk value; const name: ?[]const u8 = switch (@typeInfo(V)) { - .EnumLiteral, .Enum => @tagName(value), - .Pointer => value, + .enum_literal, .@"enum" => @tagName(value), + .pointer => value, else => null, }; if (name) |n| { @@ -262,9 +262,9 @@ pub fn EnumSet(comptime E: type) type { /// Initializes the set using a struct of bools pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self { - @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); + @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); var result: Self = .{}; - if (@typeInfo(E).Enum.is_exhaustive) { + if (@typeInfo(E).@"enum".is_exhaustive) { inline for (0..Self.len) |i| { const key = comptime Indexer.keyForIndex(i); const tag = @tagName(key); @@ -453,9 +453,9 @@ pub fn EnumMap(comptime E: type, comptime V: type) type { /// Initializes the map using a sparse struct of optionals pub fn init(init_values: EnumFieldStruct(E, ?Value, @as(?Value, null))) Self { - @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); + @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); var result: Self = .{}; - if (@typeInfo(E).Enum.is_exhaustive) { + if (@typeInfo(E).@"enum".is_exhaustive) { inline for (0..Self.len) |i| { const key = comptime Indexer.keyForIndex(i); const tag = @tagName(key); @@ -497,7 +497,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type { /// Initializes a full mapping with a provided default. /// Consider using EnumArray instead if the map will remain full. pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self { - @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); + @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); var result: Self = .{ .bits = Self.BitSet.initFull(), .values = undefined, @@ -683,9 +683,9 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// Initializes the multiset using a struct of counts. pub fn init(init_counts: EnumFieldStruct(E, CountSize, 0)) Self { - @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); + @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); var self = initWithCount(0); - inline for (@typeInfo(E).Enum.fields) |field| { + inline for (@typeInfo(E).@"enum".fields) |field| { const c = @field(init_counts, field.name); const key = @as(E, @enumFromInt(field.value)); self.counts.set(key, c); @@ -757,7 +757,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// Increases the all key counts by given multiset. Caller /// asserts operation will not overflow any key. pub fn addSetAssertSafe(self: *Self, other: Self) void { - inline for (@typeInfo(E).Enum.fields) |field| { + inline for (@typeInfo(E).@"enum".fields) |field| { const key = @as(E, @enumFromInt(field.value)); self.addAssertSafe(key, other.getCount(key)); } @@ -765,7 +765,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// Increases the all key counts by given multiset. pub fn addSet(self: *Self, other: Self) error{Overflow}!void { - inline for (@typeInfo(E).Enum.fields) |field| { + inline for (@typeInfo(E).@"enum".fields) |field| { const key = @as(E, @enumFromInt(field.value)); try self.add(key, other.getCount(key)); } @@ -775,7 +775,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// the given multiset has more key counts than this, /// then that key will have a key count of zero. pub fn removeSet(self: *Self, other: Self) void { - inline for (@typeInfo(E).Enum.fields) |field| { + inline for (@typeInfo(E).@"enum".fields) |field| { const key = @as(E, @enumFromInt(field.value)); self.remove(key, other.getCount(key)); } @@ -784,7 +784,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// Returns true iff all key counts are the same as /// given multiset. pub fn eql(self: Self, other: Self) bool { - inline for (@typeInfo(E).Enum.fields) |field| { + inline for (@typeInfo(E).@"enum".fields) |field| { const key = @as(E, @enumFromInt(field.value)); if (self.getCount(key) != other.getCount(key)) { return false; @@ -796,7 +796,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// Returns true iff all key counts less than or /// equal to the given multiset. pub fn subsetOf(self: Self, other: Self) bool { - inline for (@typeInfo(E).Enum.fields) |field| { + inline for (@typeInfo(E).@"enum".fields) |field| { const key = @as(E, @enumFromInt(field.value)); if (self.getCount(key) > other.getCount(key)) { return false; @@ -808,7 +808,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type { /// Returns true iff all key counts greater than or /// equal to the given multiset. pub fn supersetOf(self: Self, other: Self) bool { - inline for (@typeInfo(E).Enum.fields) |field| { + inline for (@typeInfo(E).@"enum".fields) |field| { const key = @as(E, @enumFromInt(field.value)); if (self.getCount(key) < other.getCount(key)) { return false; @@ -1087,7 +1087,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type { /// Initializes values in the enum array, with the specified default. pub fn initDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self { - @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len); + @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len); var result: Self = .{ .values = undefined }; inline for (0..Self.len) |i| { const key = comptime Indexer.keyForIndex(i); @@ -1277,17 +1277,17 @@ test "EnumSet non-exhaustive" { pub fn EnumIndexer(comptime E: type) type { // Assumes that the enum fields are sorted in ascending order (optimistic). // Unsorted enums may require the user to manually increase the quota. - @setEvalBranchQuota(3 * @typeInfo(E).Enum.fields.len + eval_branch_quota_cushion); + @setEvalBranchQuota(3 * @typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion); - if (!@typeInfo(E).Enum.is_exhaustive) { - const BackingInt = @typeInfo(E).Enum.tag_type; + if (!@typeInfo(E).@"enum".is_exhaustive) { + const BackingInt = @typeInfo(E).@"enum".tag_type; if (@bitSizeOf(BackingInt) > @bitSizeOf(usize)) @compileError("Cannot create an enum indexer for a given non-exhaustive enum, tag_type is larger than usize."); return struct { pub const Key: type = E; - const backing_int_sign = @typeInfo(BackingInt).Int.signedness; + const backing_int_sign = @typeInfo(BackingInt).int.signedness; const min_value = std.math.minInt(BackingInt); const max_value = std.math.maxInt(BackingInt); @@ -1312,7 +1312,7 @@ pub fn EnumIndexer(comptime E: type) type { }; } - const const_fields = @typeInfo(E).Enum.fields; + const const_fields = @typeInfo(E).@"enum".fields; var fields = const_fields[0..const_fields.len].*; const fields_len = fields.len; @@ -1359,7 +1359,7 @@ pub fn EnumIndexer(comptime E: type) type { // gives up some safety to avoid artificially limiting // the range of signed enum values to max_isize. const enum_value = if (min < 0) @as(isize, @bitCast(i)) +% min else i + min; - return @as(E, @enumFromInt(@as(@typeInfo(E).Enum.tag_type, @intCast(enum_value)))); + return @as(E, @enumFromInt(@as(@typeInfo(E).@"enum".tag_type, @intCast(enum_value)))); } }; } @@ -1411,7 +1411,7 @@ test "EnumIndexer non-exhaustive" { const RangedType = std.meta.Int(.unsigned, @bitSizeOf(BackingInt)); const max_index: comptime_int = std.math.maxInt(RangedType); - const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).Int.signedness) { + const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).int.signedness) { .unsigned => 0, .signed => std.math.divCeil(comptime_int, max_index, 2) catch unreachable, }; @@ -1501,7 +1501,7 @@ test values { X, Y, Z, - pub const X = 1; + const A = 1; }; try testing.expectEqualSlices(E, &.{ .X, .Y, .Z }, values(E)); } diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index a7136d99bb..7f323248cf 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -87,11 +87,11 @@ pub fn format( ) !void { const ArgsType = @TypeOf(args); const args_type_info = @typeInfo(ArgsType); - if (args_type_info != .Struct) { + if (args_type_info != .@"struct") { @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType)); } - const fields_info = args_type_info.Struct.fields; + const fields_info = args_type_info.@"struct".fields; if (fields_info.len > max_format_args) { @compileError("32 arguments max are supported per format call"); } @@ -397,7 +397,7 @@ pub const Parser = struct { }; pub const ArgSetType = u32; -const max_format_args = @typeInfo(ArgSetType).Int.bits; +const max_format_args = @typeInfo(ArgSetType).int.bits; pub const ArgState = struct { next_arg: usize = 0, @@ -430,7 +430,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T const T = @TypeOf(value); switch (@typeInfo(T)) { - .Pointer => |info| { + .pointer => |info| { try writer.writeAll(@typeName(info.child) ++ "@"); if (info.size == .Slice) try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer) @@ -438,8 +438,8 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); return; }, - .Optional => |info| { - if (@typeInfo(info.child) == .Pointer) { + .optional => |info| { + if (@typeInfo(info.child) == .pointer) { try writer.writeAll(@typeName(info.child) ++ "@"); try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer); return; @@ -456,17 +456,17 @@ const ANY = "any"; pub fn defaultSpec(comptime T: type) [:0]const u8 { switch (@typeInfo(T)) { - .Array => |_| return ANY, - .Pointer => |ptr_info| switch (ptr_info.size) { + .array => |_| return ANY, + .pointer => |ptr_info| switch (ptr_info.size) { .One => switch (@typeInfo(ptr_info.child)) { - .Array => |_| return ANY, + .array => |_| return ANY, else => {}, }, .Many, .C => return "*", .Slice => return ANY, }, - .Optional => |info| return "?" ++ defaultSpec(info.child), - .ErrorUnion => |info| return "!" ++ defaultSpec(info.payload), + .optional => |info| return "?" ++ defaultSpec(info.child), + .error_union => |info| return "!" ++ defaultSpec(info.payload), else => {}, } return ""; @@ -494,7 +494,7 @@ pub fn formatType( const actual_fmt = comptime if (std.mem.eql(u8, fmt, ANY)) defaultSpec(T) else if (fmt.len != 0 and (fmt[0] == '?' or fmt[0] == '!')) switch (@typeInfo(T)) { - .Optional, .ErrorUnion => fmt, + .optional, .error_union => fmt, else => stripOptionalOrErrorUnionSpec(fmt), } else fmt; @@ -507,18 +507,18 @@ pub fn formatType( } switch (@typeInfo(T)) { - .ComptimeInt, .Int, .ComptimeFloat, .Float => { + .comptime_int, .int, .comptime_float, .float => { return formatValue(value, actual_fmt, options, writer); }, - .Void => { + .void => { if (actual_fmt.len != 0) invalidFmtError(fmt, value); return formatBuf("void", options, writer); }, - .Bool => { + .bool => { if (actual_fmt.len != 0) invalidFmtError(fmt, value); return formatBuf(if (value) "true" else "false", options, writer); }, - .Optional => { + .optional => { if (actual_fmt.len == 0 or actual_fmt[0] != '?') @compileError("cannot format optional without a specifier (i.e. {?} or {any})"); const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt); @@ -528,7 +528,7 @@ pub fn formatType( return formatBuf("null", options, writer); } }, - .ErrorUnion => { + .error_union => { if (actual_fmt.len == 0 or actual_fmt[0] != '!') @compileError("cannot format error union without a specifier (i.e. {!} or {any})"); const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt); @@ -538,12 +538,12 @@ pub fn formatType( return formatType(err, "", options, writer, max_depth); } }, - .ErrorSet => { + .error_set => { if (actual_fmt.len != 0) invalidFmtError(fmt, value); try writer.writeAll("error."); return writer.writeAll(@errorName(value)); }, - .Enum => |enumInfo| { + .@"enum" => |enumInfo| { try writer.writeAll(@typeName(T)); if (enumInfo.is_exhaustive) { if (actual_fmt.len != 0) invalidFmtError(fmt, value); @@ -566,7 +566,7 @@ pub fn formatType( try formatType(@intFromEnum(value), actual_fmt, options, writer, max_depth); try writer.writeAll(")"); }, - .Union => |info| { + .@"union" => |info| { if (actual_fmt.len != 0) invalidFmtError(fmt, value); try writer.writeAll(@typeName(T)); if (max_depth == 0) { @@ -586,7 +586,7 @@ pub fn formatType( try format(writer, "@{x}", .{@intFromPtr(&value)}); } }, - .Struct => |info| { + .@"struct" => |info| { if (actual_fmt.len != 0) invalidFmtError(fmt, value); if (info.is_tuple) { // Skip the type and field names when formatting tuples. @@ -621,9 +621,9 @@ pub fn formatType( } try writer.writeAll(" }"); }, - .Pointer => |ptr_info| switch (ptr_info.size) { + .pointer => |ptr_info| switch (ptr_info.size) { .One => switch (@typeInfo(ptr_info.child)) { - .Array, .Enum, .Union, .Struct => { + .array, .@"enum", .@"union", .@"struct" => { return formatType(value.*, actual_fmt, options, writer, max_depth); }, else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }), @@ -658,7 +658,7 @@ pub fn formatType( try writer.writeAll(" }"); }, }, - .Array => |info| { + .array => |info| { if (actual_fmt.len == 0) @compileError("cannot format array without a specifier (i.e. {s} or {any})"); if (max_depth == 0) { @@ -676,7 +676,7 @@ pub fn formatType( } try writer.writeAll(" }"); }, - .Vector => |info| { + .vector => |info| { try writer.writeAll("{ "); var i: usize = 0; while (i < info.len) : (i += 1) { @@ -687,17 +687,17 @@ pub fn formatType( } try writer.writeAll(" }"); }, - .Fn => @compileError("unable to format function body type, use '*const " ++ @typeName(T) ++ "' for a function pointer type"), - .Type => { + .@"fn" => @compileError("unable to format function body type, use '*const " ++ @typeName(T) ++ "' for a function pointer type"), + .type => { if (actual_fmt.len != 0) invalidFmtError(fmt, value); return formatBuf(@typeName(value), options, writer); }, - .EnumLiteral => { + .enum_literal => { if (actual_fmt.len != 0) invalidFmtError(fmt, value); const buffer = [_]u8{'.'} ++ @tagName(value); return formatBuf(buffer, options, writer); }, - .Null => { + .null => { if (actual_fmt.len != 0) invalidFmtError(fmt, value); return formatBuf("null", options, writer); }, @@ -713,9 +713,9 @@ fn formatValue( ) !void { const T = @TypeOf(value); switch (@typeInfo(T)) { - .Float, .ComptimeFloat => return formatFloatValue(value, fmt, options, writer), - .Int, .ComptimeInt => return formatIntValue(value, fmt, options, writer), - .Bool => return formatBuf(if (value) "true" else "false", options, writer), + .float, .comptime_float => return formatFloatValue(value, fmt, options, writer), + .int, .comptime_int => return formatIntValue(value, fmt, options, writer), + .bool => return formatBuf(if (value) "true" else "false", options, writer), else => comptime unreachable, } } @@ -738,13 +738,13 @@ pub fn formatIntValue( base = 10; case = .lower; } else if (comptime std.mem.eql(u8, fmt, "c")) { - if (@typeInfo(@TypeOf(int_value)).Int.bits <= 8) { + if (@typeInfo(@TypeOf(int_value)).int.bits <= 8) { return formatAsciiChar(@as(u8, int_value), options, writer); } else { @compileError("cannot print integer that is larger than 8 bits as an ASCII character"); } } else if (comptime std.mem.eql(u8, fmt, "u")) { - if (@typeInfo(@TypeOf(int_value)).Int.bits <= 21) { + if (@typeInfo(@TypeOf(int_value)).int.bits <= 21) { return formatUnicodeCodepoint(@as(u21, int_value), options, writer); } else { @compileError("cannot print integer that is larger than 21 bits as an UTF-8 sequence"); @@ -1179,7 +1179,7 @@ pub fn formatInt( break :blk @as(Int, value); } else value; - const value_info = @typeInfo(@TypeOf(int_value)).Int; + const value_info = @typeInfo(@TypeOf(int_value)).int; // The type must have the same size as `base` or be wider in order for the // division to work @@ -1480,7 +1480,7 @@ pub const ParseIntError = error{ /// ) !void; /// pub fn Formatter(comptime format_fn: anytype) type { - const Data = @typeInfo(@TypeOf(format_fn)).Fn.params[0].type.?; + const Data = @typeInfo(@TypeOf(format_fn)).@"fn".params[0].type.?; return struct { data: Data, pub fn format( @@ -1624,7 +1624,7 @@ fn parseIntWithSign( // accumulate into Accumulate which is always 8 bits or larger. this prevents // `buf_base` from overflowing Result. const info = @typeInfo(Result); - const Accumulate = std.meta.Int(info.Int.signedness, @max(8, info.Int.bits)); + const Accumulate = std.meta.Int(info.int.signedness, @max(8, info.int.bits)); var accumulate: Accumulate = 0; if (buf_start[0] == '_' or buf_start[buf_start.len - 1] == '_') return error.InvalidCharacter; @@ -2724,7 +2724,7 @@ pub const hex_charset = "0123456789abcdef"; /// Converts an unsigned integer of any multiple of u8 to an array of lowercase /// hex bytes, little endian. pub fn hex(x: anytype) [@sizeOf(@TypeOf(x)) * 2]u8 { - comptime assert(@typeInfo(@TypeOf(x)).Int.signedness == .unsigned); + comptime assert(@typeInfo(@TypeOf(x)).int.signedness == .unsigned); var result: [@sizeOf(@TypeOf(x)) * 2]u8 = undefined; var i: usize = 0; while (i < result.len / 2) : (i += 1) { diff --git a/lib/std/fmt/format_float.zig b/lib/std/fmt/format_float.zig index b7b08281a7..4c4c1a2922 100644 --- a/lib/std/fmt/format_float.zig +++ b/lib/std/fmt/format_float.zig @@ -12,7 +12,7 @@ pub const min_buffer_size = 53; /// Returns the minimum buffer size needed to print every float of a specific type and format. pub fn bufferSize(comptime mode: Format, comptime T: type) comptime_int { - comptime std.debug.assert(@typeInfo(T) == .Float); + comptime std.debug.assert(@typeInfo(T) == .float); return switch (mode) { .scientific => 53, // Based on minimum subnormal values. @@ -60,8 +60,8 @@ pub fn formatFloat(buf: []u8, v_: anytype, options: FormatOptions) FormatError![ }; const T = @TypeOf(v); - comptime std.debug.assert(@typeInfo(T) == .Float); - const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); + comptime std.debug.assert(@typeInfo(T) == .float); + const I = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); const DT = if (@bitSizeOf(T) <= 64) u64 else u128; const tables = switch (DT) { @@ -563,13 +563,13 @@ fn pow5Factor(value_: anytype) u32 { fn multipleOfPowerOf5(value: anytype, p: u32) bool { const T = @TypeOf(value); - std.debug.assert(@typeInfo(T) == .Int); + std.debug.assert(@typeInfo(T) == .int); return pow5Factor(value) >= p; } fn multipleOfPowerOf2(value: anytype, p: u32) bool { const T = @TypeOf(value); - std.debug.assert(@typeInfo(T) == .Int); + std.debug.assert(@typeInfo(T) == .int); return (value & ((@as(T, 1) << @as(std.math.Log2Int(T), @intCast(p))) - 1)) == 0; } @@ -1516,7 +1516,7 @@ const FLOAT128_POW5_INV_ERRORS: [154]u64 = .{ const builtin = @import("builtin"); fn check(comptime T: type, value: T, comptime expected: []const u8) !void { - const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); + const I = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); var buf: [6000]u8 = undefined; const value_bits: I = @bitCast(value); diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig index 425286ff07..cb47faee8d 100644 --- a/lib/std/fmt/parse_float.zig +++ b/lib/std/fmt/parse_float.zig @@ -17,7 +17,7 @@ pub const ParseFloatError = error{ }; pub fn parseFloat(comptime T: type, s: []const u8) ParseFloatError!T { - if (@typeInfo(T) != .Float) { + if (@typeInfo(T) != .float) { @compileError("Cannot parse a float into a non-floating point type."); } @@ -128,7 +128,7 @@ test parseFloat { test "nan and inf" { inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { - const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits); try expectEqual(@as(Z, @bitCast(try parseFloat(T, "nAn"))), @as(Z, @bitCast(std.math.nan(T)))); try expectEqual(try parseFloat(T, "inF"), std.math.inf(T)); diff --git a/lib/std/fmt/parse_float/convert_slow.zig b/lib/std/fmt/parse_float/convert_slow.zig index e4539937bd..9232bc8bce 100644 --- a/lib/std/fmt/parse_float/convert_slow.zig +++ b/lib/std/fmt/parse_float/convert_slow.zig @@ -36,7 +36,7 @@ pub fn getShift(n: usize) usize { /// Note that this function needs a lot of stack space and is marked /// cold to hint against inlining into the caller. pub fn convertSlow(comptime T: type, s: []const u8) BiasedFp(T) { - @setCold(true); + @branchHint(.cold); const MantissaT = mantissaType(T); const min_exponent = -(1 << (math.floatExponentBits(T) - 1)) + 1; diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index f596c52322..b0810f81a5 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -745,6 +745,7 @@ test "directory operations on files" { test "file operations on directories" { // TODO: fix this test on FreeBSD. https://github.com/ziglang/zig/issues/1759 if (native_os == .freebsd) return error.SkipZigTest; + if (native_os == .wasi and builtin.link_libc) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/20747 try testWithAllSupportedPathTypes(struct { fn impl(ctx: *TestContext) !void { diff --git a/lib/std/hash/auto_hash.zig b/lib/std/hash/auto_hash.zig index b7321c0b9e..d9d3b1836d 100644 --- a/lib/std/hash/auto_hash.zig +++ b/lib/std/hash/auto_hash.zig @@ -22,7 +22,7 @@ pub const HashStrategy = enum { pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { const info = @typeInfo(@TypeOf(key)); - switch (info.Pointer.size) { + switch (info.pointer.size) { .One => switch (strat) { .Shallow => hash(hasher, @intFromPtr(key), .Shallow), .Deep => hash(hasher, key.*, .Shallow), @@ -64,7 +64,7 @@ pub fn hashArray(hasher: anytype, key: anytype, comptime strat: HashStrategy) vo pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { const Key = @TypeOf(key); const Hasher = switch (@typeInfo(@TypeOf(hasher))) { - .Pointer => |ptr| ptr.child, + .pointer => |ptr| ptr.child, else => @TypeOf(hasher), }; @@ -74,24 +74,24 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { } switch (@typeInfo(Key)) { - .NoReturn, - .Opaque, - .Undefined, - .Null, - .ComptimeFloat, - .ComptimeInt, - .Type, - .EnumLiteral, - .Frame, - .Float, + .noreturn, + .@"opaque", + .undefined, + .null, + .comptime_float, + .comptime_int, + .type, + .enum_literal, + .frame, + .float, => @compileError("unable to hash type " ++ @typeName(Key)), - .Void => return, + .void => return, // Help the optimizer see that hashing an int is easy by inlining! // TODO Check if the situation is better after #561 is resolved. - .Int => |int| switch (int.signedness) { - .signed => hash(hasher, @as(@Type(.{ .Int = .{ + .int => |int| switch (int.signedness) { + .signed => hash(hasher, @as(@Type(.{ .int = .{ .bits = int.bits, .signedness = .unsigned, } }), @bitCast(key)), strat), @@ -107,18 +107,18 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { }, }, - .Bool => hash(hasher, @intFromBool(key), strat), - .Enum => hash(hasher, @intFromEnum(key), strat), - .ErrorSet => hash(hasher, @intFromError(key), strat), - .AnyFrame, .Fn => hash(hasher, @intFromPtr(key), strat), + .bool => hash(hasher, @intFromBool(key), strat), + .@"enum" => hash(hasher, @intFromEnum(key), strat), + .error_set => hash(hasher, @intFromError(key), strat), + .@"anyframe", .@"fn" => hash(hasher, @intFromPtr(key), strat), - .Pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }), + .pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }), - .Optional => if (key) |k| hash(hasher, k, strat), + .optional => if (key) |k| hash(hasher, k, strat), - .Array => hashArray(hasher, key, strat), + .array => hashArray(hasher, key, strat), - .Vector => |info| { + .vector => |info| { if (std.meta.hasUniqueRepresentation(Key)) { hasher.update(mem.asBytes(&key)); } else { @@ -129,7 +129,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { } }, - .Struct => |info| { + .@"struct" => |info| { inline for (info.fields) |field| { // We reuse the hash of the previous field as the seed for the // next one so that they're dependant. @@ -137,7 +137,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { } }, - .Union => |info| { + .@"union" => |info| { if (info.tag_type) |tag_type| { const tag = std.meta.activeTag(key); hash(hasher, tag, strat); @@ -155,7 +155,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { } else @compileError("cannot hash untagged union type: " ++ @typeName(Key) ++ ", provide your own hash function"); }, - .ErrorUnion => blk: { + .error_union => blk: { const payload = key catch |err| { hash(hasher, err, strat); break :blk; @@ -167,9 +167,9 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { inline fn typeContainsSlice(comptime K: type) bool { return switch (@typeInfo(K)) { - .Pointer => |info| info.size == .Slice, + .pointer => |info| info.size == .Slice, - inline .Struct, .Union => |info| { + inline .@"struct", .@"union" => |info| { inline for (info.fields) |field| { if (typeContainsSlice(field.type)) { return true; diff --git a/lib/std/hash/verify.zig b/lib/std/hash/verify.zig index 485a1fd976..61f501a881 100644 --- a/lib/std/hash/verify.zig +++ b/lib/std/hash/verify.zig @@ -1,9 +1,9 @@ const std = @import("std"); -fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typeInfo(@TypeOf(hash_fn)).Fn.return_type.? { - const HashFn = @typeInfo(@TypeOf(hash_fn)).Fn; +fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typeInfo(@TypeOf(hash_fn)).@"fn".return_type.? { + const HashFn = @typeInfo(@TypeOf(hash_fn)).@"fn"; if (HashFn.params.len > 1) { - if (@typeInfo(HashFn.params[0].type.?) == .Int) { + if (@typeInfo(HashFn.params[0].type.?) == .int) { return hash_fn(@intCast(seed), buf); } else { return hash_fn(buf, @intCast(seed)); @@ -14,7 +14,7 @@ fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typ } fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash { - const HashFn = @typeInfo(@TypeOf(Hash.init)).Fn; + const HashFn = @typeInfo(@TypeOf(Hash.init)).@"fn"; if (HashFn.params.len == 1) { return Hash.init(@intCast(seed)); } else { @@ -27,7 +27,7 @@ fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash { // Hash keys of the form {0}, {0,1}, {0,1,2}... up to N=255, using 256-N as seed. // First four-bytes of the hash, interpreted as little-endian is the verification code. pub fn smhasher(comptime hash_fn: anytype) u32 { - const HashFnTy = @typeInfo(@TypeOf(hash_fn)).Fn; + const HashFnTy = @typeInfo(@TypeOf(hash_fn)).@"fn"; const HashResult = HashFnTy.return_type.?; const hash_size = @sizeOf(HashResult); diff --git a/lib/std/hash/xxhash.zig b/lib/std/hash/xxhash.zig index 1d7c8399fc..eb3d4ea2b9 100644 --- a/lib/std/hash/xxhash.zig +++ b/lib/std/hash/xxhash.zig @@ -593,7 +593,7 @@ pub const XxHash3 = struct { } fn hash3(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 { - @setCold(true); + @branchHint(.cold); std.debug.assert(input.len > 0 and input.len < 4); const flip: [2]u32 = @bitCast(secret[0..8].*); @@ -609,7 +609,7 @@ pub const XxHash3 = struct { } fn hash8(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 { - @setCold(true); + @branchHint(.cold); std.debug.assert(input.len >= 4 and input.len <= 8); const flip: [2]u64 = @bitCast(secret[8..24].*); @@ -625,7 +625,7 @@ pub const XxHash3 = struct { } fn hash16(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 { - @setCold(true); + @branchHint(.cold); std.debug.assert(input.len > 8 and input.len <= 16); const flip: [4]u64 = @bitCast(secret[24..56].*); @@ -641,7 +641,7 @@ pub const XxHash3 = struct { } fn hash128(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 { - @setCold(true); + @branchHint(.cold); std.debug.assert(input.len > 16 and input.len <= 128); var acc = XxHash64.prime_1 *% @as(u64, input.len); @@ -657,7 +657,7 @@ pub const XxHash3 = struct { } fn hash240(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 { - @setCold(true); + @branchHint(.cold); std.debug.assert(input.len > 128 and input.len <= 240); var acc = XxHash64.prime_1 *% @as(u64, input.len); @@ -676,7 +676,7 @@ pub const XxHash3 = struct { } noinline fn hashLong(seed: u64, input: []const u8) u64 { - @setCold(true); + @branchHint(.cold); std.debug.assert(input.len >= 240); const block_count = ((input.len - 1) / @sizeOf(Block)) * @sizeOf(Block); diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 905d44c368..1c8a5d78af 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -139,10 +139,10 @@ pub fn verifyContext( var Context = RawContext; // Make sure the context is a namespace type which may have member functions switch (@typeInfo(Context)) { - .Struct, .Union, .Enum => {}, - // Special-case .Opaque for a better error message - .Opaque => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is opaque. Use a pointer instead."), - .Pointer => |ptr| { + .@"struct", .@"union", .@"enum" => {}, + // Special-case .@"opaque" for a better error message + .@"opaque" => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is opaque. Use a pointer instead."), + .pointer => |ptr| { if (ptr.size != .One) { @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is not a single pointer."); } @@ -150,7 +150,7 @@ pub fn verifyContext( allow_const_ptr = true; allow_mutable_ptr = !ptr.is_const; switch (@typeInfo(Context)) { - .Struct, .Union, .Enum, .Opaque => {}, + .@"struct", .@"union", .@"enum", .@"opaque" => {}, else => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context)), } }, @@ -179,8 +179,8 @@ pub fn verifyContext( if (@hasDecl(Context, "hash")) { const hash = Context.hash; const info = @typeInfo(@TypeOf(hash)); - if (info == .Fn) { - const func = info.Fn; + if (info == .@"fn") { + const func = info.@"fn"; if (func.params.len != 2) { errors = errors ++ lazy.err_invalid_hash_signature; } else { @@ -255,8 +255,8 @@ pub fn verifyContext( if (@hasDecl(Context, "eql")) { const eql = Context.eql; const info = @typeInfo(@TypeOf(eql)); - if (info == .Fn) { - const func = info.Fn; + if (info == .@"fn") { + const func = info.@"fn"; const args_len = if (is_array) 4 else 3; if (func.params.len != args_len) { errors = errors ++ lazy.err_invalid_eql_signature; @@ -824,8 +824,8 @@ pub fn HashMapUnmanaged( } pub fn takeFingerprint(hash: Hash) FingerPrint { - const hash_bits = @typeInfo(Hash).Int.bits; - const fp_bits = @typeInfo(FingerPrint).Int.bits; + const hash_bits = @typeInfo(Hash).int.bits; + const fp_bits = @typeInfo(FingerPrint).int.bits; return @as(FingerPrint, @truncate(hash >> (hash_bits - fp_bits))); } @@ -1657,7 +1657,7 @@ pub fn HashMapUnmanaged( } fn grow(self: *Self, allocator: Allocator, new_capacity: Size, ctx: Context) Allocator.Error!void { - @setCold(true); + @branchHint(.cold); const new_cap = @max(new_capacity, minimal_capacity); assert(new_cap > self.capacity()); assert(std.math.isPowerOfTwo(new_cap)); diff --git a/lib/std/heap/WasmPageAllocator.zig b/lib/std/heap/WasmPageAllocator.zig index 0fb45b70d4..7cb85561d8 100644 --- a/lib/std/heap/WasmPageAllocator.zig +++ b/lib/std/heap/WasmPageAllocator.zig @@ -61,7 +61,7 @@ const FreeBlock = struct { const not_found = maxInt(usize); fn useRecycled(self: FreeBlock, num_pages: usize, log2_align: u8) usize { - @setCold(true); + @branchHint(.cold); for (self.data, 0..) |segment, i| { const spills_into_next = @as(i128, @bitCast(segment)) < 0; const has_enough_bits = @popCount(segment) >= num_pages; diff --git a/lib/std/heap/logging_allocator.zig b/lib/std/heap/logging_allocator.zig index 6924a284e3..706f2ac544 100644 --- a/lib/std/heap/logging_allocator.zig +++ b/lib/std/heap/logging_allocator.zig @@ -15,7 +15,7 @@ pub fn LoggingAllocator( /// with the given scope on every call to the allocator. /// For logging to a `std.io.Writer` see `std.heap.LogToWriterAllocator` pub fn ScopedLoggingAllocator( - comptime scope: @Type(.EnumLiteral), + comptime scope: @Type(.enum_literal), comptime success_log_level: std.log.Level, comptime failure_log_level: std.log.Level, ) type { diff --git a/lib/std/heap/sbrk_allocator.zig b/lib/std/heap/sbrk_allocator.zig index 3ccc2dddf7..08933fed52 100644 --- a/lib/std/heap/sbrk_allocator.zig +++ b/lib/std/heap/sbrk_allocator.zig @@ -7,7 +7,7 @@ const assert = std.debug.assert; pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type { return struct { - pub const vtable = Allocator.VTable{ + pub const vtable: Allocator.VTable = .{ .alloc = alloc, .resize = resize, .free = free, @@ -15,8 +15,6 @@ pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type { pub const Error = Allocator.Error; - lock: std.Thread.Mutex = .{}, - const max_usize = math.maxInt(usize); const ushift = math.Log2Int(usize); const bigpage_size = 64 * 1024; diff --git a/lib/std/io.zig b/lib/std/io.zig index 1f4cb411b4..6455693d67 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -434,7 +434,7 @@ pub fn poll( comptime StreamEnum: type, files: PollFiles(StreamEnum), ) Poller(StreamEnum) { - const enum_fields = @typeInfo(StreamEnum).Enum.fields; + const enum_fields = @typeInfo(StreamEnum).@"enum".fields; var result: Poller(StreamEnum) = undefined; if (is_windows) result.windows = .{ @@ -473,7 +473,7 @@ pub const PollFifo = std.fifo.LinearFifo(u8, .Dynamic); pub fn Poller(comptime StreamEnum: type) type { return struct { - const enum_fields = @typeInfo(StreamEnum).Enum.fields; + const enum_fields = @typeInfo(StreamEnum).@"enum".fields; const PollFd = if (is_windows) void else posix.pollfd; fifos: [enum_fields.len]PollFifo, @@ -676,7 +676,7 @@ fn windowsAsyncRead( /// Given an enum, returns a struct with fields of that enum, each field /// representing an I/O stream for polling. pub fn PollFiles(comptime StreamEnum: type) type { - const enum_fields = @typeInfo(StreamEnum).Enum.fields; + const enum_fields = @typeInfo(StreamEnum).@"enum".fields; var struct_fields: [enum_fields.len]std.builtin.Type.StructField = undefined; for (&struct_fields, enum_fields) |*struct_field, enum_field| { struct_field.* = .{ @@ -687,7 +687,7 @@ pub fn PollFiles(comptime StreamEnum: type) type { .alignment = @alignOf(fs.File), }; } - return @Type(.{ .Struct = .{ + return @Type(.{ .@"struct" = .{ .layout = .auto, .fields = &struct_fields, .decls = &.{}, diff --git a/lib/std/io/Reader.zig b/lib/std/io/Reader.zig index a769fe4c04..33187125b8 100644 --- a/lib/std/io/Reader.zig +++ b/lib/std/io/Reader.zig @@ -277,7 +277,7 @@ pub fn readBoundedBytes(self: Self, comptime num_bytes: usize) anyerror!std.Boun } pub inline fn readInt(self: Self, comptime T: type, endian: std.builtin.Endian) anyerror!T { - const bytes = try self.readBytesNoEof(@divExact(@typeInfo(T).Int.bits, 8)); + const bytes = try self.readBytesNoEof(@divExact(@typeInfo(T).int.bits, 8)); return mem.readInt(T, &bytes, endian); } @@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool { pub fn readStruct(self: Self, comptime T: type) anyerror!T { // Only extern and packed structs have defined in-memory layout. - comptime assert(@typeInfo(T).Struct.layout != .auto); + comptime assert(@typeInfo(T).@"struct".layout != .auto); var res: [1]T = undefined; try self.readNoEof(mem.sliceAsBytes(res[0..])); return res[0]; @@ -348,7 +348,7 @@ pub fn readEnum(self: Self, comptime Enum: type, endian: std.builtin.Endian) any /// An integer was read, but it did not match any of the tags in the supplied enum. InvalidValue, }; - const type_info = @typeInfo(Enum).Enum; + const type_info = @typeInfo(Enum).@"enum"; const tag = try self.readInt(type_info.tag_type, endian); inline for (std.meta.fields(Enum)) |field| { diff --git a/lib/std/io/Writer.zig b/lib/std/io/Writer.zig index 0c80393e45..26d4f88def 100644 --- a/lib/std/io/Writer.zig +++ b/lib/std/io/Writer.zig @@ -49,14 +49,14 @@ pub fn writeBytesNTimes(self: Self, bytes: []const u8, n: usize) anyerror!void { } pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.builtin.Endian) anyerror!void { - var bytes: [@divExact(@typeInfo(T).Int.bits, 8)]u8 = undefined; + var bytes: [@divExact(@typeInfo(T).int.bits, 8)]u8 = undefined; mem.writeInt(std.math.ByteAlignedInt(@TypeOf(value)), &bytes, value, endian); return self.writeAll(&bytes); } pub fn writeStruct(self: Self, value: anytype) anyerror!void { // Only extern and packed structs have defined in-memory layout. - comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .auto); + comptime assert(@typeInfo(@TypeOf(value)).@"struct".layout != .auto); return self.writeAll(mem.asBytes(&value)); } diff --git a/lib/std/io/bit_writer.zig b/lib/std/io/bit_writer.zig index 14e7f994ed..b5db45898b 100644 --- a/lib/std/io/bit_writer.zig +++ b/lib/std/io/bit_writer.zig @@ -33,7 +33,7 @@ pub fn BitWriter(comptime endian: std.builtin.Endian, comptime WriterType: type) if (bits == 0) return; const U = @TypeOf(value); - comptime assert(@typeInfo(U).Int.signedness == .unsigned); + comptime assert(@typeInfo(U).int.signedness == .unsigned); //by extending the buffer to a minimum of u8 we can cover a number of edge cases // related to shifting and casting. diff --git a/lib/std/io/fixed_buffer_stream.zig b/lib/std/io/fixed_buffer_stream.zig index 14e5e5de43..7750c29fc8 100644 --- a/lib/std/io/fixed_buffer_stream.zig +++ b/lib/std/io/fixed_buffer_stream.zig @@ -115,18 +115,18 @@ pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(Slice(@TypeOf(buffer fn Slice(comptime T: type) type { switch (@typeInfo(T)) { - .Pointer => |ptr_info| { + .pointer => |ptr_info| { var new_ptr_info = ptr_info; switch (ptr_info.size) { .Slice => {}, .One => switch (@typeInfo(ptr_info.child)) { - .Array => |info| new_ptr_info.child = info.child, + .array => |info| new_ptr_info.child = info.child, else => @compileError("invalid type given to fixedBufferStream"), }, else => @compileError("invalid type given to fixedBufferStream"), } new_ptr_info.size = .Slice; - return @Type(.{ .Pointer = new_ptr_info }); + return @Type(.{ .pointer = new_ptr_info }); }, else => @compileError("invalid type given to fixedBufferStream"), } diff --git a/lib/std/io/multi_writer.zig b/lib/std/io/multi_writer.zig index 9cd4600e63..be109867b7 100644 --- a/lib/std/io/multi_writer.zig +++ b/lib/std/io/multi_writer.zig @@ -4,7 +4,7 @@ const io = std.io; /// Takes a tuple of streams, and constructs a new stream that writes to all of them pub fn MultiWriter(comptime Writers: type) type { comptime var ErrSet = error{}; - inline for (@typeInfo(Writers).Struct.fields) |field| { + inline for (@typeInfo(Writers).@"struct".fields) |field| { const StreamType = field.type; ErrSet = ErrSet || StreamType.Error; } diff --git a/lib/std/io/tty.zig b/lib/std/io/tty.zig index 83206a6a67..013057649e 100644 --- a/lib/std/io/tty.zig +++ b/lib/std/io/tty.zig @@ -75,7 +75,7 @@ pub const Config = union(enum) { conf: Config, writer: anytype, color: Color, - ) (@typeInfo(@TypeOf(writer.writeAll(""))).ErrorUnion.error_set || + ) (@typeInfo(@TypeOf(writer.writeAll(""))).error_union.error_set || windows.SetConsoleTextAttributeError)!void { nosuspend switch (conf) { .no_color => return, diff --git a/lib/std/json/static.zig b/lib/std/json/static.zig index 74901f85a8..15cb5bc75a 100644 --- a/lib/std/json/static.zig +++ b/lib/std/json/static.zig @@ -219,14 +219,14 @@ pub fn innerParse( options: ParseOptions, ) ParseError(@TypeOf(source.*))!T { switch (@typeInfo(T)) { - .Bool => { + .bool => { return switch (try source.next()) { .true => true, .false => false, else => error.UnexpectedToken, }; }, - .Float, .ComptimeFloat => { + .float, .comptime_float => { const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?); defer freeAllocated(allocator, token); const slice = switch (token) { @@ -235,7 +235,7 @@ pub fn innerParse( }; return try std.fmt.parseFloat(T, slice); }, - .Int, .ComptimeInt => { + .int, .comptime_int => { const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?); defer freeAllocated(allocator, token); const slice = switch (token) { @@ -244,7 +244,7 @@ pub fn innerParse( }; return sliceToInt(T, slice); }, - .Optional => |optionalInfo| { + .optional => |optionalInfo| { switch (try source.peekNextTokenType()) { .null => { _ = try source.next(); @@ -255,7 +255,7 @@ pub fn innerParse( }, } }, - .Enum => { + .@"enum" => { if (std.meta.hasFn(T, "jsonParse")) { return T.jsonParse(allocator, source, options); } @@ -268,7 +268,7 @@ pub fn innerParse( }; return sliceToEnum(T, slice); }, - .Union => |unionInfo| { + .@"union" => |unionInfo| { if (std.meta.hasFn(T, "jsonParse")) { return T.jsonParse(allocator, source, options); } @@ -313,7 +313,7 @@ pub fn innerParse( return result.?; }, - .Struct => |structInfo| { + .@"struct" => |structInfo| { if (structInfo.is_tuple) { if (.array_begin != try source.next()) return error.UnexpectedToken; @@ -385,7 +385,7 @@ pub fn innerParse( return r; }, - .Array => |arrayInfo| { + .array => |arrayInfo| { switch (try source.peekNextTokenType()) { .array_begin => { // Typical array. @@ -440,7 +440,7 @@ pub fn innerParse( } }, - .Vector => |vecInfo| { + .vector => |vecInfo| { switch (try source.peekNextTokenType()) { .array_begin => { return internalParseArray(T, vecInfo.child, vecInfo.len, allocator, source, options); @@ -449,7 +449,7 @@ pub fn innerParse( } }, - .Pointer => |ptrInfo| { + .pointer => |ptrInfo| { switch (ptrInfo.size) { .One => { const r: *ptrInfo.child = try allocator.create(ptrInfo.child); @@ -550,13 +550,13 @@ pub fn innerParseFromValue( options: ParseOptions, ) ParseFromValueError!T { switch (@typeInfo(T)) { - .Bool => { + .bool => { switch (source) { .bool => |b| return b, else => return error.UnexpectedToken, } }, - .Float, .ComptimeFloat => { + .float, .comptime_float => { switch (source) { .float => |f| return @as(T, @floatCast(f)), .integer => |i| return @as(T, @floatFromInt(i)), @@ -564,7 +564,7 @@ pub fn innerParseFromValue( else => return error.UnexpectedToken, } }, - .Int, .ComptimeInt => { + .int, .comptime_int => { switch (source) { .float => |f| { if (@round(f) != f) return error.InvalidNumber; @@ -583,13 +583,13 @@ pub fn innerParseFromValue( else => return error.UnexpectedToken, } }, - .Optional => |optionalInfo| { + .optional => |optionalInfo| { switch (source) { .null => return null, else => return try innerParseFromValue(optionalInfo.child, allocator, source, options), } }, - .Enum => { + .@"enum" => { if (std.meta.hasFn(T, "jsonParseFromValue")) { return T.jsonParseFromValue(allocator, source, options); } @@ -601,7 +601,7 @@ pub fn innerParseFromValue( else => return error.UnexpectedToken, } }, - .Union => |unionInfo| { + .@"union" => |unionInfo| { if (std.meta.hasFn(T, "jsonParseFromValue")) { return T.jsonParseFromValue(allocator, source, options); } @@ -631,7 +631,7 @@ pub fn innerParseFromValue( return error.UnknownField; }, - .Struct => |structInfo| { + .@"struct" => |structInfo| { if (structInfo.is_tuple) { if (source != .array) return error.UnexpectedToken; if (source.array.items.len != structInfo.fields.len) return error.UnexpectedToken; @@ -674,7 +674,7 @@ pub fn innerParseFromValue( return r; }, - .Array => |arrayInfo| { + .array => |arrayInfo| { switch (source) { .array => |array| { // Typical array. @@ -695,7 +695,7 @@ pub fn innerParseFromValue( } }, - .Vector => |vecInfo| { + .vector => |vecInfo| { switch (source) { .array => |array| { return innerParseArrayFromArrayValue(T, vecInfo.child, vecInfo.len, allocator, array, options); @@ -704,7 +704,7 @@ pub fn innerParseFromValue( } }, - .Pointer => |ptrInfo| { + .pointer => |ptrInfo| { switch (ptrInfo.size) { .One => { const r: *ptrInfo.child = try allocator.create(ptrInfo.child); @@ -780,12 +780,12 @@ fn sliceToEnum(comptime T: type, slice: []const u8) !T { if (std.meta.stringToEnum(T, slice)) |value| return value; // Check for a numeric value. if (!isNumberFormattedLikeAnInteger(slice)) return error.InvalidEnumTag; - const n = std.fmt.parseInt(@typeInfo(T).Enum.tag_type, slice, 10) catch return error.InvalidEnumTag; + const n = std.fmt.parseInt(@typeInfo(T).@"enum".tag_type, slice, 10) catch return error.InvalidEnumTag; return std.meta.intToEnum(T, n); } -fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).Struct.fields.len]bool) !void { - inline for (@typeInfo(T).Struct.fields, 0..) |field, i| { +fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).@"struct".fields.len]bool) !void { + inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| { if (!fields_seen[i]) { if (field.default_value) |default_ptr| { const default = @as(*align(1) const field.type, @ptrCast(default_ptr)).*; diff --git a/lib/std/json/stringify.zig b/lib/std/json/stringify.zig index 965b7c3113..11e1dcf710 100644 --- a/lib/std/json/stringify.zig +++ b/lib/std/json/stringify.zig @@ -493,7 +493,7 @@ pub fn WriteStream( if (build_mode_has_safety) assert(self.raw_streaming_mode == .none); const T = @TypeOf(value); switch (@typeInfo(T)) { - .Int => { + .int => { try self.valueStart(); if (self.options.emit_nonportable_numbers_as_strings and (value <= -(1 << 53) or value >= (1 << 53))) @@ -505,10 +505,10 @@ pub fn WriteStream( self.valueDone(); return; }, - .ComptimeInt => { + .comptime_int => { return self.write(@as(std.math.IntFittingRange(value, value), value)); }, - .Float, .ComptimeFloat => { + .float, .comptime_float => { if (@as(f64, @floatCast(value)) == value) { try self.valueStart(); try self.stream.print("{}", .{@as(f64, @floatCast(value))}); @@ -521,38 +521,38 @@ pub fn WriteStream( return; }, - .Bool => { + .bool => { try self.valueStart(); try self.stream.writeAll(if (value) "true" else "false"); self.valueDone(); return; }, - .Null => { + .null => { try self.valueStart(); try self.stream.writeAll("null"); self.valueDone(); return; }, - .Optional => { + .optional => { if (value) |payload| { return try self.write(payload); } else { return try self.write(null); } }, - .Enum, .EnumLiteral => { + .@"enum", .enum_literal => { if (std.meta.hasFn(T, "jsonStringify")) { return value.jsonStringify(self); } return self.stringValue(@tagName(value)); }, - .Union => { + .@"union" => { if (std.meta.hasFn(T, "jsonStringify")) { return value.jsonStringify(self); } - const info = @typeInfo(T).Union; + const info = @typeInfo(T).@"union"; if (info.tag_type) |UnionTagType| { try self.beginObject(); inline for (info.fields) |u_field| { @@ -576,7 +576,7 @@ pub fn WriteStream( @compileError("Unable to stringify untagged union '" ++ @typeName(T) ++ "'"); } }, - .Struct => |S| { + .@"struct" => |S| { if (std.meta.hasFn(T, "jsonStringify")) { return value.jsonStringify(self); } @@ -593,7 +593,7 @@ pub fn WriteStream( var emit_field = true; // don't include optional fields that are null when emit_null_optional_fields is set to false - if (@typeInfo(Field.type) == .Optional) { + if (@typeInfo(Field.type) == .optional) { if (self.options.emit_null_optional_fields == false) { if (@field(value, Field.name) == null) { emit_field = false; @@ -615,10 +615,10 @@ pub fn WriteStream( } return; }, - .ErrorSet => return self.stringValue(@errorName(value)), - .Pointer => |ptr_info| switch (ptr_info.size) { + .error_set => return self.stringValue(@errorName(value)), + .pointer => |ptr_info| switch (ptr_info.size) { .One => switch (@typeInfo(ptr_info.child)) { - .Array => { + .array => { // Coerce `*[N]T` to `[]const T`. const Slice = []const std.meta.Elem(ptr_info.child); return self.write(@as(Slice, value)); @@ -648,11 +648,11 @@ pub fn WriteStream( }, else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"), }, - .Array => { + .array => { // Coerce `[N]T` to `*const [N]T` (and then to `[]const T`). return self.write(&value); }, - .Vector => |info| { + .vector => |info| { const array: [info.len]info.child = value; return self.write(&array); }, diff --git a/lib/std/leb128.zig b/lib/std/leb128.zig index 1915782459..2a5d9b20fc 100644 --- a/lib/std/leb128.zig +++ b/lib/std/leb128.zig @@ -4,10 +4,10 @@ const testing = std.testing; /// Read a single unsigned LEB128 value from the given reader as type T, /// or error.Overflow if the value cannot fit. pub fn readUleb128(comptime T: type, reader: anytype) !T { - const U = if (@typeInfo(T).Int.bits < 8) u8 else T; + const U = if (@typeInfo(T).int.bits < 8) u8 else T; const ShiftT = std.math.Log2Int(U); - const max_group = (@typeInfo(U).Int.bits + 6) / 7; + const max_group = (@typeInfo(U).int.bits + 6) / 7; var value: U = 0; var group: ShiftT = 0; @@ -42,7 +42,7 @@ pub fn writeUleb128(writer: anytype, arg: anytype) !void { comptime_int => std.math.IntFittingRange(arg, arg), else => Arg, }; - const Value = if (@typeInfo(Int).Int.bits < 8) u8 else Int; + const Value = if (@typeInfo(Int).int.bits < 8) u8 else Int; var value: Value = arg; while (true) { @@ -63,11 +63,11 @@ pub const writeULEB128 = writeUleb128; /// Read a single signed LEB128 value from the given reader as type T, /// or error.Overflow if the value cannot fit. pub fn readIleb128(comptime T: type, reader: anytype) !T { - const S = if (@typeInfo(T).Int.bits < 8) i8 else T; - const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits); + const S = if (@typeInfo(T).int.bits < 8) i8 else T; + const U = std.meta.Int(.unsigned, @typeInfo(S).int.bits); const ShiftU = std.math.Log2Int(U); - const max_group = (@typeInfo(U).Int.bits + 6) / 7; + const max_group = (@typeInfo(U).int.bits + 6) / 7; var value = @as(U, 0); var group = @as(ShiftU, 0); @@ -83,14 +83,14 @@ pub fn readIleb128(comptime T: type, reader: anytype) !T { if (@as(S, @bitCast(ov[0])) >= 0) return error.Overflow; // and all the overflowed bits are 1 - const remaining_shift = @as(u3, @intCast(@typeInfo(U).Int.bits - @as(u16, shift))); + const remaining_shift = @as(u3, @intCast(@typeInfo(U).int.bits - @as(u16, shift))); const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift; if (remaining_bits != -1) return error.Overflow; } else { // If we don't overflow and this is the last byte and the number being decoded // is negative, check that the remaining bits are 1 if ((byte & 0x80 == 0) and (@as(S, @bitCast(ov[0])) < 0)) { - const remaining_shift = @as(u3, @intCast(@typeInfo(U).Int.bits - @as(u16, shift))); + const remaining_shift = @as(u3, @intCast(@typeInfo(U).int.bits - @as(u16, shift))); const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift; if (remaining_bits != -1) return error.Overflow; } @@ -125,11 +125,11 @@ pub const readILEB128 = readIleb128; pub fn writeIleb128(writer: anytype, arg: anytype) !void { const Arg = @TypeOf(arg); const Int = switch (Arg) { - comptime_int => std.math.IntFittingRange(-arg - 1, arg), + comptime_int => std.math.IntFittingRange(-@abs(arg), @abs(arg)), else => Arg, }; - const Signed = if (@typeInfo(Int).Int.bits < 8) i8 else Int; - const Unsigned = std.meta.Int(.unsigned, @typeInfo(Signed).Int.bits); + const Signed = if (@typeInfo(Int).int.bits < 8) i8 else Int; + const Unsigned = std.meta.Int(.unsigned, @typeInfo(Signed).int.bits); var value: Signed = arg; while (true) { @@ -165,7 +165,7 @@ pub fn writeUnsignedExtended(slice: []u8, arg: anytype) void { comptime_int => std.math.IntFittingRange(arg, arg), else => Arg, }; - const Value = if (@typeInfo(Int).Int.bits < 8) u8 else Int; + const Value = if (@typeInfo(Int).int.bits < 8) u8 else Int; var value: Value = arg; for (slice[0 .. slice.len - 1]) |*byte| { @@ -210,7 +210,7 @@ test writeUnsignedFixed { /// different value without shifting all the following code. pub fn writeSignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.signed, l * 7)) void { const T = @TypeOf(int); - const U = if (@typeInfo(T).Int.bits < 8) u8 else T; + const U = if (@typeInfo(T).int.bits < 8) u8 else T; var value: U = @intCast(int); comptime var i = 0; @@ -388,7 +388,7 @@ test "deserialize unsigned LEB128" { fn test_write_leb128(value: anytype) !void { const T = @TypeOf(value); - const signedness = @typeInfo(T).Int.signedness; + const signedness = @typeInfo(T).int.signedness; const t_signed = signedness == .signed; const writeStream = if (t_signed) writeIleb128 else writeUleb128; @@ -396,19 +396,19 @@ fn test_write_leb128(value: anytype) !void { // decode to a larger bit size too, to ensure sign extension // is working as expected - const larger_type_bits = ((@typeInfo(T).Int.bits + 8) / 8) * 8; + const larger_type_bits = ((@typeInfo(T).int.bits + 8) / 8) * 8; const B = std.meta.Int(signedness, larger_type_bits); const bytes_needed = bn: { - if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1); + if (@typeInfo(T).int.bits <= 7) break :bn @as(u16, 1); const unused_bits = if (value < 0) @clz(~value) else @clz(value); - const used_bits: u16 = (@typeInfo(T).Int.bits - unused_bits) + @intFromBool(t_signed); + const used_bits: u16 = (@typeInfo(T).int.bits - unused_bits) + @intFromBool(t_signed); if (used_bits <= 7) break :bn @as(u16, 1); break :bn ((used_bits + 6) / 7); }; - const max_groups = if (@typeInfo(T).Int.bits == 0) 1 else (@typeInfo(T).Int.bits + 6) / 7; + const max_groups = if (@typeInfo(T).int.bits == 0) 1 else (@typeInfo(T).int.bits + 6) / 7; var buf: [max_groups]u8 = undefined; var fbs = std.io.fixedBufferStream(&buf); @@ -439,7 +439,7 @@ test "serialize unsigned LEB128" { const T = std.meta.Int(.unsigned, t); const min = std.math.minInt(T); const max = std.math.maxInt(T); - var i = @as(std.meta.Int(.unsigned, @typeInfo(T).Int.bits + 1), min); + var i = @as(std.meta.Int(.unsigned, @typeInfo(T).int.bits + 1), min); while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i))); } @@ -457,7 +457,7 @@ test "serialize signed LEB128" { const T = std.meta.Int(.signed, t); const min = std.math.minInt(T); const max = std.math.maxInt(T); - var i = @as(std.meta.Int(.signed, @typeInfo(T).Int.bits + 1), min); + var i = @as(std.meta.Int(.signed, @typeInfo(T).int.bits + 1), min); while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i))); } diff --git a/lib/std/log.zig b/lib/std/log.zig index b2c05112b0..81a0ab0947 100644 --- a/lib/std/log.zig +++ b/lib/std/log.zig @@ -28,7 +28,7 @@ //! //! pub fn myLogFn( //! comptime level: std.log.Level, -//! comptime scope: @TypeOf(.EnumLiteral), +//! comptime scope: @Type(.enum_literal), //! comptime format: []const u8, //! args: anytype, //! ) void { @@ -108,7 +108,7 @@ pub const default_level: Level = switch (builtin.mode) { const level = std.options.log_level; pub const ScopeLevel = struct { - scope: @Type(.EnumLiteral), + scope: @Type(.enum_literal), level: Level, }; @@ -116,7 +116,7 @@ const scope_levels = std.options.log_scope_levels; fn log( comptime message_level: Level, - comptime scope: @Type(.EnumLiteral), + comptime scope: @Type(.enum_literal), comptime format: []const u8, args: anytype, ) void { @@ -126,7 +126,7 @@ fn log( } /// Determine if a specific log message level and scope combination are enabled for logging. -pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.EnumLiteral)) bool { +pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.enum_literal)) bool { inline for (scope_levels) |scope_level| { if (scope_level.scope == scope) return @intFromEnum(message_level) <= @intFromEnum(scope_level.level); } @@ -142,7 +142,7 @@ pub fn defaultLogEnabled(comptime message_level: Level) bool { /// forward log messages to this function. pub fn defaultLog( comptime message_level: Level, - comptime scope: @Type(.EnumLiteral), + comptime scope: @Type(.enum_literal), comptime format: []const u8, args: anytype, ) void { @@ -162,7 +162,7 @@ pub fn defaultLog( /// Returns a scoped logging namespace that logs all messages using the scope /// provided here. -pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { +pub fn scoped(comptime scope: @Type(.enum_literal)) type { return struct { /// Log an error message. This log level is intended to be used /// when something has gone wrong. This might be recoverable or might @@ -171,7 +171,7 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { comptime format: []const u8, args: anytype, ) void { - @setCold(true); + @branchHint(.cold); log(.err, scope, format, args); } diff --git a/lib/std/math.zig b/lib/std/math.zig index f18739095c..67782bf93b 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -71,7 +71,7 @@ pub const snan = float.snan; /// /// NaN values are never considered equal to any value. pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool { - assert(@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat); + assert(@typeInfo(T) == .float or @typeInfo(T) == .comptime_float); assert(tolerance >= 0); // Fast path for equal values (and signed zeros and infinites). @@ -99,7 +99,7 @@ pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool { /// /// NaN values are never considered equal to any value. pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool { - assert(@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat); + assert(@typeInfo(T) == .float or @typeInfo(T) == .comptime_float); assert(tolerance > 0); // Fast path for equal values (and signed zeros and infinites). @@ -263,8 +263,8 @@ pub inline fn tan(value: anytype) @TypeOf(value) { pub fn radiansToDegrees(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) { const T = @TypeOf(ang); switch (@typeInfo(T)) { - .Float, .ComptimeFloat, .ComptimeInt => return ang * deg_per_rad, - .Vector => |V| if (@typeInfo(V.child) == .Float) return ang * @as(T, @splat(deg_per_rad)), + .float, .comptime_float, .comptime_int => return ang * deg_per_rad, + .vector => |V| if (@typeInfo(V.child) == .float) return ang * @as(T, @splat(deg_per_rad)), else => {}, } @compileError("Input must be float or a comptime number, or a vector of floats."); @@ -298,8 +298,8 @@ test radiansToDegrees { pub fn degreesToRadians(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) { const T = @TypeOf(ang); switch (@typeInfo(T)) { - .Float, .ComptimeFloat, .ComptimeInt => return ang * rad_per_deg, - .Vector => |V| if (@typeInfo(V.child) == .Float) return ang * @as(T, @splat(rad_per_deg)), + .float, .comptime_float, .comptime_int => return ang * rad_per_deg, + .vector => |V| if (@typeInfo(V.child) == .float) return ang * @as(T, @splat(rad_per_deg)), else => {}, } @compileError("Input must be float or a comptime number, or a vector of floats."); @@ -408,8 +408,8 @@ test { /// full range of the minimum value. pub fn Min(comptime A: type, comptime B: type) type { switch (@typeInfo(A)) { - .Int => |a_info| switch (@typeInfo(B)) { - .Int => |b_info| if (a_info.signedness == .unsigned and b_info.signedness == .unsigned) { + .int => |a_info| switch (@typeInfo(B)) { + .int => |b_info| if (a_info.signedness == .unsigned and b_info.signedness == .unsigned) { if (a_info.bits < b_info.bits) { return A; } else { @@ -437,21 +437,21 @@ pub fn Min(comptime A: type, comptime B: type) type { pub fn wrap(x: anytype, r: anytype) @TypeOf(x) { const info_x = @typeInfo(@TypeOf(x)); const info_r = @typeInfo(@TypeOf(r)); - if (info_x == .Int and info_x.Int.signedness != .signed) { + if (info_x == .int and info_x.int.signedness != .signed) { @compileError("x must be floating point, comptime integer, or signed integer."); } switch (info_r) { - .Int => { + .int => { // in the rare usecase of r not being comptime_int or float, // take the penalty of having an intermediary type conversion, // otherwise the alternative is to unwind iteratively to avoid overflow const R = comptime do: { var info = info_r; - info.Int.bits += 1; - info.Int.signedness = .signed; + info.int.bits += 1; + info.int.signedness = .signed; break :do @Type(info); }; - const radius: if (info_r.Int.signedness == .signed) @TypeOf(r) else R = r; + const radius: if (info_r.int.signedness == .signed) @TypeOf(r) else R = r; return @intCast(@mod(x - radius, 2 * @as(R, r)) - r); // provably impossible to overflow }, else => { @@ -520,9 +520,9 @@ test wrap { pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) { const T = @TypeOf(val, lower, upper); switch (@typeInfo(T)) { - .Int, .Float, .ComptimeInt, .ComptimeFloat => assert(lower <= upper), - .Vector => |vinfo| switch (@typeInfo(vinfo.child)) { - .Int, .Float => assert(@reduce(.And, lower <= upper)), + .int, .float, .comptime_int, .comptime_float => assert(lower <= upper), + .vector => |vinfo| switch (@typeInfo(vinfo.child)) { + .int, .float => assert(@reduce(.And, lower <= upper)), else => @compileError("Expected vector of ints or floats, found " ++ @typeName(T)), }, else => @compileError("Expected an int, float or vector of one, found " ++ @typeName(T)), @@ -593,18 +593,18 @@ pub fn shl(comptime T: type, a: T, shift_amt: anytype) T { const abs_shift_amt = @abs(shift_amt); const casted_shift_amt = blk: { - if (@typeInfo(T) == .Vector) { - const C = @typeInfo(T).Vector.child; - const len = @typeInfo(T).Vector.len; - if (abs_shift_amt >= @typeInfo(C).Int.bits) return @splat(0); + if (@typeInfo(T) == .vector) { + const C = @typeInfo(T).vector.child; + const len = @typeInfo(T).vector.len; + if (abs_shift_amt >= @typeInfo(C).int.bits) return @splat(0); break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt)))); } else { - if (abs_shift_amt >= @typeInfo(T).Int.bits) return 0; + if (abs_shift_amt >= @typeInfo(T).int.bits) return 0; break :blk @as(Log2Int(T), @intCast(abs_shift_amt)); } }; - if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).Int.signedness == .signed) { + if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).int.signedness == .signed) { if (shift_amt < 0) { return a >> casted_shift_amt; } @@ -633,18 +633,18 @@ pub fn shr(comptime T: type, a: T, shift_amt: anytype) T { const abs_shift_amt = @abs(shift_amt); const casted_shift_amt = blk: { - if (@typeInfo(T) == .Vector) { - const C = @typeInfo(T).Vector.child; - const len = @typeInfo(T).Vector.len; - if (abs_shift_amt >= @typeInfo(C).Int.bits) return @splat(0); + if (@typeInfo(T) == .vector) { + const C = @typeInfo(T).vector.child; + const len = @typeInfo(T).vector.len; + if (abs_shift_amt >= @typeInfo(C).int.bits) return @splat(0); break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt)))); } else { - if (abs_shift_amt >= @typeInfo(T).Int.bits) return 0; + if (abs_shift_amt >= @typeInfo(T).int.bits) return 0; break :blk @as(Log2Int(T), @intCast(abs_shift_amt)); } }; - if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).Int.signedness == .signed) { + if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).int.signedness == .signed) { if (shift_amt < 0) { return a << casted_shift_amt; } @@ -670,26 +670,26 @@ test shr { /// Rotates right. Only unsigned values can be rotated. Negative shift /// values result in shift modulo the bit count. pub fn rotr(comptime T: type, x: T, r: anytype) T { - if (@typeInfo(T) == .Vector) { - const C = @typeInfo(T).Vector.child; + if (@typeInfo(T) == .vector) { + const C = @typeInfo(T).vector.child; if (C == u0) return 0; - if (@typeInfo(C).Int.signedness == .signed) { + if (@typeInfo(C).int.signedness == .signed) { @compileError("cannot rotate signed integers"); } - const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).Int.bits)); + const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).int.bits)); return (x >> @splat(ar)) | (x << @splat(1 + ~ar)); - } else if (@typeInfo(T).Int.signedness == .signed) { + } else if (@typeInfo(T).int.signedness == .signed) { @compileError("cannot rotate signed integer"); } else { if (T == u0) return 0; - if (comptime isPowerOfTwo(@typeInfo(T).Int.bits)) { - const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits)); + if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) { + const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits)); return x >> ar | x << (1 +% ~ar); } else { - const ar = @mod(r, @typeInfo(T).Int.bits); - return shr(T, x, ar) | shl(T, x, @typeInfo(T).Int.bits - ar); + const ar = @mod(r, @typeInfo(T).int.bits); + return shr(T, x, ar) | shl(T, x, @typeInfo(T).int.bits - ar); } } } @@ -711,26 +711,26 @@ test rotr { /// Rotates left. Only unsigned values can be rotated. Negative shift /// values result in shift modulo the bit count. pub fn rotl(comptime T: type, x: T, r: anytype) T { - if (@typeInfo(T) == .Vector) { - const C = @typeInfo(T).Vector.child; + if (@typeInfo(T) == .vector) { + const C = @typeInfo(T).vector.child; if (C == u0) return 0; - if (@typeInfo(C).Int.signedness == .signed) { + if (@typeInfo(C).int.signedness == .signed) { @compileError("cannot rotate signed integers"); } - const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).Int.bits)); + const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).int.bits)); return (x << @splat(ar)) | (x >> @splat(1 +% ~ar)); - } else if (@typeInfo(T).Int.signedness == .signed) { + } else if (@typeInfo(T).int.signedness == .signed) { @compileError("cannot rotate signed integer"); } else { if (T == u0) return 0; - if (comptime isPowerOfTwo(@typeInfo(T).Int.bits)) { - const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits)); + if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) { + const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits)); return x << ar | x >> 1 +% ~ar; } else { - const ar = @mod(r, @typeInfo(T).Int.bits); - return shl(T, x, ar) | shr(T, x, @typeInfo(T).Int.bits - ar); + const ar = @mod(r, @typeInfo(T).int.bits); + return shl(T, x, ar) | shr(T, x, @typeInfo(T).int.bits - ar); } } } @@ -754,7 +754,7 @@ test rotl { pub fn Log2Int(comptime T: type) type { // comptime ceil log2 if (T == comptime_int) return comptime_int; - const bits: u16 = @typeInfo(T).Int.bits; + const bits: u16 = @typeInfo(T).int.bits; const log2_bits = 16 - @clz(bits - 1); return std.meta.Int(.unsigned, log2_bits); } @@ -763,7 +763,7 @@ pub fn Log2Int(comptime T: type) type { pub fn Log2IntCeil(comptime T: type) type { // comptime ceil log2 if (T == comptime_int) return comptime_int; - const bits: u16 = @typeInfo(T).Int.bits; + const bits: u16 = @typeInfo(T).int.bits; const log2_bits = 16 - @clz(bits); return std.meta.Int(.unsigned, log2_bits); } @@ -849,7 +849,7 @@ fn testOverflow() !void { pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T { @setRuntimeSafety(false); if (denominator == 0) return error.DivisionByZero; - if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; + if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; return @divTrunc(numerator, denominator); } @@ -873,7 +873,7 @@ fn testDivTrunc() !void { pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T { @setRuntimeSafety(false); if (denominator == 0) return error.DivisionByZero; - if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; + if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; return @divFloor(numerator, denominator); } @@ -899,10 +899,10 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T { if (denominator == 0) return error.DivisionByZero; const info = @typeInfo(T); switch (info) { - .ComptimeFloat, .Float => return @ceil(numerator / denominator), - .ComptimeInt, .Int => { + .comptime_float, .float => return @ceil(numerator / denominator), + .comptime_int, .int => { if (numerator < 0 and denominator < 0) { - if (info == .Int and numerator == minInt(T) and denominator == -1) + if (info == .int and numerator == minInt(T) and denominator == -1) return error.Overflow; return @divFloor(numerator + 1, denominator) + 1; } @@ -952,7 +952,7 @@ fn testDivCeil() !void { pub fn divExact(comptime T: type, numerator: T, denominator: T) !T { @setRuntimeSafety(false); if (denominator == 0) return error.DivisionByZero; - if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; + if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow; const result = @divTrunc(numerator, denominator); if (result * denominator != numerator) return error.UnexpectedRemainder; return result; @@ -1029,7 +1029,7 @@ fn testRem() !void { /// Returns the negation of the integer parameter. /// Result is a signed integer. pub fn negateCast(x: anytype) !std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))) { - if (@typeInfo(@TypeOf(x)).Int.signedness == .signed) return negate(x); + if (@typeInfo(@TypeOf(x)).int.signedness == .signed) return negate(x); const int = std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))); if (x > -minInt(int)) return error.Overflow; @@ -1052,9 +1052,9 @@ test negateCast { /// Cast an integer to a different integer type. If the value doesn't fit, /// return null. pub fn cast(comptime T: type, x: anytype) ?T { - comptime assert(@typeInfo(T) == .Int); // must pass an integer + comptime assert(@typeInfo(T) == .int); // must pass an integer const is_comptime = @TypeOf(x) == comptime_int; - comptime assert(is_comptime or @typeInfo(@TypeOf(x)) == .Int); // must pass an integer + comptime assert(is_comptime or @typeInfo(@TypeOf(x)) == .int); // must pass an integer if ((is_comptime or maxInt(@TypeOf(x)) > maxInt(T)) and x > maxInt(T)) { return null; } else if ((is_comptime or minInt(@TypeOf(x)) < minInt(T)) and x < minInt(T)) { @@ -1084,7 +1084,7 @@ pub const AlignCastError = error{UnalignedMemory}; fn AlignCastResult(comptime alignment: u29, comptime Ptr: type) type { var ptr_info = @typeInfo(Ptr); - ptr_info.Pointer.alignment = alignment; + ptr_info.pointer.alignment = alignment; return @Type(ptr_info); } @@ -1117,7 +1117,7 @@ test isPowerOfTwo { /// Aligns the given integer type bit width to a width divisible by 8. pub fn ByteAlignedInt(comptime T: type) type { - const info = @typeInfo(T).Int; + const info = @typeInfo(T).int; const bits = (info.bits + 7) / 8 * 8; const extended_type = std.meta.Int(info.signedness, bits); return extended_type; @@ -1157,7 +1157,7 @@ pub inline fn floor(value: anytype) @TypeOf(value) { /// Returns the nearest power of two less than or equal to value, or /// zero if value is less than or equal to zero. pub fn floorPowerOfTwo(comptime T: type, value: T) T { - const uT = std.meta.Int(.unsigned, @typeInfo(T).Int.bits); + const uT = std.meta.Int(.unsigned, @typeInfo(T).int.bits); if (value <= 0) return 0; return @as(T, 1) << log2_int(uT, @as(uT, @intCast(value))); } @@ -1192,21 +1192,21 @@ pub inline fn ceil(value: anytype) @TypeOf(value) { /// Returns the next power of two (if the value is not already a power of two). /// Only unsigned integers can be used. Zero is not an allowed input. /// Result is a type with 1 more bit than the input type. -pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1) { - comptime assert(@typeInfo(T) == .Int); - comptime assert(@typeInfo(T).Int.signedness == .unsigned); +pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1) { + comptime assert(@typeInfo(T) == .int); + comptime assert(@typeInfo(T).int.signedness == .unsigned); assert(value != 0); - const PromotedType = std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1); + const PromotedType = std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1); const ShiftType = std.math.Log2Int(PromotedType); - return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).Int.bits - @clz(value - 1))); + return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).int.bits - @clz(value - 1))); } /// Returns the next power of two (if the value is not already a power of two). /// Only unsigned integers can be used. Zero is not an allowed input. /// If the value doesn't fit, returns an error. pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) { - comptime assert(@typeInfo(T) == .Int); - const info = @typeInfo(T).Int; + comptime assert(@typeInfo(T) == .int); + const info = @typeInfo(T).int; comptime assert(info.signedness == .unsigned); const PromotedType = std.meta.Int(info.signedness, info.bits + 1); const overflowBit = @as(PromotedType, 1) << info.bits; @@ -1261,16 +1261,16 @@ fn testCeilPowerOfTwo() !void { /// Return the log base 2 of integer value x, rounding down to the /// nearest integer. pub fn log2_int(comptime T: type, x: T) Log2Int(T) { - if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned) + if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned) @compileError("log2_int requires an unsigned integer, found " ++ @typeName(T)); assert(x != 0); - return @as(Log2Int(T), @intCast(@typeInfo(T).Int.bits - 1 - @clz(x))); + return @as(Log2Int(T), @intCast(@typeInfo(T).int.bits - 1 - @clz(x))); } /// Return the log base 2 of integer value x, rounding up to the /// nearest integer. pub fn log2_int_ceil(comptime T: type, x: T) Log2IntCeil(T) { - if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned) + if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned) @compileError("log2_int_ceil requires an unsigned integer, found " ++ @typeName(T)); assert(x != 0); if (x == 1) return 0; @@ -1296,35 +1296,35 @@ test log2_int_ceil { /// converted to the closest possible representation. pub fn lossyCast(comptime T: type, value: anytype) T { switch (@typeInfo(T)) { - .Float => { + .float => { switch (@typeInfo(@TypeOf(value))) { - .Int => return @as(T, @floatFromInt(value)), - .Float => return @as(T, @floatCast(value)), - .ComptimeInt => return @as(T, value), - .ComptimeFloat => return @as(T, value), + .int => return @floatFromInt(value), + .float => return @floatCast(value), + .comptime_int => return value, + .comptime_float => return value, else => @compileError("bad type"), } }, - .Int => { + .int => { switch (@typeInfo(@TypeOf(value))) { - .Int, .ComptimeInt => { + .int, .comptime_int => { if (value >= maxInt(T)) { - return @as(T, maxInt(T)); + return maxInt(T); } else if (value <= minInt(T)) { - return @as(T, minInt(T)); + return minInt(T); } else { - return @as(T, @intCast(value)); + return @intCast(value); } }, - .Float, .ComptimeFloat => { + .float, .comptime_float => { if (isNan(value)) { return 0; } else if (value >= maxInt(T)) { - return @as(T, maxInt(T)); + return maxInt(T); } else if (value <= minInt(T)) { - return @as(T, minInt(T)); + return minInt(T); } else { - return @as(T, @intFromFloat(value)); + return @intFromFloat(value); } }, else => @compileError("bad type"), @@ -1405,16 +1405,16 @@ test lerp { /// Returns the maximum value of integer type T. pub fn maxInt(comptime T: type) comptime_int { const info = @typeInfo(T); - const bit_count = info.Int.bits; + const bit_count = info.int.bits; if (bit_count == 0) return 0; - return (1 << (bit_count - @intFromBool(info.Int.signedness == .signed))) - 1; + return (1 << (bit_count - @intFromBool(info.int.signedness == .signed))) - 1; } /// Returns the minimum value of integer type T. pub fn minInt(comptime T: type) comptime_int { const info = @typeInfo(T); - const bit_count = info.Int.bits; - if (info.Int.signedness == .unsigned) return 0; + const bit_count = info.int.bits; + if (info.int.signedness == .unsigned) return 0; if (bit_count == 0) return 0; return -(1 << (bit_count - 1)); } @@ -1466,12 +1466,12 @@ test "max value type" { /// Multiply a and b. Return type is wide enough to guarantee no /// overflow. pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int( - @typeInfo(T).Int.signedness, - @typeInfo(T).Int.bits * 2, + @typeInfo(T).int.signedness, + @typeInfo(T).int.bits * 2, ) { const ResultInt = std.meta.Int( - @typeInfo(T).Int.signedness, - @typeInfo(T).Int.bits * 2, + @typeInfo(T).int.signedness, + @typeInfo(T).int.bits * 2, ); return @as(ResultInt, a) * @as(ResultInt, b); } @@ -1616,7 +1616,7 @@ pub const CompareOperator = enum { } test reverse { - inline for (@typeInfo(CompareOperator).Enum.fields) |op_field| { + inline for (@typeInfo(CompareOperator).@"enum".fields) |op_field| { const op = @as(CompareOperator, @enumFromInt(op_field.value)); try testing.expect(compare(2, op, 3) == compare(3, op.reverse(), 2)); try testing.expect(compare(3, op, 3) == compare(3, op.reverse(), 3)); @@ -1669,7 +1669,7 @@ test order { /// and a mask of all zeroes if value is false. /// Compiles to one instruction for register sized integers. pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt { - if (@typeInfo(MaskInt) != .Int) + if (@typeInfo(MaskInt) != .int) @compileError("boolMask requires an integer mask type."); if (MaskInt == u0 or MaskInt == i0) @@ -1742,11 +1742,11 @@ pub fn break_f80(x: f80) F80 { pub inline fn sign(i: anytype) @TypeOf(i) { const T = @TypeOf(i); return switch (@typeInfo(T)) { - .Int, .ComptimeInt => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)), - .Float, .ComptimeFloat => @as(T, @floatFromInt(@intFromBool(i > 0))) - @as(T, @floatFromInt(@intFromBool(i < 0))), - .Vector => |vinfo| blk: { + .int, .comptime_int => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)), + .float, .comptime_float => @as(T, @floatFromInt(@intFromBool(i > 0))) - @as(T, @floatFromInt(@intFromBool(i < 0))), + .vector => |vinfo| blk: { switch (@typeInfo(vinfo.child)) { - .Int, .Float => { + .int, .float => { const zero: T = @splat(0); const one: T = @splat(1); break :blk @select(vinfo.child, i > zero, one, zero) - @select(vinfo.child, i < zero, one, zero); diff --git a/lib/std/math/big.zig b/lib/std/math/big.zig index c0d8e74eb2..c201bf1df2 100644 --- a/lib/std/math/big.zig +++ b/lib/std/math/big.zig @@ -4,7 +4,7 @@ const assert = std.debug.assert; pub const Rational = @import("big/rational.zig").Rational; pub const int = @import("big/int.zig"); pub const Limb = usize; -const limb_info = @typeInfo(Limb).Int; +const limb_info = @typeInfo(Limb).int; pub const SignedLimb = std.meta.Int(.signed, limb_info.bits); pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits); pub const HalfLimb = std.meta.Int(.unsigned, limb_info.bits / 2); diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index f0fd6fca4e..2c656033e9 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -2,9 +2,9 @@ const std = @import("../../std.zig"); const builtin = @import("builtin"); const math = std.math; const Limb = std.math.big.Limb; -const limb_bits = @typeInfo(Limb).Int.bits; +const limb_bits = @typeInfo(Limb).int.bits; const HalfLimb = std.math.big.HalfLimb; -const half_limb_bits = @typeInfo(HalfLimb).Int.bits; +const half_limb_bits = @typeInfo(HalfLimb).int.bits; const DoubleLimb = std.math.big.DoubleLimb; const SignedDoubleLimb = std.math.big.SignedDoubleLimb; const Log2Limb = std.math.big.Log2Limb; @@ -23,7 +23,7 @@ const debug_safety = false; /// primitive integer value. /// Note: A comptime-known upper bound of this value that may be used /// instead if `scalar` is not already comptime-known is -/// `calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).Int.bits)` +/// `calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).int.bits)` pub fn calcLimbLen(scalar: anytype) usize { if (scalar == 0) { return 1; @@ -236,7 +236,7 @@ pub const Mutable = struct { self.positive = value >= 0; switch (@typeInfo(T)) { - .Int => |info| { + .int => |info| { var w_value = @abs(value); if (info.bits <= limb_bits) { @@ -251,7 +251,7 @@ pub const Mutable = struct { } } }, - .ComptimeInt => { + .comptime_int => { comptime var w_value = @abs(value); if (w_value <= maxInt(Limb)) { @@ -405,8 +405,8 @@ pub const Mutable = struct { // is well worth being able to use the stack and not needing an allocator passed in. // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case. const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) { - .ComptimeInt => calcLimbLen(scalar), - .Int => |info| calcTwosCompLimbCount(info.bits), + .comptime_int => calcLimbLen(scalar), + .int => |info| calcTwosCompLimbCount(info.bits), else => @compileError("expected scalar to be an int"), }; var limbs: [limb_len]Limb = undefined; @@ -2158,7 +2158,7 @@ pub const Const = struct { /// Returns whether self can fit into an integer of the requested type. pub fn fits(self: Const, comptime T: type) bool { - const info = @typeInfo(T).Int; + const info = @typeInfo(T).int; return self.fitsInTwosComp(info.signedness, info.bits); } @@ -2181,7 +2181,7 @@ pub const Const = struct { /// Returns an error if self cannot be narrowed into the requested type without truncation. pub fn to(self: Const, comptime T: type) ConvertError!T { switch (@typeInfo(T)) { - .Int => |info| { + .int => |info| { // Make sure -0 is handled correctly. if (self.eqlZero()) return 0; @@ -2495,8 +2495,8 @@ pub const Const = struct { // is well worth being able to use the stack and not needing an allocator passed in. // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case. const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) { - .ComptimeInt => calcLimbLen(scalar), - .Int => |info| calcTwosCompLimbCount(info.bits), + .comptime_int => calcLimbLen(scalar), + .int => |info| calcTwosCompLimbCount(info.bits), else => @compileError("expected scalar to be an int"), }; var limbs: [limb_len]Limb = undefined; @@ -2555,7 +2555,7 @@ pub const Const = struct { /// Memory is allocated as needed to ensure operations never overflow. The range /// is bounded only by available memory. pub const Managed = struct { - pub const sign_bit: usize = 1 << (@typeInfo(usize).Int.bits - 1); + pub const sign_bit: usize = 1 << (@typeInfo(usize).int.bits - 1); /// Default number of limbs to allocate on creation of a `Managed`. pub const default_capacity = 4; diff --git a/lib/std/math/big/int_test.zig b/lib/std/math/big/int_test.zig index f06917f0f2..17652179f5 100644 --- a/lib/std/math/big/int_test.zig +++ b/lib/std/math/big/int_test.zig @@ -22,13 +22,13 @@ test "comptime_int set" { var a = try Managed.initSet(testing.allocator, s); defer a.deinit(); - const s_limb_count = 128 / @typeInfo(Limb).Int.bits; + const s_limb_count = 128 / @typeInfo(Limb).int.bits; comptime var i: usize = 0; inline while (i < s_limb_count) : (i += 1) { const result = @as(Limb, s & maxInt(Limb)); - s >>= @typeInfo(Limb).Int.bits / 2; - s >>= @typeInfo(Limb).Int.bits / 2; + s >>= @typeInfo(Limb).int.bits / 2; + s >>= @typeInfo(Limb).int.bits / 2; try testing.expect(a.limbs[i] == result); } } @@ -299,7 +299,7 @@ test "twos complement limit set" { } fn testTwosComplementLimit(comptime T: type) !void { - const int_info = @typeInfo(T).Int; + const int_info = @typeInfo(T).int; var a = try Managed.init(testing.allocator); defer a.deinit(); @@ -1893,7 +1893,7 @@ test "truncate multi to single signed" { } test "truncate multi to multi unsigned" { - const bits = @typeInfo(SignedDoubleLimb).Int.bits; + const bits = @typeInfo(SignedDoubleLimb).int.bits; const Int = std.meta.Int(.unsigned, bits - 1); var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb)); @@ -2239,11 +2239,11 @@ test "bitNotWrap more than two limbs" { const bits = @bitSizeOf(Limb) * 4 + 2; try res.bitNotWrap(&a, .unsigned, bits); - const Unsigned = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = bits } }); + const Unsigned = @Type(.{ .int = .{ .signedness = .unsigned, .bits = bits } }); try testing.expectEqual((try res.to(Unsigned)), ~@as(Unsigned, maxInt(Limb))); try res.bitNotWrap(&a, .signed, bits); - const Signed = @Type(.{ .Int = .{ .signedness = .signed, .bits = bits } }); + const Signed = @Type(.{ .int = .{ .signedness = .signed, .bits = bits } }); try testing.expectEqual((try res.to(Signed)), ~@as(Signed, maxInt(Limb))); } @@ -3037,8 +3037,8 @@ test "big int conversion write twos complement zero" { } fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void { - const bit_count = @typeInfo(T).Int.bits; - const signedness = @typeInfo(T).Int.signedness; + const bit_count = @typeInfo(T).int.bits; + const signedness = @typeInfo(T).int.signedness; var a = try Managed.initSet(testing.allocator, input); defer a.deinit(); @@ -3084,8 +3084,8 @@ test "big int bit reverse" { } fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void { - const byte_count = @typeInfo(T).Int.bits / 8; - const signedness = @typeInfo(T).Int.signedness; + const byte_count = @typeInfo(T).int.bits / 8; + const signedness = @typeInfo(T).int.signedness; var a = try Managed.initSet(testing.allocator, input); defer a.deinit(); @@ -3151,7 +3151,7 @@ test "mul multi-multi alias r with a and b" { try testing.expect(a.eql(want)); - if (@typeInfo(Limb).Int.bits == 64) { + if (@typeInfo(Limb).int.bits == 64) { try testing.expectEqual(@as(usize, 5), a.limbs.len); } } @@ -3167,7 +3167,7 @@ test "sqr multi alias r with a" { try testing.expect(a.eql(want)); - if (@typeInfo(Limb).Int.bits == 64) { + if (@typeInfo(Limb).int.bits == 64) { try testing.expectEqual(@as(usize, 5), a.limbs.len); } } diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index bbfea9de74..ce93f40a25 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -135,9 +135,9 @@ pub const Rational = struct { /// completely represent the provided float. pub fn setFloat(self: *Rational, comptime T: type, f: T) !void { // Translated from golang.go/src/math/big/rat.go. - debug.assert(@typeInfo(T) == .Float); + debug.assert(@typeInfo(T) == .float); - const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const f_bits = @as(UnsignedInt, @bitCast(f)); const exponent_bits = math.floatExponentBits(T); @@ -193,9 +193,9 @@ pub const Rational = struct { pub fn toFloat(self: Rational, comptime T: type) !T { // Translated from golang.go/src/math/big/rat.go. // TODO: Indicate whether the result is not exact. - debug.assert(@typeInfo(T) == .Float); + debug.assert(@typeInfo(T) == .float); - const fsize = @typeInfo(T).Float.bits; + const fsize = @typeInfo(T).float.bits; const BitReprType = std.meta.Int(.unsigned, fsize); const msize = math.floatMantissaBits(T); @@ -473,10 +473,10 @@ pub const Rational = struct { }; fn extractLowBits(a: Int, comptime T: type) T { - debug.assert(@typeInfo(T) == .Int); + debug.assert(@typeInfo(T) == .int); - const t_bits = @typeInfo(T).Int.bits; - const limb_bits = @typeInfo(Limb).Int.bits; + const t_bits = @typeInfo(T).int.bits; + const limb_bits = @typeInfo(Limb).int.bits; if (t_bits <= limb_bits) { return @as(T, @truncate(a.limbs[0])); } else { diff --git a/lib/std/math/copysign.zig b/lib/std/math/copysign.zig index 63daf59047..65144dfe3f 100644 --- a/lib/std/math/copysign.zig +++ b/lib/std/math/copysign.zig @@ -5,7 +5,7 @@ const expect = std.testing.expect; /// Returns a value with the magnitude of `magnitude` and the sign of `sign`. pub fn copysign(magnitude: anytype, sign: @TypeOf(magnitude)) @TypeOf(magnitude) { const T = @TypeOf(magnitude); - const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const sign_bit_mask = @as(TBits, 1) << (@bitSizeOf(T) - 1); const mag = @as(TBits, @bitCast(magnitude)) & ~sign_bit_mask; const sgn = @as(TBits, @bitCast(sign)) & sign_bit_mask; diff --git a/lib/std/math/float.zig b/lib/std/math/float.zig index 1d19fdc57c..a10332f863 100644 --- a/lib/std/math/float.zig +++ b/lib/std/math/float.zig @@ -6,21 +6,21 @@ const expectEqual = std.testing.expectEqual; /// Creates a raw "1.0" mantissa for floating point type T. Used to dedupe f80 logic. inline fn mantissaOne(comptime T: type) comptime_int { - return if (@typeInfo(T).Float.bits == 80) 1 << floatFractionalBits(T) else 0; + return if (@typeInfo(T).float.bits == 80) 1 << floatFractionalBits(T) else 0; } /// Creates floating point type T from an unbiased exponent and raw mantissa. inline fn reconstructFloat(comptime T: type, comptime exponent: comptime_int, comptime mantissa: comptime_int) T { - const TBits = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); + const TBits = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } }); const biased_exponent = @as(TBits, exponent + floatExponentMax(T)); return @as(T, @bitCast((biased_exponent << floatMantissaBits(T)) | @as(TBits, mantissa))); } /// Returns the number of bits in the exponent of floating point type T. pub inline fn floatExponentBits(comptime T: type) comptime_int { - comptime assert(@typeInfo(T) == .Float); + comptime assert(@typeInfo(T) == .float); - return switch (@typeInfo(T).Float.bits) { + return switch (@typeInfo(T).float.bits) { 16 => 5, 32 => 8, 64 => 11, @@ -32,9 +32,9 @@ pub inline fn floatExponentBits(comptime T: type) comptime_int { /// Returns the number of bits in the mantissa of floating point type T. pub inline fn floatMantissaBits(comptime T: type) comptime_int { - comptime assert(@typeInfo(T) == .Float); + comptime assert(@typeInfo(T) == .float); - return switch (@typeInfo(T).Float.bits) { + return switch (@typeInfo(T).float.bits) { 16 => 10, 32 => 23, 64 => 52, @@ -46,12 +46,12 @@ pub inline fn floatMantissaBits(comptime T: type) comptime_int { /// Returns the number of fractional bits in the mantissa of floating point type T. pub inline fn floatFractionalBits(comptime T: type) comptime_int { - comptime assert(@typeInfo(T) == .Float); + comptime assert(@typeInfo(T) == .float); // standard IEEE floats have an implicit 0.m or 1.m integer part // f80 is special and has an explicitly stored bit in the MSB // this function corresponds to `MANT_DIG - 1' from C - return switch (@typeInfo(T).Float.bits) { + return switch (@typeInfo(T).float.bits) { 16 => 10, 32 => 23, 64 => 52, @@ -97,8 +97,8 @@ pub inline fn floatEps(comptime T: type) T { /// Returns the local epsilon of floating point type T. pub inline fn floatEpsAt(comptime T: type, x: T) T { switch (@typeInfo(T)) { - .Float => |F| { - const U: type = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = F.bits } }); + .float => |F| { + const U: type = @Type(.{ .int = .{ .signedness = .unsigned, .bits = F.bits } }); const u: U = @bitCast(x); const y: T = @bitCast(u ^ 1); return @abs(x - y); diff --git a/lib/std/math/frexp.zig b/lib/std/math/frexp.zig index 97b578db98..3fb3406075 100644 --- a/lib/std/math/frexp.zig +++ b/lib/std/math/frexp.zig @@ -21,7 +21,7 @@ pub fn Frexp(comptime T: type) type { pub fn frexp(x: anytype) Frexp(@TypeOf(x)) { const T: type = @TypeOf(x); - const bits: comptime_int = @typeInfo(T).Float.bits; + const bits: comptime_int = @typeInfo(T).float.bits; const Int: type = std.meta.Int(.unsigned, bits); const exp_bits: comptime_int = math.floatExponentBits(T); diff --git a/lib/std/math/gcd.zig b/lib/std/math/gcd.zig index 298bf5fc2b..36ba8e3614 100644 --- a/lib/std/math/gcd.zig +++ b/lib/std/math/gcd.zig @@ -8,8 +8,8 @@ pub fn gcd(a: anytype, b: anytype) @TypeOf(a, b) { // only unsigned integers are allowed and not both must be zero comptime switch (@typeInfo(@TypeOf(a, b))) { - .Int => |int| std.debug.assert(int.signedness == .unsigned), - .ComptimeInt => { + .int => |int| std.debug.assert(int.signedness == .unsigned), + .comptime_int => { std.debug.assert(a >= 0); std.debug.assert(b >= 0); }, diff --git a/lib/std/math/hypot.zig b/lib/std/math/hypot.zig index ddc9408aba..e90b6505ce 100644 --- a/lib/std/math/hypot.zig +++ b/lib/std/math/hypot.zig @@ -23,8 +23,8 @@ const floatMax = math.floatMax; pub fn hypot(x: anytype, y: anytype) @TypeOf(x, y) { const T = @TypeOf(x, y); switch (@typeInfo(T)) { - .Float => {}, - .ComptimeFloat => return @sqrt(x * x + y * y), + .float => {}, + .comptime_float => return @sqrt(x * x + y * y), else => @compileError("hypot not implemented for " ++ @typeName(T)), } const lower = @sqrt(floatMin(T)); diff --git a/lib/std/math/ilogb.zig b/lib/std/math/ilogb.zig index 6f4bb13189..ba6075208d 100644 --- a/lib/std/math/ilogb.zig +++ b/lib/std/math/ilogb.zig @@ -26,7 +26,7 @@ pub const fp_ilogbnan = minInt(i32); pub const fp_ilogb0 = minInt(i32); fn ilogbX(comptime T: type, x: T) i32 { - const typeWidth = @typeInfo(T).Float.bits; + const typeWidth = @typeInfo(T).float.bits; const significandBits = math.floatMantissaBits(T); const exponentBits = math.floatExponentBits(T); diff --git a/lib/std/math/isfinite.zig b/lib/std/math/isfinite.zig index 5d5bfd2a41..8f4e170989 100644 --- a/lib/std/math/isfinite.zig +++ b/lib/std/math/isfinite.zig @@ -5,7 +5,7 @@ const expect = std.testing.expect; /// Returns whether x is a finite value. pub fn isFinite(x: anytype) bool { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const remove_sign = ~@as(TBits, 0) >> 1; return @as(TBits, @bitCast(x)) & remove_sign < @as(TBits, @bitCast(math.inf(T))); } diff --git a/lib/std/math/isinf.zig b/lib/std/math/isinf.zig index 7a2e3943d6..220f43209d 100644 --- a/lib/std/math/isinf.zig +++ b/lib/std/math/isinf.zig @@ -5,7 +5,7 @@ const expect = std.testing.expect; /// Returns whether x is an infinity, ignoring sign. pub inline fn isInf(x: anytype) bool { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const remove_sign = ~@as(TBits, 0) >> 1; return @as(TBits, @bitCast(x)) & remove_sign == @as(TBits, @bitCast(math.inf(T))); } diff --git a/lib/std/math/isnormal.zig b/lib/std/math/isnormal.zig index 1ecaf39330..f3d09441e7 100644 --- a/lib/std/math/isnormal.zig +++ b/lib/std/math/isnormal.zig @@ -5,7 +5,7 @@ const expect = std.testing.expect; /// Returns whether x is neither zero, subnormal, infinity, or NaN. pub fn isNormal(x: anytype) bool { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const increment_exp = 1 << math.floatMantissaBits(T); const remove_sign = ~@as(TBits, 0) >> 1; diff --git a/lib/std/math/iszero.zig b/lib/std/math/iszero.zig index 2d288d01e8..57d8250afd 100644 --- a/lib/std/math/iszero.zig +++ b/lib/std/math/iszero.zig @@ -5,7 +5,7 @@ const expect = std.testing.expect; /// Returns whether x is positive zero. pub inline fn isPositiveZero(x: anytype) bool { const T = @TypeOf(x); - const bit_count = @typeInfo(T).Float.bits; + const bit_count = @typeInfo(T).float.bits; const TBits = std.meta.Int(.unsigned, bit_count); return @as(TBits, @bitCast(x)) == @as(TBits, 0); } @@ -13,7 +13,7 @@ pub inline fn isPositiveZero(x: anytype) bool { /// Returns whether x is negative zero. pub inline fn isNegativeZero(x: anytype) bool { const T = @TypeOf(x); - const bit_count = @typeInfo(T).Float.bits; + const bit_count = @typeInfo(T).float.bits; const TBits = std.meta.Int(.unsigned, bit_count); return @as(TBits, @bitCast(x)) == @as(TBits, 1) << (bit_count - 1); } diff --git a/lib/std/math/ldexp.zig b/lib/std/math/ldexp.zig index c785f719f0..3b982a9bc2 100644 --- a/lib/std/math/ldexp.zig +++ b/lib/std/math/ldexp.zig @@ -7,7 +7,7 @@ const expect = std.testing.expect; /// Returns x * 2^n. pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); const exponent_bits = math.floatExponentBits(T); const mantissa_bits = math.floatMantissaBits(T); diff --git a/lib/std/math/log.zig b/lib/std/math/log.zig index 3ff13a7f19..47846fa688 100644 --- a/lib/std/math/log.zig +++ b/lib/std/math/log.zig @@ -14,26 +14,26 @@ pub fn log(comptime T: type, base: T, x: T) T { return math.log2(x); } else if (base == 10) { return math.log10(x); - } else if ((@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat) and base == math.e) { + } else if ((@typeInfo(T) == .float or @typeInfo(T) == .comptime_float) and base == math.e) { return @log(x); } const float_base = math.lossyCast(f64, base); switch (@typeInfo(T)) { - .ComptimeFloat => { + .comptime_float => { return @as(comptime_float, @log(@as(f64, x)) / @log(float_base)); }, - .ComptimeInt => { + .comptime_int => { return @as(comptime_int, math.log_int(comptime_int, base, x)); }, - .Int => |IntType| switch (IntType.signedness) { + .int => |IntType| switch (IntType.signedness) { .signed => @compileError("log not implemented for signed integers"), .unsigned => return @as(T, math.log_int(T, base, x)), }, - .Float => { + .float => { switch (T) { f32 => return @as(f32, @floatCast(@log(@as(f64, x)) / @log(float_base))), f64 => return @log(x) / @log(float_base), diff --git a/lib/std/math/log10.zig b/lib/std/math/log10.zig index 5b3ee8a840..6f3d9a47f6 100644 --- a/lib/std/math/log10.zig +++ b/lib/std/math/log10.zig @@ -12,14 +12,14 @@ const testing = std.testing; pub fn log10(x: anytype) @TypeOf(x) { const T = @TypeOf(x); switch (@typeInfo(T)) { - .ComptimeFloat => { + .comptime_float => { return @as(comptime_float, @log10(x)); }, - .Float => return @log10(x), - .ComptimeInt => { + .float => return @log10(x), + .comptime_int => { return @as(comptime_int, @floor(@log10(@as(f64, x)))); }, - .Int => |IntType| switch (IntType.signedness) { + .int => |IntType| switch (IntType.signedness) { .signed => @compileError("log10 not implemented for signed integers"), .unsigned => return log10_int(x), }, @@ -37,12 +37,12 @@ pub fn log10(x: anytype) @TypeOf(x) { pub fn log10_int(x: anytype) std.math.Log2Int(@TypeOf(x)) { const T = @TypeOf(x); const OutT = std.math.Log2Int(T); - if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned) + if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned) @compileError("log10_int requires an unsigned integer, found " ++ @typeName(T)); std.debug.assert(x != 0); - const bit_size = @typeInfo(T).Int.bits; + const bit_size = @typeInfo(T).int.bits; if (bit_size <= 8) { return @as(OutT, @intCast(log10_int_u8(x))); diff --git a/lib/std/math/log2.zig b/lib/std/math/log2.zig index 0902f3e10c..01a1bd3856 100644 --- a/lib/std/math/log2.zig +++ b/lib/std/math/log2.zig @@ -13,11 +13,11 @@ const expect = std.testing.expect; pub fn log2(x: anytype) @TypeOf(x) { const T = @TypeOf(x); switch (@typeInfo(T)) { - .ComptimeFloat => { + .comptime_float => { return @as(comptime_float, @log2(x)); }, - .Float => return @log2(x), - .ComptimeInt => comptime { + .float => return @log2(x), + .comptime_int => comptime { var x_shifted = x; // First, calculate floorPowerOfTwo(x) var shift_amt = 1; @@ -34,7 +34,7 @@ pub fn log2(x: anytype) @TypeOf(x) { } return result; }, - .Int => |IntType| switch (IntType.signedness) { + .int => |IntType| switch (IntType.signedness) { .signed => @compileError("log2 not implemented for signed integers"), .unsigned => return math.log2_int(T, x), }, diff --git a/lib/std/math/log_int.zig b/lib/std/math/log_int.zig index edf5c31782..376aa69a4d 100644 --- a/lib/std/math/log_int.zig +++ b/lib/std/math/log_int.zig @@ -8,8 +8,8 @@ const Log2Int = math.Log2Int; /// Asserts that `base > 1` and `x > 0`. pub fn log_int(comptime T: type, base: T, x: T) Log2Int(T) { const valid = switch (@typeInfo(T)) { - .ComptimeInt => true, - .Int => |IntType| IntType.signedness == .unsigned, + .comptime_int => true, + .int => |IntType| IntType.signedness == .unsigned, else => false, }; if (!valid) @compileError("log_int requires an unsigned integer, found " ++ @typeName(T)); @@ -64,9 +64,7 @@ test "log_int" { // Test all unsigned integers with 2, 3, ..., 64 bits. // We cannot test 0 or 1 bits since base must be > 1. inline for (2..64 + 1) |bits| { - const T = @Type(std.builtin.Type{ - .Int = std.builtin.Type.Int{ .signedness = .unsigned, .bits = @intCast(bits) }, - }); + const T = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @intCast(bits) } }); // for base = 2, 3, ..., min(maxInt(T),1024) var base: T = 1; diff --git a/lib/std/math/nextafter.zig b/lib/std/math/nextafter.zig index b88648229b..12418b5a1a 100644 --- a/lib/std/math/nextafter.zig +++ b/lib/std/math/nextafter.zig @@ -14,15 +14,15 @@ const expect = std.testing.expect; /// pub fn nextAfter(comptime T: type, x: T, y: T) T { return switch (@typeInfo(T)) { - .Int, .ComptimeInt => nextAfterInt(T, x, y), - .Float => nextAfterFloat(T, x, y), + .int, .comptime_int => nextAfterInt(T, x, y), + .float => nextAfterFloat(T, x, y), else => @compileError("expected int or non-comptime float, found '" ++ @typeName(T) ++ "'"), }; } fn nextAfterInt(comptime T: type, x: T, y: T) T { - comptime assert(@typeInfo(T) == .Int or @typeInfo(T) == .ComptimeInt); - return if (@typeInfo(T) == .Int and @bitSizeOf(T) < 2) + comptime assert(@typeInfo(T) == .int or @typeInfo(T) == .comptime_int); + return if (@typeInfo(T) == .int and @bitSizeOf(T) < 2) // Special case for `i0`, `u0`, `i1`, and `u1`. y else if (y > x) @@ -38,7 +38,7 @@ fn nextAfterInt(comptime T: type, x: T, y: T) T { // <https://github.com/mingw-w64/mingw-w64/blob/e89de847dd3e05bb8e46344378ce3e124f4e7d1c/mingw-w64-crt/math/nextafterl.c> fn nextAfterFloat(comptime T: type, x: T, y: T) T { - comptime assert(@typeInfo(T) == .Float); + comptime assert(@typeInfo(T) == .float); if (x == y) { // Returning `y` ensures that (0.0, -0.0) returns -0.0 and that (-0.0, 0.0) returns 0.0. return y; @@ -320,7 +320,7 @@ test "float" { /// Helps ensure that 0.0 doesn't compare equal to -0.0. fn bitwiseEqual(comptime T: type, x: T, y: T) bool { - comptime assert(@typeInfo(T) == .Float); + comptime assert(@typeInfo(T) == .float); const Bits = std.meta.Int(.unsigned, @bitSizeOf(T)); return @as(Bits, @bitCast(x)) == @as(Bits, @bitCast(y)); } diff --git a/lib/std/math/pow.zig b/lib/std/math/pow.zig index 2e50cc16dd..7409561e1f 100644 --- a/lib/std/math/pow.zig +++ b/lib/std/math/pow.zig @@ -31,7 +31,7 @@ const expect = std.testing.expect; /// - pow(-inf, y) = pow(-0, -y) /// - pow(x, y) = nan for finite x < 0 and finite non-integer y pub fn pow(comptime T: type, x: T, y: T) T { - if (@typeInfo(T) == .Int) { + if (@typeInfo(T) == .int) { return math.powi(T, x, y) catch unreachable; } @@ -122,7 +122,7 @@ pub fn pow(comptime T: type, x: T, y: T) T { if (yf != 0 and x < 0) { return math.nan(T); } - if (yi >= 1 << (@typeInfo(T).Float.bits - 1)) { + if (yi >= 1 << (@typeInfo(T).float.bits - 1)) { return @exp(y * @log(x)); } @@ -144,7 +144,7 @@ pub fn pow(comptime T: type, x: T, y: T) T { var xe = r2.exponent; var x1 = r2.significand; - var i = @as(std.meta.Int(.signed, @typeInfo(T).Float.bits), @intFromFloat(yi)); + var i = @as(std.meta.Int(.signed, @typeInfo(T).float.bits), @intFromFloat(yi)); while (i != 0) : (i >>= 1) { const overflow_shift = math.floatExponentBits(T) + 1; if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) { diff --git a/lib/std/math/powi.zig b/lib/std/math/powi.zig index 271d24352a..aed79e097c 100644 --- a/lib/std/math/powi.zig +++ b/lib/std/math/powi.zig @@ -27,7 +27,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{ Overflow, Underflow, }!T) { - const bit_size = @typeInfo(T).Int.bits; + const bit_size = @typeInfo(T).int.bits; // `y & 1 == 0` won't compile when `does_one_overflow`. const does_one_overflow = math.maxInt(T) < 1; diff --git a/lib/std/math/signbit.zig b/lib/std/math/signbit.zig index eeb729ceb7..97dd03613a 100644 --- a/lib/std/math/signbit.zig +++ b/lib/std/math/signbit.zig @@ -5,7 +5,7 @@ const expect = std.testing.expect; /// Returns whether x is negative or negative 0. pub fn signbit(x: anytype) bool { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); + const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits); return @as(TBits, @bitCast(x)) >> (@bitSizeOf(T) - 1) != 0; } diff --git a/lib/std/math/sqrt.zig b/lib/std/math/sqrt.zig index a000911897..0753277bb7 100644 --- a/lib/std/math/sqrt.zig +++ b/lib/std/math/sqrt.zig @@ -15,8 +15,8 @@ const maxInt = std.math.maxInt; pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) { const T = @TypeOf(x); switch (@typeInfo(T)) { - .Float, .ComptimeFloat => return @sqrt(x), - .ComptimeInt => comptime { + .float, .comptime_float => return @sqrt(x), + .comptime_int => comptime { if (x > maxInt(u128)) { @compileError("sqrt not implemented for comptime_int greater than 128 bits"); } @@ -25,7 +25,7 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) { } return @as(T, sqrt_int(u128, x)); }, - .Int => |IntType| switch (IntType.signedness) { + .int => |IntType| switch (IntType.signedness) { .signed => @compileError("sqrt not implemented for signed integers"), .unsigned => return sqrt_int(T, x), }, @@ -34,10 +34,10 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) { } fn sqrt_int(comptime T: type, value: T) Sqrt(T) { - if (@typeInfo(T).Int.bits <= 2) { + if (@typeInfo(T).int.bits <= 2) { return if (value == 0) 0 else 1; // shortcut for small number of bits to simplify general case } else { - const bits = @typeInfo(T).Int.bits; + const bits = @typeInfo(T).int.bits; const max = math.maxInt(T); const minustwo = (@as(T, 2) ^ max) + 1; // unsigned int cannot represent -2 var op = value; @@ -80,7 +80,7 @@ test sqrt_int { /// Returns the return type `sqrt` will return given an operand of type `T`. pub fn Sqrt(comptime T: type) type { return switch (@typeInfo(T)) { - .Int => |int| std.meta.Int(.unsigned, (int.bits + 1) / 2), + .int => |int| @Type(.{ .int = .{ .signedness = .unsigned, .bits = (int.bits + 1) / 2 } }), else => T, }; } diff --git a/lib/std/mem.zig b/lib/std/mem.zig index c2c168a2ae..b4580b1aa4 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -229,22 +229,22 @@ pub fn copyBackwards(comptime T: type, dest: []T, source: []const T) void { /// This can be used to zero-initialize any type for which it makes sense. Structs will be initialized recursively. pub fn zeroes(comptime T: type) T { switch (@typeInfo(T)) { - .ComptimeInt, .Int, .ComptimeFloat, .Float => { + .comptime_int, .int, .comptime_float, .float => { return @as(T, 0); }, - .Enum => { + .@"enum" => { return @as(T, @enumFromInt(0)); }, - .Void => { + .void => { return {}; }, - .Bool => { + .bool => { return false; }, - .Optional, .Null => { + .optional, .null => { return null; }, - .Struct => |struct_info| { + .@"struct" => |struct_info| { if (@sizeOf(T) == 0) return undefined; if (struct_info.layout == .@"extern") { var item: T = undefined; @@ -260,7 +260,7 @@ pub fn zeroes(comptime T: type) T { return structure; } }, - .Pointer => |ptr_info| { + .pointer => |ptr_info| { switch (ptr_info.size) { .Slice => { if (ptr_info.sentinel) |sentinel| { @@ -281,17 +281,17 @@ pub fn zeroes(comptime T: type) T { }, } }, - .Array => |info| { + .array => |info| { if (info.sentinel) |sentinel_ptr| { const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; return [_:sentinel]info.child{zeroes(info.child)} ** info.len; } return [_]info.child{zeroes(info.child)} ** info.len; }, - .Vector => |info| { + .vector => |info| { return @splat(zeroes(info.child)); }, - .Union => |info| { + .@"union" => |info| { if (info.layout == .@"extern") { var item: T = undefined; @memset(asBytes(&item), 0); @@ -299,16 +299,16 @@ pub fn zeroes(comptime T: type) T { } @compileError("Can't set a " ++ @typeName(T) ++ " to zero."); }, - .EnumLiteral, - .ErrorUnion, - .ErrorSet, - .Fn, - .Type, - .NoReturn, - .Undefined, - .Opaque, - .Frame, - .AnyFrame, + .enum_literal, + .error_union, + .error_set, + .@"fn", + .type, + .noreturn, + .undefined, + .@"opaque", + .frame, + .@"anyframe", => { @compileError("Can't set a " ++ @typeName(T) ++ " to zero."); }, @@ -423,9 +423,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T { const Init = @TypeOf(init); switch (@typeInfo(T)) { - .Struct => |struct_info| { + .@"struct" => |struct_info| { switch (@typeInfo(Init)) { - .Struct => |init_info| { + .@"struct" => |init_info| { if (init_info.is_tuple) { if (init_info.fields.len > struct_info.fields.len) { @compileError("Tuple initializer has more elements than there are fields in `" ++ @typeName(T) ++ "`"); @@ -449,7 +449,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { @field(value, field.name) = @field(init, init_info.fields[i].name); } else if (@hasField(@TypeOf(init), field.name)) { switch (@typeInfo(field.type)) { - .Struct => { + .@"struct" => { @field(value, field.name) = zeroInit(field.type, @field(init, field.name)); }, else => { @@ -461,7 +461,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { @field(value, field.name) = default_value; } else { switch (@typeInfo(field.type)) { - .Struct => { + .@"struct" => { @field(value, field.name) = std.mem.zeroInit(field.type, .{}); }, else => { @@ -752,10 +752,10 @@ test indexOfDiff { /// `[*c]` pointers are assumed to be 0-terminated and assumed to not be allowzero. fn Span(comptime T: type) type { switch (@typeInfo(T)) { - .Optional => |optional_info| { + .optional => |optional_info| { return ?Span(optional_info.child); }, - .Pointer => |ptr_info| { + .pointer => |ptr_info| { var new_ptr_info = ptr_info; switch (ptr_info.size) { .C => { @@ -766,7 +766,7 @@ fn Span(comptime T: type) type { .One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)), } new_ptr_info.size = .Slice; - return @Type(.{ .Pointer = new_ptr_info }); + return @Type(.{ .pointer = new_ptr_info }); }, else => {}, } @@ -789,7 +789,7 @@ test Span { /// Pointer attributes such as const are preserved. /// `[*c]` pointers are assumed to be non-null and 0-terminated. pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { - if (@typeInfo(@TypeOf(ptr)) == .Optional) { + if (@typeInfo(@TypeOf(ptr)) == .optional) { if (ptr) |non_null| { return span(non_null); } else { @@ -798,7 +798,7 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { } const Result = Span(@TypeOf(ptr)); const l = len(ptr); - const ptr_info = @typeInfo(Result).Pointer; + const ptr_info = @typeInfo(Result).pointer; if (ptr_info.sentinel) |s_ptr| { const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*; return ptr[0..l :s]; @@ -817,15 +817,15 @@ test span { /// Helper for the return type of sliceTo() fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type { switch (@typeInfo(T)) { - .Optional => |optional_info| { + .optional => |optional_info| { return ?SliceTo(optional_info.child, end); }, - .Pointer => |ptr_info| { + .pointer => |ptr_info| { var new_ptr_info = ptr_info; new_ptr_info.size = .Slice; switch (ptr_info.size) { .One => switch (@typeInfo(ptr_info.child)) { - .Array => |array_info| { + .array => |array_info| { new_ptr_info.child = array_info.child; // The return type must only be sentinel terminated if we are guaranteed // to find the value searched for, which is only the case if it matches @@ -861,7 +861,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type { new_ptr_info.is_allowzero = false; }, } - return @Type(.{ .Pointer = new_ptr_info }); + return @Type(.{ .pointer = new_ptr_info }); }, else => {}, } @@ -876,13 +876,13 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type { /// Pointer properties such as mutability and alignment are preserved. /// C pointers are assumed to be non-null. pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo(@TypeOf(ptr), end) { - if (@typeInfo(@TypeOf(ptr)) == .Optional) { + if (@typeInfo(@TypeOf(ptr)) == .optional) { const non_null = ptr orelse return null; return sliceTo(non_null, end); } const Result = SliceTo(@TypeOf(ptr), end); const length = lenSliceTo(ptr, end); - const ptr_info = @typeInfo(Result).Pointer; + const ptr_info = @typeInfo(Result).pointer; if (ptr_info.sentinel) |s_ptr| { const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*; return ptr[0..length :s]; @@ -933,9 +933,9 @@ test sliceTo { /// Private helper for sliceTo(). If you want the length, use sliceTo(foo, x).len fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize { switch (@typeInfo(@TypeOf(ptr))) { - .Pointer => |ptr_info| switch (ptr_info.size) { + .pointer => |ptr_info| switch (ptr_info.size) { .One => switch (@typeInfo(ptr_info.child)) { - .Array => |array_info| { + .array => |array_info| { if (array_info.sentinel) |sentinel_ptr| { const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; if (sentinel == end) { @@ -1015,7 +1015,7 @@ test lenSliceTo { /// `[*c]` pointers are assumed to be non-null and 0-terminated. pub fn len(value: anytype) usize { switch (@typeInfo(@TypeOf(value))) { - .Pointer => |info| switch (info.size) { + .pointer => |info| switch (info.size) { .Many => { const sentinel_ptr = info.sentinel orelse @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value))); @@ -1051,7 +1051,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co if (backend_supports_vectors and !std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/17717 !@inComptime() and - (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T))) + (@typeInfo(T) == .int or @typeInfo(T) == .float) and std.math.isPowerOfTwo(@bitSizeOf(T))) { switch (@import("builtin").cpu.arch) { // The below branch assumes that reading past the end of the buffer is valid, as long @@ -1202,7 +1202,7 @@ pub fn indexOfScalarPos(comptime T: type, slice: []const T, start_index: usize, if (backend_supports_vectors and !std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/17717 !@inComptime() and - (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T))) + (@typeInfo(T) == .int or @typeInfo(T) == .float) and std.math.isPowerOfTwo(@bitSizeOf(T))) { if (std.simd.suggestVectorLength(T)) |block_len| { // For Intel Nehalem (2009) and AMD Bulldozer (2012) or later, unaligned loads on aligned data result @@ -1602,8 +1602,8 @@ test containsAtLeast { /// T specifies the return type, which must be large enough to store /// the result. pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType { - const bits = @typeInfo(ReturnType).Int.bits; - const signedness = @typeInfo(ReturnType).Int.signedness; + const bits = @typeInfo(ReturnType).int.bits; + const signedness = @typeInfo(ReturnType).int.signedness; const WorkType = std.meta.Int(signedness, @max(16, bits)); var result: WorkType = 0; switch (endian) { @@ -1635,7 +1635,7 @@ test readVarInt { try testing.expect(readVarInt(i16, &[_]u8{ 0xff, 0xfd }, .big) == -3); try testing.expect(readVarInt(i16, &[_]u8{ 0xfc, 0xff }, .little) == -4); - // Return type can be oversized (bytes.len * 8 < @typeInfo(ReturnType).Int.bits) + // Return type can be oversized (bytes.len * 8 < @typeInfo(ReturnType).int.bits) try testing.expect(readVarInt(u9, &[_]u8{0x12}, .little) == 0x12); try testing.expect(readVarInt(u9, &[_]u8{0xde}, .big) == 0xde); try testing.expect(readVarInt(u80, &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }, .big) == 0x123456789abcdef024); @@ -1719,7 +1719,7 @@ test readVarPackedInt { /// Reads an integer from memory with bit count specified by T. /// The bit count of T must be evenly divisible by 8. /// This function cannot fail and cannot cause undefined behavior. -pub inline fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).Int.bits, 8)]u8, endian: Endian) T { +pub inline fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).int.bits, 8)]u8, endian: Endian) T { const value: T = @bitCast(buffer.*); return if (endian == native_endian) value else @byteSwap(value); } @@ -1844,7 +1844,7 @@ test "comptime read/write int" { /// Writes an integer to memory, storing it in twos-complement. /// This function always succeeds, has defined behavior for all inputs, but /// the integer bit width must be divisible by 8. -pub inline fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).Int.bits, 8)]u8, value: T, endian: Endian) void { +pub inline fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).int.bits, 8)]u8, value: T, endian: Endian) void { buffer.* = @bitCast(if (endian == native_endian) value else @byteSwap(value)); } @@ -2047,20 +2047,20 @@ test writeVarPackedInt { /// (Changing their endianness) pub fn byteSwapAllFields(comptime S: type, ptr: *S) void { switch (@typeInfo(S)) { - .Struct => { + .@"struct" => { inline for (std.meta.fields(S)) |f| { switch (@typeInfo(f.type)) { - .Struct => |struct_info| if (struct_info.backing_integer) |Int| { + .@"struct" => |struct_info| if (struct_info.backing_integer) |Int| { @field(ptr, f.name) = @bitCast(@byteSwap(@as(Int, @bitCast(@field(ptr, f.name))))); } else { byteSwapAllFields(f.type, &@field(ptr, f.name)); }, - .Array => byteSwapAllFields(f.type, &@field(ptr, f.name)), - .Enum => { + .array => byteSwapAllFields(f.type, &@field(ptr, f.name)), + .@"enum" => { @field(ptr, f.name) = @enumFromInt(@byteSwap(@intFromEnum(@field(ptr, f.name)))); }, - .Bool => {}, - .Float => |float_info| { + .bool => {}, + .float => |float_info| { @field(ptr, f.name) = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(@field(ptr, f.name))))); }, else => { @@ -2069,15 +2069,15 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void { } } }, - .Array => { + .array => { for (ptr) |*item| { switch (@typeInfo(@TypeOf(item.*))) { - .Struct, .Array => byteSwapAllFields(@TypeOf(item.*), item), - .Enum => { + .@"struct", .array => byteSwapAllFields(@TypeOf(item.*), item), + .@"enum" => { item.* = @enumFromInt(@byteSwap(@intFromEnum(item.*))); }, - .Bool => {}, - .Float => |float_info| { + .bool => {}, + .float => |float_info| { item.* = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(item.*)))); }, else => { @@ -3560,21 +3560,21 @@ test reverse { fn ReverseIterator(comptime T: type) type { const Pointer = blk: { switch (@typeInfo(T)) { - .Pointer => |ptr_info| switch (ptr_info.size) { + .pointer => |ptr_info| switch (ptr_info.size) { .One => switch (@typeInfo(ptr_info.child)) { - .Array => |array_info| { + .array => |array_info| { var new_ptr_info = ptr_info; new_ptr_info.size = .Many; new_ptr_info.child = array_info.child; new_ptr_info.sentinel = array_info.sentinel; - break :blk @Type(.{ .Pointer = new_ptr_info }); + break :blk @Type(.{ .pointer = new_ptr_info }); }, else => {}, }, .Slice => { var new_ptr_info = ptr_info; new_ptr_info.size = .Many; - break :blk @Type(.{ .Pointer = new_ptr_info }); + break :blk @Type(.{ .pointer = new_ptr_info }); }, else => {}, }, @@ -3583,8 +3583,8 @@ fn ReverseIterator(comptime T: type) type { @compileError("expected slice or pointer to array, found '" ++ @typeName(T) ++ "'"); }; const Element = std.meta.Elem(Pointer); - const ElementPointer = @Type(.{ .Pointer = ptr: { - var ptr = @typeInfo(Pointer).Pointer; + const ElementPointer = @Type(.{ .pointer = ptr: { + var ptr = @typeInfo(Pointer).pointer; ptr.size = .One; ptr.child = Element; ptr.sentinel = null; @@ -3891,11 +3891,11 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { const T = @TypeOf(ptr); const info = @typeInfo(T); - if (info != .Pointer or info.Pointer.size != .Many) + if (info != .pointer or info.pointer.size != .Many) @compileError("expected many item pointer, got " ++ @typeName(T)); // Do nothing if the pointer is already well-aligned. - if (align_to <= info.Pointer.alignment) + if (align_to <= info.pointer.alignment) return 0; // Calculate the aligned base address with an eye out for overflow. @@ -3907,7 +3907,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { // The delta is expressed in terms of bytes, turn it into a number of child // type elements. const delta = ov[0] - addr; - const pointee_size = @sizeOf(info.Pointer.child); + const pointee_size = @sizeOf(info.pointer.child); if (delta % pointee_size != 0) return null; return delta / pointee_size; } @@ -3948,9 +3948,9 @@ fn CopyPtrAttrs( comptime size: std.builtin.Type.Pointer.Size, comptime child: type, ) type { - const info = @typeInfo(source).Pointer; + const info = @typeInfo(source).pointer; return @Type(.{ - .Pointer = .{ + .pointer = .{ .size = size, .is_const = info.is_const, .is_volatile = info.is_volatile, @@ -4019,8 +4019,8 @@ test "asBytes preserves pointer attributes" { const inPtr = @as(*align(16) const volatile u32, @ptrCast(&inArr)); const outSlice = asBytes(inPtr); - const in = @typeInfo(@TypeOf(inPtr)).Pointer; - const out = @typeInfo(@TypeOf(outSlice)).Pointer; + const in = @typeInfo(@TypeOf(inPtr)).pointer; + const out = @typeInfo(@TypeOf(outSlice)).pointer; try testing.expectEqual(in.is_const, out.is_const); try testing.expectEqual(in.is_volatile, out.is_volatile); @@ -4102,8 +4102,8 @@ test "bytesAsValue preserves pointer attributes" { const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..]; const outPtr = bytesAsValue(u32, inSlice); - const in = @typeInfo(@TypeOf(inSlice)).Pointer; - const out = @typeInfo(@TypeOf(outPtr)).Pointer; + const in = @typeInfo(@TypeOf(inSlice)).pointer; + const out = @typeInfo(@TypeOf(outPtr)).pointer; try testing.expectEqual(in.is_const, out.is_const); try testing.expectEqual(in.is_volatile, out.is_volatile); @@ -4204,8 +4204,8 @@ test "bytesAsSlice preserves pointer attributes" { const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..]; const outSlice = bytesAsSlice(u16, inSlice); - const in = @typeInfo(@TypeOf(inSlice)).Pointer; - const out = @typeInfo(@TypeOf(outSlice)).Pointer; + const in = @typeInfo(@TypeOf(inSlice)).pointer; + const out = @typeInfo(@TypeOf(outSlice)).pointer; try testing.expectEqual(in.is_const, out.is_const); try testing.expectEqual(in.is_volatile, out.is_volatile); @@ -4303,8 +4303,8 @@ test "sliceAsBytes preserves pointer attributes" { const inSlice = @as(*align(16) const volatile [2]u16, @ptrCast(&inArr))[0..]; const outSlice = sliceAsBytes(inSlice); - const in = @typeInfo(@TypeOf(inSlice)).Pointer; - const out = @typeInfo(@TypeOf(outSlice)).Pointer; + const in = @typeInfo(@TypeOf(inSlice)).pointer; + const out = @typeInfo(@TypeOf(outSlice)).pointer; try testing.expectEqual(in.is_const, out.is_const); try testing.expectEqual(in.is_volatile, out.is_volatile); @@ -4346,14 +4346,14 @@ pub fn doNotOptimizeAway(val: anytype) void { const max_gp_register_bits = @bitSizeOf(c_long); const t = @typeInfo(@TypeOf(val)); switch (t) { - .Void, .Null, .ComptimeInt, .ComptimeFloat => return, - .Enum => doNotOptimizeAway(@intFromEnum(val)), - .Bool => doNotOptimizeAway(@intFromBool(val)), - .Int => { - const bits = t.Int.bits; + .void, .null, .comptime_int, .comptime_float => return, + .@"enum" => doNotOptimizeAway(@intFromEnum(val)), + .bool => doNotOptimizeAway(@intFromBool(val)), + .int => { + const bits = t.int.bits; if (bits <= max_gp_register_bits and builtin.zig_backend != .stage2_c) { const val2 = @as( - std.meta.Int(t.Int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))), + std.meta.Int(t.int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))), val, ); asm volatile ("" @@ -4362,15 +4362,15 @@ pub fn doNotOptimizeAway(val: anytype) void { ); } else doNotOptimizeAway(&val); }, - .Float => { - if ((t.Float.bits == 32 or t.Float.bits == 64) and builtin.zig_backend != .stage2_c) { + .float => { + if ((t.float.bits == 32 or t.float.bits == 64) and builtin.zig_backend != .stage2_c) { asm volatile ("" : : [val] "rm" (val), ); } else doNotOptimizeAway(&val); }, - .Pointer => { + .pointer => { if (builtin.zig_backend == .stage2_c) { doNotOptimizeAwayC(val); } else { @@ -4381,8 +4381,8 @@ pub fn doNotOptimizeAway(val: anytype) void { ); } }, - .Array => { - if (t.Array.len * @sizeOf(t.Array.child) <= 64) { + .array => { + if (t.array.len * @sizeOf(t.array.child) <= 64) { for (val) |v| doNotOptimizeAway(v); } else doNotOptimizeAway(&val); }, @@ -4518,9 +4518,9 @@ test "freeing empty string with null-terminated sentinel" { /// Returns a slice with the given new alignment, /// all other pointer attributes copied from `AttributeSource`. fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) type { - const info = @typeInfo(AttributeSource).Pointer; + const info = @typeInfo(AttributeSource).pointer; return @Type(.{ - .Pointer = .{ + .pointer = .{ .size = .Slice, .is_const = info.is_const, .is_volatile = info.is_volatile, @@ -4659,7 +4659,7 @@ test "read/write(Var)PackedInt" { try expect(diff_bits << @as(Log2T, @intCast(@bitSizeOf(BackingType) - offset)) == 0); } - const signedness = @typeInfo(PackedType).Int.signedness; + const signedness = @typeInfo(PackedType).int.signedness; const NextPowerOfTwoInt = std.meta.Int(signedness, try comptime std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType))); const ui64 = std.meta.Int(signedness, 64); inline for ([_]type{ PackedType, NextPowerOfTwoInt, ui64 }) |U| { diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index 1cd6285355..0d4ab9141f 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -109,7 +109,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T { /// `ptr` should be the return value of `create`, or otherwise /// have the same address and alignment property. pub fn destroy(self: Allocator, ptr: anytype) void { - const info = @typeInfo(@TypeOf(ptr)).Pointer; + const info = @typeInfo(@TypeOf(ptr)).pointer; if (info.size != .One) @compileError("ptr must be a single item pointer"); const T = info.child; if (@sizeOf(T) == 0) return; @@ -232,7 +232,7 @@ fn allocBytesWithAlignment(self: Allocator, comptime alignment: u29, byte_count: /// the pointer, however the allocator implementation may refuse the resize /// request by returning `false`. pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool { - const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; + const Slice = @typeInfo(@TypeOf(old_mem)).pointer; const T = Slice.child; if (new_n == 0) { self.free(old_mem); @@ -253,7 +253,7 @@ pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool { /// can be larger, smaller, or the same size as the old memory allocation. /// If `new_n` is 0, this is the same as `free` and it always succeeds. pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) t: { - const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; + const Slice = @typeInfo(@TypeOf(old_mem)).pointer; break :t Error![]align(Slice.alignment) Slice.child; } { return self.reallocAdvanced(old_mem, new_n, @returnAddress()); @@ -265,10 +265,10 @@ pub fn reallocAdvanced( new_n: usize, return_address: usize, ) t: { - const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; + const Slice = @typeInfo(@TypeOf(old_mem)).pointer; break :t Error![]align(Slice.alignment) Slice.child; } { - const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; + const Slice = @typeInfo(@TypeOf(old_mem)).pointer; const T = Slice.child; if (old_mem.len == 0) { return self.allocAdvancedWithRetAddr(T, Slice.alignment, new_n, return_address); @@ -304,7 +304,7 @@ pub fn reallocAdvanced( /// Free an array allocated with `alloc`. To free a single item, /// see `destroy`. pub fn free(self: Allocator, memory: anytype) void { - const Slice = @typeInfo(@TypeOf(memory)).Pointer; + const Slice = @typeInfo(@TypeOf(memory)).pointer; const bytes = mem.sliceAsBytes(memory); const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; if (bytes_len == 0) return; @@ -332,13 +332,13 @@ pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T { /// TODO replace callsites with `@log2` after this proposal is implemented: /// https://github.com/ziglang/zig/issues/13642 inline fn log2a(x: anytype) switch (@typeInfo(@TypeOf(x))) { - .Int => math.Log2Int(@TypeOf(x)), - .ComptimeInt => comptime_int, + .int => math.Log2Int(@TypeOf(x)), + .comptime_int => comptime_int, else => @compileError("int please"), } { switch (@typeInfo(@TypeOf(x))) { - .Int => return math.log2_int(@TypeOf(x), x), - .ComptimeInt => return math.log2(x), + .int => return math.log2_int(@TypeOf(x), x), + .comptime_int => return math.log2(x), else => @compileError("bad"), } } diff --git a/lib/std/meta.zig b/lib/std/meta.zig index a06674f086..e7ea5b5f0e 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -21,11 +21,11 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T { // TODO The '100' here is arbitrary and should be increased when possible: // - https://github.com/ziglang/zig/issues/4055 // - https://github.com/ziglang/zig/issues/3863 - if (@typeInfo(T).Enum.fields.len <= 100) { + if (@typeInfo(T).@"enum".fields.len <= 100) { const kvs = comptime build_kvs: { const EnumKV = struct { []const u8, T }; - var kvs_array: [@typeInfo(T).Enum.fields.len]EnumKV = undefined; - for (@typeInfo(T).Enum.fields, 0..) |enumField, i| { + var kvs_array: [@typeInfo(T).@"enum".fields.len]EnumKV = undefined; + for (@typeInfo(T).@"enum".fields, 0..) |enumField, i| { kvs_array[i] = .{ enumField.name, @field(T, enumField.name) }; } break :build_kvs kvs_array[0..]; @@ -33,7 +33,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T { const map = std.StaticStringMap(T).initComptime(kvs); return map.get(str); } else { - inline for (@typeInfo(T).Enum.fields) |enumField| { + inline for (@typeInfo(T).@"enum".fields) |enumField| { if (mem.eql(u8, str, enumField.name)) { return @field(T, enumField.name); } @@ -58,11 +58,11 @@ test stringToEnum { /// If T is a pointer type the alignment of the type it points to is returned. pub fn alignment(comptime T: type) comptime_int { return switch (@typeInfo(T)) { - .Optional => |info| switch (@typeInfo(info.child)) { - .Pointer, .Fn => alignment(info.child), + .optional => |info| switch (@typeInfo(info.child)) { + .pointer, .@"fn" => alignment(info.child), else => @alignOf(T), }, - .Pointer => |info| info.alignment, + .pointer => |info| info.alignment, else => @alignOf(T), }; } @@ -81,10 +81,10 @@ test alignment { /// Given a parameterized type (array, vector, pointer, optional), returns the "child type". pub fn Child(comptime T: type) type { return switch (@typeInfo(T)) { - .Array => |info| info.child, - .Vector => |info| info.child, - .Pointer => |info| info.child, - .Optional => |info| info.child, + .array => |info| info.child, + .vector => |info| info.child, + .pointer => |info| info.child, + .optional => |info| info.child, else => @compileError("Expected pointer, optional, array or vector type, found '" ++ @typeName(T) ++ "'"), }; } @@ -100,17 +100,17 @@ test Child { /// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type". pub fn Elem(comptime T: type) type { switch (@typeInfo(T)) { - .Array => |info| return info.child, - .Vector => |info| return info.child, - .Pointer => |info| switch (info.size) { + .array => |info| return info.child, + .vector => |info| return info.child, + .pointer => |info| switch (info.size) { .One => switch (@typeInfo(info.child)) { - .Array => |array_info| return array_info.child, - .Vector => |vector_info| return vector_info.child, + .array => |array_info| return array_info.child, + .vector => |vector_info| return vector_info.child, else => {}, }, .Many, .C, .Slice => return info.child, }, - .Optional => |info| return Elem(info.child), + .optional => |info| return Elem(info.child), else => {}, } @compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'"); @@ -132,18 +132,18 @@ test Elem { /// Result is always comptime-known. pub inline fn sentinel(comptime T: type) ?Elem(T) { switch (@typeInfo(T)) { - .Array => |info| { + .array => |info| { const sentinel_ptr = info.sentinel orelse return null; return @as(*const info.child, @ptrCast(sentinel_ptr)).*; }, - .Pointer => |info| { + .pointer => |info| { switch (info.size) { .Many, .Slice => { const sentinel_ptr = info.sentinel orelse return null; return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; }, .One => switch (@typeInfo(info.child)) { - .Array => |array_info| { + .array => |array_info| { const sentinel_ptr = array_info.sentinel orelse return null; return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; }, @@ -177,17 +177,17 @@ fn testSentinel() !void { /// Given a "memory span" type, returns the same type except with the given sentinel value. pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { switch (@typeInfo(T)) { - .Pointer => |info| switch (info.size) { + .pointer => |info| switch (info.size) { .One => switch (@typeInfo(info.child)) { - .Array => |array_info| return @Type(.{ - .Pointer = .{ + .array => |array_info| return @Type(.{ + .pointer = .{ .size = info.size, .is_const = info.is_const, .is_volatile = info.is_volatile, .alignment = info.alignment, .address_space = info.address_space, .child = @Type(.{ - .Array = .{ + .array = .{ .len = array_info.len, .child = array_info.child, .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)), @@ -200,7 +200,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { else => {}, }, .Many, .Slice => return @Type(.{ - .Pointer = .{ + .pointer = .{ .size = info.size, .is_const = info.is_const, .is_volatile = info.is_volatile, @@ -213,12 +213,12 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type { }), else => {}, }, - .Optional => |info| switch (@typeInfo(info.child)) { - .Pointer => |ptr_info| switch (ptr_info.size) { + .optional => |info| switch (@typeInfo(info.child)) { + .pointer => |ptr_info| switch (ptr_info.size) { .Many => return @Type(.{ - .Optional = .{ + .optional = .{ .child = @Type(.{ - .Pointer = .{ + .pointer = .{ .size = ptr_info.size, .is_const = ptr_info.is_const, .is_volatile = ptr_info.is_volatile, @@ -244,8 +244,8 @@ pub const assumeSentinel = @compileError("This function has been removed, consid pub fn containerLayout(comptime T: type) Type.ContainerLayout { return switch (@typeInfo(T)) { - .Struct => |info| info.layout, - .Union => |info| info.layout, + .@"struct" => |info| info.layout, + .@"union" => |info| info.layout, else => @compileError("expected struct or union type, found '" ++ @typeName(T) ++ "'"), }; } @@ -276,10 +276,10 @@ test containerLayout { /// directly when you know what kind of type it is. pub fn declarations(comptime T: type) []const Type.Declaration { return switch (@typeInfo(T)) { - .Struct => |info| info.decls, - .Enum => |info| info.decls, - .Union => |info| info.decls, - .Opaque => |info| info.decls, + .@"struct" => |info| info.decls, + .@"enum" => |info| info.decls, + .@"union" => |info| info.decls, + .@"opaque" => |info| info.decls, else => @compileError("Expected struct, enum, union, or opaque type, found '" ++ @typeName(T) ++ "'"), }; } @@ -294,7 +294,7 @@ test declarations { pub fn a() void {} }; const U1 = union { - a: u8, + b: u8, pub fn a() void {} }; @@ -334,7 +334,7 @@ test declarationInfo { pub fn a() void {} }; const U1 = union { - a: u8, + b: u8, pub fn a() void {} }; @@ -350,17 +350,17 @@ test declarationInfo { } } pub fn fields(comptime T: type) switch (@typeInfo(T)) { - .Struct => []const Type.StructField, - .Union => []const Type.UnionField, - .ErrorSet => []const Type.Error, - .Enum => []const Type.EnumField, + .@"struct" => []const Type.StructField, + .@"union" => []const Type.UnionField, + .@"enum" => []const Type.EnumField, + .error_set => []const Type.Error, else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"), } { return switch (@typeInfo(T)) { - .Struct => |info| info.fields, - .Union => |info| info.fields, - .Enum => |info| info.fields, - .ErrorSet => |errors| errors.?, // must be non global error set + .@"struct" => |info| info.fields, + .@"union" => |info| info.fields, + .@"enum" => |info| info.fields, + .error_set => |errors| errors.?, // must be non global error set else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"), }; } @@ -395,10 +395,10 @@ test fields { } pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) { - .Struct => Type.StructField, - .Union => Type.UnionField, - .ErrorSet => Type.Error, - .Enum => Type.EnumField, + .@"struct" => Type.StructField, + .@"union" => Type.UnionField, + .@"enum" => Type.EnumField, + .error_set => Type.Error, else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"), } { return fields(T)[@intFromEnum(field)]; @@ -430,7 +430,7 @@ test fieldInfo { } pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type { - if (@typeInfo(T) != .Struct and @typeInfo(T) != .Union) { + if (@typeInfo(T) != .@"struct" and @typeInfo(T) != .@"union") { @compileError("Expected struct or union, found '" ++ @typeName(T) ++ "'"); } @@ -528,7 +528,7 @@ pub fn FieldEnum(comptime T: type) type { if (field_infos.len == 0) { return @Type(.{ - .Enum = .{ + .@"enum" = .{ .tag_type = u0, .fields = &.{}, .decls = &.{}, @@ -537,8 +537,8 @@ pub fn FieldEnum(comptime T: type) type { }); } - if (@typeInfo(T) == .Union) { - if (@typeInfo(T).Union.tag_type) |tag_type| { + if (@typeInfo(T) == .@"union") { + if (@typeInfo(T).@"union".tag_type) |tag_type| { for (std.enums.values(tag_type), 0..) |v, i| { if (@intFromEnum(v) != i) break; // enum values not consecutive if (!std.mem.eql(u8, @tagName(v), field_infos[i].name)) break; // fields out of order @@ -557,7 +557,7 @@ pub fn FieldEnum(comptime T: type) type { }; } return @Type(.{ - .Enum = .{ + .@"enum" = .{ .tag_type = std.math.IntFittingRange(0, field_infos.len - 1), .fields = &enumFields, .decls = &decls, @@ -568,17 +568,17 @@ pub fn FieldEnum(comptime T: type) type { fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { // TODO: https://github.com/ziglang/zig/issues/7419 - // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum); + // testing.expectEqual(@typeInfo(expected).@"enum", @typeInfo(actual).@"enum"); try testing.expectEqual( - @typeInfo(expected).Enum.tag_type, - @typeInfo(actual).Enum.tag_type, + @typeInfo(expected).@"enum".tag_type, + @typeInfo(actual).@"enum".tag_type, ); // For comparing decls and fields, we cannot use the meta eql function here // because the language does not guarantee that the slice pointers for field names // and decl names will be the same. comptime { - const expected_fields = @typeInfo(expected).Enum.fields; - const actual_fields = @typeInfo(actual).Enum.fields; + const expected_fields = @typeInfo(expected).@"enum".fields; + const actual_fields = @typeInfo(actual).@"enum".fields; if (expected_fields.len != actual_fields.len) return error.FailedTest; for (expected_fields, 0..) |expected_field, i| { const actual_field = actual_fields[i]; @@ -587,8 +587,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { } } comptime { - const expected_decls = @typeInfo(expected).Enum.decls; - const actual_decls = @typeInfo(actual).Enum.decls; + const expected_decls = @typeInfo(expected).@"enum".decls; + const actual_decls = @typeInfo(actual).@"enum".decls; if (expected_decls.len != actual_decls.len) return error.FailedTest; for (expected_decls, 0..) |expected_decl, i| { const actual_decl = actual_decls[i]; @@ -596,8 +596,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { } } try testing.expectEqual( - @typeInfo(expected).Enum.is_exhaustive, - @typeInfo(actual).Enum.is_exhaustive, + @typeInfo(expected).@"enum".is_exhaustive, + @typeInfo(actual).@"enum".is_exhaustive, ); } @@ -627,7 +627,7 @@ pub fn DeclEnum(comptime T: type) type { enumDecls[i] = .{ .name = field.name ++ "", .value = i }; } return @Type(.{ - .Enum = .{ + .@"enum" = .{ .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1), .fields = &enumDecls, .decls = &decls, @@ -661,8 +661,8 @@ test DeclEnum { pub fn Tag(comptime T: type) type { return switch (@typeInfo(T)) { - .Enum => |info| info.tag_type, - .Union => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"), + .@"enum" => |info| info.tag_type, + .@"union" => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"), else => @compileError("expected enum or union type, found '" ++ @typeName(T) ++ "'"), }; } @@ -708,7 +708,7 @@ test activeTag { const TagPayloadType = TagPayload; pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type { - const info = @typeInfo(U).Union; + const info = @typeInfo(U).@"union"; inline for (info.fields) |field_info| { if (comptime mem.eql(u8, field_info.name, tag_name)) @@ -742,20 +742,20 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { const T = @TypeOf(a); switch (@typeInfo(T)) { - .Struct => |info| { + .@"struct" => |info| { inline for (info.fields) |field_info| { if (!eql(@field(a, field_info.name), @field(b, field_info.name))) return false; } return true; }, - .ErrorUnion => { + .error_union => { if (a) |a_p| { if (b) |b_p| return eql(a_p, b_p) else |_| return false; } else |a_e| { if (b) |_| return false else |b_e| return a_e == b_e; } }, - .Union => |info| { + .@"union" => |info| { if (info.tag_type) |UnionTag| { const tag_a: UnionTag = a; const tag_b: UnionTag = b; @@ -768,26 +768,26 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { @compileError("cannot compare untagged union type " ++ @typeName(T)); }, - .Array => { + .array => { if (a.len != b.len) return false; for (a, 0..) |e, i| if (!eql(e, b[i])) return false; return true; }, - .Vector => |info| { + .vector => |info| { var i: usize = 0; while (i < info.len) : (i += 1) { if (!eql(a[i], b[i])) return false; } return true; }, - .Pointer => |info| { + .pointer => |info| { return switch (info.size) { .One, .Many, .C => a == b, .Slice => a.ptr == b.ptr and a.len == b.len, }; }, - .Optional => { + .optional => { if (a == null and b == null) return true; if (a == null or b == null) return false; return eql(a.?, b.?); @@ -893,7 +893,7 @@ test intToEnum { pub const IntToEnumError = error{InvalidEnumTag}; pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag { - const enum_info = @typeInfo(EnumTag).Enum; + const enum_info = @typeInfo(EnumTag).@"enum"; if (!enum_info.is_exhaustive) { if (std.math.cast(enum_info.tag_type, tag_int)) |tag| { @@ -955,7 +955,7 @@ pub const IntType = @compileError("replaced by std.meta.Int"); pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type { return @Type(.{ - .Int = .{ + .int = .{ .signedness = signedness, .bits = bit_count, }, @@ -964,7 +964,7 @@ pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) pub fn Float(comptime bit_count: u8) type { return @Type(.{ - .Float = .{ .bits = bit_count }, + .float = .{ .bits = bit_count }, }); } @@ -984,10 +984,10 @@ test Float { /// - `ArgsTuple(fn (a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }` pub fn ArgsTuple(comptime Function: type) type { const info = @typeInfo(Function); - if (info != .Fn) + if (info != .@"fn") @compileError("ArgsTuple expects a function type"); - const function_info = info.Fn; + const function_info = info.@"fn"; if (function_info.is_var_args) @compileError("Cannot create ArgsTuple for variadic function"); @@ -1026,7 +1026,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { } return @Type(.{ - .Struct = .{ + .@"struct" = .{ .is_tuple = true, .layout = .auto, .decls = &.{}, @@ -1043,9 +1043,9 @@ const TupleTester = struct { fn assertTuple(comptime expected: anytype, comptime Actual: type) void { const info = @typeInfo(Actual); - if (info != .Struct) + if (info != .@"struct") @compileError("Expected struct type"); - if (!info.Struct.is_tuple) + if (!info.@"struct".is_tuple) @compileError("Struct type must be a tuple type"); const fields_list = std.meta.fields(Actual); @@ -1115,13 +1115,13 @@ test isError { /// `false` otherwise. Result is always comptime-known. pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool { switch (@typeInfo(T)) { - .Struct, .Union, .Enum, .Opaque => {}, + .@"struct", .@"union", .@"enum", .@"opaque" => {}, else => return false, } if (!@hasDecl(T, name)) return false; - return @typeInfo(@TypeOf(@field(T, name))) == .Fn; + return @typeInfo(@TypeOf(@field(T, name))) == .@"fn"; } test hasFn { @@ -1144,7 +1144,7 @@ test hasFn { /// Result is always comptime-known. pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool { return switch (@typeInfo(T)) { - .Pointer => |P| switch (P.size) { + .pointer => |P| switch (P.size) { .One => hasFn(P.child, name), .Many, .Slice, .C => false, }, @@ -1191,29 +1191,29 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { return switch (@typeInfo(T)) { else => false, // TODO can we know if it's true for some of these types ? - .AnyFrame, - .Enum, - .ErrorSet, - .Fn, + .@"anyframe", + .@"enum", + .error_set, + .@"fn", => true, - .Bool => false, + .bool => false, - .Int => |info| @sizeOf(T) * 8 == info.bits, + .int => |info| @sizeOf(T) * 8 == info.bits, - .Pointer => |info| info.size != .Slice, + .pointer => |info| info.size != .Slice, - .Optional => |info| switch (@typeInfo(info.child)) { - .Pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) { + .optional => |info| switch (@typeInfo(info.child)) { + .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) { .Slice, .C => false, .One, .Many => true, }, else => false, }, - .Array => |info| hasUniqueRepresentation(info.child), + .array => |info| hasUniqueRepresentation(info.child), - .Struct => |info| { + .@"struct" => |info| { if (info.layout == .@"packed") return @sizeOf(T) * 8 == @bitSizeOf(T); var sum_size = @as(usize, 0); @@ -1226,7 +1226,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool { return @sizeOf(T) == sum_size; }, - .Vector => |info| hasUniqueRepresentation(info.child) and + .vector => |info| hasUniqueRepresentation(info.child) and @sizeOf(T) == @sizeOf(info.child) * info.len, }; } diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index 9e223768a7..e00d32c789 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -14,14 +14,14 @@ pub fn TrailerFlags(comptime Fields: type) type { bits: Int, pub const Int = meta.Int(.unsigned, bit_count); - pub const bit_count = @typeInfo(Fields).Struct.fields.len; + pub const bit_count = @typeInfo(Fields).@"struct".fields.len; pub const FieldEnum = std.meta.FieldEnum(Fields); pub const ActiveFields = std.enums.EnumFieldStruct(FieldEnum, bool, false); pub const FieldValues = blk: { var fields: [bit_count]Type.StructField = undefined; - for (@typeInfo(Fields).Struct.fields, 0..) |struct_field, i| { + for (@typeInfo(Fields).@"struct".fields, 0..) |struct_field, i| { fields[i] = Type.StructField{ .name = struct_field.name, .type = ?struct_field.type, @@ -31,7 +31,7 @@ pub fn TrailerFlags(comptime Fields: type) type { }; } break :blk @Type(.{ - .Struct = .{ + .@"struct" = .{ .layout = .auto, .fields = &fields, .decls = &.{}, @@ -61,7 +61,7 @@ pub fn TrailerFlags(comptime Fields: type) type { /// `fields` is a boolean struct where each active field is set to `true` pub fn init(fields: ActiveFields) Self { var self: Self = .{ .bits = 0 }; - inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { + inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| { if (@field(fields, field.name)) self.bits |= 1 << i; } @@ -70,7 +70,7 @@ pub fn TrailerFlags(comptime Fields: type) type { /// `fields` is a struct with each field set to an optional value pub fn setMany(self: Self, p: [*]align(@alignOf(Fields)) u8, fields: FieldValues) void { - inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { + inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| { if (@field(fields, field.name)) |value| self.set(p, @as(FieldEnum, @enumFromInt(i)), value); } @@ -101,7 +101,7 @@ pub fn TrailerFlags(comptime Fields: type) type { pub fn offset(self: Self, comptime field: FieldEnum) usize { var off: usize = 0; - inline for (@typeInfo(Fields).Struct.fields, 0..) |field_info, i| { + inline for (@typeInfo(Fields).@"struct".fields, 0..) |field_info, i| { const active = (self.bits & (1 << i)) != 0; if (i == @intFromEnum(field)) { assert(active); @@ -114,12 +114,12 @@ pub fn TrailerFlags(comptime Fields: type) type { } pub fn Field(comptime field: FieldEnum) type { - return @typeInfo(Fields).Struct.fields[@intFromEnum(field)].type; + return @typeInfo(Fields).@"struct".fields[@intFromEnum(field)].type; } pub fn sizeInBytes(self: Self) usize { var off: usize = 0; - inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { + inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| { if (@sizeOf(field.type) == 0) continue; if ((self.bits & (1 << i)) != 0) { diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index cfe77f11b5..0d9272d492 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -24,10 +24,9 @@ pub fn MultiArrayList(comptime T: type) type { capacity: usize = 0, const Elem = switch (@typeInfo(T)) { - .Struct => T, - .Union => |u| struct { - pub const Bare = - @Type(.{ .Union = .{ + .@"struct" => T, + .@"union" => |u| struct { + pub const Bare = @Type(.{ .@"union" = .{ .layout = u.layout, .tag_type = null, .fields = u.fields, @@ -84,8 +83,8 @@ pub fn MultiArrayList(comptime T: type) type { pub fn set(self: *Slice, index: usize, elem: T) void { const e = switch (@typeInfo(T)) { - .Struct => elem, - .Union => Elem.fromT(elem), + .@"struct" => elem, + .@"union" => Elem.fromT(elem), else => unreachable, }; inline for (fields, 0..) |field_info, i| { @@ -99,8 +98,8 @@ pub fn MultiArrayList(comptime T: type) type { @field(result, field_info.name) = self.items(@as(Field, @enumFromInt(i)))[index]; } return switch (@typeInfo(T)) { - .Struct => result, - .Union => Elem.toT(result.tags, result.data), + .@"struct" => result, + .@"union" => Elem.toT(result.tags, result.data), else => unreachable, }; } @@ -287,8 +286,8 @@ pub fn MultiArrayList(comptime T: type) type { assert(index <= self.len); self.len += 1; const entry = switch (@typeInfo(T)) { - .Struct => elem, - .Union => Elem.fromT(elem), + .@"struct" => elem, + .@"union" => Elem.fromT(elem), else => unreachable, }; const slices = self.slice(); @@ -557,7 +556,7 @@ pub fn MultiArrayList(comptime T: type) type { .is_comptime = fields[i].is_comptime, .alignment = fields[i].alignment, }; - break :entry @Type(.{ .Struct = .{ + break :entry @Type(.{ .@"struct" = .{ .layout = .@"extern", .fields = &entry_fields, .decls = &.{}, diff --git a/lib/std/once.zig b/lib/std/once.zig index ee3a8b7a35..326487df07 100644 --- a/lib/std/once.zig +++ b/lib/std/once.zig @@ -25,7 +25,7 @@ pub fn Once(comptime f: fn () void) type { } fn callSlow(self: *@This()) void { - @setCold(true); + @branchHint(.cold); self.mutex.lock(); defer self.mutex.unlock(); diff --git a/lib/std/os/emscripten.zig b/lib/std/os/emscripten.zig index 15b0bdbdf0..6c6a34ac47 100644 --- a/lib/std/os/emscripten.zig +++ b/lib/std/os/emscripten.zig @@ -21,8 +21,8 @@ comptime { if (builtin.os.tag == .emscripten) { if (builtin.mode == .Debug or builtin.mode == .ReleaseSafe) { // Emscripten does not provide these symbols, so we must export our own - @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = .strong }); - @export(__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = .strong }); + @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = .strong }); + @export(&__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = .strong }); } } } @@ -560,7 +560,7 @@ pub const Sigaction = extern struct { }; pub const sigset_t = [1024 / 32]u32; -pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len; +pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).array.len; pub const siginfo_t = extern struct { signo: i32, errno: i32, diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 20f1370bfc..df9d491a5e 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -434,7 +434,7 @@ comptime { // Export this only when building executable, otherwise it is overriding // the libc implementation if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) { - @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); + @export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); } } @@ -630,12 +630,13 @@ pub fn futex2_waitv( nr_futexes, flags, @intFromPtr(timeout), - @bitCast(@as(isize, clockid)), + @bitCast(@as(isize, @intFromEnum(clockid))), ); } /// Wait on a futex. -/// Identical to `FUTEX.WAIT`, except it is part of the futex2 family of calls. +/// Identical to the traditional `FUTEX.FUTEX_WAIT_BITSET` op, except it is part of the +/// futex2 familiy of calls. pub fn futex2_wait( /// Address of the futex to wait on. uaddr: *const anyopaque, @@ -646,7 +647,7 @@ pub fn futex2_wait( /// `FUTEX2` flags. flags: u32, /// Optional absolute timeout. - timeout: *const timespec, + timeout: ?*const timespec, /// Clock to be used for the timeout, realtime or monotonic. clockid: clockid_t, ) usize { @@ -657,15 +658,16 @@ pub fn futex2_wait( mask, flags, @intFromPtr(timeout), - @bitCast(@as(isize, clockid)), + @bitCast(@as(isize, @intFromEnum(clockid))), ); } /// Wake a number of futexes. -/// Identical to `FUTEX.WAKE`, except it is part of the futex2 family of calls. +/// Identical to the traditional `FUTEX.FUTEX_WAIT_BITSET` op, except it is part of the +/// futex2 family of calls. pub fn futex2_wake( /// Address of the futex(es) to wake. - uaddr: [*]const anyopaque, + uaddr: *const anyopaque, /// Bitmask mask: usize, /// Number of the futexes to wake. @@ -1545,7 +1547,7 @@ pub fn seteuid(euid: uid_t) usize { // The setresuid(2) man page says that if -1 is passed the corresponding // id will not be changed. Since uid_t is unsigned, this wraps around to the // max value in C. - comptime assert(@typeInfo(uid_t) == .Int and @typeInfo(uid_t).Int.signedness == .unsigned); + comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned); return setresuid(std.math.maxInt(uid_t), euid, std.math.maxInt(uid_t)); } @@ -1556,7 +1558,7 @@ pub fn setegid(egid: gid_t) usize { // The setresgid(2) man page says that if -1 is passed the corresponding // id will not be changed. Since gid_t is unsigned, this wraps around to the // max value in C. - comptime assert(@typeInfo(uid_t) == .Int and @typeInfo(uid_t).Int.signedness == .unsigned); + comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned); return setresgid(std.math.maxInt(gid_t), egid, std.math.maxInt(gid_t)); } @@ -1671,7 +1673,7 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact return 0; } -const usize_bits = @typeInfo(usize).Int.bits; +const usize_bits = @typeInfo(usize).int.bits; pub fn sigaddset(set: *sigset_t, sig: u6) void { const s = sig - 1; @@ -1683,7 +1685,7 @@ pub fn sigaddset(set: *sigset_t, sig: u6) void { pub fn sigismember(set: *const sigset_t, sig: u6) bool { const s = sig - 1; - return ((set.*)[@as(usize, @intCast(s)) / usize_bits] & (@as(usize, @intCast(1)) << (s & (usize_bits - 1)))) != 0; + return ((set.*)[@as(usize, @intCast(s)) / usize_bits] & (@as(usize, @intCast(1)) << @intCast(s & (usize_bits - 1)))) != 0; } pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { @@ -1732,7 +1734,7 @@ pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize { } pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize { - if (@typeInfo(usize).Int.bits > @typeInfo(@typeInfo(mmsghdr).Struct.fields[1].type).Int.bits) { + if (@typeInfo(usize).int.bits > @typeInfo(@typeInfo(mmsghdr).@"struct".fields[1].type).int.bits) { // workaround kernel brokenness: // if adding up all iov_len overflows a i32 then split into multiple calls // see https://www.openwall.com/lists/musl/2014/06/07/5 @@ -1740,31 +1742,31 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize var next_unsent: usize = 0; for (msgvec[0..kvlen], 0..) |*msg, i| { var size: i32 = 0; - const msg_iovlen = @as(usize, @intCast(msg.msg_hdr.msg_iovlen)); // kernel side this is treated as unsigned - for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| { + const msg_iovlen = @as(usize, @intCast(msg.hdr.iovlen)); // kernel side this is treated as unsigned + for (msg.hdr.iov[0..msg_iovlen]) |iov| { if (iov.len > std.math.maxInt(i32) or @addWithOverflow(size, @as(i32, @intCast(iov.len)))[1] != 0) { // batch-send all messages up to the current message if (next_unsent < i) { const batch_size = i - next_unsent; const r = syscall4(.sendmmsg, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(&msgvec[next_unsent]), batch_size, flags); - if (E.init(r) != 0) return next_unsent; + if (E.init(r) != .SUCCESS) return next_unsent; if (r < batch_size) return next_unsent + r; } // send current message as own packet - const r = sendmsg(fd, &msg.msg_hdr, flags); - if (E.init(r) != 0) return r; + const r = sendmsg(fd, &msg.hdr, flags); + if (E.init(r) != .SUCCESS) return r; // Linux limits the total bytes sent by sendmsg to INT_MAX, so this cast is safe. - msg.msg_len = @as(u32, @intCast(r)); + msg.len = @as(u32, @intCast(r)); next_unsent = i + 1; break; } - size += iov.len; + size += @intCast(iov.len); } } if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR) const batch_size = kvlen - next_unsent; const r = syscall4(.sendmmsg, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(&msgvec[next_unsent]), batch_size, flags); - if (E.init(r) != 0) return r; + if (E.init(r) != .SUCCESS) return r; return next_unsent + r; } return kvlen; @@ -4902,7 +4904,7 @@ pub const NSIG = if (is_mips) 128 else 65; pub const sigset_t = [1024 / 32]u32; -pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).Array.len; +pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.len; pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30; const k_sigaction_funcs = struct { @@ -4945,7 +4947,7 @@ pub const Sigaction = extern struct { restorer: ?*const fn () callconv(.C) void = null, }; -const sigset_len = @typeInfo(sigset_t).Array.len; +const sigset_len = @typeInfo(sigset_t).array.len; pub const empty_sigset = [_]u32{0} ** sigset_len; pub const filled_sigset = [_]u32{(1 << (31 & (usize_bits - 1))) - 1} ++ [_]u32{0} ** (sigset_len - 1); @@ -5095,7 +5097,7 @@ pub const epoll_event = extern struct { pub const VFS_CAP_REVISION_MASK = 0xFF000000; pub const VFS_CAP_REVISION_SHIFT = 24; -pub const VFS_CAP_FLAGS_MASK = ~VFS_CAP_REVISION_MASK; +pub const VFS_CAP_FLAGS_MASK = ~@as(u32, VFS_CAP_REVISION_MASK); pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001; pub const VFS_CAP_REVISION_1 = 0x01000000; @@ -5113,7 +5115,7 @@ pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2; pub const vfs_cap_data = extern struct { //all of these are mandated as little endian //when on disk. - const Data = struct { + const Data = extern struct { permitted: u32, inheritable: u32, }; @@ -7067,6 +7069,153 @@ pub const ifreq = extern struct { }, }; +pub const PACKET = struct { + pub const HOST = 0; + pub const BROADCAST = 1; + pub const MULTICAST = 2; + pub const OTHERHOST = 3; + pub const OUTGOING = 4; + pub const LOOPBACK = 5; + pub const USER = 6; + pub const KERNEL = 7; + + pub const ADD_MEMBERSHIP = 1; + pub const DROP_MEMBERSHIP = 2; + pub const RECV_OUTPUT = 3; + pub const RX_RING = 5; + pub const STATISTICS = 6; + pub const COPY_THRESH = 7; + pub const AUXDATA = 8; + pub const ORIGDEV = 9; + pub const VERSION = 10; + pub const HDRLEN = 11; + pub const RESERVE = 12; + pub const TX_RING = 13; + pub const LOSS = 14; + pub const VNET_HDR = 15; + pub const TX_TIMESTAMP = 16; + pub const TIMESTAMP = 17; + pub const FANOUT = 18; + pub const TX_HAS_OFF = 19; + pub const QDISC_BYPASS = 20; + pub const ROLLOVER_STATS = 21; + pub const FANOUT_DATA = 22; + pub const IGNORE_OUTGOING = 23; + pub const VNET_HDR_SZ = 24; + + pub const FANOUT_HASH = 0; + pub const FANOUT_LB = 1; + pub const FANOUT_CPU = 2; + pub const FANOUT_ROLLOVER = 3; + pub const FANOUT_RND = 4; + pub const FANOUT_QM = 5; + pub const FANOUT_CBPF = 6; + pub const FANOUT_EBPF = 7; + pub const FANOUT_FLAG_ROLLOVER = 0x1000; + pub const FANOUT_FLAG_UNIQUEID = 0x2000; + pub const FANOUT_FLAG_IGNORE_OUTGOING = 0x4000; + pub const FANOUT_FLAG_DEFRAG = 0x8000; +}; + +pub const tpacket_versions = enum(u32) { + V1 = 0, + V2 = 1, + V3 = 2, +}; + +pub const tpacket_req3 = extern struct { + block_size: c_uint, // Minimal size of contiguous block + block_nr: c_uint, // Number of blocks + frame_size: c_uint, // Size of frame + frame_nr: c_uint, // Total number of frames + retire_blk_tov: c_uint, // Timeout in msecs + sizeof_priv: c_uint, // Offset to private data area + feature_req_word: c_uint, +}; + +pub const tpacket_bd_ts = extern struct { + sec: c_uint, + frac: extern union { + usec: c_uint, + nsec: c_uint, + }, +}; + +pub const TP_STATUS = extern union { + rx: packed struct(u32) { + USER: bool, + COPY: bool, + LOSING: bool, + CSUMNOTREADY: bool, + VLAN_VALID: bool, + BLK_TMO: bool, + VLAN_TPID_VALID: bool, + CSUM_VALID: bool, + GSO_TCP: bool, + _: u20, + TS_SOFTWARE: bool, + TS_SYS_HARDWARE: bool, + TS_RAW_HARDWARE: bool, + }, + tx: packed struct(u32) { + SEND_REQUEST: bool, + SENDING: bool, + WRONG_FORMAT: bool, + _: u26, + TS_SOFTWARE: bool, + TS_SYS_HARDWARE: bool, + TS_RAW_HARDWARE: bool, + }, +}; + +pub const tpacket_hdr_v1 = extern struct { + block_status: TP_STATUS, + num_pkts: u32, + offset_to_first_pkt: u32, + blk_len: u32, + seq_num: u64 align(8), + ts_first_pkt: tpacket_bd_ts, + ts_last_pkt: tpacket_bd_ts, +}; + +pub const tpacket_bd_header_u = extern union { + bh1: tpacket_hdr_v1, +}; + +pub const tpacket_block_desc = extern struct { + version: u32, + offset_to_priv: u32, + hdr: tpacket_bd_header_u, +}; + +pub const tpacket_hdr_variant1 = extern struct { + rxhash: u32, + vlan_tci: u32, + vlan_tpid: u16, + padding: u16, +}; + +pub const tpacket3_hdr = extern struct { + next_offset: u32, + sec: u32, + nsec: u32, + snaplen: u32, + len: u32, + status: u32, + mac: u16, + net: u16, + variant: extern union { + hv1: tpacket_hdr_variant1, + }, + padding: [8]u8, +}; + +pub const tpacket_stats_v3 = extern struct { + packets: c_uint, + drops: c_uint, + freeze_q_cnt: c_uint, +}; + // doc comments copied from musl pub const rlimit_resource = if (native_arch.isMIPS()) enum(c_int) { /// Per-process CPU limit, in seconds. @@ -7271,7 +7420,7 @@ pub const MADV = struct { }; pub const POSIX_FADV = switch (native_arch) { - .s390x => if (@typeInfo(usize).Int.bits == 64) struct { + .s390x => if (@typeInfo(usize).int.bits == 64) struct { pub const NORMAL = 0; pub const RANDOM = 1; pub const SEQUENTIAL = 2; diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig index 7661ba9d7c..f35ccf4f1a 100644 --- a/lib/std/os/linux/bpf.zig +++ b/lib/std/os/linux/bpf.zig @@ -459,7 +459,7 @@ pub const Insn = packed struct { }; fn imm_reg(code: u8, dst: Reg, src: anytype, off: i16) Insn { - const imm_or_reg = if (@TypeOf(src) == Reg or @typeInfo(@TypeOf(src)) == .EnumLiteral) + const imm_or_reg = if (@TypeOf(src) == Reg or @typeInfo(@TypeOf(src)) == .enum_literal) ImmOrReg{ .reg = @as(Reg, src) } else ImmOrReg{ .imm = src }; diff --git a/lib/std/os/linux/bpf/btf.zig b/lib/std/os/linux/bpf/btf.zig index 39d25014da..3988fce349 100644 --- a/lib/std/os/linux/bpf/btf.zig +++ b/lib/std/os/linux/bpf/btf.zig @@ -83,13 +83,14 @@ pub const Kind = enum(u5) { /// int kind is followed by this struct pub const IntInfo = packed struct(u32) { bits: u8, - unused: u8, + reserved_1: u8, offset: u8, encoding: enum(u4) { signed = 1 << 0, char = 1 << 1, boolean = 1 << 2, }, + reserved_2: u4, }; test "IntInfo is 32 bits" { diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig index 8562d4be8e..a8ebec47a5 100644 --- a/lib/std/os/linux/test.zig +++ b/lib/std/os/linux/test.zig @@ -125,6 +125,23 @@ test "fadvise" { try expectEqual(@as(usize, 0), ret); } +test "sigset_t" { + var sigset = linux.empty_sigset; + + try expectEqual(linux.sigismember(&sigset, linux.SIG.USR1), false); + try expectEqual(linux.sigismember(&sigset, linux.SIG.USR2), false); + + linux.sigaddset(&sigset, linux.SIG.USR1); + + try expectEqual(linux.sigismember(&sigset, linux.SIG.USR1), true); + try expectEqual(linux.sigismember(&sigset, linux.SIG.USR2), false); + + linux.sigaddset(&sigset, linux.SIG.USR2); + + try expectEqual(linux.sigismember(&sigset, linux.SIG.USR1), true); + try expectEqual(linux.sigismember(&sigset, linux.SIG.USR2), true); +} + test { _ = linux.IoUring; } diff --git a/lib/std/os/linux/x86.zig b/lib/std/os/linux/x86.zig index 0eb826bebd..abcfb99b37 100644 --- a/lib/std/os/linux/x86.zig +++ b/lib/std/os/linux/x86.zig @@ -85,24 +85,27 @@ pub fn syscall6( arg5: usize, arg6: usize, ) usize { - // The 6th argument is passed via memory as we're out of registers if ebp is - // used as frame pointer. We push arg6 value on the stack before changing - // ebp or esp as the compiler may reference it as an offset relative to one - // of those two registers. + // arg5/arg6 are passed via memory as we're out of registers if ebp is used as frame pointer, or + // if we're compiling with PIC. We push arg5/arg6 on the stack before changing ebp/esp as the + // compiler may reference arg5/arg6 as an offset relative to ebp/esp. return asm volatile ( + \\ push %[arg5] \\ push %[arg6] + \\ push %%edi \\ push %%ebp - \\ mov 4(%%esp), %%ebp + \\ mov 12(%%esp), %%edi + \\ mov 8(%%esp), %%ebp \\ int $0x80 \\ pop %%ebp - \\ add $4, %%esp + \\ pop %%edi + \\ add $8, %%esp : [ret] "={eax}" (-> usize), : [number] "{eax}" (@intFromEnum(number)), [arg1] "{ebx}" (arg1), [arg2] "{ecx}" (arg2), [arg3] "{edx}" (arg3), [arg4] "{esi}" (arg4), - [arg5] "{edi}" (arg5), + [arg5] "rm" (arg5), [arg6] "rm" (arg6), : "memory" ); diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig index abaadbe71c..cef15105ee 100644 --- a/lib/std/os/linux/x86_64.zig +++ b/lib/std/os/linux/x86_64.zig @@ -114,14 +114,15 @@ pub fn clone() callconv(.Naked) usize { \\ movq %%rcx,(%%rsi) \\ syscall \\ testq %%rax,%%rax - \\ jnz 1f + \\ jz 1f + \\ retq + \\1: .cfi_undefined %%rip \\ xorl %%ebp,%%ebp \\ popq %%rdi \\ callq *%%r9 \\ movl %%eax,%%edi \\ movl $60,%%eax // SYS_exit \\ syscall - \\1: ret \\ ); } diff --git a/lib/std/os/uefi/device_path.zig b/lib/std/os/uefi/device_path.zig index 55a3763d66..e02d452b09 100644 --- a/lib/std/os/uefi/device_path.zig +++ b/lib/std/os/uefi/device_path.zig @@ -4,38 +4,38 @@ const uefi = std.os.uefi; const Guid = uefi.Guid; pub const DevicePath = union(Type) { - Hardware: Hardware, - Acpi: Acpi, - Messaging: Messaging, - Media: Media, - BiosBootSpecification: BiosBootSpecification, - End: End, + hardware: Hardware, + acpi: Acpi, + messaging: Messaging, + media: Media, + bios_boot_specification: BiosBootSpecification, + end: End, pub const Type = enum(u8) { - Hardware = 0x01, - Acpi = 0x02, - Messaging = 0x03, - Media = 0x04, - BiosBootSpecification = 0x05, - End = 0x7f, + hardware = 0x01, + acpi = 0x02, + messaging = 0x03, + media = 0x04, + bios_boot_specification = 0x05, + end = 0x7f, _, }; pub const Hardware = union(Subtype) { - Pci: *const PciDevicePath, - PcCard: *const PcCardDevicePath, - MemoryMapped: *const MemoryMappedDevicePath, - Vendor: *const VendorDevicePath, - Controller: *const ControllerDevicePath, - Bmc: *const BmcDevicePath, + pci: *const PciDevicePath, + pc_card: *const PcCardDevicePath, + memory_mapped: *const MemoryMappedDevicePath, + vendor: *const VendorDevicePath, + controller: *const ControllerDevicePath, + bmc: *const BmcDevicePath, pub const Subtype = enum(u8) { - Pci = 1, - PcCard = 2, - MemoryMapped = 3, - Vendor = 4, - Controller = 5, - Bmc = 6, + pci = 1, + pc_card = 2, + memory_mapped = 3, + vendor = 4, + controller = 5, + bmc = 6, _, }; @@ -151,14 +151,14 @@ pub const DevicePath = union(Type) { }; pub const Acpi = union(Subtype) { - Acpi: *const BaseAcpiDevicePath, - ExpandedAcpi: *const ExpandedAcpiDevicePath, - Adr: *const AdrDevicePath, + acpi: *const BaseAcpiDevicePath, + expanded_acpi: *const ExpandedAcpiDevicePath, + adr: *const AdrDevicePath, pub const Subtype = enum(u8) { - Acpi = 1, - ExpandedAcpi = 2, - Adr = 3, + acpi = 1, + expanded_acpi = 2, + adr = 3, _, }; diff --git a/lib/std/os/uefi/protocol/device_path.zig b/lib/std/os/uefi/protocol/device_path.zig index a08eee193c..b59ebb7be0 100644 --- a/lib/std/os/uefi/protocol/device_path.zig +++ b/lib/std/os/uefi/protocol/device_path.zig @@ -76,7 +76,7 @@ pub const DevicePath = extern struct { } pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath { - inline for (@typeInfo(uefi.DevicePath).Union.fields) |ufield| { + inline for (@typeInfo(uefi.DevicePath).@"union".fields) |ufield| { const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield.name); // Got the associated union type for self.type, now @@ -94,7 +94,7 @@ pub const DevicePath = extern struct { } pub fn initSubtype(self: *const DevicePath, comptime TUnion: type) ?TUnion { - const type_info = @typeInfo(TUnion).Union; + const type_info = @typeInfo(TUnion).@"union"; const TTag = type_info.tag_type.?; inline for (type_info.fields) |subtype| { diff --git a/lib/std/os/uefi/status.zig b/lib/std/os/uefi/status.zig index e975b92a15..79a939e6b9 100644 --- a/lib/std/os/uefi/status.zig +++ b/lib/std/os/uefi/status.zig @@ -1,6 +1,6 @@ const testing = @import("std").testing; -const high_bit = 1 << @typeInfo(usize).Int.bits - 1; +const high_bit = 1 << @typeInfo(usize).int.bits - 1; pub const Status = enum(usize) { /// The operation completed successfully. @@ -186,7 +186,7 @@ pub const Status = enum(usize) { }; pub fn err(self: Status) EfiError!void { - inline for (@typeInfo(EfiError).ErrorSet.?) |efi_err| { + inline for (@typeInfo(EfiError).error_set.?) |efi_err| { if (self == @field(Status, efi_err.name)) { return @field(EfiError, efi_err.name); } diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index e06a3ff02c..d277361352 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -2123,6 +2123,10 @@ pub fn teb() *TEB { ); } }, + .thumb => asm ( + \\ mrc p15, 0, %[ptr], c13, c0, 2 + : [ptr] "=r" (-> *TEB), + ), .aarch64 => asm ( \\ mov %[ptr], x18 : [ptr] "=r" (-> *TEB), @@ -4120,6 +4124,10 @@ pub const XMM_SAVE_AREA32 = switch (native_arch) { }; pub const NEON128 = switch (native_arch) { + .thumb => extern struct { + Low: ULONGLONG, + High: LONGLONG, + }, .aarch64 => extern union { DUMMYSTRUCTNAME: extern struct { Low: ULONGLONG, @@ -4248,6 +4256,54 @@ pub const CONTEXT = switch (native_arch) { ctx.Rsp = sp; } }, + .thumb => extern struct { + ContextFlags: ULONG, + R0: ULONG, + R1: ULONG, + R2: ULONG, + R3: ULONG, + R4: ULONG, + R5: ULONG, + R6: ULONG, + R7: ULONG, + R8: ULONG, + R9: ULONG, + R10: ULONG, + R11: ULONG, + R12: ULONG, + Sp: ULONG, + Lr: ULONG, + Pc: ULONG, + Cpsr: ULONG, + Fpcsr: ULONG, + Padding: ULONG, + DUMMYUNIONNAME: extern union { + Q: [16]NEON128, + D: [32]ULONGLONG, + S: [32]ULONG, + }, + Bvr: [8]ULONG, + Bcr: [8]ULONG, + Wvr: [1]ULONG, + Wcr: [1]ULONG, + Padding2: [2]ULONG, + + pub fn getRegs(ctx: *const CONTEXT) struct { bp: usize, ip: usize, sp: usize } { + return .{ + .bp = ctx.DUMMYUNIONNAME.S[11], + .ip = ctx.Pc, + .sp = ctx.Sp, + }; + } + + pub fn setIp(ctx: *CONTEXT, ip: usize) void { + ctx.Pc = ip; + } + + pub fn setSp(ctx: *CONTEXT, sp: usize) void { + ctx.Sp = sp; + } + }, .aarch64 => extern struct { ContextFlags: ULONG align(16), Cpsr: ULONG, @@ -4322,6 +4378,23 @@ pub const RUNTIME_FUNCTION = switch (native_arch) { EndAddress: DWORD, UnwindData: DWORD, }, + .thumb => extern struct { + BeginAddress: DWORD, + DUMMYUNIONNAME: extern union { + UnwindData: DWORD, + DUMMYSTRUCTNAME: packed struct { + Flag: u2, + FunctionLength: u11, + Ret: u2, + H: u1, + Reg: u3, + R: u1, + L: u1, + C: u1, + StackAdjust: u10, + }, + }, + }, .aarch64 => extern struct { BeginAddress: DWORD, DUMMYUNIONNAME: extern union { @@ -4345,6 +4418,25 @@ pub const KNONVOLATILE_CONTEXT_POINTERS = switch (native_arch) { FloatingContext: [16]?*M128A, IntegerContext: [16]?*ULONG64, }, + .thumb => extern struct { + R4: ?*DWORD, + R5: ?*DWORD, + R6: ?*DWORD, + R7: ?*DWORD, + R8: ?*DWORD, + R9: ?*DWORD, + R10: ?*DWORD, + R11: ?*DWORD, + Lr: ?*DWORD, + D8: ?*ULONGLONG, + D9: ?*ULONGLONG, + D10: ?*ULONGLONG, + D11: ?*ULONGLONG, + D12: ?*ULONGLONG, + D13: ?*ULONGLONG, + D14: ?*ULONGLONG, + D15: ?*ULONGLONG, + }, .aarch64 => extern struct { X19: ?*DWORD64, X20: ?*DWORD64, diff --git a/lib/std/pdb.zig b/lib/std/pdb.zig index 31ad02e945..b44f48974d 100644 --- a/lib/std/pdb.zig +++ b/lib/std/pdb.zig @@ -20,297 +20,297 @@ const ArrayList = std.ArrayList; /// https://llvm.org/docs/PDB/DbiStream.html#stream-header pub const DbiStreamHeader = extern struct { - VersionSignature: i32, - VersionHeader: u32, - Age: u32, - GlobalStreamIndex: u16, - BuildNumber: u16, - PublicStreamIndex: u16, - PdbDllVersion: u16, - SymRecordStream: u16, - PdbDllRbld: u16, - ModInfoSize: u32, - SectionContributionSize: u32, - SectionMapSize: u32, - SourceInfoSize: i32, - TypeServerSize: i32, - MFCTypeServerIndex: u32, - OptionalDbgHeaderSize: i32, - ECSubstreamSize: i32, - Flags: u16, - Machine: u16, - Padding: u32, + version_signature: i32, + version_header: u32, + age: u32, + global_stream_index: u16, + build_number: u16, + public_stream_index: u16, + pdb_dll_version: u16, + sym_record_stream: u16, + pdb_dll_rbld: u16, + mod_info_size: u32, + section_contribution_size: u32, + section_map_size: u32, + source_info_size: i32, + type_server_size: i32, + mfc_type_server_index: u32, + optional_dbg_header_size: i32, + ec_substream_size: i32, + flags: u16, + machine: u16, + padding: u32, }; pub const SectionContribEntry = extern struct { /// COFF Section index, 1-based - Section: u16, - Padding1: [2]u8, - Offset: u32, - Size: u32, - Characteristics: u32, - ModuleIndex: u16, - Padding2: [2]u8, - DataCrc: u32, - RelocCrc: u32, + section: u16, + padding1: [2]u8, + offset: u32, + size: u32, + characteristics: u32, + module_index: u16, + padding2: [2]u8, + data_crc: u32, + reloc_crc: u32, }; pub const ModInfo = extern struct { - Unused1: u32, - SectionContr: SectionContribEntry, - Flags: u16, - ModuleSymStream: u16, - SymByteSize: u32, - C11ByteSize: u32, - C13ByteSize: u32, - SourceFileCount: u16, - Padding: [2]u8, - Unused2: u32, - SourceFileNameIndex: u32, - PdbFilePathNameIndex: u32, + unused1: u32, + section_contr: SectionContribEntry, + flags: u16, + module_sym_stream: u16, + sym_byte_size: u32, + c11_byte_size: u32, + c13_byte_size: u32, + source_file_count: u16, + padding: [2]u8, + unused2: u32, + source_file_name_index: u32, + pdb_file_path_name_index: u32, // These fields are variable length - //ModuleName: char[], - //ObjFileName: char[], + //module_name: char[], + //obj_file_name: char[], }; pub const SectionMapHeader = extern struct { /// Number of segment descriptors - Count: u16, + count: u16, /// Number of logical segment descriptors - LogCount: u16, + log_count: u16, }; pub const SectionMapEntry = extern struct { /// See the SectionMapEntryFlags enum below. - Flags: u16, + flags: u16, /// Logical overlay number - Ovl: u16, + ovl: u16, /// Group index into descriptor array. - Group: u16, - Frame: u16, + group: u16, + frame: u16, /// Byte index of segment / group name in string table, or 0xFFFF. - SectionName: u16, + section_name: u16, /// Byte index of class in string table, or 0xFFFF. - ClassName: u16, + class_name: u16, /// Byte offset of the logical segment within physical segment. If group is set in flags, this is the offset of the group. - Offset: u32, + offset: u32, /// Byte count of the segment or group. - SectionLength: u32, + section_length: u32, }; pub const StreamType = enum(u16) { - Pdb = 1, - Tpi = 2, - Dbi = 3, - Ipi = 4, + pdb = 1, + tpi = 2, + dbi = 3, + ipi = 4, }; /// Duplicate copy of SymbolRecordKind, but using the official CV names. Useful /// for reference purposes and when dealing with unknown record types. pub const SymbolKind = enum(u16) { - S_COMPILE = 1, - S_REGISTER_16t = 2, - S_CONSTANT_16t = 3, - S_UDT_16t = 4, - S_SSEARCH = 5, - S_SKIP = 7, - S_CVRESERVE = 8, - S_OBJNAME_ST = 9, - S_ENDARG = 10, - S_COBOLUDT_16t = 11, - S_MANYREG_16t = 12, - S_RETURN = 13, - S_ENTRYTHIS = 14, - S_BPREL16 = 256, - S_LDATA16 = 257, - S_GDATA16 = 258, - S_PUB16 = 259, - S_LPROC16 = 260, - S_GPROC16 = 261, - S_THUNK16 = 262, - S_BLOCK16 = 263, - S_WITH16 = 264, - S_LABEL16 = 265, - S_CEXMODEL16 = 266, - S_VFTABLE16 = 267, - S_REGREL16 = 268, - S_BPREL32_16t = 512, - S_LDATA32_16t = 513, - S_GDATA32_16t = 514, - S_PUB32_16t = 515, - S_LPROC32_16t = 516, - S_GPROC32_16t = 517, - S_THUNK32_ST = 518, - S_BLOCK32_ST = 519, - S_WITH32_ST = 520, - S_LABEL32_ST = 521, - S_CEXMODEL32 = 522, - S_VFTABLE32_16t = 523, - S_REGREL32_16t = 524, - S_LTHREAD32_16t = 525, - S_GTHREAD32_16t = 526, - S_SLINK32 = 527, - S_LPROCMIPS_16t = 768, - S_GPROCMIPS_16t = 769, - S_PROCREF_ST = 1024, - S_DATAREF_ST = 1025, - S_ALIGN = 1026, - S_LPROCREF_ST = 1027, - S_OEM = 1028, - S_TI16_MAX = 4096, - S_REGISTER_ST = 4097, - S_CONSTANT_ST = 4098, - S_UDT_ST = 4099, - S_COBOLUDT_ST = 4100, - S_MANYREG_ST = 4101, - S_BPREL32_ST = 4102, - S_LDATA32_ST = 4103, - S_GDATA32_ST = 4104, - S_PUB32_ST = 4105, - S_LPROC32_ST = 4106, - S_GPROC32_ST = 4107, - S_VFTABLE32 = 4108, - S_REGREL32_ST = 4109, - S_LTHREAD32_ST = 4110, - S_GTHREAD32_ST = 4111, - S_LPROCMIPS_ST = 4112, - S_GPROCMIPS_ST = 4113, - S_COMPILE2_ST = 4115, - S_MANYREG2_ST = 4116, - S_LPROCIA64_ST = 4117, - S_GPROCIA64_ST = 4118, - S_LOCALSLOT_ST = 4119, - S_PARAMSLOT_ST = 4120, - S_ANNOTATION = 4121, - S_GMANPROC_ST = 4122, - S_LMANPROC_ST = 4123, - S_RESERVED1 = 4124, - S_RESERVED2 = 4125, - S_RESERVED3 = 4126, - S_RESERVED4 = 4127, - S_LMANDATA_ST = 4128, - S_GMANDATA_ST = 4129, - S_MANFRAMEREL_ST = 4130, - S_MANREGISTER_ST = 4131, - S_MANSLOT_ST = 4132, - S_MANMANYREG_ST = 4133, - S_MANREGREL_ST = 4134, - S_MANMANYREG2_ST = 4135, - S_MANTYPREF = 4136, - S_UNAMESPACE_ST = 4137, - S_ST_MAX = 4352, - S_WITH32 = 4356, - S_MANYREG = 4362, - S_LPROCMIPS = 4372, - S_GPROCMIPS = 4373, - S_MANYREG2 = 4375, - S_LPROCIA64 = 4376, - S_GPROCIA64 = 4377, - S_LOCALSLOT = 4378, - S_PARAMSLOT = 4379, - S_MANFRAMEREL = 4382, - S_MANREGISTER = 4383, - S_MANSLOT = 4384, - S_MANMANYREG = 4385, - S_MANREGREL = 4386, - S_MANMANYREG2 = 4387, - S_UNAMESPACE = 4388, - S_DATAREF = 4390, - S_ANNOTATIONREF = 4392, - S_TOKENREF = 4393, - S_GMANPROC = 4394, - S_LMANPROC = 4395, - S_ATTR_FRAMEREL = 4398, - S_ATTR_REGISTER = 4399, - S_ATTR_REGREL = 4400, - S_ATTR_MANYREG = 4401, - S_SEPCODE = 4402, - S_LOCAL_2005 = 4403, - S_DEFRANGE_2005 = 4404, - S_DEFRANGE2_2005 = 4405, - S_DISCARDED = 4411, - S_LPROCMIPS_ID = 4424, - S_GPROCMIPS_ID = 4425, - S_LPROCIA64_ID = 4426, - S_GPROCIA64_ID = 4427, - S_DEFRANGE_HLSL = 4432, - S_GDATA_HLSL = 4433, - S_LDATA_HLSL = 4434, - S_LOCAL_DPC_GROUPSHARED = 4436, - S_DEFRANGE_DPC_PTR_TAG = 4439, - S_DPC_SYM_TAG_MAP = 4440, - S_ARMSWITCHTABLE = 4441, - S_POGODATA = 4444, - S_INLINESITE2 = 4445, - S_MOD_TYPEREF = 4447, - S_REF_MINIPDB = 4448, - S_PDBMAP = 4449, - S_GDATA_HLSL32 = 4450, - S_LDATA_HLSL32 = 4451, - S_GDATA_HLSL32_EX = 4452, - S_LDATA_HLSL32_EX = 4453, - S_FASTLINK = 4455, - S_INLINEES = 4456, - S_END = 6, - S_INLINESITE_END = 4430, - S_PROC_ID_END = 4431, - S_THUNK32 = 4354, - S_TRAMPOLINE = 4396, - S_SECTION = 4406, - S_COFFGROUP = 4407, - S_EXPORT = 4408, - S_LPROC32 = 4367, - S_GPROC32 = 4368, - S_LPROC32_ID = 4422, - S_GPROC32_ID = 4423, - S_LPROC32_DPC = 4437, - S_LPROC32_DPC_ID = 4438, - S_REGISTER = 4358, - S_PUB32 = 4366, - S_PROCREF = 4389, - S_LPROCREF = 4391, - S_ENVBLOCK = 4413, - S_INLINESITE = 4429, - S_LOCAL = 4414, - S_DEFRANGE = 4415, - S_DEFRANGE_SUBFIELD = 4416, - S_DEFRANGE_REGISTER = 4417, - S_DEFRANGE_FRAMEPOINTER_REL = 4418, - S_DEFRANGE_SUBFIELD_REGISTER = 4419, - S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE = 4420, - S_DEFRANGE_REGISTER_REL = 4421, - S_BLOCK32 = 4355, - S_LABEL32 = 4357, - S_OBJNAME = 4353, - S_COMPILE2 = 4374, - S_COMPILE3 = 4412, - S_FRAMEPROC = 4114, - S_CALLSITEINFO = 4409, - S_FILESTATIC = 4435, - S_HEAPALLOCSITE = 4446, - S_FRAMECOOKIE = 4410, - S_CALLEES = 4442, - S_CALLERS = 4443, - S_UDT = 4360, - S_COBOLUDT = 4361, - S_BUILDINFO = 4428, - S_BPREL32 = 4363, - S_REGREL32 = 4369, - S_CONSTANT = 4359, - S_MANCONSTANT = 4397, - S_LDATA32 = 4364, - S_GDATA32 = 4365, - S_LMANDATA = 4380, - S_GMANDATA = 4381, - S_LTHREAD32 = 4370, - S_GTHREAD32 = 4371, + compile = 1, + register_16t = 2, + constant_16t = 3, + udt_16t = 4, + ssearch = 5, + skip = 7, + cvreserve = 8, + objname_st = 9, + endarg = 10, + coboludt_16t = 11, + manyreg_16t = 12, + @"return" = 13, + entrythis = 14, + bprel16 = 256, + ldata16 = 257, + gdata16 = 258, + pub16 = 259, + lproc16 = 260, + gproc16 = 261, + thunk16 = 262, + block16 = 263, + with16 = 264, + label16 = 265, + cexmodel16 = 266, + vftable16 = 267, + regrel16 = 268, + bprel32_16t = 512, + ldata32_16t = 513, + gdata32_16t = 514, + pub32_16t = 515, + lproc32_16t = 516, + gproc32_16t = 517, + thunk32_st = 518, + block32_st = 519, + with32_st = 520, + label32_st = 521, + cexmodel32 = 522, + vftable32_16t = 523, + regrel32_16t = 524, + lthread32_16t = 525, + gthread32_16t = 526, + slink32 = 527, + lprocmips_16t = 768, + gprocmips_16t = 769, + procref_st = 1024, + dataref_st = 1025, + @"align" = 1026, + lprocref_st = 1027, + oem = 1028, + ti16_max = 4096, + register_st = 4097, + constant_st = 4098, + udt_st = 4099, + coboludt_st = 4100, + manyreg_st = 4101, + bprel32_st = 4102, + ldata32_st = 4103, + gdata32_st = 4104, + pub32_st = 4105, + lproc32_st = 4106, + gproc32_st = 4107, + vftable32 = 4108, + regrel32_st = 4109, + lthread32_st = 4110, + gthread32_st = 4111, + lprocmips_st = 4112, + gprocmips_st = 4113, + compile2_st = 4115, + manyreg2_st = 4116, + lprocia64_st = 4117, + gprocia64_st = 4118, + localslot_st = 4119, + paramslot_st = 4120, + annotation = 4121, + gmanproc_st = 4122, + lmanproc_st = 4123, + reserved1 = 4124, + reserved2 = 4125, + reserved3 = 4126, + reserved4 = 4127, + lmandata_st = 4128, + gmandata_st = 4129, + manframerel_st = 4130, + manregister_st = 4131, + manslot_st = 4132, + manmanyreg_st = 4133, + manregrel_st = 4134, + manmanyreg2_st = 4135, + mantypref = 4136, + unamespace_st = 4137, + st_max = 4352, + with32 = 4356, + manyreg = 4362, + lprocmips = 4372, + gprocmips = 4373, + manyreg2 = 4375, + lprocia64 = 4376, + gprocia64 = 4377, + localslot = 4378, + paramslot = 4379, + manframerel = 4382, + manregister = 4383, + manslot = 4384, + manmanyreg = 4385, + manregrel = 4386, + manmanyreg2 = 4387, + unamespace = 4388, + dataref = 4390, + annotationref = 4392, + tokenref = 4393, + gmanproc = 4394, + lmanproc = 4395, + attr_framerel = 4398, + attr_register = 4399, + attr_regrel = 4400, + attr_manyreg = 4401, + sepcode = 4402, + local_2005 = 4403, + defrange_2005 = 4404, + defrange2_2005 = 4405, + discarded = 4411, + lprocmips_id = 4424, + gprocmips_id = 4425, + lprocia64_id = 4426, + gprocia64_id = 4427, + defrange_hlsl = 4432, + gdata_hlsl = 4433, + ldata_hlsl = 4434, + local_dpc_groupshared = 4436, + defrange_dpc_ptr_tag = 4439, + dpc_sym_tag_map = 4440, + armswitchtable = 4441, + pogodata = 4444, + inlinesite2 = 4445, + mod_typeref = 4447, + ref_minipdb = 4448, + pdbmap = 4449, + gdata_hlsl32 = 4450, + ldata_hlsl32 = 4451, + gdata_hlsl32_ex = 4452, + ldata_hlsl32_ex = 4453, + fastlink = 4455, + inlinees = 4456, + end = 6, + inlinesite_end = 4430, + proc_id_end = 4431, + thunk32 = 4354, + trampoline = 4396, + section = 4406, + coffgroup = 4407, + @"export" = 4408, + lproc32 = 4367, + gproc32 = 4368, + lproc32_id = 4422, + gproc32_id = 4423, + lproc32_dpc = 4437, + lproc32_dpc_id = 4438, + register = 4358, + pub32 = 4366, + procref = 4389, + lprocref = 4391, + envblock = 4413, + inlinesite = 4429, + local = 4414, + defrange = 4415, + defrange_subfield = 4416, + defrange_register = 4417, + defrange_framepointer_rel = 4418, + defrange_subfield_register = 4419, + defrange_framepointer_rel_full_scope = 4420, + defrange_register_rel = 4421, + block32 = 4355, + label32 = 4357, + objname = 4353, + compile2 = 4374, + compile3 = 4412, + frameproc = 4114, + callsiteinfo = 4409, + filestatic = 4435, + heapallocsite = 4446, + framecookie = 4410, + callees = 4442, + callers = 4443, + udt = 4360, + coboludt = 4361, + buildinfo = 4428, + bprel32 = 4363, + regrel32 = 4369, + constant = 4359, + manconstant = 4397, + ldata32 = 4364, + gdata32 = 4365, + lmandata = 4380, + gmandata = 4381, + lthread32 = 4370, + gthread32 = 4371, }; pub const TypeIndex = u32; @@ -320,28 +320,28 @@ pub const TypeIndex = u32; // we should define RecordPrefix as part of the ProcSym structure. // This might be important when we start generating PDB in self-hosted with our own PE linker. pub const ProcSym = extern struct { - Parent: u32, - End: u32, - Next: u32, - CodeSize: u32, - DbgStart: u32, - DbgEnd: u32, - FunctionType: TypeIndex, - CodeOffset: u32, - Segment: u16, - Flags: ProcSymFlags, - Name: [1]u8, // null-terminated + parent: u32, + end: u32, + next: u32, + code_size: u32, + dbg_start: u32, + dbg_end: u32, + function_type: TypeIndex, + code_offset: u32, + segment: u16, + flags: ProcSymFlags, + name: [1]u8, // null-terminated }; pub const ProcSymFlags = packed struct { - HasFP: bool, - HasIRET: bool, - HasFRET: bool, - IsNoReturn: bool, - IsUnreachable: bool, - HasCustomCallingConv: bool, - IsNoInline: bool, - HasOptimizedDebugInfo: bool, + has_fp: bool, + has_iret: bool, + has_fret: bool, + is_no_return: bool, + is_unreachable: bool, + has_custom_calling_conv: bool, + is_no_inline: bool, + has_optimized_debug_info: bool, }; pub const SectionContrSubstreamVersion = enum(u32) { @@ -351,11 +351,11 @@ pub const SectionContrSubstreamVersion = enum(u32) { }; pub const RecordPrefix = extern struct { - /// Record length, starting from &RecordKind. - RecordLen: u16, + /// Record length, starting from &record_kind. + record_len: u16, /// Record kind enum (SymRecordKind or TypeRecordKind) - RecordKind: SymbolKind, + record_kind: SymbolKind, }; /// The following variable length array appears immediately after the header. @@ -364,19 +364,19 @@ pub const RecordPrefix = extern struct { /// Each `LineBlockFragmentHeader` as specified below. pub const LineFragmentHeader = extern struct { /// Code offset of line contribution. - RelocOffset: u32, + reloc_offset: u32, /// Code segment of line contribution. - RelocSegment: u16, - Flags: LineFlags, + reloc_segment: u16, + flags: LineFlags, /// Code size of this line contribution. - CodeSize: u32, + code_size: u32, }; pub const LineFlags = packed struct { /// CV_LINES_HAVE_COLUMNS - LF_HaveColumns: bool, + have_columns: bool, unused: u15, }; @@ -389,110 +389,109 @@ pub const LineBlockFragmentHeader = extern struct { /// checksums buffer. The checksum entry then /// contains another offset into the string /// table of the actual name. - NameIndex: u32, - NumLines: u32, + name_index: u32, + num_lines: u32, /// code size of block, in bytes - BlockSize: u32, + block_size: u32, }; pub const LineNumberEntry = extern struct { /// Offset to start of code bytes for line number - Offset: u32, - Flags: u32, + offset: u32, + flags: Flags, - /// TODO runtime crash when I make the actual type of Flags this - pub const Flags = packed struct { + pub const Flags = packed struct(u32) { /// Start line number - Start: u24, + start: u24, /// Delta of lines to the end of the expression. Still unclear. // TODO figure out the point of this field. - End: u7, - IsStatement: bool, + end: u7, + is_statement: bool, }; }; pub const ColumnNumberEntry = extern struct { - StartColumn: u16, - EndColumn: u16, + start_column: u16, + end_column: u16, }; /// Checksum bytes follow. pub const FileChecksumEntryHeader = extern struct { /// Byte offset of filename in global string table. - FileNameOffset: u32, + file_name_offset: u32, /// Number of bytes of checksum. - ChecksumSize: u8, + checksum_size: u8, /// FileChecksumKind - ChecksumKind: u8, + checksum_kind: u8, }; pub const DebugSubsectionKind = enum(u32) { - None = 0, - Symbols = 0xf1, - Lines = 0xf2, - StringTable = 0xf3, - FileChecksums = 0xf4, - FrameData = 0xf5, - InlineeLines = 0xf6, - CrossScopeImports = 0xf7, - CrossScopeExports = 0xf8, + none = 0, + symbols = 0xf1, + lines = 0xf2, + string_table = 0xf3, + file_checksums = 0xf4, + frame_data = 0xf5, + inlinee_lines = 0xf6, + cross_scope_imports = 0xf7, + cross_scope_exports = 0xf8, // These appear to relate to .Net assembly info. - ILLines = 0xf9, - FuncMDTokenMap = 0xfa, - TypeMDTokenMap = 0xfb, - MergedAssemblyInput = 0xfc, + il_lines = 0xf9, + func_md_token_map = 0xfa, + type_md_token_map = 0xfb, + merged_assembly_input = 0xfc, - CoffSymbolRVA = 0xfd, + coff_symbol_rva = 0xfd, }; pub const DebugSubsectionHeader = extern struct { /// codeview::DebugSubsectionKind enum - Kind: DebugSubsectionKind, + kind: DebugSubsectionKind, /// number of bytes occupied by this record. - Length: u32, + length: u32, }; pub const StringTableHeader = extern struct { /// PDBStringTableSignature - Signature: u32, + signature: u32, /// 1 or 2 - HashVersion: u32, + hash_version: u32, /// Number of bytes of names buffer. - ByteSize: u32, + byte_size: u32, }; // https://llvm.org/docs/PDB/MsfFile.html#the-superblock pub const SuperBlock = extern struct { /// The LLVM docs list a space between C / C++ but empirically this is not the case. - pub const file_magic = "Microsoft C/C++ MSF 7.00\r\n\x1a\x44\x53\x00\x00\x00"; + pub const expect_magic = "Microsoft C/C++ MSF 7.00\r\n\x1a\x44\x53\x00\x00\x00"; - FileMagic: [file_magic.len]u8, + file_magic: [expect_magic.len]u8, /// The block size of the internal file system. Valid values are 512, 1024, /// 2048, and 4096 bytes. Certain aspects of the MSF file layout vary depending /// on the block sizes. For the purposes of LLVM, we handle only block sizes of /// 4KiB, and all further discussion assumes a block size of 4KiB. - BlockSize: u32, + block_size: u32, /// The index of a block within the file, at which begins a bitfield representing /// the set of all blocks within the file which are “free” (i.e. the data within /// that block is not used). See The Free Block Map for more information. Important: /// FreeBlockMapBlock can only be 1 or 2! - FreeBlockMapBlock: u32, + free_block_map_block: u32, /// The total number of blocks in the file. NumBlocks * BlockSize should equal the /// size of the file on disk. - NumBlocks: u32, + num_blocks: u32, /// The size of the stream directory, in bytes. The stream directory contains /// information about each stream’s size and the set of blocks that it occupies. /// It will be described in more detail later. - NumDirectoryBytes: u32, + num_directory_bytes: u32, - Unknown: u32, + unknown: u32, /// The index of a block within the MSF file. At this block is an array of /// ulittle32_t’s listing the blocks that the stream directory resides on. /// For large MSF files, the stream directory (which describes the block @@ -508,5 +507,5 @@ pub const SuperBlock = extern struct { // This would mean the Stream Directory is bigger than BlockSize / sizeof(u32) // blocks. We're not even close to this with a 1GB pdb file, and LLVM didn't // implement it so we're kind of safe making this assumption for now. - BlockMapAddr: u32, + block_map_addr: u32, }; diff --git a/lib/std/posix.zig b/lib/std/posix.zig index bc270395cc..9e1631dd20 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -654,7 +654,7 @@ fn getRandomBytesDevURandom(buf: []u8) !void { /// it raises SIGABRT followed by SIGKILL and finally lo /// Invokes the current signal handler for SIGABRT, if any. pub fn abort() noreturn { - @setCold(true); + @branchHint(.cold); // MSVCRT abort() sometimes opens a popup window which is undesirable, so // even when linking libc on Windows we use our own abort implementation. // See https://github.com/ziglang/zig/issues/2071 for more details. @@ -4746,11 +4746,13 @@ pub fn munmap(memory: []align(mem.page_size) const u8) void { pub const MSyncError = error{ UnmappedMemory, + PermissionDenied, } || UnexpectedError; pub fn msync(memory: []align(mem.page_size) u8, flags: i32) MSyncError!void { switch (errno(system.msync(memory.ptr, memory.len, flags))) { .SUCCESS => return, + .PERM => return error.PermissionDenied, .NOMEM => return error.UnmappedMemory, // Unsuccessful, provided pointer does not point mapped memory .INVAL => unreachable, // Invalid parameters. else => unreachable, @@ -6179,7 +6181,7 @@ pub fn sendfile( var total_written: usize = 0; // Prevents EOVERFLOW. - const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1); + const size_t = std.meta.Int(.unsigned, @typeInfo(usize).int.bits - 1); const max_count = switch (native_os) { .linux => 0x7ffff000, .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32), @@ -6986,7 +6988,7 @@ pub const PrctlError = error{ } || UnexpectedError; pub fn prctl(option: PR, args: anytype) PrctlError!u31 { - if (@typeInfo(@TypeOf(args)) != .Struct) + if (@typeInfo(@TypeOf(args)) != .@"struct") @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args))); if (args.len > 4) @compileError("prctl takes a maximum of 4 optional arguments"); @@ -7106,6 +7108,7 @@ pub const MadviseError = error{ pub fn madvise(ptr: [*]align(mem.page_size) u8, length: usize, advice: u32) MadviseError!void { switch (errno(system.madvise(ptr, length, advice))) { .SUCCESS => return, + .PERM => return error.PermissionDenied, .ACCES => return error.AccessDenied, .AGAIN => return error.SystemResources, .BADF => unreachable, // The map exists, but the area maps something that isn't a file. diff --git a/lib/std/posix/test.zig b/lib/std/posix/test.zig index 7ba9a7701e..474de28f6d 100644 --- a/lib/std/posix/test.zig +++ b/lib/std/posix/test.zig @@ -782,7 +782,7 @@ test "fsync" { test "getrlimit and setrlimit" { if (posix.system.rlimit_resource == void) return error.SkipZigTest; - inline for (@typeInfo(posix.rlimit_resource).Enum.fields) |field| { + inline for (@typeInfo(posix.rlimit_resource).@"enum".fields) |field| { const resource: posix.rlimit_resource = @enumFromInt(field.value); const limit = try posix.getrlimit(resource); diff --git a/lib/std/process/Child.zig b/lib/std/process/Child.zig index dfe0c6578e..2002bad20e 100644 --- a/lib/std/process/Child.zig +++ b/lib/std/process/Child.zig @@ -1112,7 +1112,7 @@ fn windowsCreateProcessPathExt( } var io_status: windows.IO_STATUS_BLOCK = undefined; - const num_supported_pathext = @typeInfo(WindowsExtension).Enum.fields.len; + const num_supported_pathext = @typeInfo(WindowsExtension).@"enum".fields.len; var pathext_seen = [_]bool{false} ** num_supported_pathext; var any_pathext_seen = false; var unappended_exists = false; diff --git a/lib/std/segmented_list.zig b/lib/std/segmented_list.zig index a729c368ed..72397dc1ab 100644 --- a/lib/std/segmented_list.zig +++ b/lib/std/segmented_list.zig @@ -99,7 +99,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type pub const prealloc_count = prealloc_item_count; fn AtType(comptime SelfType: type) type { - if (@typeInfo(SelfType).Pointer.is_const) { + if (@typeInfo(SelfType).pointer.is_const) { return *const T; } else { return *T; diff --git a/lib/std/simd.zig b/lib/std/simd.zig index 236b9fbab8..6817c7e082 100644 --- a/lib/std/simd.zig +++ b/lib/std/simd.zig @@ -105,8 +105,8 @@ test "suggestVectorLengthForCpu works with signed and unsigned values" { fn vectorLength(comptime VectorType: type) comptime_int { return switch (@typeInfo(VectorType)) { - .Vector => |info| info.len, - .Array => |info| info.len, + .vector => |info| info.len, + .array => |info| info.len, else => @compileError("Invalid type " ++ @typeName(VectorType)), }; } @@ -128,8 +128,8 @@ pub inline fn iota(comptime T: type, comptime len: usize) @Vector(len, T) { var out: [len]T = undefined; for (&out, 0..) |*element, i| { element.* = switch (@typeInfo(T)) { - .Int => @as(T, @intCast(i)), - .Float => @as(T, @floatFromInt(i)), + .int => @as(T, @intCast(i)), + .float => @as(T, @floatFromInt(i)), else => @compileError("Can't use type " ++ @typeName(T) ++ " in iota."), }; } @@ -417,18 +417,18 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a const Child = std.meta.Child(VecType); const identity = comptime switch (@typeInfo(Child)) { - .Bool => switch (op) { + .bool => switch (op) { .Or, .Xor => false, .And => true, else => @compileError("Invalid prefixScan operation " ++ @tagName(op) ++ " for vector of booleans."), }, - .Int => switch (op) { + .int => switch (op) { .Max => std.math.minInt(Child), .Add, .Or, .Xor => 0, .Mul => 1, .And, .Min => std.math.maxInt(Child), }, - .Float => switch (op) { + .float => switch (op) { .Max => -std.math.inf(Child), .Add => 0, .Mul => 1, diff --git a/lib/std/sort/pdq.zig b/lib/std/sort/pdq.zig index 61d78797c5..55bd17ae93 100644 --- a/lib/std/sort/pdq.zig +++ b/lib/std/sort/pdq.zig @@ -203,7 +203,7 @@ fn partitionEqual(a: usize, b: usize, pivot: usize, context: anytype) usize { /// /// returns `true` if the slice is sorted at the end. This function is `O(n)` worst-case. fn partialInsertionSort(a: usize, b: usize, context: anytype) bool { - @setCold(true); + @branchHint(.cold); // maximum number of adjacent out-of-order pairs that will get shifted const max_steps = 5; @@ -247,7 +247,7 @@ fn partialInsertionSort(a: usize, b: usize, context: anytype) bool { } fn breakPatterns(a: usize, b: usize, context: anytype) void { - @setCold(true); + @branchHint(.cold); const len = b - a; if (len < 8) return; diff --git a/lib/std/start.zig b/lib/std/start.zig index e899e80568..ea6f347bd6 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -30,39 +30,39 @@ comptime { if (simplified_logic) { if (builtin.output_mode == .Exe) { if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { - if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { - @export(main2, .{ .name = "main" }); + if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) { + @export(&main2, .{ .name = "main" }); } } else if (builtin.os.tag == .windows) { if (!@hasDecl(root, "wWinMainCRTStartup") and !@hasDecl(root, "mainCRTStartup")) { - @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" }); + @export(&wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" }); } } else if (builtin.os.tag == .opencl) { if (@hasDecl(root, "main")) - @export(spirvMain2, .{ .name = "main" }); + @export(&spirvMain2, .{ .name = "main" }); } else { if (!@hasDecl(root, "_start")) { - @export(_start2, .{ .name = "_start" }); + @export(&_start2, .{ .name = "_start" }); } } } } else { if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) { if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) { - @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" }); + @export(&_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" }); } } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) { if (builtin.link_libc and @hasDecl(root, "main")) { if (native_arch.isWasm()) { - @export(mainWithoutEnv, .{ .name = "main" }); - } else if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { - @export(main, .{ .name = "main" }); + @export(&mainWithoutEnv, .{ .name = "main" }); + } else if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) { + @export(&main, .{ .name = "main" }); } } else if (native_os == .windows) { if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup")) { - @export(WinStartup, .{ .name = "wWinMainCRTStartup" }); + @export(&WinStartup, .{ .name = "wWinMainCRTStartup" }); } else if (@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup")) { @@ -70,10 +70,10 @@ comptime { } else if (@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup") and !@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) { - @export(wWinMainCRTStartup, .{ .name = "wWinMainCRTStartup" }); + @export(&wWinMainCRTStartup, .{ .name = "wWinMainCRTStartup" }); } } else if (native_os == .uefi) { - if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" }); + if (!@hasDecl(root, "EfiMain")) @export(&EfiMain, .{ .name = "EfiMain" }); } else if (native_os == .wasi) { const wasm_start_sym = switch (builtin.wasi_exec_model) { .reactor => "_initialize", @@ -82,14 +82,14 @@ comptime { if (!@hasDecl(root, wasm_start_sym) and @hasDecl(root, "main")) { // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which // case it's not required to provide an entrypoint such as main. - @export(wasi_start, .{ .name = wasm_start_sym }); + @export(&wasi_start, .{ .name = wasm_start_sym }); } } else if (native_arch.isWasm() and native_os == .freestanding) { // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which // case it's not required to provide an entrypoint such as main. - if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(wasm_freestanding_start, .{ .name = start_sym_name }); + if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(&wasm_freestanding_start, .{ .name = start_sym_name }); } else if (native_os != .other and native_os != .freestanding) { - if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name }); + if (!@hasDecl(root, start_sym_name)) @export(&_start, .{ .name = start_sym_name }); } } } @@ -205,7 +205,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv uefi.handle = handle; uefi.system_table = system_table; - switch (@typeInfo(@TypeOf(root.main)).Fn.return_type.?) { + switch (@typeInfo(@TypeOf(root.main)).@"fn".return_type.?) { noreturn => { root.main(); }, @@ -249,6 +249,7 @@ fn _start() callconv(.Naked) noreturn { // linker explicitly. asm volatile (switch (native_arch) { .x86_64 => + \\ .cfi_undefined %%rip \\ xorl %%ebp, %%ebp \\ movq %%rsp, %%rdi \\ andq $-16, %%rsp @@ -598,7 +599,7 @@ fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.C) c_int { const bad_main_ret = "expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8'"; pub inline fn callMain() u8 { - const ReturnType = @typeInfo(@TypeOf(root.main)).Fn.return_type.?; + const ReturnType = @typeInfo(@TypeOf(root.main)).@"fn".return_type.?; switch (ReturnType) { void => { @@ -609,7 +610,7 @@ pub inline fn callMain() u8 { return root.main(); }, else => { - if (@typeInfo(ReturnType) != .ErrorUnion) @compileError(bad_main_ret); + if (@typeInfo(ReturnType) != .error_union) @compileError(bad_main_ret); const result = root.main() catch |err| { if (builtin.zig_backend == .stage2_riscv64) { @@ -634,7 +635,7 @@ pub inline fn callMain() u8 { pub fn call_wWinMain() std.os.windows.INT { const peb = std.os.windows.peb(); - const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?; + const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).@"fn".params[0].type.?; const hInstance = @as(MAIN_HINSTANCE, @ptrCast(peb.ImageBaseAddress)); const lpCmdLine: [*:0]u16 = @ptrCast(peb.ProcessParameters.CommandLine.Buffer); diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 80e8ab13bb..35bb13bf0d 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -64,33 +64,33 @@ pub inline fn expectEqual(expected: anytype, actual: anytype) !void { fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { switch (@typeInfo(@TypeOf(actual))) { - .NoReturn, - .Opaque, - .Frame, - .AnyFrame, + .noreturn, + .@"opaque", + .frame, + .@"anyframe", => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"), - .Undefined, - .Null, - .Void, + .undefined, + .null, + .void, => return, - .Type => { + .type => { if (actual != expected) { print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) }); return error.TestExpectedEqual; } }, - .Bool, - .Int, - .Float, - .ComptimeFloat, - .ComptimeInt, - .EnumLiteral, - .Enum, - .Fn, - .ErrorSet, + .bool, + .int, + .float, + .comptime_float, + .comptime_int, + .enum_literal, + .@"enum", + .@"fn", + .error_set, => { if (actual != expected) { print("expected {}, found {}\n", .{ expected, actual }); @@ -98,7 +98,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { } }, - .Pointer => |pointer| { + .pointer => |pointer| { switch (pointer.size) { .One, .Many, .C => { if (actual != expected) { @@ -119,9 +119,9 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { } }, - .Array => |array| try expectEqualSlices(array.child, &expected, &actual), + .array => |array| try expectEqualSlices(array.child, &expected, &actual), - .Vector => |info| { + .vector => |info| { var i: usize = 0; while (i < info.len) : (i += 1) { if (!std.meta.eql(expected[i], actual[i])) { @@ -133,13 +133,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { } }, - .Struct => |structType| { + .@"struct" => |structType| { inline for (structType.fields) |field| { try expectEqual(@field(expected, field.name), @field(actual, field.name)); } }, - .Union => |union_info| { + .@"union" => |union_info| { if (union_info.tag_type == null) { @compileError("Unable to compare untagged union values"); } @@ -157,7 +157,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { } }, - .Optional => { + .optional => { if (expected) |expected_payload| { if (actual) |actual_payload| { try expectEqual(expected_payload, actual_payload); @@ -173,7 +173,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { } }, - .ErrorUnion => { + .error_union => { if (expected) |expected_payload| { if (actual) |actual_payload| { try expectEqual(expected_payload, actual_payload); @@ -237,12 +237,12 @@ pub inline fn expectApproxEqAbs(expected: anytype, actual: anytype, tolerance: a fn expectApproxEqAbsInner(comptime T: type, expected: T, actual: T, tolerance: T) !void { switch (@typeInfo(T)) { - .Float => if (!math.approxEqAbs(T, expected, actual, tolerance)) { + .float => if (!math.approxEqAbs(T, expected, actual, tolerance)) { print("actual {}, not within absolute tolerance {} of expected {}\n", .{ actual, tolerance, expected }); return error.TestExpectedApproxEqAbs; }, - .ComptimeFloat => @compileError("Cannot approximately compare two comptime_float values"), + .comptime_float => @compileError("Cannot approximately compare two comptime_float values"), else => @compileError("Unable to compare non floating point values"), } @@ -273,12 +273,12 @@ pub inline fn expectApproxEqRel(expected: anytype, actual: anytype, tolerance: a fn expectApproxEqRelInner(comptime T: type, expected: T, actual: T, tolerance: T) !void { switch (@typeInfo(T)) { - .Float => if (!math.approxEqRel(T, expected, actual, tolerance)) { + .float => if (!math.approxEqRel(T, expected, actual, tolerance)) { print("actual {}, not within relative tolerance {} of expected {}\n", .{ actual, tolerance, expected }); return error.TestExpectedApproxEqRel; }, - .ComptimeFloat => @compileError("Cannot approximately compare two comptime_float values"), + .comptime_float => @compileError("Cannot approximately compare two comptime_float values"), else => @compileError("Unable to compare non floating point values"), } @@ -415,7 +415,7 @@ fn SliceDiffer(comptime T: type) type { const full_index = self.start_index + i; const diff = if (i < self.actual.len) !std.meta.eql(self.actual[i], value) else true; if (diff) try self.ttyconf.setColor(writer, .red); - if (@typeInfo(T) == .Pointer) { + if (@typeInfo(T) == .pointer) { try writer.print("[{}]{*}: {any}\n", .{ full_index, value, value }); } else { try writer.print("[{}]: {any}\n", .{ full_index, value }); @@ -505,10 +505,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s const expected_value_sentinel = blk: { switch (@typeInfo(@TypeOf(expected))) { - .Pointer => { + .pointer => { break :blk expected[expected.len]; }, - .Array => |array_info| { + .array => |array_info| { const indexable_outside_of_bounds = @as([]const array_info.child, &expected); break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len]; }, @@ -518,10 +518,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s const actual_value_sentinel = blk: { switch (@typeInfo(@TypeOf(actual))) { - .Pointer => { + .pointer => { break :blk actual[actual.len]; }, - .Array => |array_info| { + .array => |array_info| { const indexable_outside_of_bounds = @as([]const array_info.child, &actual); break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len]; }, @@ -689,33 +689,33 @@ pub inline fn expectEqualDeep(expected: anytype, actual: anytype) error{TestExpe fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpectedEqual}!void { switch (@typeInfo(@TypeOf(actual))) { - .NoReturn, - .Opaque, - .Frame, - .AnyFrame, + .noreturn, + .@"opaque", + .frame, + .@"anyframe", => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"), - .Undefined, - .Null, - .Void, + .undefined, + .null, + .void, => return, - .Type => { + .type => { if (actual != expected) { print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) }); return error.TestExpectedEqual; } }, - .Bool, - .Int, - .Float, - .ComptimeFloat, - .ComptimeInt, - .EnumLiteral, - .Enum, - .Fn, - .ErrorSet, + .bool, + .int, + .float, + .comptime_float, + .comptime_int, + .enum_literal, + .@"enum", + .@"fn", + .error_set, => { if (actual != expected) { print("expected {}, found {}\n", .{ expected, actual }); @@ -723,7 +723,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe } }, - .Pointer => |pointer| { + .pointer => |pointer| { switch (pointer.size) { // We have no idea what is behind those pointers, so the best we can do is `==` check. .C, .Many => { @@ -735,7 +735,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe .One => { // Length of those pointers are runtime value, so the best we can do is `==` check. switch (@typeInfo(pointer.child)) { - .Fn, .Opaque => { + .@"fn", .@"opaque" => { if (actual != expected) { print("expected {*}, found {*}\n", .{ expected, actual }); return error.TestExpectedEqual; @@ -762,7 +762,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe } }, - .Array => |_| { + .array => |_| { if (expected.len != actual.len) { print("Array len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len }); return error.TestExpectedEqual; @@ -778,9 +778,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe } }, - .Vector => |info| { - if (info.len != @typeInfo(@TypeOf(actual)).Vector.len) { - print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).Vector.len }); + .vector => |info| { + if (info.len != @typeInfo(@TypeOf(actual)).vector.len) { + print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).vector.len }); return error.TestExpectedEqual; } var i: usize = 0; @@ -794,7 +794,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe } }, - .Struct => |structType| { + .@"struct" => |structType| { inline for (structType.fields) |field| { expectEqualDeep(@field(expected, field.name), @field(actual, field.name)) catch |e| { print("Field {s} incorrect. expected {any}, found {any}\n", .{ field.name, @field(expected, field.name), @field(actual, field.name) }); @@ -803,7 +803,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe } }, - .Union => |union_info| { + .@"union" => |union_info| { if (union_info.tag_type == null) { @compileError("Unable to compare untagged union values"); } @@ -823,7 +823,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe } }, - .Optional => { + .optional => { if (expected) |expected_payload| { if (actual) |actual_payload| { try expectEqualDeep(expected_payload, actual_payload); @@ -839,7 +839,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe } }, - .ErrorUnion => { + .error_union => { if (expected) |expected_payload| { if (actual) |actual_payload| { try expectEqualDeep(expected_payload, actual_payload); @@ -1036,20 +1036,20 @@ test { /// } /// ``` pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime test_fn: anytype, extra_args: anytype) !void { - switch (@typeInfo(@typeInfo(@TypeOf(test_fn)).Fn.return_type.?)) { - .ErrorUnion => |info| { + switch (@typeInfo(@typeInfo(@TypeOf(test_fn)).@"fn".return_type.?)) { + .error_union => |info| { if (info.payload != void) { @compileError("Return type must be !void"); } }, else => @compileError("Return type must be !void"), } - if (@typeInfo(@TypeOf(extra_args)) != .Struct) { + if (@typeInfo(@TypeOf(extra_args)) != .@"struct") { @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(extra_args))); } const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn)); - const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields; + const fn_args_fields = @typeInfo(ArgsTuple).@"struct".fields; if (fn_args_fields.len == 0 or fn_args_fields[0].type != std.mem.Allocator) { @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument"); } @@ -1061,7 +1061,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime // Setup the tuple that will actually be used with @call (we'll need to insert // the failing allocator in field @"0" before each @call) var args: ArgsTuple = undefined; - inline for (@typeInfo(@TypeOf(extra_args)).Struct.fields, 0..) |field, i| { + inline for (@typeInfo(@TypeOf(extra_args)).@"struct".fields, 0..) |field, i| { const arg_i_str = comptime str: { var str_buf: [100]u8 = undefined; const args_i = i + 1; @@ -1129,7 +1129,7 @@ pub fn refAllDeclsRecursive(comptime T: type) void { inline for (comptime std.meta.declarations(T)) |decl| { if (@TypeOf(@field(T, decl.name)) == type) { switch (@typeInfo(@field(T, decl.name))) { - .Struct, .Enum, .Union, .Opaque => refAllDeclsRecursive(@field(T, decl.name)), + .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(@field(T, decl.name)), else => {}, } } diff --git a/lib/std/valgrind.zig b/lib/std/valgrind.zig index 8590302e9a..241f4c732a 100644 --- a/lib/std/valgrind.zig +++ b/lib/std/valgrind.zig @@ -278,8 +278,10 @@ pub fn monitorCommand(command: [*]u8) bool { pub const memcheck = @import("valgrind/memcheck.zig"); pub const callgrind = @import("valgrind/callgrind.zig"); +pub const cachegrind = @import("valgrind/cachegrind.zig"); test { _ = memcheck; _ = callgrind; + _ = cachegrind; } diff --git a/lib/std/valgrind/cachegrind.zig b/lib/std/valgrind/cachegrind.zig new file mode 100644 index 0000000000..b6aef5391b --- /dev/null +++ b/lib/std/valgrind/cachegrind.zig @@ -0,0 +1,29 @@ +const std = @import("../std.zig"); +const valgrind = std.valgrind; + +pub const ClientRequest = enum(usize) { + StartInstrumentation = valgrind.ToolBase("CG".*), + StopInstrumentation, +}; + +fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { + return valgrind.doClientRequest(default, @as(usize, @intCast(@intFromEnum(request))), a1, a2, a3, a4, a5); +} + +fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { + _ = doClientRequestExpr(0, request, a1, a2, a3, a4, a5); +} + +/// Start Cachegrind instrumentation if not already enabled. Use this in +/// combination with `std.valgrind.cachegrind.stopInstrumentation` and +/// `--instr-at-start` to measure only part of a client program's execution. +pub fn startInstrumentation() void { + doClientRequestStmt(.StartInstrumentation, 0, 0, 0, 0, 0); +} + +/// Stop Cachegrind instrumentation if not already disabled. Use this in +/// combination with `std.valgrind.cachegrind.startInstrumentation` and +/// `--instr-at-start` to measure only part of a client program's execution. +pub fn stopInstrumentation() void { + doClientRequestStmt(.StopInstrumentation, 0, 0, 0, 0, 0); +} diff --git a/lib/std/valgrind/callgrind.zig b/lib/std/valgrind/callgrind.zig index 716573e7b0..6718f40643 100644 --- a/lib/std/valgrind/callgrind.zig +++ b/lib/std/valgrind/callgrind.zig @@ -1,7 +1,7 @@ const std = @import("../std.zig"); const valgrind = std.valgrind; -pub const CallgrindClientRequest = enum(usize) { +pub const ClientRequest = enum(usize) { DumpStats = valgrind.ToolBase("CT".*), ZeroStats, ToggleCollect, @@ -10,17 +10,19 @@ pub const CallgrindClientRequest = enum(usize) { StopInstrumentation, }; -fn doCallgrindClientRequestExpr(default: usize, request: CallgrindClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { +pub const CallgrindClientRequest = @compileError("std.valgrind.callgrind.CallgrindClientRequest renamed to std.valgrind.callgrind.ClientRequest"); + +fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { return valgrind.doClientRequest(default, @as(usize, @intCast(@intFromEnum(request))), a1, a2, a3, a4, a5); } -fn doCallgrindClientRequestStmt(request: CallgrindClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { - _ = doCallgrindClientRequestExpr(0, request, a1, a2, a3, a4, a5); +fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { + _ = doClientRequestExpr(0, request, a1, a2, a3, a4, a5); } /// Dump current state of cost centers, and zero them afterwards pub fn dumpStats() void { - doCallgrindClientRequestStmt(.DumpStats, 0, 0, 0, 0, 0); + doClientRequestStmt(.DumpStats, 0, 0, 0, 0, 0); } /// Dump current state of cost centers, and zero them afterwards. @@ -28,12 +30,12 @@ pub fn dumpStats() void { /// the dump. This string is written as a description field into the /// profile data dump. pub fn dumpStatsAt(pos_str: [*:0]const u8) void { - doCallgrindClientRequestStmt(.DumpStatsAt, @intFromPtr(pos_str), 0, 0, 0, 0); + doClientRequestStmt(.DumpStatsAt, @intFromPtr(pos_str), 0, 0, 0, 0); } /// Zero cost centers pub fn zeroStats() void { - doCallgrindClientRequestStmt(.ZeroStats, 0, 0, 0, 0, 0); + doClientRequestStmt(.ZeroStats, 0, 0, 0, 0, 0); } /// Toggles collection state. @@ -41,7 +43,7 @@ pub fn zeroStats() void { /// should be noted or if they are to be ignored. Events are noted /// by increment of counters in a cost center pub fn toggleCollect() void { - doCallgrindClientRequestStmt(.ToggleCollect, 0, 0, 0, 0, 0); + doClientRequestStmt(.ToggleCollect, 0, 0, 0, 0, 0); } /// Start full callgrind instrumentation if not already switched on. @@ -49,7 +51,7 @@ pub fn toggleCollect() void { /// this will lead to an artificial cache warmup phase afterwards with /// cache misses which would not have happened in reality. pub fn startInstrumentation() void { - doCallgrindClientRequestStmt(.StartInstrumentation, 0, 0, 0, 0, 0); + doClientRequestStmt(.StartInstrumentation, 0, 0, 0, 0, 0); } /// Stop full callgrind instrumentation if not already switched off. @@ -60,5 +62,5 @@ pub fn startInstrumentation() void { /// To start Callgrind in this mode to ignore the setup phase, use /// the option "--instr-atstart=no". pub fn stopInstrumentation() void { - doCallgrindClientRequestStmt(.StopInstrumentation, 0, 0, 0, 0, 0); + doClientRequestStmt(.StopInstrumentation, 0, 0, 0, 0, 0); } diff --git a/lib/std/valgrind/memcheck.zig b/lib/std/valgrind/memcheck.zig index e66943ee2c..950026afc5 100644 --- a/lib/std/valgrind/memcheck.zig +++ b/lib/std/valgrind/memcheck.zig @@ -2,7 +2,7 @@ const std = @import("../std.zig"); const testing = std.testing; const valgrind = std.valgrind; -pub const MemCheckClientRequest = enum(usize) { +pub const ClientRequest = enum(usize) { MakeMemNoAccess = valgrind.ToolBase("MC".*), MakeMemUndefined, MakeMemDefined, @@ -20,29 +20,31 @@ pub const MemCheckClientRequest = enum(usize) { DisableAddrErrorReportingInRange, }; -fn doMemCheckClientRequestExpr(default: usize, request: MemCheckClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { +pub const MemCheckClientRequest = @compileError("std.valgrind.memcheck.MemCheckClientRequest renamed to std.valgrind.memcheck.ClientRequest"); + +fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { return valgrind.doClientRequest(default, @as(usize, @intCast(@intFromEnum(request))), a1, a2, a3, a4, a5); } -fn doMemCheckClientRequestStmt(request: MemCheckClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { - _ = doMemCheckClientRequestExpr(0, request, a1, a2, a3, a4, a5); +fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { + _ = doClientRequestExpr(0, request, a1, a2, a3, a4, a5); } /// Mark memory at qzz.ptr as unaddressable for qzz.len bytes. pub fn makeMemNoAccess(qzz: []const u8) void { - _ = doMemCheckClientRequestExpr(0, // default return + _ = doClientRequestExpr(0, // default return .MakeMemNoAccess, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } /// Mark memory at qzz.ptr as addressable but undefined for qzz.len bytes. pub fn makeMemUndefined(qzz: []const u8) void { - _ = doMemCheckClientRequestExpr(0, // default return + _ = doClientRequestExpr(0, // default return .MakeMemUndefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } /// Mark memory at qzz.ptr as addressable and defined or qzz.len bytes. pub fn makeMemDefined(qzz: []const u8) void { - _ = doMemCheckClientRequestExpr(0, // default return + _ = doClientRequestExpr(0, // default return .MakeMemDefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } @@ -50,7 +52,7 @@ pub fn makeMemDefined(qzz: []const u8) void { /// not altered: bytes which are addressable are marked as defined, /// but those which are not addressable are left unchanged. pub fn makeMemDefinedIfAddressable(qzz: []const u8) void { - _ = doMemCheckClientRequestExpr(0, // default return + _ = doClientRequestExpr(0, // default return .MakeMemDefinedIfAddressable, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } @@ -59,14 +61,14 @@ pub fn makeMemDefinedIfAddressable(qzz: []const u8) void { /// within the specified memory range. Has no other effect on the /// properties of the memory range. pub fn createBlock(qzz: []const u8, desc: [*:0]const u8) usize { - return doMemCheckClientRequestExpr(0, // default return + return doClientRequestExpr(0, // default return .CreateBlock, @intFromPtr(qzz.ptr), qzz.len, @intFromPtr(desc), 0, 0); } /// Discard a block-description-handle. Returns 1 for an /// invalid handle, 0 for a valid handle. pub fn discard(blkindex: usize) bool { - return doMemCheckClientRequestExpr(0, // default return + return doClientRequestExpr(0, // default return .Discard, 0, blkindex, 0, 0, 0) != 0; } @@ -75,7 +77,7 @@ pub fn discard(blkindex: usize) bool { /// error message and returns the address of the first offending byte. /// Otherwise it returns zero. pub fn checkMemIsAddressable(qzz: []const u8) usize { - return doMemCheckClientRequestExpr(0, .CheckMemIsAddressable, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); + return doClientRequestExpr(0, .CheckMemIsAddressable, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } /// Check that memory at qzz.ptr is addressable and defined for @@ -83,31 +85,31 @@ pub fn checkMemIsAddressable(qzz: []const u8) usize { /// established, Valgrind prints an error message and returns the /// address of the first offending byte. Otherwise it returns zero. pub fn checkMemIsDefined(qzz: []const u8) usize { - return doMemCheckClientRequestExpr(0, .CheckMemIsDefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); + return doClientRequestExpr(0, .CheckMemIsDefined, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } /// Do a full memory leak check (like --leak-check=full) mid-execution. pub fn doLeakCheck() void { - doMemCheckClientRequestStmt(.DO_LEAK_CHECK, 0, 0, 0, 0, 0); + doClientRequestStmt(.DO_LEAK_CHECK, 0, 0, 0, 0, 0); } /// Same as doLeakCheck() but only showing the entries for /// which there was an increase in leaked bytes or leaked nr of blocks /// since the previous leak search. pub fn doAddedLeakCheck() void { - doMemCheckClientRequestStmt(.DO_LEAK_CHECK, 0, 1, 0, 0, 0); + doClientRequestStmt(.DO_LEAK_CHECK, 0, 1, 0, 0, 0); } /// Same as doAddedLeakCheck() but showing entries with /// increased or decreased leaked bytes/blocks since previous leak /// search. pub fn doChangedLeakCheck() void { - doMemCheckClientRequestStmt(.DO_LEAK_CHECK, 0, 2, 0, 0, 0); + doClientRequestStmt(.DO_LEAK_CHECK, 0, 2, 0, 0, 0); } /// Do a summary memory leak check (like --leak-check=summary) mid-execution. pub fn doQuickLeakCheck() void { - doMemCheckClientRequestStmt(.DO_LEAK_CHECK, 1, 0, 0, 0, 0); + doClientRequestStmt(.DO_LEAK_CHECK, 1, 0, 0, 0, 0); } /// Return number of leaked, dubious, reachable and suppressed bytes found by @@ -126,7 +128,7 @@ pub fn countLeaks() CountResult { .reachable = 0, .suppressed = 0, }; - doMemCheckClientRequestStmt( + doClientRequestStmt( .CountLeaks, @intFromPtr(&res.leaked), @intFromPtr(&res.dubious), @@ -156,7 +158,7 @@ pub fn countLeakBlocks() CountResult { .reachable = 0, .suppressed = 0, }; - doMemCheckClientRequestStmt( + doClientRequestStmt( .CountLeakBlocks, @intFromPtr(&res.leaked), @intFromPtr(&res.dubious), @@ -189,7 +191,7 @@ test countLeakBlocks { /// impossible to segfault your system by using this call. pub fn getVbits(zza: []u8, zzvbits: []u8) u2 { std.debug.assert(zzvbits.len >= zza.len / 8); - return @as(u2, @intCast(doMemCheckClientRequestExpr(0, .GetVbits, @intFromPtr(zza.ptr), @intFromPtr(zzvbits), zza.len, 0, 0))); + return @as(u2, @intCast(doClientRequestExpr(0, .GetVbits, @intFromPtr(zza.ptr), @intFromPtr(zzvbits), zza.len, 0, 0))); } /// Set the validity data for addresses zza, copying it @@ -202,17 +204,17 @@ pub fn getVbits(zza: []u8, zzvbits: []u8) u2 { /// impossible to segfault your system by using this call. pub fn setVbits(zzvbits: []u8, zza: []u8) u2 { std.debug.assert(zzvbits.len >= zza.len / 8); - return @as(u2, @intCast(doMemCheckClientRequestExpr(0, .SetVbits, @intFromPtr(zza.ptr), @intFromPtr(zzvbits), zza.len, 0, 0))); + return @as(u2, @intCast(doClientRequestExpr(0, .SetVbits, @intFromPtr(zza.ptr), @intFromPtr(zzvbits), zza.len, 0, 0))); } /// Disable and re-enable reporting of addressing errors in the /// specified address range. pub fn disableAddrErrorReportingInRange(qzz: []u8) usize { - return doMemCheckClientRequestExpr(0, // default return + return doClientRequestExpr(0, // default return .DisableAddrErrorReportingInRange, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } pub fn enableAddrErrorReportingInRange(qzz: []u8) usize { - return doMemCheckClientRequestExpr(0, // default return + return doClientRequestExpr(0, // default return .EnableAddrErrorReportingInRange, @intFromPtr(qzz.ptr), qzz.len, 0, 0, 0); } diff --git a/lib/std/zig.zig b/lib/std/zig.zig index c11b5319c5..325b7bea90 100644 --- a/lib/std/zig.zig +++ b/lib/std/zig.zig @@ -246,7 +246,7 @@ pub const BuildId = union(enum) { hexstring: HexString, pub fn eql(a: BuildId, b: BuildId) bool { - const Tag = @typeInfo(BuildId).Union.tag_type.?; + const Tag = @typeInfo(BuildId).@"union".tag_type.?; const a_tag: Tag = a; const b_tag: Tag = b; if (a_tag != b_tag) return false; @@ -654,7 +654,7 @@ pub fn parseTargetQueryOrReportFatalError( help: { var help_text = std.ArrayList(u8).init(allocator); defer help_text.deinit(); - inline for (@typeInfo(std.Target.ObjectFormat).Enum.fields) |field| { + inline for (@typeInfo(std.Target.ObjectFormat).@"enum".fields) |field| { help_text.writer().print(" {s}\n", .{field.name}) catch break :help; } std.log.info("available object formats:\n{s}", .{help_text.items}); diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig index 3450e39cc6..9c27d1e036 100644 --- a/lib/std/zig/AstGen.zig +++ b/lib/std/zig/AstGen.zig @@ -153,7 +153,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { try astgen.instructions.ensureTotalCapacity(gpa, tree.nodes.len); // First few indexes of extra are reserved and set at the end. - const reserved_count = @typeInfo(Zir.ExtraIndex).Enum.fields.len; + const reserved_count = @typeInfo(Zir.ExtraIndex).@"enum".fields.len; try astgen.extra.ensureTotalCapacity(gpa, tree.nodes.len + reserved_count); astgen.extra.items.len += reserved_count; @@ -197,7 +197,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { astgen.extra.items[err_index] = 0; } else { try astgen.extra.ensureUnusedCapacity(gpa, 1 + astgen.compile_errors.items.len * - @typeInfo(Zir.Inst.CompileErrors.Item).Struct.fields.len); + @typeInfo(Zir.Inst.CompileErrors.Item).@"struct".fields.len); astgen.extra.items[err_index] = astgen.addExtraAssumeCapacity(Zir.Inst.CompileErrors{ .items_len = @intCast(astgen.compile_errors.items.len), @@ -212,8 +212,8 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { if (astgen.imports.count() == 0) { astgen.extra.items[imports_index] = 0; } else { - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).Struct.fields.len + - astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).Struct.fields.len); + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).@"struct".fields.len + + astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).@"struct".fields.len); astgen.extra.items[imports_index] = astgen.addExtraAssumeCapacity(Zir.Inst.Imports{ .imports_len = @intCast(astgen.imports.count()), @@ -811,18 +811,18 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE .builtin_call_two, .builtin_call_two_comma => { if (node_datas[node].lhs == 0) { const params = [_]Ast.Node.Index{}; - return builtinCall(gz, scope, ri, node, ¶ms); + return builtinCall(gz, scope, ri, node, ¶ms, false); } else if (node_datas[node].rhs == 0) { const params = [_]Ast.Node.Index{node_datas[node].lhs}; - return builtinCall(gz, scope, ri, node, ¶ms); + return builtinCall(gz, scope, ri, node, ¶ms, false); } else { const params = [_]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs }; - return builtinCall(gz, scope, ri, node, ¶ms); + return builtinCall(gz, scope, ri, node, ¶ms, false); } }, .builtin_call, .builtin_call_comma => { const params = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs]; - return builtinCall(gz, scope, ri, node, params); + return builtinCall(gz, scope, ri, node, params, false); }, .call_one, @@ -1017,16 +1017,16 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE .block_two, .block_two_semicolon => { const statements = [2]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs }; if (node_datas[node].lhs == 0) { - return blockExpr(gz, scope, ri, node, statements[0..0]); + return blockExpr(gz, scope, ri, node, statements[0..0], .normal); } else if (node_datas[node].rhs == 0) { - return blockExpr(gz, scope, ri, node, statements[0..1]); + return blockExpr(gz, scope, ri, node, statements[0..1], .normal); } else { - return blockExpr(gz, scope, ri, node, statements[0..2]); + return blockExpr(gz, scope, ri, node, statements[0..2], .normal); } }, .block, .block_semicolon => { const statements = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs]; - return blockExpr(gz, scope, ri, node, statements); + return blockExpr(gz, scope, ri, node, statements, .normal); }, .enum_literal => return simpleStrTok(gz, ri, main_tokens[node], node, .enum_literal), .error_value => return simpleStrTok(gz, ri, node_datas[node].rhs, node, .error_value), @@ -1241,7 +1241,7 @@ fn suspendExpr( suspend_scope.suspend_node = node; defer suspend_scope.unstack(); - const body_result = try fullBodyExpr(&suspend_scope, &suspend_scope.base, .{ .rl = .none }, body_node); + const body_result = try fullBodyExpr(&suspend_scope, &suspend_scope.base, .{ .rl = .none }, body_node, .normal); if (!gz.refIsNoReturn(body_result)) { _ = try suspend_scope.addBreak(.break_inline, suspend_inst, .void_value); } @@ -1362,7 +1362,7 @@ fn fnProtoExpr( assert(param_type_node != 0); var param_gz = block_scope.makeSubBlock(scope); defer param_gz.unstack(); - const param_type = try fullBodyExpr(¶m_gz, scope, coerced_type_ri, param_type_node); + const param_type = try fullBodyExpr(¶m_gz, scope, coerced_type_ri, param_type_node, .normal); const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1); _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node); const main_tokens = tree.nodes.items(.main_token); @@ -1885,7 +1885,7 @@ fn structInitExprAnon( const payload_index = try addExtra(astgen, Zir.Inst.StructInitAnon{ .fields_len = @intCast(struct_init.ast.fields.len), }); - const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).Struct.fields.len; + const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).@"struct".fields.len; var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size); for (struct_init.ast.fields) |field_init| { @@ -1916,7 +1916,7 @@ fn structInitExprTyped( const payload_index = try addExtra(astgen, Zir.Inst.StructInit{ .fields_len = @intCast(struct_init.ast.fields.len), }); - const field_size = @typeInfo(Zir.Inst.StructInit.Item).Struct.fields.len; + const field_size = @typeInfo(Zir.Inst.StructInit.Item).@"struct".fields.len; var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size); for (struct_init.ast.fields) |field_init| { @@ -2040,13 +2040,13 @@ fn comptimeExpr( else stmts[0..2]; - const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmt_slice, true); + const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmt_slice, true, .normal); return rvalue(gz, ri, block_ref, node); }, .block, .block_semicolon => { const stmts = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs]; // Replace result location and copy back later - see above. - const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmts, true); + const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmts, true, .normal); return rvalue(gz, ri, block_ref, node); }, else => unreachable, @@ -2071,7 +2071,7 @@ fn comptimeExpr( else .none, }; - const block_result = try fullBodyExpr(&block_scope, scope, ty_only_ri, node); + const block_result = try fullBodyExpr(&block_scope, scope, ty_only_ri, node, .normal); if (!gz.refIsNoReturn(block_result)) { _ = try block_scope.addBreak(.@"break", block_inst, block_result); } @@ -2311,6 +2311,7 @@ fn fullBodyExpr( scope: *Scope, ri: ResultInfo, node: Ast.Node.Index, + block_kind: BlockKind, ) InnerError!Zir.Inst.Ref { const tree = gz.astgen.tree; const node_tags = tree.nodes.items(.tag); @@ -2340,21 +2341,24 @@ fn fullBodyExpr( // Labeled blocks are tricky - forwarding result location information properly is non-trivial, // plus if this block is exited with a `break_inline` we aren't allowed multiple breaks. This // case is rare, so just treat it as a normal expression and create a nested block. - return expr(gz, scope, ri, node); + return blockExpr(gz, scope, ri, node, statements, block_kind); } var sub_gz = gz.makeSubBlock(scope); - try blockExprStmts(&sub_gz, &sub_gz.base, statements); + try blockExprStmts(&sub_gz, &sub_gz.base, statements, block_kind); return rvalue(gz, ri, .void_value, node); } +const BlockKind = enum { normal, allow_branch_hint }; + fn blockExpr( gz: *GenZir, scope: *Scope, ri: ResultInfo, block_node: Ast.Node.Index, statements: []const Ast.Node.Index, + kind: BlockKind, ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; @@ -2365,7 +2369,7 @@ fn blockExpr( if (token_tags[lbrace - 1] == .colon and token_tags[lbrace - 2] == .identifier) { - return labeledBlockExpr(gz, scope, ri, block_node, statements, false); + return labeledBlockExpr(gz, scope, ri, block_node, statements, false, kind); } if (!gz.is_comptime) { @@ -2380,7 +2384,7 @@ fn blockExpr( var block_scope = gz.makeSubBlock(scope); defer block_scope.unstack(); - try blockExprStmts(&block_scope, &block_scope.base, statements); + try blockExprStmts(&block_scope, &block_scope.base, statements, kind); if (!block_scope.endsWithNoReturn()) { // As our last action before the break, "pop" the error trace if needed @@ -2391,7 +2395,7 @@ fn blockExpr( try block_scope.setBlockBody(block_inst); } else { var sub_gz = gz.makeSubBlock(scope); - try blockExprStmts(&sub_gz, &sub_gz.base, statements); + try blockExprStmts(&sub_gz, &sub_gz.base, statements, kind); } return rvalue(gz, ri, .void_value, block_node); @@ -2436,6 +2440,7 @@ fn labeledBlockExpr( block_node: Ast.Node.Index, statements: []const Ast.Node.Index, force_comptime: bool, + block_kind: BlockKind, ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; @@ -2459,7 +2464,7 @@ fn labeledBlockExpr( }; // We need to call `rvalue` to write through to the pointer only if we had a // result pointer and aren't forwarding it. - const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; + const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); // Reserve the Block ZIR instruction index so that we can put it into the GenZir struct @@ -2476,7 +2481,7 @@ fn labeledBlockExpr( if (force_comptime) block_scope.is_comptime = true; defer block_scope.unstack(); - try blockExprStmts(&block_scope, &block_scope.base, statements); + try blockExprStmts(&block_scope, &block_scope.base, statements, block_kind); if (!block_scope.endsWithNoReturn()) { // As our last action before the return, "pop" the error trace if needed _ = try gz.addRestoreErrRetIndex(.{ .block = block_inst }, .always, block_node); @@ -2495,7 +2500,7 @@ fn labeledBlockExpr( } } -fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Node.Index) !void { +fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Node.Index, block_kind: BlockKind) !void { const astgen = gz.astgen; const tree = astgen.tree; const node_tags = tree.nodes.items(.tag); @@ -2509,7 +2514,7 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod var noreturn_src_node: Ast.Node.Index = 0; var scope = parent_scope; - for (statements) |statement| { + for (statements, 0..) |statement, stmt_idx| { if (noreturn_src_node != 0) { try astgen.appendErrorNodeNotes( statement, @@ -2524,6 +2529,10 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod }, ); } + const allow_branch_hint = switch (block_kind) { + .normal => false, + .allow_branch_hint => stmt_idx == 0, + }; var inner_node = statement; while (true) { switch (node_tags[inner_node]) { @@ -2567,6 +2576,30 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod .for_simple, .@"for", => _ = try forExpr(gz, scope, .{ .rl = .none }, inner_node, tree.fullFor(inner_node).?, true), + // These cases are here to allow branch hints. + .builtin_call_two, .builtin_call_two_comma => { + try emitDbgNode(gz, inner_node); + const ri: ResultInfo = .{ .rl = .none }; + const result = if (node_data[inner_node].lhs == 0) r: { + break :r try builtinCall(gz, scope, ri, inner_node, &.{}, allow_branch_hint); + } else if (node_data[inner_node].rhs == 0) r: { + break :r try builtinCall(gz, scope, ri, inner_node, &.{node_data[inner_node].lhs}, allow_branch_hint); + } else r: { + break :r try builtinCall(gz, scope, ri, inner_node, &.{ + node_data[inner_node].lhs, + node_data[inner_node].rhs, + }, allow_branch_hint); + }; + noreturn_src_node = try addEnsureResult(gz, result, inner_node); + }, + .builtin_call, .builtin_call_comma => { + try emitDbgNode(gz, inner_node); + const ri: ResultInfo = .{ .rl = .none }; + const params = tree.extra_data[node_data[inner_node].lhs..node_data[inner_node].rhs]; + const result = try builtinCall(gz, scope, ri, inner_node, params, allow_branch_hint); + noreturn_src_node = try addEnsureResult(gz, result, inner_node); + }, + else => noreturn_src_node = try unusedResultExpr(gz, scope, inner_node), // zig fmt: on } @@ -2827,7 +2860,7 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As .fence, .set_float_mode, .set_align_stack, - .set_cold, + .branch_hint, => break :b true, else => break :b false, }, @@ -2861,7 +2894,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As .ensure_result_non_error, .ensure_err_union_payload_void, .@"export", - .export_value, .set_eval_branch_quota, .atomic_store, .store_node, @@ -3832,7 +3864,7 @@ fn ptrType( const gpa = gz.astgen.gpa; try gz.instructions.ensureUnusedCapacity(gpa, 1); try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1); - try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).Struct.fields.len + + try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).@"struct".fields.len + trailing_count); const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.PtrType{ @@ -4021,7 +4053,7 @@ fn fnDecl( // The source slice is added towards the *end* of this function. astgen.src_hasher.update(std.mem.asBytes(&astgen.source_column)); - // missing function name already happened in scanDecls() + // missing function name already happened in scanContainer() const fn_name_token = fn_proto.name_token orelse return error.AnalysisFail; // We insert this at the beginning so that its instruction index marks the @@ -4155,7 +4187,7 @@ fn fnDecl( assert(param_type_node != 0); var param_gz = decl_gz.makeSubBlock(scope); defer param_gz.unstack(); - const param_type = try fullBodyExpr(¶m_gz, params_scope, coerced_type_ri, param_type_node); + const param_type = try fullBodyExpr(¶m_gz, params_scope, coerced_type_ri, param_type_node, .normal); const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1); _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node); @@ -4277,7 +4309,7 @@ fn fnDecl( var ret_gz = decl_gz.makeSubBlock(params_scope); defer ret_gz.unstack(); const ret_ref: Zir.Inst.Ref = inst: { - const inst = try fullBodyExpr(&ret_gz, params_scope, coerced_type_ri, fn_proto.ast.return_type); + const inst = try fullBodyExpr(&ret_gz, params_scope, coerced_type_ri, fn_proto.ast.return_type, .normal); if (ret_gz.instructionsSlice().len == 0) { // In this case we will send a len=0 body which can be encoded more efficiently. break :inst inst; @@ -4352,7 +4384,7 @@ fn fnDecl( const lbrace_line = astgen.source_line - decl_gz.decl_line; const lbrace_column = astgen.source_column; - _ = try fullBodyExpr(&fn_gz, params_scope, .{ .rl = .none }, body_node); + _ = try fullBodyExpr(&fn_gz, params_scope, .{ .rl = .none }, body_node, .allow_branch_hint); try checkUsed(gz, &fn_gz.base, params_scope); if (!fn_gz.endsWithNoReturn()) { @@ -4553,20 +4585,20 @@ fn globalVarDecl( var align_gz = block_scope.makeSubBlock(scope); if (var_decl.ast.align_node != 0) { - const align_inst = try fullBodyExpr(&align_gz, &align_gz.base, coerced_align_ri, var_decl.ast.align_node); + const align_inst = try fullBodyExpr(&align_gz, &align_gz.base, coerced_align_ri, var_decl.ast.align_node, .normal); _ = try align_gz.addBreakWithSrcNode(.break_inline, decl_inst, align_inst, node); } var linksection_gz = align_gz.makeSubBlock(scope); if (var_decl.ast.section_node != 0) { - const linksection_inst = try fullBodyExpr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, var_decl.ast.section_node); + const linksection_inst = try fullBodyExpr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, var_decl.ast.section_node, .normal); _ = try linksection_gz.addBreakWithSrcNode(.break_inline, decl_inst, linksection_inst, node); } var addrspace_gz = linksection_gz.makeSubBlock(scope); if (var_decl.ast.addrspace_node != 0) { const addrspace_ty = try addrspace_gz.addBuiltinValue(var_decl.ast.addrspace_node, .address_space); - const addrspace_inst = try fullBodyExpr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, var_decl.ast.addrspace_node); + const addrspace_inst = try fullBodyExpr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, var_decl.ast.addrspace_node, .normal); _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node); } @@ -4623,7 +4655,7 @@ fn comptimeDecl( }; defer decl_block.unstack(); - const block_result = try fullBodyExpr(&decl_block, &decl_block.base, .{ .rl = .none }, body_node); + const block_result = try fullBodyExpr(&decl_block, &decl_block.base, .{ .rl = .none }, body_node, .normal); if (decl_block.isEmpty() or !decl_block.refIsNoReturn(block_result)) { _ = try decl_block.addBreak(.break_inline, decl_inst, .void_value); } @@ -4844,7 +4876,7 @@ fn testDecl( const lbrace_line = astgen.source_line - decl_block.decl_line; const lbrace_column = astgen.source_column; - const block_result = try fullBodyExpr(&fn_block, &fn_block.base, .{ .rl = .none }, body_node); + const block_result = try fullBodyExpr(&fn_block, &fn_block.base, .{ .rl = .none }, body_node, .normal); if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) { // As our last action before the return, "pop" the error trace if needed @@ -4987,7 +5019,7 @@ fn structDeclInner( } }; - const decl_count = try astgen.scanDecls(&namespace, container_decl.ast.members); + const decl_count = try astgen.scanContainer(&namespace, container_decl.ast.members, .@"struct"); const field_count: u32 = @intCast(container_decl.ast.members.len - decl_count); const bits_per_field = 4; @@ -5056,15 +5088,6 @@ fn structDeclInner( astgen.src_hasher.update(tree.getNodeSource(backing_int_node)); } - var sfba = std.heap.stackFallback(256, astgen.arena); - const sfba_allocator = sfba.get(); - - var duplicate_names = std.AutoArrayHashMap(Zir.NullTerminatedString, std.ArrayListUnmanaged(Ast.TokenIndex)).init(sfba_allocator); - try duplicate_names.ensureTotalCapacity(field_count); - - // When there aren't errors, use this to avoid a second iteration. - var any_duplicate = false; - var known_non_opv = false; var known_comptime_only = false; var any_comptime_fields = false; @@ -5085,16 +5108,6 @@ fn structDeclInner( assert(!member.ast.tuple_like); wip_members.appendToField(@intFromEnum(field_name)); - - const gop = try duplicate_names.getOrPut(field_name); - - if (gop.found_existing) { - try gop.value_ptr.append(sfba_allocator, member.ast.main_token); - any_duplicate = true; - } else { - gop.value_ptr.* = .{}; - try gop.value_ptr.append(sfba_allocator, member.ast.main_token); - } } else if (!member.ast.tuple_like) { return astgen.failTok(member.ast.main_token, "tuple field has a name", .{}); } @@ -5179,32 +5192,6 @@ fn structDeclInner( } } - if (any_duplicate) { - var it = duplicate_names.iterator(); - - while (it.next()) |entry| { - const record = entry.value_ptr.*; - if (record.items.len > 1) { - var error_notes = std.ArrayList(u32).init(astgen.arena); - - for (record.items[1..]) |duplicate| { - try error_notes.append(try astgen.errNoteTok(duplicate, "duplicate field here", .{})); - } - - try error_notes.append(try astgen.errNoteNode(node, "struct declared here", .{})); - - try astgen.appendErrorTokNotes( - record.items[0], - "duplicate struct field name", - .{}, - error_notes.items, - ); - } - } - - return error.AnalysisFail; - } - var fields_hash: std.zig.SrcHash = undefined; astgen.src_hasher.final(&fields_hash); @@ -5285,7 +5272,7 @@ fn unionDeclInner( }; defer block_scope.unstack(); - const decl_count = try astgen.scanDecls(&namespace, members); + const decl_count = try astgen.scanContainer(&namespace, members, .@"union"); const field_count: u32 = @intCast(members.len - decl_count); if (layout != .auto and (auto_enum_tok != null or arg_node != 0)) { @@ -5316,15 +5303,6 @@ fn unionDeclInner( astgen.src_hasher.update(astgen.tree.getNodeSource(arg_node)); } - var sfba = std.heap.stackFallback(256, astgen.arena); - const sfba_allocator = sfba.get(); - - var duplicate_names = std.AutoArrayHashMap(Zir.NullTerminatedString, std.ArrayListUnmanaged(Ast.TokenIndex)).init(sfba_allocator); - try duplicate_names.ensureTotalCapacity(field_count); - - // When there aren't errors, use this to avoid a second iteration. - var any_duplicate = false; - for (members) |member_node| { var member = switch (try containerMember(&block_scope, &namespace.base, &wip_members, member_node)) { .decl => continue, @@ -5342,16 +5320,6 @@ fn unionDeclInner( const field_name = try astgen.identAsString(member.ast.main_token); wip_members.appendToField(@intFromEnum(field_name)); - const gop = try duplicate_names.getOrPut(field_name); - - if (gop.found_existing) { - try gop.value_ptr.append(sfba_allocator, member.ast.main_token); - any_duplicate = true; - } else { - gop.value_ptr.* = .{}; - try gop.value_ptr.append(sfba_allocator, member.ast.main_token); - } - const doc_comment_index = try astgen.docCommentAsString(member.firstToken()); wip_members.appendToField(@intFromEnum(doc_comment_index)); @@ -5406,32 +5374,6 @@ fn unionDeclInner( } } - if (any_duplicate) { - var it = duplicate_names.iterator(); - - while (it.next()) |entry| { - const record = entry.value_ptr.*; - if (record.items.len > 1) { - var error_notes = std.ArrayList(u32).init(astgen.arena); - - for (record.items[1..]) |duplicate| { - try error_notes.append(try astgen.errNoteTok(duplicate, "duplicate field here", .{})); - } - - try error_notes.append(try astgen.errNoteNode(node, "union declared here", .{})); - - try astgen.appendErrorTokNotes( - record.items[0], - "duplicate union field name", - .{}, - error_notes.items, - ); - } - } - - return error.AnalysisFail; - } - var fields_hash: std.zig.SrcHash = undefined; astgen.src_hasher.final(&fields_hash); @@ -5634,7 +5576,7 @@ fn containerDecl( }; defer block_scope.unstack(); - _ = try astgen.scanDecls(&namespace, container_decl.ast.members); + _ = try astgen.scanContainer(&namespace, container_decl.ast.members, .@"enum"); namespace.base.tag = .namespace; const arg_inst: Zir.Inst.Ref = if (container_decl.ast.arg != 0) @@ -5655,15 +5597,6 @@ fn containerDecl( } astgen.src_hasher.update(&.{@intFromBool(nonexhaustive)}); - var sfba = std.heap.stackFallback(256, astgen.arena); - const sfba_allocator = sfba.get(); - - var duplicate_names = std.AutoArrayHashMap(Zir.NullTerminatedString, std.ArrayListUnmanaged(Ast.TokenIndex)).init(sfba_allocator); - try duplicate_names.ensureTotalCapacity(counts.total_fields); - - // When there aren't errors, use this to avoid a second iteration. - var any_duplicate = false; - for (container_decl.ast.members) |member_node| { if (member_node == counts.nonexhaustive_node) continue; @@ -5680,16 +5613,6 @@ fn containerDecl( const field_name = try astgen.identAsString(member.ast.main_token); wip_members.appendToField(@intFromEnum(field_name)); - const gop = try duplicate_names.getOrPut(field_name); - - if (gop.found_existing) { - try gop.value_ptr.append(sfba_allocator, member.ast.main_token); - any_duplicate = true; - } else { - gop.value_ptr.* = .{}; - try gop.value_ptr.append(sfba_allocator, member.ast.main_token); - } - const doc_comment_index = try astgen.docCommentAsString(member.firstToken()); wip_members.appendToField(@intFromEnum(doc_comment_index)); @@ -5716,32 +5639,6 @@ fn containerDecl( } } - if (any_duplicate) { - var it = duplicate_names.iterator(); - - while (it.next()) |entry| { - const record = entry.value_ptr.*; - if (record.items.len > 1) { - var error_notes = std.ArrayList(u32).init(astgen.arena); - - for (record.items[1..]) |duplicate| { - try error_notes.append(try astgen.errNoteTok(duplicate, "duplicate field here", .{})); - } - - try error_notes.append(try astgen.errNoteNode(node, "enum declared here", .{})); - - try astgen.appendErrorTokNotes( - record.items[0], - "duplicate enum field name", - .{}, - error_notes.items, - ); - } - } - - return error.AnalysisFail; - } - if (!block_scope.isEmpty()) { _ = try block_scope.addBreak(.break_inline, decl_inst, .void_value); } @@ -5801,7 +5698,7 @@ fn containerDecl( }; defer block_scope.unstack(); - const decl_count = try astgen.scanDecls(&namespace, container_decl.ast.members); + const decl_count = try astgen.scanContainer(&namespace, container_decl.ast.members, .@"opaque"); var wip_members = try WipMembers.init(gpa, &astgen.scratch, decl_count, 0, 0, 0); defer wip_members.deinit(); @@ -5907,7 +5804,7 @@ fn errorSetDecl(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index) InnerError!Zi const main_tokens = tree.nodes.items(.main_token); const token_tags = tree.tokens.items(.tag); - const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).Struct.fields.len); + const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).@"struct".fields.len); var fields_len: usize = 0; { var idents: std.AutoHashMapUnmanaged(Zir.NullTerminatedString, Ast.TokenIndex) = .{}; @@ -6046,7 +5943,7 @@ fn orelseCatchExpr( }; // We need to call `rvalue` to write through to the pointer only if we had a // result pointer and aren't forwarding it. - const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; + const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); const do_err_trace = astgen.fn_block != null and (cond_op == .is_non_err or cond_op == .is_non_err_ptr); @@ -6113,7 +6010,7 @@ fn orelseCatchExpr( break :blk &err_val_scope.base; }; - const else_result = try fullBodyExpr(&else_scope, else_sub_scope, block_scope.break_result_info, rhs); + const else_result = try fullBodyExpr(&else_scope, else_sub_scope, block_scope.break_result_info, rhs, .allow_branch_hint); if (!else_scope.endsWithNoReturn()) { // As our last action before the break, "pop" the error trace if needed if (do_err_trace) @@ -6281,7 +6178,7 @@ fn boolBinOp( var rhs_scope = gz.makeSubBlock(scope); defer rhs_scope.unstack(); - const rhs = try fullBodyExpr(&rhs_scope, &rhs_scope.base, coerced_bool_ri, node_datas[node].rhs); + const rhs = try fullBodyExpr(&rhs_scope, &rhs_scope.base, coerced_bool_ri, node_datas[node].rhs, .allow_branch_hint); if (!gz.refIsNoReturn(rhs)) { _ = try rhs_scope.addBreakWithSrcNode(.break_inline, bool_br, rhs, node_datas[node].rhs); } @@ -6315,7 +6212,7 @@ fn ifExpr( }; // We need to call `rvalue` to write through to the pointer only if we had a // result pointer and aren't forwarding it. - const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; + const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); var block_scope = parent_gz.makeSubBlock(scope); @@ -6425,7 +6322,7 @@ fn ifExpr( } }; - const then_result = try fullBodyExpr(&then_scope, then_sub_scope, block_scope.break_result_info, then_node); + const then_result = try fullBodyExpr(&then_scope, then_sub_scope, block_scope.break_result_info, then_node, .allow_branch_hint); try checkUsed(parent_gz, &then_scope.base, then_sub_scope); if (!then_scope.endsWithNoReturn()) { _ = try then_scope.addBreakWithSrcNode(.@"break", block, then_result, then_node); @@ -6467,7 +6364,7 @@ fn ifExpr( break :s &else_scope.base; } }; - const else_result = try fullBodyExpr(&else_scope, sub_scope, block_scope.break_result_info, else_node); + const else_result = try fullBodyExpr(&else_scope, sub_scope, block_scope.break_result_info, else_node, .allow_branch_hint); if (!else_scope.endsWithNoReturn()) { // As our last action before the break, "pop" the error trace if needed if (do_err_trace) @@ -6505,7 +6402,7 @@ fn setCondBrPayload( const else_body_len = astgen.countBodyLenAfterFixups(else_body); try astgen.extra.ensureUnusedCapacity( astgen.gpa, - @typeInfo(Zir.Inst.CondBr).Struct.fields.len + then_body_len + else_body_len, + @typeInfo(Zir.Inst.CondBr).@"struct".fields.len + then_body_len + else_body_len, ); const zir_datas = astgen.instructions.items(.data); @@ -6541,7 +6438,7 @@ fn whileExpr( }; // We need to call `rvalue` to write through to the pointer only if we had a // result pointer and aren't forwarding it. - const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; + const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); if (while_full.label_token) |label_token| { @@ -6576,7 +6473,7 @@ fn whileExpr( } = c: { if (while_full.error_token) |_| { const cond_ri: ResultInfo = .{ .rl = if (payload_is_ref) .ref else .none }; - const err_union = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr); + const err_union = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr, .normal); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_err_ptr else .is_non_err; break :c .{ .inst = err_union, @@ -6584,14 +6481,14 @@ fn whileExpr( }; } else if (while_full.payload_token) |_| { const cond_ri: ResultInfo = .{ .rl = if (payload_is_ref) .ref else .none }; - const optional = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr); + const optional = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr, .normal); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null; break :c .{ .inst = optional, .bool_bit = try cond_scope.addUnNode(tag, optional, while_full.ast.cond_expr), }; } else { - const cond = try fullBodyExpr(&cond_scope, &cond_scope.base, coerced_bool_ri, while_full.ast.cond_expr); + const cond = try fullBodyExpr(&cond_scope, &cond_scope.base, coerced_bool_ri, while_full.ast.cond_expr, .normal); break :c .{ .inst = cond, .bool_bit = cond, @@ -6716,7 +6613,7 @@ fn whileExpr( continue_scope.instructions_top = continue_scope.instructions.items.len; { try emitDbgNode(&continue_scope, then_node); - const unused_result = try fullBodyExpr(&continue_scope, &continue_scope.base, .{ .rl = .none }, then_node); + const unused_result = try fullBodyExpr(&continue_scope, &continue_scope.base, .{ .rl = .none }, then_node, .allow_branch_hint); _ = try addEnsureResult(&continue_scope, unused_result, then_node); } try checkUsed(parent_gz, &then_scope.base, then_sub_scope); @@ -6762,7 +6659,7 @@ fn whileExpr( // control flow apply to outer loops; not this one. loop_scope.continue_block = .none; loop_scope.break_block = .none; - const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node); + const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint); if (is_statement) { _ = try addEnsureResult(&else_scope, else_result, else_node); } @@ -6821,7 +6718,7 @@ fn forExpr( }; // We need to call `rvalue` to write through to the pointer only if we had a // result pointer and aren't forwarding it. - const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; + const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); const is_inline = for_full.inline_token != null; @@ -6919,7 +6816,7 @@ fn forExpr( // nicer error reporting as well as fewer ZIR bytes emitted. const len: Zir.Inst.Ref = len: { const lens_len: u32 = @intCast(lens.len); - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).Struct.fields.len + lens_len); + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).@"struct".fields.len + lens_len); const len = try parent_gz.addPlNode(.for_len, node, Zir.Inst.MultiOp{ .operands_len = lens_len, }); @@ -7030,7 +6927,7 @@ fn forExpr( break :blk capture_sub_scope; }; - const then_result = try fullBodyExpr(&then_scope, then_sub_scope, .{ .rl = .none }, then_node); + const then_result = try fullBodyExpr(&then_scope, then_sub_scope, .{ .rl = .none }, then_node, .allow_branch_hint); _ = try addEnsureResult(&then_scope, then_result, then_node); try checkUsed(parent_gz, &then_scope.base, then_sub_scope); @@ -7049,7 +6946,7 @@ fn forExpr( // control flow apply to outer loops; not this one. loop_scope.continue_block = .none; loop_scope.break_block = .none; - const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node); + const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint); if (is_statement) { _ = try addEnsureResult(&else_scope, else_result, else_node); } @@ -7156,7 +7053,7 @@ fn switchExprErrUnion( // We need to call `rvalue` to write through to the pointer only if we had a // result pointer and aren't forwarding it. - const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; + const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); var scalar_cases_len: u32 = 0; var multi_cases_len: u32 = 0; @@ -7526,7 +7423,7 @@ fn switchExprErrUnion( } const target_expr_node = case.ast.target_expr; - const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node); + const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node, .allow_branch_hint); // check capture_scope, not err_scope to avoid false positive unused error capture try checkUsed(parent_gz, &case_scope.base, err_scope.parent); const uses_err = err_scope.used != 0 or err_scope.discarded != 0; @@ -7590,10 +7487,10 @@ fn switchExprErrUnion( // Now that the item expressions are generated we can add this. try parent_gz.instructions.append(gpa, switch_block); - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlockErrUnion).Struct.fields.len + + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlockErrUnion).@"struct".fields.len + @intFromBool(multi_cases_len != 0) + payloads.items.len - case_table_end + - (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).Struct.fields.len); + (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).@"struct".fields.len); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlockErrUnion{ .operand = raw_operand, @@ -7673,7 +7570,7 @@ fn switchExpr( }; // We need to call `rvalue` to write through to the pointer only if we had a // result pointer and aren't forwarding it. - const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?; + const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?; const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl); // We perform two passes over the AST. This first pass is to collect information @@ -7987,7 +7884,7 @@ fn switchExpr( try case_scope.addDbgVar(.dbg_var_val, dbg_var_tag_name, dbg_var_tag_inst); } const target_expr_node = case.ast.target_expr; - const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node); + const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node, .allow_branch_hint); try checkUsed(parent_gz, &case_scope.base, sub_scope); if (!parent_gz.refIsNoReturn(case_result)) { _ = try case_scope.addBreakWithSrcNode(.@"break", switch_block, case_result, target_expr_node); @@ -8036,11 +7933,11 @@ fn switchExpr( // Now that the item expressions are generated we can add this. try parent_gz.instructions.append(gpa, switch_block); - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).Struct.fields.len + + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).@"struct".fields.len + @intFromBool(multi_cases_len != 0) + @intFromBool(any_has_tag_capture) + payloads.items.len - case_table_end + - (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).Struct.fields.len); + (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).@"struct".fields.len); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlock{ .operand = raw_operand, @@ -8939,7 +8836,7 @@ fn ptrCast( const node_datas = tree.nodes.items(.data); const node_tags = tree.nodes.items(.tag); - const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?; + const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; var flags: Zir.Inst.FullPtrCastFlags = .{}; // Note that all pointer cast builtins have one parameter, so we only need @@ -9155,6 +9052,7 @@ fn builtinCall( ri: ResultInfo, node: Ast.Node.Index, params: []const Ast.Node.Index, + allow_branch_hint: bool, ) InnerError!Zir.Inst.Ref { const astgen = gz.astgen; const tree = astgen.tree; @@ -9188,6 +9086,18 @@ fn builtinCall( return astgen.failNode(node, "'{s}' outside function scope", .{builtin_name}); switch (info.tag) { + .branch_hint => { + if (!allow_branch_hint) { + return astgen.failNode(node, "'@branchHint' must appear as the first statement in a function or conditional branch", .{}); + } + const hint_ty = try gz.addBuiltinValue(node, .branch_hint); + const hint_val = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = hint_ty } }, params[0]); + _ = try gz.addExtendedPayload(.branch_hint, Zir.Inst.UnNode{ + .node = gz.nodeIndexToRelative(node), + .operand = hint_val, + }); + return rvalue(gz, ri, .void_value, node); + }, .import => { const node_tags = tree.nodes.items(.tag); const operand_node = params[0]; @@ -9249,87 +9159,11 @@ fn builtinCall( // zig fmt: on .@"export" => { + const exported = try expr(gz, scope, .{ .rl = .none }, params[0]); const export_options_ty = try gz.addBuiltinValue(node, .export_options); - const node_tags = tree.nodes.items(.tag); - const node_datas = tree.nodes.items(.data); - // This function causes a Decl to be exported. The first parameter is not an expression, - // but an identifier of the Decl to be exported. - var namespace: Zir.Inst.Ref = .none; - var decl_name: Zir.NullTerminatedString = .empty; - switch (node_tags[params[0]]) { - .identifier => { - const ident_token = main_tokens[params[0]]; - if (isPrimitive(tree.tokenSlice(ident_token))) { - return astgen.failTok(ident_token, "unable to export primitive value", .{}); - } - decl_name = try astgen.identAsString(ident_token); - - var s = scope; - var found_already: ?Ast.Node.Index = null; // we have found a decl with the same name already - while (true) switch (s.tag) { - .local_val => { - const local_val = s.cast(Scope.LocalVal).?; - if (local_val.name == decl_name) { - local_val.used = ident_token; - _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{ - .operand = local_val.inst, - .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]), - }); - return rvalue(gz, ri, .void_value, node); - } - s = local_val.parent; - }, - .local_ptr => { - const local_ptr = s.cast(Scope.LocalPtr).?; - if (local_ptr.name == decl_name) { - if (!local_ptr.maybe_comptime) - return astgen.failNode(params[0], "unable to export runtime-known value", .{}); - local_ptr.used = ident_token; - const loaded = try gz.addUnNode(.load, local_ptr.ptr, node); - _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{ - .operand = loaded, - .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]), - }); - return rvalue(gz, ri, .void_value, node); - } - s = local_ptr.parent; - }, - .gen_zir => s = s.cast(GenZir).?.parent, - .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent, - .namespace => { - const ns = s.cast(Scope.Namespace).?; - if (ns.decls.get(decl_name)) |i| { - if (found_already) |f| { - return astgen.failNodeNotes(node, "ambiguous reference", .{}, &.{ - try astgen.errNoteNode(f, "declared here", .{}), - try astgen.errNoteNode(i, "also declared here", .{}), - }); - } - // We found a match but must continue looking for ambiguous references to decls. - found_already = i; - } - s = ns.parent; - }, - .top => break, - }; - if (found_already == null) { - const ident_name = try astgen.identifierTokenString(ident_token); - return astgen.failNode(params[0], "use of undeclared identifier '{s}'", .{ident_name}); - } - }, - .field_access => { - const namespace_node = node_datas[params[0]].lhs; - namespace = try typeExpr(gz, scope, namespace_node); - const dot_token = main_tokens[params[0]]; - const field_ident = dot_token + 1; - decl_name = try astgen.identAsString(field_ident); - }, - else => return astgen.failNode(params[0], "symbol to export must identify a declaration", .{}), - } const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]); _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{ - .namespace = namespace, - .decl_name = decl_name, + .exported = exported, .options = options, }); return rvalue(gz, ri, .void_value, node); @@ -9371,14 +9205,6 @@ fn builtinCall( }); return rvalue(gz, ri, .void_value, node); }, - .set_cold => { - const order = try expr(gz, scope, ri, params[0]); - _ = try gz.addExtendedPayload(.set_cold, Zir.Inst.UnNode{ - .node = gz.nodeIndexToRelative(node), - .operand = order, - }); - return rvalue(gz, ri, .void_value, node); - }, .src => { // Incorporate the source location into the source hash, so that @@ -10040,7 +9866,7 @@ fn cImport( defer block_scope.unstack(); const block_inst = try gz.makeBlockInst(.c_import, node); - const block_result = try fullBodyExpr(&block_scope, &block_scope.base, .{ .rl = .none }, body_node); + const block_result = try fullBodyExpr(&block_scope, &block_scope.base, .{ .rl = .none }, body_node, .normal); _ = try gz.addUnNode(.ensure_result_used, block_result, node); if (!gz.refIsNoReturn(block_result)) { _ = try block_scope.addBreak(.break_inline, block_inst, .void_value); @@ -10123,7 +9949,7 @@ fn callExpr( defer arg_block.unstack(); // `call_inst` is reused to provide the param type. - const arg_ref = try fullBodyExpr(&arg_block, &arg_block.base, .{ .rl = .{ .coerced_ty = call_inst }, .ctx = .fn_arg }, param_node); + const arg_ref = try fullBodyExpr(&arg_block, &arg_block.base, .{ .rl = .{ .coerced_ty = call_inst }, .ctx = .fn_arg }, param_node, .normal); _ = try arg_block.addBreakWithSrcNode(.break_inline, call_index, arg_ref, param_node); const body = arg_block.instructionsSlice(); @@ -11474,7 +11300,7 @@ fn appendErrorNodeNotes( args: anytype, notes: []const u32, ) Allocator.Error!void { - @setCold(true); + @branchHint(.cold); const string_bytes = &astgen.string_bytes; const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len); try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args); @@ -11565,7 +11391,7 @@ fn appendErrorTokNotesOff( args: anytype, notes: []const u32, ) !void { - @setCold(true); + @branchHint(.cold); const gpa = astgen.gpa; const string_bytes = &astgen.string_bytes; const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len); @@ -11602,7 +11428,7 @@ fn errNoteTokOff( comptime format: []const u8, args: anytype, ) Allocator.Error!u32 { - @setCold(true); + @branchHint(.cold); const string_bytes = &astgen.string_bytes; const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len); try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args); @@ -11621,7 +11447,7 @@ fn errNoteNode( comptime format: []const u8, args: anytype, ) Allocator.Error!u32 { - @setCold(true); + @branchHint(.cold); const string_bytes = &astgen.string_bytes; const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len); try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args); @@ -12119,7 +11945,7 @@ const GenZir = struct { const body_len = astgen.countBodyLenAfterFixups(body); try astgen.extra.ensureUnusedCapacity( gpa, - @typeInfo(Zir.Inst.BoolBr).Struct.fields.len + body_len, + @typeInfo(Zir.Inst.BoolBr).@"struct".fields.len + body_len, ); const zir_datas = astgen.instructions.items(.data); zir_datas[@intFromEnum(bool_br)].pl_node.payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.BoolBr{ @@ -12138,7 +11964,7 @@ const GenZir = struct { const body_len = astgen.countBodyLenAfterFixups(body); try astgen.extra.ensureUnusedCapacity( gpa, - @typeInfo(Zir.Inst.Block).Struct.fields.len + body_len, + @typeInfo(Zir.Inst.Block).@"struct".fields.len + body_len, ); const zir_datas = astgen.instructions.items(.data); zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity( @@ -12156,7 +11982,7 @@ const GenZir = struct { const body_len = astgen.countBodyLenAfterFixups(body); try astgen.extra.ensureUnusedCapacity( gpa, - @typeInfo(Zir.Inst.Try).Struct.fields.len + body_len, + @typeInfo(Zir.Inst.Try).@"struct".fields.len + body_len, ); const zir_datas = astgen.instructions.items(.data); zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity( @@ -12274,7 +12100,7 @@ const GenZir = struct { try astgen.extra.ensureUnusedCapacity( gpa, - @typeInfo(Zir.Inst.FuncFancy).Struct.fields.len + + @typeInfo(Zir.Inst.FuncFancy).@"struct".fields.len + fancyFnExprExtraLen(astgen, align_body, args.align_ref) + fancyFnExprExtraLen(astgen, addrspace_body, args.addrspace_ref) + fancyFnExprExtraLen(astgen, section_body, args.section_ref) + @@ -12393,7 +12219,7 @@ const GenZir = struct { } else { try astgen.extra.ensureUnusedCapacity( gpa, - @typeInfo(Zir.Inst.Func).Struct.fields.len + 1 + + @typeInfo(Zir.Inst.Func).@"struct".fields.len + 1 + fancyFnExprExtraLen(astgen, ret_body, ret_ref) + body_len + src_locs_and_hash.len, ); @@ -12467,7 +12293,7 @@ const GenZir = struct { try astgen.extra.ensureUnusedCapacity( gpa, - @typeInfo(Zir.Inst.ExtendedVar).Struct.fields.len + + @typeInfo(Zir.Inst.ExtendedVar).@"struct".fields.len + @intFromBool(args.lib_name != .empty) + @intFromBool(args.align_inst != .none) + @intFromBool(args.init != .none), @@ -12629,7 +12455,7 @@ const GenZir = struct { const param_body = param_gz.instructionsSlice(); const body_len = gz.astgen.countBodyLenAfterFixups(param_body); try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1); - try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).Struct.fields.len + body_len); + try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).@"struct".fields.len + body_len); const doc_comment_index = if (first_doc_comment) |first| try gz.astgen.docCommentAsStringFromFirst(abs_tok_index, first) @@ -12702,7 +12528,7 @@ const GenZir = struct { try astgen.instructions.ensureUnusedCapacity(gpa, 1); try astgen.extra.ensureUnusedCapacity( gpa, - @typeInfo(Zir.Inst.NodeMultiOp).Struct.fields.len + operands.len, + @typeInfo(Zir.Inst.NodeMultiOp).@"struct".fields.len + operands.len, ); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.NodeMultiOp{ @@ -12943,7 +12769,7 @@ const GenZir = struct { ) !Zir.Inst.Index { const gpa = gz.astgen.gpa; try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1); - try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).Struct.fields.len); + try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).@"struct".fields.len); const new_index: Zir.Inst.Index = @enumFromInt(gz.astgen.instructions.len); gz.astgen.instructions.appendAssumeCapacity(.{ @@ -13066,7 +12892,7 @@ const GenZir = struct { try astgen.instructions.ensureUnusedCapacity(gpa, 1); try astgen.extra.ensureUnusedCapacity( gpa, - @typeInfo(Zir.Inst.AllocExtended).Struct.fields.len + + @typeInfo(Zir.Inst.AllocExtended).@"struct".fields.len + @intFromBool(args.type_inst != .none) + @intFromBool(args.align_inst != .none), ); @@ -13118,9 +12944,9 @@ const GenZir = struct { try gz.instructions.ensureUnusedCapacity(gpa, 1); try astgen.instructions.ensureUnusedCapacity(gpa, 1); - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).Struct.fields.len + - args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).Struct.fields.len + - args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).Struct.fields.len + + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"struct".fields.len + + args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).@"struct".fields.len + + args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".fields.len + args.clobbers.len); const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{ @@ -13229,7 +13055,7 @@ const GenZir = struct { const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash); - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).Struct.fields.len + 3); + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len + 3); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.StructDecl{ .fields_hash_0 = fields_hash_arr[0], .fields_hash_1 = fields_hash_arr[1], @@ -13290,7 +13116,7 @@ const GenZir = struct { const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash); - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).Struct.fields.len + 5); + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).@"struct".fields.len + 5); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.UnionDecl{ .fields_hash_0 = fields_hash_arr[0], .fields_hash_1 = fields_hash_arr[1], @@ -13352,7 +13178,7 @@ const GenZir = struct { const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash); - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).Struct.fields.len + 5); + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).@"struct".fields.len + 5); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.EnumDecl{ .fields_hash_0 = fields_hash_arr[0], .fields_hash_1 = fields_hash_arr[1], @@ -13405,7 +13231,7 @@ const GenZir = struct { assert(args.src_node != 0); - try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).Struct.fields.len + 2); + try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).@"struct".fields.len + 2); const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.OpaqueDecl{ .src_line = astgen.source_line, .src_node = args.src_node, @@ -13633,31 +13459,67 @@ fn advanceSourceCursor(astgen: *AstGen, end: usize) void { astgen.source_column = column; } -fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const Ast.Node.Index) !u32 { +/// Detects name conflicts for decls and fields, and populates `namespace.decls` with all named declarations. +/// Returns the number of declarations in the namespace, including unnamed declarations (e.g. `comptime` decls). +fn scanContainer( + astgen: *AstGen, + namespace: *Scope.Namespace, + members: []const Ast.Node.Index, + container_kind: enum { @"struct", @"union", @"enum", @"opaque" }, +) !u32 { const gpa = astgen.gpa; const tree = astgen.tree; const node_tags = tree.nodes.items(.tag); const main_tokens = tree.nodes.items(.main_token); const token_tags = tree.tokens.items(.tag); - // We don't have shadowing for test names, so we just track those for duplicate reporting locally. - var named_tests: std.AutoHashMapUnmanaged(Zir.NullTerminatedString, Ast.Node.Index) = .{}; - var decltests: std.AutoHashMapUnmanaged(Zir.NullTerminatedString, Ast.Node.Index) = .{}; + // This type forms a linked list of source tokens declaring the same name. + const NameEntry = struct { + tok: Ast.TokenIndex, + /// Using a linked list here simplifies memory management, and is acceptable since + ///ewntries are only allocated in error situations. The entries are allocated into the + /// AstGen arena. + next: ?*@This(), + }; + + // The maps below are allocated into this SFBA to avoid using the GPA for small namespaces. + var sfba_state = std.heap.stackFallback(512, astgen.gpa); + const sfba = sfba_state.get(); + + var names: std.AutoArrayHashMapUnmanaged(Zir.NullTerminatedString, NameEntry) = .{}; + var test_names: std.AutoArrayHashMapUnmanaged(Zir.NullTerminatedString, NameEntry) = .{}; + var decltest_names: std.AutoArrayHashMapUnmanaged(Zir.NullTerminatedString, NameEntry) = .{}; defer { - named_tests.deinit(gpa); - decltests.deinit(gpa); + names.deinit(sfba); + test_names.deinit(sfba); + decltest_names.deinit(sfba); } + var any_duplicates = false; var decl_count: u32 = 0; for (members) |member_node| { - const name_token = switch (node_tags[member_node]) { + const Kind = enum { decl, field }; + const kind: Kind, const name_token = switch (node_tags[member_node]) { + .container_field_init, + .container_field_align, + .container_field, + => blk: { + var full = tree.fullContainerField(member_node).?; + switch (container_kind) { + .@"struct", .@"opaque" => {}, + .@"union", .@"enum" => full.convertToNonTupleLike(astgen.tree.nodes), + } + if (full.ast.tuple_like) continue; + break :blk .{ .field, full.ast.main_token }; + }, + .global_var_decl, .local_var_decl, .simple_var_decl, .aligned_var_decl, => blk: { decl_count += 1; - break :blk main_tokens[member_node] + 1; + break :blk .{ .decl, main_tokens[member_node] + 1 }; }, .fn_proto_simple, @@ -13669,12 +13531,10 @@ fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const Ast. decl_count += 1; const ident = main_tokens[member_node] + 1; if (token_tags[ident] != .identifier) { - switch (astgen.failNode(member_node, "missing function name", .{})) { - error.AnalysisFail => continue, - error.OutOfMemory => return error.OutOfMemory, - } + try astgen.appendErrorNode(member_node, "missing function name", .{}); + continue; } - break :blk ident; + break :blk .{ .decl, ident }; }, .@"comptime", .@"usingnamespace" => { @@ -13687,70 +13547,87 @@ fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const Ast. // We don't want shadowing detection here, and test names work a bit differently, so // we must do the redeclaration detection ourselves. const test_name_token = main_tokens[member_node] + 1; + const new_ent: NameEntry = .{ + .tok = test_name_token, + .next = null, + }; switch (token_tags[test_name_token]) { else => {}, // unnamed test .string_literal => { const name = try astgen.strLitAsString(test_name_token); - const gop = try named_tests.getOrPut(gpa, name.index); + const gop = try test_names.getOrPut(sfba, name.index); if (gop.found_existing) { - const name_slice = astgen.string_bytes.items[@intFromEnum(name.index)..][0..name.len]; - const name_duped = try gpa.dupe(u8, name_slice); - defer gpa.free(name_duped); - try astgen.appendErrorNodeNotes(member_node, "duplicate test name '{s}'", .{name_duped}, &.{ - try astgen.errNoteNode(gop.value_ptr.*, "other test here", .{}), - }); + var e = gop.value_ptr; + while (e.next) |n| e = n; + e.next = try astgen.arena.create(NameEntry); + e.next.?.* = new_ent; + any_duplicates = true; } else { - gop.value_ptr.* = member_node; + gop.value_ptr.* = new_ent; } }, .identifier => { const name = try astgen.identAsString(test_name_token); - const gop = try decltests.getOrPut(gpa, name); + const gop = try decltest_names.getOrPut(sfba, name); if (gop.found_existing) { - const name_slice = mem.span(astgen.nullTerminatedString(name)); - const name_duped = try gpa.dupe(u8, name_slice); - defer gpa.free(name_duped); - try astgen.appendErrorNodeNotes(member_node, "duplicate decltest '{s}'", .{name_duped}, &.{ - try astgen.errNoteNode(gop.value_ptr.*, "other decltest here", .{}), - }); + var e = gop.value_ptr; + while (e.next) |n| e = n; + e.next = try astgen.arena.create(NameEntry); + e.next.?.* = new_ent; + any_duplicates = true; } else { - gop.value_ptr.* = member_node; + gop.value_ptr.* = new_ent; } }, } continue; }, - else => continue, + else => unreachable, }; + const name_str_index = try astgen.identAsString(name_token); + + if (kind == .decl) { + // Put the name straight into `decls`, even if there are compile errors. + // This avoids incorrect "undeclared identifier" errors later on. + try namespace.decls.put(gpa, name_str_index, member_node); + } + + { + const gop = try names.getOrPut(sfba, name_str_index); + const new_ent: NameEntry = .{ + .tok = name_token, + .next = null, + }; + if (gop.found_existing) { + var e = gop.value_ptr; + while (e.next) |n| e = n; + e.next = try astgen.arena.create(NameEntry); + e.next.?.* = new_ent; + any_duplicates = true; + continue; + } else { + gop.value_ptr.* = new_ent; + } + } + + // For fields, we only needed the duplicate check! Decls have some more checks to do, though. + switch (kind) { + .decl => {}, + .field => continue, + } + const token_bytes = astgen.tree.tokenSlice(name_token); if (token_bytes[0] != '@' and isPrimitive(token_bytes)) { - switch (astgen.failTokNotes(name_token, "name shadows primitive '{s}'", .{ + try astgen.appendErrorTokNotes(name_token, "name shadows primitive '{s}'", .{ token_bytes, - }, &[_]u32{ + }, &.{ try astgen.errNoteTok(name_token, "consider using @\"{s}\" to disambiguate", .{ token_bytes, }), - })) { - error.AnalysisFail => continue, - error.OutOfMemory => return error.OutOfMemory, - } - } - - const name_str_index = try astgen.identAsString(name_token); - const gop = try namespace.decls.getOrPut(gpa, name_str_index); - if (gop.found_existing) { - const name = try gpa.dupe(u8, mem.span(astgen.nullTerminatedString(name_str_index))); - defer gpa.free(name); - switch (astgen.failNodeNotes(member_node, "redeclaration of '{s}'", .{ - name, - }, &[_]u32{ - try astgen.errNoteNode(gop.value_ptr.*, "other declaration here", .{}), - })) { - error.AnalysisFail => continue, - error.OutOfMemory => return error.OutOfMemory, - } + }); + continue; } var s = namespace.parent; @@ -13758,30 +13635,32 @@ fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const Ast. .local_val => { const local_val = s.cast(Scope.LocalVal).?; if (local_val.name == name_str_index) { - return astgen.failTokNotes(name_token, "declaration '{s}' shadows {s} from outer scope", .{ + try astgen.appendErrorTokNotes(name_token, "declaration '{s}' shadows {s} from outer scope", .{ token_bytes, @tagName(local_val.id_cat), - }, &[_]u32{ + }, &.{ try astgen.errNoteTok( local_val.token_src, "previous declaration here", .{}, ), }); + break; } s = local_val.parent; }, .local_ptr => { const local_ptr = s.cast(Scope.LocalPtr).?; if (local_ptr.name == name_str_index) { - return astgen.failTokNotes(name_token, "declaration '{s}' shadows {s} from outer scope", .{ + try astgen.appendErrorTokNotes(name_token, "declaration '{s}' shadows {s} from outer scope", .{ token_bytes, @tagName(local_ptr.id_cat), - }, &[_]u32{ + }, &.{ try astgen.errNoteTok( local_ptr.token_src, "previous declaration here", .{}, ), }); + break; } s = local_ptr.parent; }, @@ -13790,8 +13669,46 @@ fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const Ast. .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent, .top => break, }; - gop.value_ptr.* = member_node; } + + if (!any_duplicates) return decl_count; + + for (names.keys(), names.values()) |name, first| { + if (first.next == null) continue; + var notes: std.ArrayListUnmanaged(u32) = .{}; + var prev: NameEntry = first; + while (prev.next) |cur| : (prev = cur.*) { + try notes.append(astgen.arena, try astgen.errNoteTok(cur.tok, "duplicate name here", .{})); + } + try notes.append(astgen.arena, try astgen.errNoteNode(namespace.node, "{s} declared here", .{@tagName(container_kind)})); + const name_duped = try astgen.arena.dupe(u8, mem.span(astgen.nullTerminatedString(name))); + try astgen.appendErrorTokNotes(first.tok, "duplicate {s} member name '{s}'", .{ @tagName(container_kind), name_duped }, notes.items); + } + + for (test_names.keys(), test_names.values()) |name, first| { + if (first.next == null) continue; + var notes: std.ArrayListUnmanaged(u32) = .{}; + var prev: NameEntry = first; + while (prev.next) |cur| : (prev = cur.*) { + try notes.append(astgen.arena, try astgen.errNoteTok(cur.tok, "duplicate test here", .{})); + } + try notes.append(astgen.arena, try astgen.errNoteNode(namespace.node, "{s} declared here", .{@tagName(container_kind)})); + const name_duped = try astgen.arena.dupe(u8, mem.span(astgen.nullTerminatedString(name))); + try astgen.appendErrorTokNotes(first.tok, "duplicate test name '{s}'", .{name_duped}, notes.items); + } + + for (decltest_names.keys(), decltest_names.values()) |name, first| { + if (first.next == null) continue; + var notes: std.ArrayListUnmanaged(u32) = .{}; + var prev: NameEntry = first; + while (prev.next) |cur| : (prev = cur.*) { + try notes.append(astgen.arena, try astgen.errNoteTok(cur.tok, "duplicate decltest here", .{})); + } + try notes.append(astgen.arena, try astgen.errNoteNode(namespace.node, "{s} declared here", .{@tagName(container_kind)})); + const name_duped = try astgen.arena.dupe(u8, mem.span(astgen.nullTerminatedString(name))); + try astgen.appendErrorTokNotes(first.tok, "duplicate decltest '{s}'", .{name_duped}, notes.items); + } + return decl_count; } diff --git a/lib/std/zig/AstRlAnnotate.zig b/lib/std/zig/AstRlAnnotate.zig index e956ffd2a9..597baa2936 100644 --- a/lib/std/zig/AstRlAnnotate.zig +++ b/lib/std/zig/AstRlAnnotate.zig @@ -829,6 +829,10 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast. } switch (info.tag) { .import => return false, + .branch_hint => { + _ = try astrl.expr(args[0], block, ResultInfo.type_only); + return false; + }, .compile_log, .TypeOf => { for (args) |arg_node| { _ = try astrl.expr(arg_node, block, ResultInfo.none); @@ -907,7 +911,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast. .fence, .set_float_mode, .set_align_stack, - .set_cold, .type_info, .work_item_id, .work_group_size, diff --git a/lib/std/zig/BuiltinFn.zig b/lib/std/zig/BuiltinFn.zig index fc08f9eb85..1da3ffb5a7 100644 --- a/lib/std/zig/BuiltinFn.zig +++ b/lib/std/zig/BuiltinFn.zig @@ -14,6 +14,7 @@ pub const Tag = enum { bit_offset_of, int_from_bool, bit_size_of, + branch_hint, breakpoint, disable_instrumentation, mul_add, @@ -82,7 +83,6 @@ pub const Tag = enum { return_address, select, set_align_stack, - set_cold, set_eval_branch_quota, set_float_mode, set_runtime_safety, @@ -257,6 +257,14 @@ pub const list = list: { }, }, .{ + "@branchHint", + .{ + .tag = .branch_hint, + .param_count = 1, + .illegal_outside_function = true, + }, + }, + .{ "@breakpoint", .{ .tag = .breakpoint, @@ -745,14 +753,6 @@ pub const list = list: { }, }, .{ - "@setCold", - .{ - .tag = .set_cold, - .param_count = 1, - .illegal_outside_function = true, - }, - }, - .{ "@setEvalBranchQuota", .{ .tag = .set_eval_branch_quota, diff --git a/lib/std/zig/ErrorBundle.zig b/lib/std/zig/ErrorBundle.zig index 2d69ff901d..63e0748d8d 100644 --- a/lib/std/zig/ErrorBundle.zig +++ b/lib/std/zig/ErrorBundle.zig @@ -108,7 +108,7 @@ pub fn getSourceLocation(eb: ErrorBundle, index: SourceLocationIndex) SourceLoca pub fn getNotes(eb: ErrorBundle, index: MessageIndex) []const MessageIndex { const notes_len = eb.getErrorMessage(index).notes_len; - const start = @intFromEnum(index) + @typeInfo(ErrorMessage).Struct.fields.len; + const start = @intFromEnum(index) + @typeInfo(ErrorMessage).@"struct".fields.len; return @as([]const MessageIndex, @ptrCast(eb.extra[start..][0..notes_len])); } @@ -119,7 +119,7 @@ pub fn getCompileLogOutput(eb: ErrorBundle) [:0]const u8 { /// Returns the requested data, as well as the new index which is at the start of the /// trailers for the object. fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T, end: usize } { - const fields = @typeInfo(T).Struct.fields; + const fields = @typeInfo(T).@"struct".fields; var i: usize = index; var result: T = undefined; inline for (fields) |field| { @@ -456,7 +456,7 @@ pub const Wip = struct { pub fn reserveNotes(wip: *Wip, notes_len: u32) !u32 { try wip.extra.ensureUnusedCapacity(wip.gpa, notes_len + - notes_len * @typeInfo(ErrorBundle.ErrorMessage).Struct.fields.len); + notes_len * @typeInfo(ErrorBundle.ErrorMessage).@"struct".fields.len); wip.extra.items.len += notes_len; return @intCast(wip.extra.items.len - notes_len); } @@ -616,13 +616,13 @@ pub const Wip = struct { fn addExtra(wip: *Wip, extra: anytype) Allocator.Error!u32 { const gpa = wip.gpa; - const fields = @typeInfo(@TypeOf(extra)).Struct.fields; + const fields = @typeInfo(@TypeOf(extra)).@"struct".fields; try wip.extra.ensureUnusedCapacity(gpa, fields.len); return addExtraAssumeCapacity(wip, extra); } fn addExtraAssumeCapacity(wip: *Wip, extra: anytype) u32 { - const fields = @typeInfo(@TypeOf(extra)).Struct.fields; + const fields = @typeInfo(@TypeOf(extra)).@"struct".fields; const result: u32 = @intCast(wip.extra.items.len); wip.extra.items.len += fields.len; setExtra(wip, result, extra); @@ -630,7 +630,7 @@ pub const Wip = struct { } fn setExtra(wip: *Wip, index: usize, extra: anytype) void { - const fields = @typeInfo(@TypeOf(extra)).Struct.fields; + const fields = @typeInfo(@TypeOf(extra)).@"struct".fields; var i = index; inline for (fields) |field| { wip.extra.items[i] = switch (field.type) { diff --git a/lib/std/zig/Parse.zig b/lib/std/zig/Parse.zig index c43868a7d4..6f557a0f55 100644 --- a/lib/std/zig/Parse.zig +++ b/lib/std/zig/Parse.zig @@ -81,7 +81,7 @@ fn addExtra(p: *Parse, extra: anytype) Allocator.Error!Node.Index { } fn warnExpected(p: *Parse, expected_token: Token.Tag) error{OutOfMemory}!void { - @setCold(true); + @branchHint(.cold); try p.warnMsg(.{ .tag = .expected_token, .token = p.tok_i, @@ -90,12 +90,12 @@ fn warnExpected(p: *Parse, expected_token: Token.Tag) error{OutOfMemory}!void { } fn warn(p: *Parse, error_tag: AstError.Tag) error{OutOfMemory}!void { - @setCold(true); + @branchHint(.cold); try p.warnMsg(.{ .tag = error_tag, .token = p.tok_i }); } fn warnMsg(p: *Parse, msg: Ast.Error) error{OutOfMemory}!void { - @setCold(true); + @branchHint(.cold); switch (msg.tag) { .expected_semi_after_decl, .expected_semi_after_stmt, @@ -141,12 +141,12 @@ fn warnMsg(p: *Parse, msg: Ast.Error) error{OutOfMemory}!void { } fn fail(p: *Parse, tag: Ast.Error.Tag) error{ ParseError, OutOfMemory } { - @setCold(true); + @branchHint(.cold); return p.failMsg(.{ .tag = tag, .token = p.tok_i }); } fn failExpected(p: *Parse, expected_token: Token.Tag) error{ ParseError, OutOfMemory } { - @setCold(true); + @branchHint(.cold); return p.failMsg(.{ .tag = .expected_token, .token = p.tok_i, @@ -155,7 +155,7 @@ fn failExpected(p: *Parse, expected_token: Token.Tag) error{ ParseError, OutOfMe } fn failMsg(p: *Parse, msg: Ast.Error) error{ ParseError, OutOfMemory } { - @setCold(true); + @branchHint(.cold); try p.warnMsg(msg); return error.ParseError; } diff --git a/lib/std/zig/Server.zig b/lib/std/zig/Server.zig index 0ed9cfcd0b..2f03c78083 100644 --- a/lib/std/zig/Server.zig +++ b/lib/std/zig/Server.zig @@ -124,9 +124,9 @@ pub fn receiveMessage(s: *Server) !InMessage.Header { const buf = fifo.readableSlice(0); assert(fifo.readableLength() == buf.len); if (buf.len >= @sizeOf(Header)) { - // workaround for https://github.com/ziglang/zig/issues/14904 - const bytes_len = bswap_and_workaround_u32(buf[4..][0..4]); - const tag = bswap_and_workaround_tag(buf[0..][0..4]); + const header: *align(1) const Header = @ptrCast(buf[0..@sizeOf(Header)]); + const bytes_len = bswap(header.bytes_len); + const tag = bswap(header.tag); if (buf.len - @sizeOf(Header) >= bytes_len) { fifo.discard(@sizeOf(Header)); @@ -282,9 +282,9 @@ fn bswap(x: anytype) @TypeOf(x) { const T = @TypeOf(x); switch (@typeInfo(T)) { - .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))), - .Int => return @byteSwap(x), - .Struct => |info| switch (info.layout) { + .@"enum" => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))), + .int => return @byteSwap(x), + .@"struct" => |info| switch (info.layout) { .@"extern" => { var result: T = undefined; inline for (info.fields) |field| { @@ -307,17 +307,6 @@ fn bswap_u32_array(slice: []u32) void { for (slice) |*elem| elem.* = @byteSwap(elem.*); } -/// workaround for https://github.com/ziglang/zig/issues/14904 -fn bswap_and_workaround_u32(bytes_ptr: *const [4]u8) u32 { - return std.mem.readInt(u32, bytes_ptr, .little); -} - -/// workaround for https://github.com/ziglang/zig/issues/14904 -fn bswap_and_workaround_tag(bytes_ptr: *const [4]u8) InMessage.Tag { - const int = std.mem.readInt(u32, bytes_ptr, .little); - return @as(InMessage.Tag, @enumFromInt(int)); -} - const OutMessage = std.zig.Server.Message; const InMessage = std.zig.Client.Message; diff --git a/lib/std/zig/WindowsSdk.zig b/lib/std/zig/WindowsSdk.zig index caa389b010..1e1f0f1629 100644 --- a/lib/std/zig/WindowsSdk.zig +++ b/lib/std/zig/WindowsSdk.zig @@ -580,10 +580,10 @@ pub const Installation = struct { defer options_key.closeKey(); const option_name = comptime switch (builtin.target.cpu.arch) { - .arm, .armeb => "OptionId.DesktopCPParm", + .thumb => "OptionId.DesktopCPParm", .aarch64 => "OptionId.DesktopCPParm64", - .x86_64 => "OptionId.DesktopCPPx64", .x86 => "OptionId.DesktopCPPx86", + .x86_64 => "OptionId.DesktopCPPx64", else => |tag| @compileError("Windows SDK cannot be detected on architecture " ++ tag), }; @@ -824,10 +824,10 @@ const MsvcLibDir = struct { try lib_dir_buf.appendSlice("VC\\Tools\\MSVC\\"); try lib_dir_buf.appendSlice(default_tools_version); const folder_with_arch = "\\Lib\\" ++ comptime switch (builtin.target.cpu.arch) { + .thumb => "arm", + .aarch64 => "arm64", .x86 => "x86", .x86_64 => "x64", - .arm, .armeb => "arm", - .aarch64 => "arm64", else => |tag| @compileError("MSVC lib dir cannot be detected on architecture " ++ tag), }; try lib_dir_buf.appendSlice(folder_with_arch); @@ -909,10 +909,10 @@ const MsvcLibDir = struct { } const folder_with_arch = "\\Lib\\" ++ comptime switch (builtin.target.cpu.arch) { + .thumb => "arm", + .aarch64 => "arm64", .x86 => "x86", .x86_64 => "x64", - .arm, .armeb => "arm", - .aarch64 => "arm64", else => |tag| @compileError("MSVC lib dir cannot be detected on architecture " ++ tag), }; @@ -977,10 +977,10 @@ const MsvcLibDir = struct { errdefer base_path.deinit(); const folder_with_arch = "\\VC\\lib\\" ++ comptime switch (builtin.target.cpu.arch) { + .thumb => "arm", + .aarch64 => "arm64", .x86 => "", //x86 is in the root of the Lib folder .x86_64 => "amd64", - .arm, .armeb => "arm", - .aarch64 => "arm64", else => |tag| @compileError("MSVC lib dir cannot be detected on architecture " ++ tag), }; try base_path.appendSlice(folder_with_arch); diff --git a/lib/std/zig/Zir.zig b/lib/std/zig/Zir.zig index 26f4c4780f..af4ddaad6a 100644 --- a/lib/std/zig/Zir.zig +++ b/lib/std/zig/Zir.zig @@ -68,7 +68,7 @@ fn ExtraData(comptime T: type) type { /// Returns the requested data, as well as the new index which is at the start of the /// trailers for the object. pub fn extraData(code: Zir, comptime T: type, index: usize) ExtraData(T) { - const fields = @typeInfo(T).Struct.fields; + const fields = @typeInfo(T).@"struct".fields; var i: usize = index; var result: T = undefined; inline for (fields) |field| { @@ -431,14 +431,9 @@ pub const Inst = struct { error_union_type, /// `error.Foo` syntax. Uses the `str_tok` field of the Data union. error_value, - /// Implements the `@export` builtin function, based on either an identifier to a Decl, - /// or field access of a Decl. The thing being exported is the Decl. + /// Implements the `@export` builtin function. /// Uses the `pl_node` union field. Payload is `Export`. @"export", - /// Implements the `@export` builtin function, based on a comptime-known value. - /// The thing being exported is the comptime-known value which is the operand. - /// Uses the `pl_node` union field. Payload is `ExportValue`. - export_value, /// Given a pointer to a struct or object that contains virtual fields, returns a pointer /// to the named field. The field name is stored in string_bytes. Used by a.b syntax. /// Uses `pl_node` field. The AST node is the a.b syntax. Payload is Field. @@ -1093,7 +1088,6 @@ pub const Inst = struct { .ensure_result_non_error, .ensure_err_union_payload_void, .@"export", - .export_value, .field_ptr, .field_val, .field_ptr_named, @@ -1314,7 +1308,6 @@ pub const Inst = struct { .validate_deref, .validate_destructure, .@"export", - .export_value, .set_runtime_safety, .memcpy, .memset, @@ -1553,7 +1546,7 @@ pub const Inst = struct { => false, .extended => switch (data.extended.opcode) { - .fence, .set_cold, .breakpoint, .disable_instrumentation => true, + .fence, .branch_hint, .breakpoint, .disable_instrumentation => true, else => false, }, }; @@ -1637,7 +1630,6 @@ pub const Inst = struct { .error_union_type = .pl_node, .error_value = .str_tok, .@"export" = .pl_node, - .export_value = .pl_node, .field_ptr = .pl_node, .field_val = .pl_node, .field_ptr_named = .pl_node, @@ -1831,7 +1823,7 @@ pub const Inst = struct { // Uncomment to view how many tag slots are available. //comptime { - // @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).Enum.fields.len); + // @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).@"enum".fields.len); //} }; @@ -1962,9 +1954,6 @@ pub const Inst = struct { /// Implement builtin `@setAlignStack`. /// `operand` is payload index to `UnNode`. set_align_stack, - /// Implements `@setCold`. - /// `operand` is payload index to `UnNode`. - set_cold, /// Implements the `@errorCast` builtin. /// `operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand. error_cast, @@ -2059,6 +2048,10 @@ pub const Inst = struct { /// `operand` is `src_node: i32`. /// `small` is an `Inst.BuiltinValue`. builtin_value, + /// Provide a `@branchHint` for the current block. + /// `operand` is payload index to `UnNode`. + /// `small` is unused. + branch_hint, pub const InstData = struct { opcode: Extended, @@ -3150,6 +3143,7 @@ pub const Inst = struct { export_options, extern_options, type_info, + branch_hint, // Values calling_convention_c, calling_convention_inline, @@ -3425,17 +3419,7 @@ pub const Inst = struct { }; pub const Export = struct { - /// If present, this is referring to a Decl via field access, e.g. `a.b`. - /// If omitted, this is referring to a Decl via identifier, e.g. `a`. - namespace: Ref, - /// Null-terminated string index. - decl_name: NullTerminatedString, - options: Ref, - }; - - pub const ExportValue = struct { - /// The comptime value to export. - operand: Ref, + exported: Ref, options: Ref, }; @@ -3567,7 +3551,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { }, .struct_decl => { const small: Inst.StructDecl.Small = @bitCast(extended.small); - var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).Struct.fields.len); + var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).@"struct".fields.len); const captures_len = if (small.has_captures_len) captures_len: { const captures_len = zir.extra[extra_index]; extra_index += 1; @@ -3600,7 +3584,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { }, .enum_decl => { const small: Inst.EnumDecl.Small = @bitCast(extended.small); - var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.EnumDecl).Struct.fields.len); + var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.EnumDecl).@"struct".fields.len); extra_index += @intFromBool(small.has_tag_type); const captures_len = if (small.has_captures_len) captures_len: { const captures_len = zir.extra[extra_index]; @@ -3625,7 +3609,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { }, .union_decl => { const small: Inst.UnionDecl.Small = @bitCast(extended.small); - var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.UnionDecl).Struct.fields.len); + var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.UnionDecl).@"struct".fields.len); extra_index += @intFromBool(small.has_tag_type); const captures_len = if (small.has_captures_len) captures_len: { const captures_len = zir.extra[extra_index]; @@ -3650,7 +3634,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator { }, .opaque_decl => { const small: Inst.OpaqueDecl.Small = @bitCast(extended.small); - var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.OpaqueDecl).Struct.fields.len); + var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.OpaqueDecl).@"struct".fields.len); const decls_len = if (small.has_decls_len) decls_len: { const decls_len = zir.extra[extra_index]; extra_index += 1; @@ -3793,7 +3777,6 @@ fn findDeclsInner( .error_union_type, .error_value, .@"export", - .export_value, .field_ptr, .field_val, .field_ptr_named, @@ -3981,7 +3964,6 @@ fn findDeclsInner( .fence, .set_float_mode, .set_align_stack, - .set_cold, .error_cast, .await_nosuspend, .breakpoint, @@ -4005,6 +3987,7 @@ fn findDeclsInner( .closure_get, .field_parent_ptr, .builtin_value, + .branch_hint, => return, // `@TypeOf` has a body. @@ -4624,7 +4607,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash { const extra_index = extra.end + extra.data.ret_body_len + extra.data.body_len + - @typeInfo(Inst.Func.SrcLocs).Struct.fields.len; + @typeInfo(Inst.Func.SrcLocs).@"struct".fields.len; return @bitCast([4]u32{ zir.extra[extra_index + 0], zir.extra[extra_index + 1], @@ -4664,7 +4647,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash { } else extra_index += @intFromBool(bits.has_ret_ty_ref); extra_index += @intFromBool(bits.has_any_noalias); extra_index += extra.data.body_len; - extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).Struct.fields.len; + extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).@"struct".fields.len; return @bitCast([4]u32{ zir.extra[extra_index + 0], zir.extra[extra_index + 1], diff --git a/lib/std/zig/c_translation.zig b/lib/std/zig/c_translation.zig index 504f134b41..39f7fa9a11 100644 --- a/lib/std/zig/c_translation.zig +++ b/lib/std/zig/c_translation.zig @@ -9,60 +9,60 @@ pub fn cast(comptime DestType: type, target: anytype) DestType { // this function should behave like transCCast in translate-c, except it's for macros const SourceType = @TypeOf(target); switch (@typeInfo(DestType)) { - .Fn => return castToPtr(*const DestType, SourceType, target), - .Pointer => return castToPtr(DestType, SourceType, target), - .Optional => |dest_opt| { - if (@typeInfo(dest_opt.child) == .Pointer) { + .@"fn" => return castToPtr(*const DestType, SourceType, target), + .pointer => return castToPtr(DestType, SourceType, target), + .optional => |dest_opt| { + if (@typeInfo(dest_opt.child) == .pointer) { return castToPtr(DestType, SourceType, target); - } else if (@typeInfo(dest_opt.child) == .Fn) { + } else if (@typeInfo(dest_opt.child) == .@"fn") { return castToPtr(?*const dest_opt.child, SourceType, target); } }, - .Int => { + .int => { switch (@typeInfo(SourceType)) { - .Pointer => { + .pointer => { return castInt(DestType, @intFromPtr(target)); }, - .Optional => |opt| { - if (@typeInfo(opt.child) == .Pointer) { + .optional => |opt| { + if (@typeInfo(opt.child) == .pointer) { return castInt(DestType, @intFromPtr(target)); } }, - .Int => { + .int => { return castInt(DestType, target); }, - .Fn => { + .@"fn" => { return castInt(DestType, @intFromPtr(&target)); }, - .Bool => { + .bool => { return @intFromBool(target); }, else => {}, } }, - .Float => { + .float => { switch (@typeInfo(SourceType)) { - .Int => return @as(DestType, @floatFromInt(target)), - .Float => return @as(DestType, @floatCast(target)), - .Bool => return @as(DestType, @floatFromInt(@intFromBool(target))), + .int => return @as(DestType, @floatFromInt(target)), + .float => return @as(DestType, @floatCast(target)), + .bool => return @as(DestType, @floatFromInt(@intFromBool(target))), else => {}, } }, - .Union => |info| { + .@"union" => |info| { inline for (info.fields) |field| { if (field.type == SourceType) return @unionInit(DestType, field.name, target); } @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union"); }, - .Bool => return cast(usize, target) != 0, + .bool => return cast(usize, target) != 0, else => {}, } return @as(DestType, target); } fn castInt(comptime DestType: type, target: anytype) DestType { - const dest = @typeInfo(DestType).Int; - const source = @typeInfo(@TypeOf(target)).Int; + const dest = @typeInfo(DestType).int; + const source = @typeInfo(@TypeOf(target)).int; if (dest.bits < source.bits) return @as(DestType, @bitCast(@as(std.meta.Int(source.signedness, dest.bits), @truncate(target)))) @@ -76,20 +76,20 @@ fn castPtr(comptime DestType: type, target: anytype) DestType { fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType { switch (@typeInfo(SourceType)) { - .Int => { + .int => { return @as(DestType, @ptrFromInt(castInt(usize, target))); }, - .ComptimeInt => { + .comptime_int => { if (target < 0) return @as(DestType, @ptrFromInt(@as(usize, @bitCast(@as(isize, @intCast(target)))))) else return @as(DestType, @ptrFromInt(@as(usize, @intCast(target)))); }, - .Pointer => { + .pointer => { return castPtr(DestType, target); }, - .Optional => |target_opt| { - if (@typeInfo(target_opt.child) == .Pointer) { + .optional => |target_opt| { + if (@typeInfo(target_opt.child) == .pointer) { return castPtr(DestType, target); } }, @@ -100,8 +100,8 @@ fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype fn ptrInfo(comptime PtrType: type) std.builtin.Type.Pointer { return switch (@typeInfo(PtrType)) { - .Optional => |opt_info| @typeInfo(opt_info.child).Pointer, - .Pointer => |ptr_info| ptr_info, + .optional => |opt_info| @typeInfo(opt_info.child).pointer, + .pointer => |ptr_info| ptr_info, else => unreachable, }; } @@ -144,17 +144,17 @@ test "cast" { pub fn sizeof(target: anytype) usize { const T: type = if (@TypeOf(target) == type) target else @TypeOf(target); switch (@typeInfo(T)) { - .Float, .Int, .Struct, .Union, .Array, .Bool, .Vector => return @sizeOf(T), - .Fn => { + .float, .int, .@"struct", .@"union", .array, .bool, .vector => return @sizeOf(T), + .@"fn" => { // sizeof(main) in C returns 1 return 1; }, - .Null => return @sizeOf(*anyopaque), - .Void => { + .null => return @sizeOf(*anyopaque), + .void => { // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC. return 1; }, - .Opaque => { + .@"opaque" => { if (T == anyopaque) { // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC. return 1; @@ -162,24 +162,24 @@ pub fn sizeof(target: anytype) usize { @compileError("Cannot use C sizeof on opaque type " ++ @typeName(T)); } }, - .Optional => |opt| { - if (@typeInfo(opt.child) == .Pointer) { + .optional => |opt| { + if (@typeInfo(opt.child) == .pointer) { return sizeof(opt.child); } else { @compileError("Cannot use C sizeof on non-pointer optional " ++ @typeName(T)); } }, - .Pointer => |ptr| { + .pointer => |ptr| { if (ptr.size == .Slice) { @compileError("Cannot use C sizeof on slice type " ++ @typeName(T)); } // for strings, sizeof("a") returns 2. // normal pointer decay scenarios from C are handled - // in the .Array case above, but strings remain literals + // in the .array case above, but strings remain literals // and are therefore always pointers, so they need to be // specially handled here. - if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .Array) { - const array_info = @typeInfo(ptr.child).Array; + if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .array) { + const array_info = @typeInfo(ptr.child).array; if ((array_info.child == u8 or array_info.child == u16) and array_info.sentinel != null and @as(*align(1) const array_info.child, @ptrCast(array_info.sentinel.?)).* == 0) @@ -195,8 +195,8 @@ pub fn sizeof(target: anytype) usize { } return @sizeOf(T); }, - .ComptimeFloat => return @sizeOf(f64), // TODO c_double #3999 - .ComptimeInt => { + .comptime_float => return @sizeOf(f64), // TODO c_double #3999 + .comptime_int => { // TODO to get the correct result we have to translate // `1073741824 * 4` as `int(1073741824) *% int(4)` since // sizeof(1073741824 * 4) != sizeof(4294967296). @@ -262,7 +262,7 @@ fn PromoteIntLiteralReturnType(comptime SuffixType: type, comptime number: compt const signed_oct_hex = [_]type{ c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong }; const unsigned = [_]type{ c_uint, c_ulong, c_ulonglong }; - const list: []const type = if (@typeInfo(SuffixType).Int.signedness == .unsigned) + const list: []const type = if (@typeInfo(SuffixType).int.signedness == .unsigned) &unsigned else if (base == .decimal) &signed_decimal @@ -339,8 +339,8 @@ test "shuffleVectorIndex" { /// from SelfType for pointing to a C flexible array of ElementType. pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type { switch (@typeInfo(SelfType)) { - .Pointer => |ptr| { - return @Type(.{ .Pointer = .{ + .pointer => |ptr| { + return @Type(.{ .pointer = .{ .size = .C, .is_const = ptr.is_const, .is_volatile = ptr.is_volatile, @@ -372,7 +372,7 @@ test "Flexible Array Type" { /// the type and denominator is -1. C has undefined behavior for those two cases; this function has safety /// checked undefined behavior pub fn signedRemainder(numerator: anytype, denominator: anytype) @TypeOf(numerator, denominator) { - std.debug.assert(@typeInfo(@TypeOf(numerator, denominator)).Int.signedness == .signed); + std.debug.assert(@typeInfo(@TypeOf(numerator, denominator)).int.signedness == .signed); if (denominator > 0) return @rem(numerator, denominator); return numerator - @divTrunc(numerator, denominator) * denominator; } @@ -384,15 +384,15 @@ pub const Macros = struct { fn L_SUFFIX_ReturnType(comptime number: anytype) type { switch (@typeInfo(@TypeOf(number))) { - .Int, .ComptimeInt => return @TypeOf(promoteIntLiteral(c_long, number, .decimal)), - .Float, .ComptimeFloat => return c_longdouble, + .int, .comptime_int => return @TypeOf(promoteIntLiteral(c_long, number, .decimal)), + .float, .comptime_float => return c_longdouble, else => @compileError("Invalid value for L suffix"), } } pub fn L_SUFFIX(comptime number: anytype) L_SUFFIX_ReturnType(number) { switch (@typeInfo(@TypeOf(number))) { - .Int, .ComptimeInt => return promoteIntLiteral(c_long, number, .decimal), - .Float, .ComptimeFloat => @compileError("TODO: c_longdouble initialization from comptime_float not supported"), + .int, .comptime_int => return promoteIntLiteral(c_long, number, .decimal), + .float, .comptime_float => @compileError("TODO: c_longdouble initialization from comptime_float not supported"), else => @compileError("Invalid value for L suffix"), } } @@ -420,13 +420,13 @@ pub const Macros = struct { /// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B) /// could be either: cast B to A, or call A with the value B. pub fn CAST_OR_CALL(a: anytype, b: anytype) switch (@typeInfo(@TypeOf(a))) { - .Type => a, - .Fn => |fn_info| fn_info.return_type orelse void, + .type => a, + .@"fn" => |fn_info| fn_info.return_type orelse void, else => |info| @compileError("Unexpected argument type: " ++ @tagName(info)), } { switch (@typeInfo(@TypeOf(a))) { - .Type => return cast(a, b), - .Fn => return a(b), + .type => return cast(a, b), + .@"fn" => return a(b), else => unreachable, // return type will be a compile error otherwise } } @@ -444,7 +444,7 @@ fn PromotedIntType(comptime T: type) type { c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong => T, else => if (T == comptime_int) { @compileError("Cannot promote `" ++ @typeName(T) ++ "`; a fixed-size number type is required"); - } else if (@typeInfo(T) == .Int) { + } else if (@typeInfo(T) == .int) { @compileError("Cannot promote `" ++ @typeName(T) ++ "`; a C ABI type is required"); } else { @compileError("Attempted to promote invalid type `" ++ @typeName(T) ++ "`"); @@ -490,8 +490,8 @@ fn ArithmeticConversion(comptime A: type, comptime B: type) type { if (A_Promoted == B_Promoted) return A_Promoted; - const a_signed = @typeInfo(A_Promoted).Int.signedness == .signed; - const b_signed = @typeInfo(B_Promoted).Int.signedness == .signed; + const a_signed = @typeInfo(A_Promoted).int.signedness == .signed; + const b_signed = @typeInfo(B_Promoted).int.signedness == .signed; if (a_signed == b_signed) { return if (integerRank(A_Promoted) > integerRank(B_Promoted)) A_Promoted else B_Promoted; @@ -544,8 +544,8 @@ pub const MacroArithmetic = struct { const a_casted = cast(ResType, a); const b_casted = cast(ResType, b); switch (@typeInfo(ResType)) { - .Float => return a_casted / b_casted, - .Int => return @divTrunc(a_casted, b_casted), + .float => return a_casted / b_casted, + .int => return @divTrunc(a_casted, b_casted), else => unreachable, } } @@ -555,8 +555,8 @@ pub const MacroArithmetic = struct { const a_casted = cast(ResType, a); const b_casted = cast(ResType, b); switch (@typeInfo(ResType)) { - .Int => { - if (@typeInfo(ResType).Int.signedness == .signed) { + .int => { + if (@typeInfo(ResType).int.signedness == .signed) { return signedRemainder(a_casted, b_casted); } else { return a_casted % b_casted; diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 530aa924d0..d399c58c9c 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -2548,7 +2548,7 @@ test "zig fmt: same-line comment after non-block if expression" { test "zig fmt: same-line comment on comptime expression" { try testCanonical( \\test "" { - \\ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt + \\ comptime assert(@typeInfo(T) == .int); // must pass an integer to absInt \\} \\ ); diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 92058fbf3b..4de1e20656 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -86,6 +86,7 @@ pub fn getExternalExecutor( .arm => Executor{ .qemu = "qemu-arm" }, .armeb => Executor{ .qemu = "qemu-armeb" }, .hexagon => Executor{ .qemu = "qemu-hexagon" }, + .loongarch64 => Executor{ .qemu = "qemu-loongarch64" }, .m68k => Executor{ .qemu = "qemu-m68k" }, .mips => Executor{ .qemu = "qemu-mips" }, .mipsel => Executor{ .qemu = "qemu-mipsel" }, diff --git a/lib/std/zig/system/windows.zig b/lib/std/zig/system/windows.zig index 4c8e911a9f..43d407c3a0 100644 --- a/lib/std/zig/system/windows.zig +++ b/lib/std/zig/system/windows.zig @@ -56,11 +56,11 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void { const ArgsType = @TypeOf(args); const args_type_info = @typeInfo(ArgsType); - if (args_type_info != .Struct) { + if (args_type_info != .@"struct") { @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType)); } - const fields_info = args_type_info.Struct.fields; + const fields_info = args_type_info.@"struct".fields; // Originally, I wanted to issue a single call with a more complex table structure such that we // would sequentially visit each CPU#d subkey in the registry and pull the value of interest into diff --git a/lib/std/zig/target.zig b/lib/std/zig/target.zig index b248f21d6a..d0d68acd70 100644 --- a/lib/std/zig/target.zig +++ b/lib/std/zig/target.zig @@ -24,15 +24,11 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .arm, .os = .linux, .abi = .gnueabihf }, .{ .arch = .arm, .os = .linux, .abi = .musleabi }, .{ .arch = .arm, .os = .linux, .abi = .musleabihf }, - .{ .arch = .thumb, .os = .linux, .abi = .gnueabi }, - .{ .arch = .thumb, .os = .linux, .abi = .gnueabihf }, .{ .arch = .thumb, .os = .linux, .abi = .musleabi }, .{ .arch = .thumb, .os = .linux, .abi = .musleabihf }, - .{ .arch = .thumbeb, .os = .linux, .abi = .gnueabi }, - .{ .arch = .thumbeb, .os = .linux, .abi = .gnueabihf }, .{ .arch = .thumbeb, .os = .linux, .abi = .musleabi }, .{ .arch = .thumbeb, .os = .linux, .abi = .musleabihf }, - .{ .arch = .arm, .os = .windows, .abi = .gnu }, + .{ .arch = .thumb, .os = .windows, .abi = .gnu }, .{ .arch = .csky, .os = .linux, .abi = .gnueabi, .glibc_min = .{ .major = 2, .minor = 29, .patch = 0 } }, .{ .arch = .csky, .os = .linux, .abi = .gnueabihf, .glibc_min = .{ .major = 2, .minor = 29, .patch = 0 } }, .{ .arch = .x86, .os = .linux, .abi = .gnu }, |
