| author | |
| committer | |
| log | 4f782d1e853accbe1c4bfab2617c3813d4b1e59f |
| tree | 0eb768171ecfb058fba72d199afc951af206f8fb |
| parent | d0c06ca7127110a8afeb0ef524a197049892db21 |
| parent | 6067d39522f939c08dd3f3ea4fb5889ff0024e72 |
| signature |
std.builtin: make enum fields lowercase126 files changed, 909 insertions(+), 916 deletions(-)
build.zig+1-1| ... | ... | @@ -855,7 +855,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void { |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | const CMakeConfig = struct { |
| 858 | llvm_linkage: std.Build.Step.Compile.Linkage, | |
| 858 | llvm_linkage: std.builtin.LinkMode, | |
| 859 | 859 | cmake_binary_dir: []const u8, |
| 860 | 860 | cmake_prefix_path: []const u8, |
| 861 | 861 | cmake_static_library_prefix: []const u8, |
doc/langref.html.in+2-2| ... | ... | @@ -1453,7 +1453,7 @@ export fn foo_strict(x: f64) f64 { |
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | export fn foo_optimized(x: f64) f64 { |
| 1456 | @setFloatMode(.Optimized); | |
| 1456 | @setFloatMode(.optimized); | |
| 1457 | 1457 | return x + big - big; |
| 1458 | 1458 | } |
| 1459 | 1459 | {#code_end#} |
| ... | ... | @@ -8356,7 +8356,7 @@ test "main" { |
| 8356 | 8356 | </p> |
| 8357 | 8357 | {#code_begin|obj|export_builtin#} |
| 8358 | 8358 | comptime { |
| 8359 | @export(internalName, .{ .name = "foo", .linkage = .Strong }); | |
| 8359 | @export(internalName, .{ .name = "foo", .linkage = .strong }); | |
| 8360 | 8360 | } |
| 8361 | 8361 | |
| 8362 | 8362 | fn internalName() callconv(.C) void {} |
lib/build_runner.zig+6-6| ... | ... | @@ -892,10 +892,10 @@ fn workerMakeOneStep( |
| 892 | 892 | // then we return without doing the step, relying on another worker to |
| 893 | 893 | // queue this step up again when dependencies are met. |
| 894 | 894 | for (s.dependencies.items) |dep| { |
| 895 | switch (@atomicLoad(Step.State, &dep.state, .SeqCst)) { | |
| 895 | switch (@atomicLoad(Step.State, &dep.state, .seq_cst)) { | |
| 896 | 896 | .success, .skipped => continue, |
| 897 | 897 | .failure, .dependency_failure, .skipped_oom => { |
| 898 | @atomicStore(Step.State, &s.state, .dependency_failure, .SeqCst); | |
| 898 | @atomicStore(Step.State, &s.state, .dependency_failure, .seq_cst); | |
| 899 | 899 | return; |
| 900 | 900 | }, |
| 901 | 901 | .precheck_done, .running => { |
| ... | ... | @@ -929,7 +929,7 @@ fn workerMakeOneStep( |
| 929 | 929 | s.state = .running; |
| 930 | 930 | } else { |
| 931 | 931 | // Avoid running steps twice. |
| 932 | if (@cmpxchgStrong(Step.State, &s.state, .precheck_done, .running, .SeqCst, .SeqCst) != null) { | |
| 932 | if (@cmpxchgStrong(Step.State, &s.state, .precheck_done, .running, .seq_cst, .seq_cst) != null) { | |
| 933 | 933 | // Another worker got the job. |
| 934 | 934 | return; |
| 935 | 935 | } |
| ... | ... | @@ -956,13 +956,13 @@ fn workerMakeOneStep( |
| 956 | 956 | |
| 957 | 957 | handle_result: { |
| 958 | 958 | if (make_result) |_| { |
| 959 | @atomicStore(Step.State, &s.state, .success, .SeqCst); | |
| 959 | @atomicStore(Step.State, &s.state, .success, .seq_cst); | |
| 960 | 960 | } else |err| switch (err) { |
| 961 | 961 | error.MakeFailed => { |
| 962 | @atomicStore(Step.State, &s.state, .failure, .SeqCst); | |
| 962 | @atomicStore(Step.State, &s.state, .failure, .seq_cst); | |
| 963 | 963 | break :handle_result; |
| 964 | 964 | }, |
| 965 | error.MakeSkipped => @atomicStore(Step.State, &s.state, .skipped, .SeqCst), | |
| 965 | error.MakeSkipped => @atomicStore(Step.State, &s.state, .skipped, .seq_cst), | |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | // Successful completion of a step, so we queue up its dependants as well. |
lib/c.zig+10-10| ... | ... | @@ -26,7 +26,7 @@ const is_freestanding = switch (native_os) { |
| 26 | 26 | |
| 27 | 27 | comptime { |
| 28 | 28 | if (is_freestanding and is_wasm and builtin.link_libc) { |
| 29 | @export(wasm_start, .{ .name = "_start", .linkage = .Strong }); | |
| 29 | @export(wasm_start, .{ .name = "_start", .linkage = .strong }); | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if (native_os == .linux) { |
| ... | ... | @@ -34,16 +34,16 @@ comptime { |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | if (builtin.link_libc) { |
| 37 | @export(strcmp, .{ .name = "strcmp", .linkage = .Strong }); | |
| 38 | @export(strncmp, .{ .name = "strncmp", .linkage = .Strong }); | |
| 39 | @export(strerror, .{ .name = "strerror", .linkage = .Strong }); | |
| 40 | @export(strlen, .{ .name = "strlen", .linkage = .Strong }); | |
| 41 | @export(strcpy, .{ .name = "strcpy", .linkage = .Strong }); | |
| 42 | @export(strncpy, .{ .name = "strncpy", .linkage = .Strong }); | |
| 43 | @export(strcat, .{ .name = "strcat", .linkage = .Strong }); | |
| 44 | @export(strncat, .{ .name = "strncat", .linkage = .Strong }); | |
| 37 | @export(strcmp, .{ .name = "strcmp", .linkage = .strong }); | |
| 38 | @export(strncmp, .{ .name = "strncmp", .linkage = .strong }); | |
| 39 | @export(strerror, .{ .name = "strerror", .linkage = .strong }); | |
| 40 | @export(strlen, .{ .name = "strlen", .linkage = .strong }); | |
| 41 | @export(strcpy, .{ .name = "strcpy", .linkage = .strong }); | |
| 42 | @export(strncpy, .{ .name = "strncpy", .linkage = .strong }); | |
| 43 | @export(strcat, .{ .name = "strcat", .linkage = .strong }); | |
| 44 | @export(strncat, .{ .name = "strncat", .linkage = .strong }); | |
| 45 | 45 | } else if (is_msvc) { |
| 46 | @export(_fltused, .{ .name = "_fltused", .linkage = .Strong }); | |
| 46 | @export(_fltused, .{ .name = "_fltused", .linkage = .strong }); | |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 |
lib/compiler/aro/aro/Attribute.zig+1-1| ... | ... | @@ -653,7 +653,7 @@ pub const Arguments = blk: { |
| 653 | 653 | |
| 654 | 654 | break :blk @Type(.{ |
| 655 | 655 | .Union = .{ |
| 656 | .layout = .Auto, | |
| 656 | .layout = .auto, | |
| 657 | 657 | .tag_type = null, |
| 658 | 658 | .fields = &union_fields, |
| 659 | 659 | .decls = &.{}, |
lib/compiler_rt/atomics.zig+9-9| ... | ... | @@ -74,7 +74,7 @@ const SpinlockTable = struct { |
| 74 | 74 | : "memory" |
| 75 | 75 | ); |
| 76 | 76 | } else flag: { |
| 77 | break :flag @atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .Acquire); | |
| 77 | break :flag @atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .acquire); | |
| 78 | 78 | }; |
| 79 | 79 | |
| 80 | 80 | switch (flag) { |
| ... | ... | @@ -91,7 +91,7 @@ const SpinlockTable = struct { |
| 91 | 91 | : "memory" |
| 92 | 92 | ); |
| 93 | 93 | } else { |
| 94 | @atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .Release); | |
| 94 | @atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .release); | |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | }; |
| ... | ... | @@ -172,7 +172,7 @@ inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T { |
| 172 | 172 | defer sl.release(); |
| 173 | 173 | return src.*; |
| 174 | 174 | } else { |
| 175 | return @atomicLoad(T, src, .SeqCst); | |
| 175 | return @atomicLoad(T, src, .seq_cst); | |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| ... | ... | @@ -203,7 +203,7 @@ inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void { |
| 203 | 203 | defer sl.release(); |
| 204 | 204 | dst.* = value; |
| 205 | 205 | } else { |
| 206 | @atomicStore(T, dst, value, .SeqCst); | |
| 206 | @atomicStore(T, dst, value, .seq_cst); | |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
| ... | ... | @@ -239,12 +239,12 @@ fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T { |
| 239 | 239 | |
| 240 | 240 | const mask = @as(WideAtomic, std.math.maxInt(T)) << inner_shift; |
| 241 | 241 | |
| 242 | var wide_old = @atomicLoad(WideAtomic, wide_ptr, .SeqCst); | |
| 242 | var wide_old = @atomicLoad(WideAtomic, wide_ptr, .seq_cst); | |
| 243 | 243 | while (true) { |
| 244 | 244 | const old = @as(T, @truncate((wide_old & mask) >> inner_shift)); |
| 245 | 245 | const new = update(val, old); |
| 246 | 246 | const wide_new = wide_old & ~mask | (@as(WideAtomic, new) << inner_shift); |
| 247 | if (@cmpxchgWeak(WideAtomic, wide_ptr, wide_old, wide_new, .SeqCst, .SeqCst)) |new_wide_old| { | |
| 247 | if (@cmpxchgWeak(WideAtomic, wide_ptr, wide_old, wide_new, .seq_cst, .seq_cst)) |new_wide_old| { | |
| 248 | 248 | wide_old = new_wide_old; |
| 249 | 249 | } else { |
| 250 | 250 | return old; |
| ... | ... | @@ -270,7 +270,7 @@ inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T { |
| 270 | 270 | }; |
| 271 | 271 | return wideUpdate(T, ptr, val, Updater.update); |
| 272 | 272 | } else { |
| 273 | return @atomicRmw(T, ptr, .Xchg, val, .SeqCst); | |
| 273 | return @atomicRmw(T, ptr, .Xchg, val, .seq_cst); | |
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
| ... | ... | @@ -315,7 +315,7 @@ inline fn atomic_compare_exchange_N( |
| 315 | 315 | expected.* = value; |
| 316 | 316 | return 0; |
| 317 | 317 | } else { |
| 318 | if (@cmpxchgStrong(T, ptr, expected.*, desired, .SeqCst, .SeqCst)) |old_value| { | |
| 318 | if (@cmpxchgStrong(T, ptr, expected.*, desired, .seq_cst, .seq_cst)) |old_value| { | |
| 319 | 319 | expected.* = old_value; |
| 320 | 320 | return 0; |
| 321 | 321 | } |
| ... | ... | @@ -373,7 +373,7 @@ inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr |
| 373 | 373 | return wideUpdate(T, ptr, val, Updater.update); |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | return @atomicRmw(T, ptr, op, val, .SeqCst); | |
| 376 | return @atomicRmw(T, ptr, op, val, .seq_cst); | |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | fn __atomic_fetch_add_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 { |
lib/compiler_rt/clear_cache.zig+1-1| ... | ... | @@ -162,7 +162,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void { |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.Internal else std.builtin.GlobalLinkage.Weak; | |
| 165 | const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.internal else std.builtin.GlobalLinkage.weak; | |
| 166 | 166 | |
| 167 | 167 | fn exportIt() void { |
| 168 | 168 | @export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage }); |
lib/compiler_rt/common.zig+2-2| ... | ... | @@ -2,12 +2,12 @@ const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | const native_endian = builtin.cpu.arch.endian(); |
| 4 | 4 | |
| 5 | pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | |
| 5 | pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak; | |
| 6 | 6 | /// Determines the symbol's visibility to other objects. |
| 7 | 7 | /// For WebAssembly this allows the symbol to be resolved to other modules, but will not |
| 8 | 8 | /// export it to the host runtime. |
| 9 | 9 | pub const visibility: std.builtin.SymbolVisibility = |
| 10 | if (builtin.target.isWasm() and linkage != .Internal) .hidden else .default; | |
| 10 | if (builtin.target.isWasm() and linkage != .internal) .hidden else .default; | |
| 11 | 11 | pub const want_aeabi = switch (builtin.abi) { |
| 12 | 12 | .eabi, |
| 13 | 13 | .eabihf, |
lib/compiler_rt/os_version_check.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const testing = std.testing; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak; | |
| 5 | 5 | const panic = @import("common.zig").panic; |
| 6 | 6 | |
| 7 | 7 | const have_availability_version_check = builtin.os.tag.isDarwin() and |
lib/compiler_rt/stack_probe.zig+2-2| ... | ... | @@ -8,8 +8,8 @@ const is_test = builtin.is_test; |
| 8 | 8 | const is_gnu = abi.isGnu(); |
| 9 | 9 | const is_mingw = os_tag == .windows and is_gnu; |
| 10 | 10 | |
| 11 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | |
| 12 | const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong; | |
| 11 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .weak; | |
| 12 | const strong_linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .internal else .strong; | |
| 13 | 13 | pub const panic = @import("common.zig").panic; |
| 14 | 14 | |
| 15 | 15 | comptime { |
lib/std/Build.zig+1-1| ... | ... | @@ -645,7 +645,7 @@ pub const ExecutableOptions = struct { |
| 645 | 645 | version: ?std.SemanticVersion = null, |
| 646 | 646 | optimize: std.builtin.OptimizeMode = .Debug, |
| 647 | 647 | code_model: std.builtin.CodeModel = .default, |
| 648 | linkage: ?Step.Compile.Linkage = null, | |
| 648 | linkage: ?std.builtin.LinkMode = null, | |
| 649 | 649 | max_rss: usize = 0, |
| 650 | 650 | link_libc: ?bool = null, |
| 651 | 651 | single_threaded: ?bool = null, |
lib/std/Build/Module.zig+1-1| ... | ... | @@ -414,7 +414,7 @@ pub const LinkSystemLibraryOptions = struct { |
| 414 | 414 | needed: bool = false, |
| 415 | 415 | weak: bool = false, |
| 416 | 416 | use_pkg_config: SystemLib.UsePkgConfig = .yes, |
| 417 | preferred_link_mode: std.builtin.LinkMode = .Dynamic, | |
| 417 | preferred_link_mode: std.builtin.LinkMode = .dynamic, | |
| 418 | 418 | search_strategy: SystemLib.SearchStrategy = .paths_first, |
| 419 | 419 | }; |
| 420 | 420 |
lib/std/Build/Step/Compile.zig+13-18| ... | ... | @@ -28,7 +28,7 @@ linker_script: ?LazyPath = null, |
| 28 | 28 | version_script: ?LazyPath = null, |
| 29 | 29 | out_filename: []const u8, |
| 30 | 30 | out_lib_filename: []const u8, |
| 31 | linkage: ?Linkage = null, | |
| 31 | linkage: ?std.builtin.LinkMode = null, | |
| 32 | 32 | version: ?std.SemanticVersion, |
| 33 | 33 | kind: Kind, |
| 34 | 34 | major_only_filename: ?[]const u8, |
| ... | ... | @@ -223,7 +223,7 @@ pub const Options = struct { |
| 223 | 223 | name: []const u8, |
| 224 | 224 | root_module: Module.CreateOptions, |
| 225 | 225 | kind: Kind, |
| 226 | linkage: ?Linkage = null, | |
| 226 | linkage: ?std.builtin.LinkMode = null, | |
| 227 | 227 | version: ?std.SemanticVersion = null, |
| 228 | 228 | max_rss: usize = 0, |
| 229 | 229 | filters: []const []const u8 = &.{}, |
| ... | ... | @@ -246,8 +246,6 @@ pub const Kind = enum { |
| 246 | 246 | @"test", |
| 247 | 247 | }; |
| 248 | 248 | |
| 249 | pub const Linkage = enum { dynamic, static }; | |
| 250 | ||
| 251 | 249 | pub fn create(owner: *std.Build, options: Options) *Compile { |
| 252 | 250 | const name = owner.dupe(options.name); |
| 253 | 251 | if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) { |
| ... | ... | @@ -283,10 +281,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile { |
| 283 | 281 | .obj => .Obj, |
| 284 | 282 | .exe, .@"test" => .Exe, |
| 285 | 283 | }, |
| 286 | .link_mode = if (options.linkage) |some| @as(std.builtin.LinkMode, switch (some) { | |
| 287 | .dynamic => .Dynamic, | |
| 288 | .static => .Static, | |
| 289 | }) else null, | |
| 284 | .link_mode = options.linkage, | |
| 290 | 285 | .version = options.version, |
| 291 | 286 | }) catch @panic("OOM"); |
| 292 | 287 | |
| ... | ... | @@ -531,11 +526,11 @@ pub fn dependsOnSystemLibrary(self: *const Compile, name: []const u8) bool { |
| 531 | 526 | } |
| 532 | 527 | |
| 533 | 528 | pub fn isDynamicLibrary(self: *const Compile) bool { |
| 534 | return self.kind == .lib and self.linkage == Linkage.dynamic; | |
| 529 | return self.kind == .lib and self.linkage == .dynamic; | |
| 535 | 530 | } |
| 536 | 531 | |
| 537 | 532 | pub fn isStaticLibrary(self: *const Compile) bool { |
| 538 | return self.kind == .lib and self.linkage != Linkage.dynamic; | |
| 533 | return self.kind == .lib and self.linkage != .dynamic; | |
| 539 | 534 | } |
| 540 | 535 | |
| 541 | 536 | pub fn producesPdbFile(self: *Compile) bool { |
| ... | ... | @@ -988,7 +983,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 988 | 983 | var prev_has_cflags = false; |
| 989 | 984 | var prev_has_rcflags = false; |
| 990 | 985 | var prev_search_strategy: Module.SystemLib.SearchStrategy = .paths_first; |
| 991 | var prev_preferred_link_mode: std.builtin.LinkMode = .Dynamic; | |
| 986 | var prev_preferred_link_mode: std.builtin.LinkMode = .dynamic; | |
| 992 | 987 | // Track the number of positional arguments so that a nice error can be |
| 993 | 988 | // emitted if there is nothing to link. |
| 994 | 989 | var total_linker_objects: usize = @intFromBool(self.root_module.root_source_file != null); |
| ... | ... | @@ -1053,16 +1048,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1053 | 1048 | { |
| 1054 | 1049 | switch (system_lib.search_strategy) { |
| 1055 | 1050 | .no_fallback => switch (system_lib.preferred_link_mode) { |
| 1056 | .Dynamic => try zig_args.append("-search_dylibs_only"), | |
| 1057 | .Static => try zig_args.append("-search_static_only"), | |
| 1051 | .dynamic => try zig_args.append("-search_dylibs_only"), | |
| 1052 | .static => try zig_args.append("-search_static_only"), | |
| 1058 | 1053 | }, |
| 1059 | 1054 | .paths_first => switch (system_lib.preferred_link_mode) { |
| 1060 | .Dynamic => try zig_args.append("-search_paths_first"), | |
| 1061 | .Static => try zig_args.append("-search_paths_first_static"), | |
| 1055 | .dynamic => try zig_args.append("-search_paths_first"), | |
| 1056 | .static => try zig_args.append("-search_paths_first_static"), | |
| 1062 | 1057 | }, |
| 1063 | 1058 | .mode_first => switch (system_lib.preferred_link_mode) { |
| 1064 | .Dynamic => try zig_args.append("-search_dylibs_first"), | |
| 1065 | .Static => try zig_args.append("-search_static_first"), | |
| 1059 | .dynamic => try zig_args.append("-search_dylibs_first"), | |
| 1060 | .static => try zig_args.append("-search_static_first"), | |
| 1066 | 1061 | }, |
| 1067 | 1062 | } |
| 1068 | 1063 | prev_search_strategy = system_lib.search_strategy; |
| ... | ... | @@ -1138,7 +1133,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1138 | 1133 | try zig_args.append(full_path_lib); |
| 1139 | 1134 | total_linker_objects += 1; |
| 1140 | 1135 | |
| 1141 | if (other.linkage == Linkage.dynamic and | |
| 1136 | if (other.linkage == .dynamic and | |
| 1142 | 1137 | self.rootModuleTarget().os.tag != .windows) |
| 1143 | 1138 | { |
| 1144 | 1139 | if (fs.path.dirname(full_path_lib)) |dirname| { |
lib/std/Build/Step/TranslateC.zig+1-1| ... | ... | @@ -55,7 +55,7 @@ pub const AddExecutableOptions = struct { |
| 55 | 55 | version: ?std.SemanticVersion = null, |
| 56 | 56 | target: ?std.Build.ResolvedTarget = null, |
| 57 | 57 | optimize: ?std.builtin.OptimizeMode = null, |
| 58 | linkage: ?Step.Compile.Linkage = null, | |
| 58 | linkage: ?std.builtin.LinkMode = null, | |
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | 61 | pub fn getOutput(self: *TranslateC) std.Build.LazyPath { |
lib/std/Progress.zig+13-13| ... | ... | @@ -95,9 +95,9 @@ pub const Node = struct { |
| 95 | 95 | /// This is the same as calling `start` and then `end` on the returned `Node`. Thread-safe. |
| 96 | 96 | pub fn completeOne(self: *Node) void { |
| 97 | 97 | if (self.parent) |parent| { |
| 98 | @atomicStore(?*Node, &parent.recently_updated_child, self, .Release); | |
| 98 | @atomicStore(?*Node, &parent.recently_updated_child, self, .release); | |
| 99 | 99 | } |
| 100 | _ = @atomicRmw(usize, &self.unprotected_completed_items, .Add, 1, .Monotonic); | |
| 100 | _ = @atomicRmw(usize, &self.unprotected_completed_items, .Add, 1, .monotonic); | |
| 101 | 101 | self.context.maybeRefresh(); |
| 102 | 102 | } |
| 103 | 103 | |
| ... | ... | @@ -108,7 +108,7 @@ pub const Node = struct { |
| 108 | 108 | { |
| 109 | 109 | self.context.update_mutex.lock(); |
| 110 | 110 | defer self.context.update_mutex.unlock(); |
| 111 | _ = @cmpxchgStrong(?*Node, &parent.recently_updated_child, self, null, .Monotonic, .Monotonic); | |
| 111 | _ = @cmpxchgStrong(?*Node, &parent.recently_updated_child, self, null, .monotonic, .monotonic); | |
| 112 | 112 | } |
| 113 | 113 | parent.completeOne(); |
| 114 | 114 | } else { |
| ... | ... | @@ -122,7 +122,7 @@ pub const Node = struct { |
| 122 | 122 | /// Tell the parent node that this node is actively being worked on. Thread-safe. |
| 123 | 123 | pub fn activate(self: *Node) void { |
| 124 | 124 | if (self.parent) |parent| { |
| 125 | @atomicStore(?*Node, &parent.recently_updated_child, self, .Release); | |
| 125 | @atomicStore(?*Node, &parent.recently_updated_child, self, .release); | |
| 126 | 126 | self.context.maybeRefresh(); |
| 127 | 127 | } |
| 128 | 128 | } |
| ... | ... | @@ -134,9 +134,9 @@ pub const Node = struct { |
| 134 | 134 | defer progress.update_mutex.unlock(); |
| 135 | 135 | self.name = name; |
| 136 | 136 | if (self.parent) |parent| { |
| 137 | @atomicStore(?*Node, &parent.recently_updated_child, self, .Release); | |
| 137 | @atomicStore(?*Node, &parent.recently_updated_child, self, .release); | |
| 138 | 138 | if (parent.parent) |grand_parent| { |
| 139 | @atomicStore(?*Node, &grand_parent.recently_updated_child, parent, .Release); | |
| 139 | @atomicStore(?*Node, &grand_parent.recently_updated_child, parent, .release); | |
| 140 | 140 | } |
| 141 | 141 | if (progress.timer) |*timer| progress.maybeRefreshWithHeldLock(timer); |
| 142 | 142 | } |
| ... | ... | @@ -149,9 +149,9 @@ pub const Node = struct { |
| 149 | 149 | defer progress.update_mutex.unlock(); |
| 150 | 150 | self.unit = unit; |
| 151 | 151 | if (self.parent) |parent| { |
| 152 | @atomicStore(?*Node, &parent.recently_updated_child, self, .Release); | |
| 152 | @atomicStore(?*Node, &parent.recently_updated_child, self, .release); | |
| 153 | 153 | if (parent.parent) |grand_parent| { |
| 154 | @atomicStore(?*Node, &grand_parent.recently_updated_child, parent, .Release); | |
| 154 | @atomicStore(?*Node, &grand_parent.recently_updated_child, parent, .release); | |
| 155 | 155 | } |
| 156 | 156 | if (progress.timer) |*timer| progress.maybeRefreshWithHeldLock(timer); |
| 157 | 157 | } |
| ... | ... | @@ -159,12 +159,12 @@ pub const Node = struct { |
| 159 | 159 | |
| 160 | 160 | /// Thread-safe. 0 means unknown. |
| 161 | 161 | pub fn setEstimatedTotalItems(self: *Node, count: usize) void { |
| 162 | @atomicStore(usize, &self.unprotected_estimated_total_items, count, .Monotonic); | |
| 162 | @atomicStore(usize, &self.unprotected_estimated_total_items, count, .monotonic); | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /// Thread-safe. |
| 166 | 166 | pub fn setCompletedItems(self: *Node, completed_items: usize) void { |
| 167 | @atomicStore(usize, &self.unprotected_completed_items, completed_items, .Monotonic); | |
| 167 | @atomicStore(usize, &self.unprotected_completed_items, completed_items, .monotonic); | |
| 168 | 168 | } |
| 169 | 169 | }; |
| 170 | 170 | |
| ... | ... | @@ -313,8 +313,8 @@ fn refreshWithHeldLock(self: *Progress) void { |
| 313 | 313 | self.bufWrite(&end, "... ", .{}); |
| 314 | 314 | } |
| 315 | 315 | need_ellipse = false; |
| 316 | const eti = @atomicLoad(usize, &node.unprotected_estimated_total_items, .Monotonic); | |
| 317 | const completed_items = @atomicLoad(usize, &node.unprotected_completed_items, .Monotonic); | |
| 316 | const eti = @atomicLoad(usize, &node.unprotected_estimated_total_items, .monotonic); | |
| 317 | const completed_items = @atomicLoad(usize, &node.unprotected_completed_items, .monotonic); | |
| 318 | 318 | const current_item = completed_items + 1; |
| 319 | 319 | if (node.name.len != 0 or eti > 0) { |
| 320 | 320 | if (node.name.len != 0) { |
| ... | ... | @@ -331,7 +331,7 @@ fn refreshWithHeldLock(self: *Progress) void { |
| 331 | 331 | need_ellipse = false; |
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | maybe_node = @atomicLoad(?*Node, &node.recently_updated_child, .Acquire); | |
| 334 | maybe_node = @atomicLoad(?*Node, &node.recently_updated_child, .acquire); | |
| 335 | 335 | } |
| 336 | 336 | if (need_ellipse) { |
| 337 | 337 | self.bufWrite(&end, "... ", .{}); |
lib/std/Thread.zig+12-12| ... | ... | @@ -510,7 +510,7 @@ const WindowsThreadImpl = struct { |
| 510 | 510 | |
| 511 | 511 | fn entryFn(raw_ptr: windows.PVOID) callconv(.C) windows.DWORD { |
| 512 | 512 | const self: *@This() = @ptrCast(@alignCast(raw_ptr)); |
| 513 | defer switch (self.thread.completion.swap(.completed, .SeqCst)) { | |
| 513 | defer switch (self.thread.completion.swap(.completed, .seq_cst)) { | |
| 514 | 514 | .running => {}, |
| 515 | 515 | .completed => unreachable, |
| 516 | 516 | .detached => self.thread.free(), |
| ... | ... | @@ -563,7 +563,7 @@ const WindowsThreadImpl = struct { |
| 563 | 563 | |
| 564 | 564 | fn detach(self: Impl) void { |
| 565 | 565 | windows.CloseHandle(self.thread.thread_handle); |
| 566 | switch (self.thread.completion.swap(.detached, .SeqCst)) { | |
| 566 | switch (self.thread.completion.swap(.detached, .seq_cst)) { | |
| 567 | 567 | .running => {}, |
| 568 | 568 | .completed => self.thread.free(), |
| 569 | 569 | .detached => unreachable, |
| ... | ... | @@ -573,7 +573,7 @@ const WindowsThreadImpl = struct { |
| 573 | 573 | fn join(self: Impl) void { |
| 574 | 574 | windows.WaitForSingleObjectEx(self.thread.thread_handle, windows.INFINITE, false) catch unreachable; |
| 575 | 575 | windows.CloseHandle(self.thread.thread_handle); |
| 576 | assert(self.thread.completion.load(.SeqCst) == .completed); | |
| 576 | assert(self.thread.completion.load(.seq_cst) == .completed); | |
| 577 | 577 | self.thread.free(); |
| 578 | 578 | } |
| 579 | 579 | }; |
| ... | ... | @@ -780,11 +780,11 @@ const WasiThreadImpl = struct { |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | fn getHandle(self: Impl) ThreadHandle { |
| 783 | return self.thread.tid.load(.SeqCst); | |
| 783 | return self.thread.tid.load(.seq_cst); | |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | fn detach(self: Impl) void { |
| 787 | switch (self.thread.state.swap(.detached, .SeqCst)) { | |
| 787 | switch (self.thread.state.swap(.detached, .seq_cst)) { | |
| 788 | 788 | .running => {}, |
| 789 | 789 | .completed => self.join(), |
| 790 | 790 | .detached => unreachable, |
| ... | ... | @@ -801,7 +801,7 @@ const WasiThreadImpl = struct { |
| 801 | 801 | |
| 802 | 802 | var spin: u8 = 10; |
| 803 | 803 | while (true) { |
| 804 | const tid = self.thread.tid.load(.SeqCst); | |
| 804 | const tid = self.thread.tid.load(.seq_cst); | |
| 805 | 805 | if (tid == 0) { |
| 806 | 806 | break; |
| 807 | 807 | } |
| ... | ... | @@ -901,7 +901,7 @@ const WasiThreadImpl = struct { |
| 901 | 901 | if (tid < 0) { |
| 902 | 902 | return error.SystemResources; |
| 903 | 903 | } |
| 904 | instance.thread.tid.store(tid, .SeqCst); | |
| 904 | instance.thread.tid.store(tid, .seq_cst); | |
| 905 | 905 | |
| 906 | 906 | return .{ .thread = &instance.thread }; |
| 907 | 907 | } |
| ... | ... | @@ -914,12 +914,12 @@ const WasiThreadImpl = struct { |
| 914 | 914 | } |
| 915 | 915 | __set_stack_pointer(arg.thread.memory.ptr + arg.stack_offset); |
| 916 | 916 | __wasm_init_tls(arg.thread.memory.ptr + arg.tls_offset); |
| 917 | @atomicStore(u32, &WasiThreadImpl.tls_thread_id, @intCast(tid), .SeqCst); | |
| 917 | @atomicStore(u32, &WasiThreadImpl.tls_thread_id, @intCast(tid), .seq_cst); | |
| 918 | 918 | |
| 919 | 919 | // Finished bootstrapping, call user's procedure. |
| 920 | 920 | arg.call_back(arg.raw_ptr); |
| 921 | 921 | |
| 922 | switch (arg.thread.state.swap(.completed, .SeqCst)) { | |
| 922 | switch (arg.thread.state.swap(.completed, .seq_cst)) { | |
| 923 | 923 | .running => { |
| 924 | 924 | // reset the Thread ID |
| 925 | 925 | asm volatile ( |
| ... | ... | @@ -1191,7 +1191,7 @@ const LinuxThreadImpl = struct { |
| 1191 | 1191 | |
| 1192 | 1192 | fn entryFn(raw_arg: usize) callconv(.C) u8 { |
| 1193 | 1193 | const self = @as(*@This(), @ptrFromInt(raw_arg)); |
| 1194 | defer switch (self.thread.completion.swap(.completed, .SeqCst)) { | |
| 1194 | defer switch (self.thread.completion.swap(.completed, .seq_cst)) { | |
| 1195 | 1195 | .running => {}, |
| 1196 | 1196 | .completed => unreachable, |
| 1197 | 1197 | .detached => self.thread.freeAndExit(), |
| ... | ... | @@ -1311,7 +1311,7 @@ const LinuxThreadImpl = struct { |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | 1313 | fn detach(self: Impl) void { |
| 1314 | switch (self.thread.completion.swap(.detached, .SeqCst)) { | |
| 1314 | switch (self.thread.completion.swap(.detached, .seq_cst)) { | |
| 1315 | 1315 | .running => {}, |
| 1316 | 1316 | .completed => self.join(), |
| 1317 | 1317 | .detached => unreachable, |
| ... | ... | @@ -1323,7 +1323,7 @@ const LinuxThreadImpl = struct { |
| 1323 | 1323 | |
| 1324 | 1324 | var spin: u8 = 10; |
| 1325 | 1325 | while (true) { |
| 1326 | const tid = self.thread.child_tid.load(.SeqCst); | |
| 1326 | const tid = self.thread.child_tid.load(.seq_cst); | |
| 1327 | 1327 | if (tid == 0) { |
| 1328 | 1328 | break; |
| 1329 | 1329 | } |
lib/std/Thread/Condition.zig+12-12| ... | ... | @@ -163,7 +163,7 @@ const WindowsImpl = struct { |
| 163 | 163 | |
| 164 | 164 | if (comptime builtin.mode == .Debug) { |
| 165 | 165 | // The internal state of the DebugMutex needs to be handled here as well. |
| 166 | mutex.impl.locking_thread.store(0, .Unordered); | |
| 166 | mutex.impl.locking_thread.store(0, .unordered); | |
| 167 | 167 | } |
| 168 | 168 | const rc = os.windows.kernel32.SleepConditionVariableSRW( |
| 169 | 169 | &self.condition, |
| ... | ... | @@ -173,7 +173,7 @@ const WindowsImpl = struct { |
| 173 | 173 | ); |
| 174 | 174 | if (comptime builtin.mode == .Debug) { |
| 175 | 175 | // The internal state of the DebugMutex needs to be handled here as well. |
| 176 | mutex.impl.locking_thread.store(std.Thread.getCurrentId(), .Unordered); | |
| 176 | mutex.impl.locking_thread.store(std.Thread.getCurrentId(), .unordered); | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // Return error.Timeout if we know the timeout elapsed correctly. |
| ... | ... | @@ -212,8 +212,8 @@ const FutexImpl = struct { |
| 212 | 212 | // - T1: s & signals == 0 -> FUTEX_WAIT(&epoch, e) (missed the state update + the epoch change) |
| 213 | 213 | // |
| 214 | 214 | // Acquire barrier to ensure the epoch load happens before the state load. |
| 215 | var epoch = self.epoch.load(.Acquire); | |
| 216 | var state = self.state.fetchAdd(one_waiter, .Monotonic); | |
| 215 | var epoch = self.epoch.load(.acquire); | |
| 216 | var state = self.state.fetchAdd(one_waiter, .monotonic); | |
| 217 | 217 | assert(state & waiter_mask != waiter_mask); |
| 218 | 218 | state += one_waiter; |
| 219 | 219 | |
| ... | ... | @@ -231,30 +231,30 @@ const FutexImpl = struct { |
| 231 | 231 | // Acquire barrier ensures code before the wake() which added the signal happens before we decrement it and return. |
| 232 | 232 | while (state & signal_mask != 0) { |
| 233 | 233 | const new_state = state - one_waiter - one_signal; |
| 234 | state = self.state.cmpxchgWeak(state, new_state, .Acquire, .Monotonic) orelse return; | |
| 234 | state = self.state.cmpxchgWeak(state, new_state, .acquire, .monotonic) orelse return; | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // Remove the waiter we added and officially return timed out. |
| 238 | 238 | const new_state = state - one_waiter; |
| 239 | state = self.state.cmpxchgWeak(state, new_state, .Monotonic, .Monotonic) orelse return err; | |
| 239 | state = self.state.cmpxchgWeak(state, new_state, .monotonic, .monotonic) orelse return err; | |
| 240 | 240 | } |
| 241 | 241 | }, |
| 242 | 242 | }; |
| 243 | 243 | |
| 244 | epoch = self.epoch.load(.Acquire); | |
| 245 | state = self.state.load(.Monotonic); | |
| 244 | epoch = self.epoch.load(.acquire); | |
| 245 | state = self.state.load(.monotonic); | |
| 246 | 246 | |
| 247 | 247 | // Try to wake up by consuming a signal and decremented the waiter we added previously. |
| 248 | 248 | // Acquire barrier ensures code before the wake() which added the signal happens before we decrement it and return. |
| 249 | 249 | while (state & signal_mask != 0) { |
| 250 | 250 | const new_state = state - one_waiter - one_signal; |
| 251 | state = self.state.cmpxchgWeak(state, new_state, .Acquire, .Monotonic) orelse return; | |
| 251 | state = self.state.cmpxchgWeak(state, new_state, .acquire, .monotonic) orelse return; | |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | fn wake(self: *Impl, comptime notify: Notify) void { |
| 257 | var state = self.state.load(.Monotonic); | |
| 257 | var state = self.state.load(.monotonic); | |
| 258 | 258 | while (true) { |
| 259 | 259 | const waiters = (state & waiter_mask) / one_waiter; |
| 260 | 260 | const signals = (state & signal_mask) / one_signal; |
| ... | ... | @@ -275,7 +275,7 @@ const FutexImpl = struct { |
| 275 | 275 | // Reserve the amount of waiters to wake by incrementing the signals count. |
| 276 | 276 | // Release barrier ensures code before the wake() happens before the signal it posted and consumed by the wait() threads. |
| 277 | 277 | const new_state = state + (one_signal * to_wake); |
| 278 | state = self.state.cmpxchgWeak(state, new_state, .Release, .Monotonic) orelse { | |
| 278 | state = self.state.cmpxchgWeak(state, new_state, .release, .monotonic) orelse { | |
| 279 | 279 | // Wake up the waiting threads we reserved above by changing the epoch value. |
| 280 | 280 | // NOTE: a waiting thread could miss a wake up if *exactly* ((1<<32)-1) wake()s happen between it observing the epoch and sleeping on it. |
| 281 | 281 | // This is very unlikely due to how many precise amount of Futex.wake() calls that would be between the waiting thread's potential preemption. |
| ... | ... | @@ -288,7 +288,7 @@ const FutexImpl = struct { |
| 288 | 288 | // - T1: s = LOAD(&state) |
| 289 | 289 | // - T2: UPDATE(&state, signal) + FUTEX_WAKE(&epoch) |
| 290 | 290 | // - T1: s & signals == 0 -> FUTEX_WAIT(&epoch, e) (missed both epoch change and state change) |
| 291 | _ = self.epoch.fetchAdd(1, .Release); | |
| 291 | _ = self.epoch.fetchAdd(1, .release); | |
| 292 | 292 | Futex.wake(&self.epoch, to_wake); |
| 293 | 293 | return; |
| 294 | 294 | }; |
lib/std/Thread/Futex.zig+15-15| ... | ... | @@ -40,7 +40,7 @@ pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) er |
| 40 | 40 | |
| 41 | 41 | // Avoid calling into the OS for no-op timeouts. |
| 42 | 42 | if (timeout_ns == 0) { |
| 43 | if (ptr.load(.SeqCst) != expect) return; | |
| 43 | if (ptr.load(.seq_cst) != expect) return; | |
| 44 | 44 | return error.Timeout; |
| 45 | 45 | } |
| 46 | 46 | |
| ... | ... | @@ -783,16 +783,16 @@ const PosixImpl = struct { |
| 783 | 783 | // - T1: bumps pending waiters (was reordered after the ptr == expect check) |
| 784 | 784 | // - T1: goes to sleep and misses both the ptr change and T2's wake up |
| 785 | 785 | // |
| 786 | // SeqCst as Acquire barrier to ensure the announcement happens before the ptr check below. | |
| 787 | // SeqCst as shared modification order to form a happens-before edge with the fence(.SeqCst)+load() in wake(). | |
| 788 | var pending = bucket.pending.fetchAdd(1, .SeqCst); | |
| 786 | // seq_cst as Acquire barrier to ensure the announcement happens before the ptr check below. | |
| 787 | // seq_cst as shared modification order to form a happens-before edge with the fence(.seq_cst)+load() in wake(). | |
| 788 | var pending = bucket.pending.fetchAdd(1, .seq_cst); | |
| 789 | 789 | assert(pending < std.math.maxInt(usize)); |
| 790 | 790 | |
| 791 | 791 | // If the wait gets cancelled, remove the pending count we previously added. |
| 792 | 792 | // This is done outside the mutex lock to keep the critical section short in case of contention. |
| 793 | 793 | var cancelled = false; |
| 794 | 794 | defer if (cancelled) { |
| 795 | pending = bucket.pending.fetchSub(1, .Monotonic); | |
| 795 | pending = bucket.pending.fetchSub(1, .monotonic); | |
| 796 | 796 | assert(pending > 0); |
| 797 | 797 | }; |
| 798 | 798 | |
| ... | ... | @@ -850,11 +850,11 @@ const PosixImpl = struct { |
| 850 | 850 | // but the RMW operation unconditionally marks the cache-line as modified for others causing unnecessary fetching/contention. |
| 851 | 851 | // |
| 852 | 852 | // Instead we opt to do a full-fence + load instead which avoids taking ownership of the cache-line. |
| 853 | // fence(SeqCst) effectively converts the ptr update to SeqCst and the pending load to SeqCst: creating a Store-Load barrier. | |
| 853 | // fence(seq_cst) effectively converts the ptr update to seq_cst and the pending load to seq_cst: creating a Store-Load barrier. | |
| 854 | 854 | // |
| 855 | // The pending count increment in wait() must also now use SeqCst for the update + this pending load | |
| 856 | // to be in the same modification order as our load isn't using Release/Acquire to guarantee it. | |
| 857 | bucket.pending.fence(.SeqCst); | |
| 855 | // The pending count increment in wait() must also now use seq_cst for the update + this pending load | |
| 856 | // to be in the same modification order as our load isn't using release/acquire to guarantee it. | |
| 857 | bucket.pending.fence(.seq_cst); | |
| 858 | 858 | if (bucket.pending.load(.Monotonic) == 0) { |
| 859 | 859 | return; |
| 860 | 860 | } |
| ... | ... | @@ -912,7 +912,7 @@ test "signaling" { |
| 912 | 912 | current: u32 = 0, |
| 913 | 913 | |
| 914 | 914 | fn hit(self: *@This()) void { |
| 915 | _ = self.value.fetchAdd(1, .Release); | |
| 915 | _ = self.value.fetchAdd(1, .release); | |
| 916 | 916 | Futex.wake(&self.value, 1); |
| 917 | 917 | } |
| 918 | 918 | |
| ... | ... | @@ -921,7 +921,7 @@ test "signaling" { |
| 921 | 921 | // Wait for the value to change from hit() |
| 922 | 922 | var new_value: u32 = undefined; |
| 923 | 923 | while (true) { |
| 924 | new_value = self.value.load(.Acquire); | |
| 924 | new_value = self.value.load(.acquire); | |
| 925 | 925 | if (new_value != self.current) break; |
| 926 | 926 | Futex.wait(&self.value, self.current); |
| 927 | 927 | } |
| ... | ... | @@ -968,7 +968,7 @@ test "broadcasting" { |
| 968 | 968 | fn wait(self: *@This()) !void { |
| 969 | 969 | // Decrement the counter. |
| 970 | 970 | // Release ensures stuff before this barrier.wait() happens before the last one. |
| 971 | const count = self.count.fetchSub(1, .Release); | |
| 971 | const count = self.count.fetchSub(1, .release); | |
| 972 | 972 | try testing.expect(count <= num_threads); |
| 973 | 973 | try testing.expect(count > 0); |
| 974 | 974 | |
| ... | ... | @@ -976,15 +976,15 @@ test "broadcasting" { |
| 976 | 976 | // Acquire for the last counter ensures stuff before previous barrier.wait()s happened before it. |
| 977 | 977 | // Release on futex update ensures stuff before all barrier.wait()'s happens before they all return. |
| 978 | 978 | if (count - 1 == 0) { |
| 979 | _ = self.count.load(.Acquire); // TODO: could be fence(Acquire) if not for TSAN | |
| 980 | self.futex.store(1, .Release); | |
| 979 | _ = self.count.load(.acquire); // TODO: could be fence(acquire) if not for TSAN | |
| 980 | self.futex.store(1, .release); | |
| 981 | 981 | Futex.wake(&self.futex, num_threads - 1); |
| 982 | 982 | return; |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | // Other threads wait until last counter wakes them up. |
| 986 | 986 | // Acquire on futex synchronizes with last barrier count to ensure stuff before all barrier.wait()'s happen before us. |
| 987 | while (self.futex.load(.Acquire) == 0) { | |
| 987 | while (self.futex.load(.acquire) == 0) { | |
| 988 | 988 | Futex.wait(&self.futex, 0); |
| 989 | 989 | } |
| 990 | 990 | } |
lib/std/Thread/Mutex.zig+10-10| ... | ... | @@ -72,23 +72,23 @@ const DebugImpl = struct { |
| 72 | 72 | inline fn tryLock(self: *@This()) bool { |
| 73 | 73 | const locking = self.impl.tryLock(); |
| 74 | 74 | if (locking) { |
| 75 | self.locking_thread.store(Thread.getCurrentId(), .Unordered); | |
| 75 | self.locking_thread.store(Thread.getCurrentId(), .unordered); | |
| 76 | 76 | } |
| 77 | 77 | return locking; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | inline fn lock(self: *@This()) void { |
| 81 | 81 | const current_id = Thread.getCurrentId(); |
| 82 | if (self.locking_thread.load(.Unordered) == current_id and current_id != 0) { | |
| 82 | if (self.locking_thread.load(.unordered) == current_id and current_id != 0) { | |
| 83 | 83 | @panic("Deadlock detected"); |
| 84 | 84 | } |
| 85 | 85 | self.impl.lock(); |
| 86 | self.locking_thread.store(current_id, .Unordered); | |
| 86 | self.locking_thread.store(current_id, .unordered); | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | inline fn unlock(self: *@This()) void { |
| 90 | assert(self.locking_thread.load(.Unordered) == Thread.getCurrentId()); | |
| 91 | self.locking_thread.store(0, .Unordered); | |
| 90 | assert(self.locking_thread.load(.unordered) == Thread.getCurrentId()); | |
| 91 | self.locking_thread.store(0, .unordered); | |
| 92 | 92 | self.impl.unlock(); |
| 93 | 93 | } |
| 94 | 94 | }; |
| ... | ... | @@ -167,12 +167,12 @@ const FutexImpl = struct { |
| 167 | 167 | // - `lock bts` is smaller instruction-wise which makes it better for inlining |
| 168 | 168 | if (comptime builtin.target.cpu.arch.isX86()) { |
| 169 | 169 | const locked_bit = @ctz(locked); |
| 170 | return self.state.bitSet(locked_bit, .Acquire) == 0; | |
| 170 | return self.state.bitSet(locked_bit, .acquire) == 0; | |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Acquire barrier ensures grabbing the lock happens before the critical section |
| 174 | 174 | // and that the previous lock holder's critical section happens before we grab the lock. |
| 175 | return self.state.cmpxchgWeak(unlocked, locked, .Acquire, .Monotonic) == null; | |
| 175 | return self.state.cmpxchgWeak(unlocked, locked, .acquire, .monotonic) == null; | |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | fn lockSlow(self: *@This()) void { |
| ... | ... | @@ -180,7 +180,7 @@ const FutexImpl = struct { |
| 180 | 180 | |
| 181 | 181 | // Avoid doing an atomic swap below if we already know the state is contended. |
| 182 | 182 | // An atomic swap unconditionally stores which marks the cache-line as modified unnecessarily. |
| 183 | if (self.state.load(.Monotonic) == contended) { | |
| 183 | if (self.state.load(.monotonic) == contended) { | |
| 184 | 184 | Futex.wait(&self.state, contended); |
| 185 | 185 | } |
| 186 | 186 | |
| ... | ... | @@ -193,7 +193,7 @@ const FutexImpl = struct { |
| 193 | 193 | // |
| 194 | 194 | // Acquire barrier ensures grabbing the lock happens before the critical section |
| 195 | 195 | // and that the previous lock holder's critical section happens before we grab the lock. |
| 196 | while (self.state.swap(contended, .Acquire) != unlocked) { | |
| 196 | while (self.state.swap(contended, .acquire) != unlocked) { | |
| 197 | 197 | Futex.wait(&self.state, contended); |
| 198 | 198 | } |
| 199 | 199 | } |
| ... | ... | @@ -206,7 +206,7 @@ const FutexImpl = struct { |
| 206 | 206 | // |
| 207 | 207 | // Release barrier ensures the critical section happens before we let go of the lock |
| 208 | 208 | // and that our critical section happens before the next lock holder grabs the lock. |
| 209 | const state = self.state.swap(unlocked, .Release); | |
| 209 | const state = self.state.swap(unlocked, .release); | |
| 210 | 210 | assert(state != unlocked); |
| 211 | 211 | |
| 212 | 212 | if (state == contended) { |
lib/std/Thread/ResetEvent.zig+9-9| ... | ... | @@ -96,7 +96,7 @@ const FutexImpl = struct { |
| 96 | 96 | |
| 97 | 97 | fn isSet(self: *const Impl) bool { |
| 98 | 98 | // Acquire barrier ensures memory accesses before set() happen before we return true. |
| 99 | return self.state.load(.Acquire) == is_set; | |
| 99 | return self.state.load(.acquire) == is_set; | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | fn wait(self: *Impl, timeout: ?u64) error{Timeout}!void { |
| ... | ... | @@ -112,9 +112,9 @@ const FutexImpl = struct { |
| 112 | 112 | // Try to set the state from `unset` to `waiting` to indicate |
| 113 | 113 | // to the set() thread that others are blocked on the ResetEvent. |
| 114 | 114 | // We avoid using any strict barriers until the end when we know the ResetEvent is set. |
| 115 | var state = self.state.load(.Monotonic); | |
| 115 | var state = self.state.load(.monotonic); | |
| 116 | 116 | if (state == unset) { |
| 117 | state = self.state.cmpxchgStrong(state, waiting, .Monotonic, .Monotonic) orelse waiting; | |
| 117 | state = self.state.cmpxchgStrong(state, waiting, .monotonic, .monotonic) orelse waiting; | |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Wait until the ResetEvent is set since the state is waiting. |
| ... | ... | @@ -124,7 +124,7 @@ const FutexImpl = struct { |
| 124 | 124 | const wait_result = futex_deadline.wait(&self.state, waiting); |
| 125 | 125 | |
| 126 | 126 | // Check if the ResetEvent was set before possibly reporting error.Timeout below. |
| 127 | state = self.state.load(.Monotonic); | |
| 127 | state = self.state.load(.monotonic); | |
| 128 | 128 | if (state != waiting) { |
| 129 | 129 | break; |
| 130 | 130 | } |
| ... | ... | @@ -135,25 +135,25 @@ const FutexImpl = struct { |
| 135 | 135 | |
| 136 | 136 | // Acquire barrier ensures memory accesses before set() happen before we return. |
| 137 | 137 | assert(state == is_set); |
| 138 | self.state.fence(.Acquire); | |
| 138 | self.state.fence(.acquire); | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | fn set(self: *Impl) void { |
| 142 | 142 | // Quick check if the ResetEvent is already set before doing the atomic swap below. |
| 143 | 143 | // set() could be getting called quite often and multiple threads calling swap() increases contention unnecessarily. |
| 144 | if (self.state.load(.Monotonic) == is_set) { | |
| 144 | if (self.state.load(.monotonic) == is_set) { | |
| 145 | 145 | return; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Mark the ResetEvent as set and unblock all waiters waiting on it if any. |
| 149 | 149 | // Release barrier ensures memory accesses before set() happen before the ResetEvent is observed to be "set". |
| 150 | if (self.state.swap(is_set, .Release) == waiting) { | |
| 150 | if (self.state.swap(is_set, .release) == waiting) { | |
| 151 | 151 | Futex.wake(&self.state, std.math.maxInt(u32)); |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | fn reset(self: *Impl) void { |
| 156 | self.state.store(unset, .Monotonic); | |
| 156 | self.state.store(unset, .monotonic); | |
| 157 | 157 | } |
| 158 | 158 | }; |
| 159 | 159 | |
| ... | ... | @@ -254,7 +254,7 @@ test "broadcast" { |
| 254 | 254 | counter: std.atomic.Value(usize) = std.atomic.Value(usize).init(num_threads), |
| 255 | 255 | |
| 256 | 256 | fn wait(self: *@This()) void { |
| 257 | if (self.counter.fetchSub(1, .AcqRel) == 1) { | |
| 257 | if (self.counter.fetchSub(1, .acq_rel) == 1) { | |
| 258 | 258 | self.event.set(); |
| 259 | 259 | } |
| 260 | 260 | } |
lib/std/Thread/RwLock.zig+16-16| ... | ... | @@ -179,9 +179,9 @@ pub const DefaultRwLock = struct { |
| 179 | 179 | |
| 180 | 180 | pub fn tryLock(rwl: *DefaultRwLock) bool { |
| 181 | 181 | if (rwl.mutex.tryLock()) { |
| 182 | const state = @atomicLoad(usize, &rwl.state, .SeqCst); | |
| 182 | const state = @atomicLoad(usize, &rwl.state, .seq_cst); | |
| 183 | 183 | if (state & READER_MASK == 0) { |
| 184 | _ = @atomicRmw(usize, &rwl.state, .Or, IS_WRITING, .SeqCst); | |
| 184 | _ = @atomicRmw(usize, &rwl.state, .Or, IS_WRITING, .seq_cst); | |
| 185 | 185 | return true; |
| 186 | 186 | } |
| 187 | 187 | |
| ... | ... | @@ -192,34 +192,34 @@ pub const DefaultRwLock = struct { |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | pub fn lock(rwl: *DefaultRwLock) void { |
| 195 | _ = @atomicRmw(usize, &rwl.state, .Add, WRITER, .SeqCst); | |
| 195 | _ = @atomicRmw(usize, &rwl.state, .Add, WRITER, .seq_cst); | |
| 196 | 196 | rwl.mutex.lock(); |
| 197 | 197 | |
| 198 | const state = @atomicRmw(usize, &rwl.state, .Add, IS_WRITING -% WRITER, .SeqCst); | |
| 198 | const state = @atomicRmw(usize, &rwl.state, .Add, IS_WRITING -% WRITER, .seq_cst); | |
| 199 | 199 | if (state & READER_MASK != 0) |
| 200 | 200 | rwl.semaphore.wait(); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | pub fn unlock(rwl: *DefaultRwLock) void { |
| 204 | _ = @atomicRmw(usize, &rwl.state, .And, ~IS_WRITING, .SeqCst); | |
| 204 | _ = @atomicRmw(usize, &rwl.state, .And, ~IS_WRITING, .seq_cst); | |
| 205 | 205 | rwl.mutex.unlock(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | pub fn tryLockShared(rwl: *DefaultRwLock) bool { |
| 209 | const state = @atomicLoad(usize, &rwl.state, .SeqCst); | |
| 209 | const state = @atomicLoad(usize, &rwl.state, .seq_cst); | |
| 210 | 210 | if (state & (IS_WRITING | WRITER_MASK) == 0) { |
| 211 | 211 | _ = @cmpxchgStrong( |
| 212 | 212 | usize, |
| 213 | 213 | &rwl.state, |
| 214 | 214 | state, |
| 215 | 215 | state + READER, |
| 216 | .SeqCst, | |
| 217 | .SeqCst, | |
| 216 | .seq_cst, | |
| 217 | .seq_cst, | |
| 218 | 218 | ) orelse return true; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | if (rwl.mutex.tryLock()) { |
| 222 | _ = @atomicRmw(usize, &rwl.state, .Add, READER, .SeqCst); | |
| 222 | _ = @atomicRmw(usize, &rwl.state, .Add, READER, .seq_cst); | |
| 223 | 223 | rwl.mutex.unlock(); |
| 224 | 224 | return true; |
| 225 | 225 | } |
| ... | ... | @@ -228,25 +228,25 @@ pub const DefaultRwLock = struct { |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | pub fn lockShared(rwl: *DefaultRwLock) void { |
| 231 | var state = @atomicLoad(usize, &rwl.state, .SeqCst); | |
| 231 | var state = @atomicLoad(usize, &rwl.state, .seq_cst); | |
| 232 | 232 | while (state & (IS_WRITING | WRITER_MASK) == 0) { |
| 233 | 233 | state = @cmpxchgWeak( |
| 234 | 234 | usize, |
| 235 | 235 | &rwl.state, |
| 236 | 236 | state, |
| 237 | 237 | state + READER, |
| 238 | .SeqCst, | |
| 239 | .SeqCst, | |
| 238 | .seq_cst, | |
| 239 | .seq_cst, | |
| 240 | 240 | ) orelse return; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | rwl.mutex.lock(); |
| 244 | _ = @atomicRmw(usize, &rwl.state, .Add, READER, .SeqCst); | |
| 244 | _ = @atomicRmw(usize, &rwl.state, .Add, READER, .seq_cst); | |
| 245 | 245 | rwl.mutex.unlock(); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | pub fn unlockShared(rwl: *DefaultRwLock) void { |
| 249 | const state = @atomicRmw(usize, &rwl.state, .Sub, READER, .SeqCst); | |
| 249 | const state = @atomicRmw(usize, &rwl.state, .Sub, READER, .seq_cst); | |
| 250 | 250 | |
| 251 | 251 | if ((state & READER_MASK == READER) and (state & IS_WRITING != 0)) |
| 252 | 252 | rwl.semaphore.post(); |
| ... | ... | @@ -318,12 +318,12 @@ test "concurrent access" { |
| 318 | 318 | self.rwl.lockShared(); |
| 319 | 319 | defer self.rwl.unlockShared(); |
| 320 | 320 | |
| 321 | if (self.writes >= num_writes or self.reads.load(.Unordered) >= num_reads) | |
| 321 | if (self.writes >= num_writes or self.reads.load(.unordered) >= num_reads) | |
| 322 | 322 | break; |
| 323 | 323 | |
| 324 | 324 | try self.check(); |
| 325 | 325 | |
| 326 | _ = self.reads.fetchAdd(1, .Monotonic); | |
| 326 | _ = self.reads.fetchAdd(1, .monotonic); | |
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 |
lib/std/Thread/WaitGroup.zig+6-6| ... | ... | @@ -10,22 +10,22 @@ state: std.atomic.Value(usize) = std.atomic.Value(usize).init(0), |
| 10 | 10 | event: std.Thread.ResetEvent = .{}, |
| 11 | 11 | |
| 12 | 12 | pub fn start(self: *WaitGroup) void { |
| 13 | const state = self.state.fetchAdd(one_pending, .Monotonic); | |
| 13 | const state = self.state.fetchAdd(one_pending, .monotonic); | |
| 14 | 14 | assert((state / one_pending) < (std.math.maxInt(usize) / one_pending)); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | pub fn finish(self: *WaitGroup) void { |
| 18 | const state = self.state.fetchSub(one_pending, .Release); | |
| 18 | const state = self.state.fetchSub(one_pending, .release); | |
| 19 | 19 | assert((state / one_pending) > 0); |
| 20 | 20 | |
| 21 | 21 | if (state == (one_pending | is_waiting)) { |
| 22 | self.state.fence(.Acquire); | |
| 22 | self.state.fence(.acquire); | |
| 23 | 23 | self.event.set(); |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | pub fn wait(self: *WaitGroup) void { |
| 28 | const state = self.state.fetchAdd(is_waiting, .Acquire); | |
| 28 | const state = self.state.fetchAdd(is_waiting, .acquire); | |
| 29 | 29 | assert(state & is_waiting == 0); |
| 30 | 30 | |
| 31 | 31 | if ((state / one_pending) > 0) { |
| ... | ... | @@ -34,12 +34,12 @@ pub fn wait(self: *WaitGroup) void { |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | pub fn reset(self: *WaitGroup) void { |
| 37 | self.state.store(0, .Monotonic); | |
| 37 | self.state.store(0, .monotonic); | |
| 38 | 38 | self.event.reset(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | pub fn isDone(wg: *WaitGroup) bool { |
| 42 | const state = wg.state.load(.Acquire); | |
| 42 | const state = wg.state.load(.acquire); | |
| 43 | 43 | assert(state & is_waiting == 0); |
| 44 | 44 | |
| 45 | 45 | return (state / one_pending) == 0; |
lib/std/atomic.zig+82-82| ... | ... | @@ -23,10 +23,10 @@ pub fn Value(comptime T: type) type { |
| 23 | 23 | |
| 24 | 24 | const addr: *anyopaque = self; |
| 25 | 25 | return switch (order) { |
| 26 | .Unordered, .Monotonic => @compileError(@tagName(order) ++ " only applies to atomic loads and stores"), | |
| 27 | .Acquire => tsan.__tsan_acquire(addr), | |
| 28 | .Release => tsan.__tsan_release(addr), | |
| 29 | .AcqRel, .SeqCst => { | |
| 26 | .unordered, .monotonic => @compileError(@tagName(order) ++ " only applies to atomic loads and stores"), | |
| 27 | .acquire => tsan.__tsan_acquire(addr), | |
| 28 | .release => tsan.__tsan_release(addr), | |
| 29 | .acq_rel, .seq_cst => { | |
| 30 | 30 | tsan.__tsan_acquire(addr); |
| 31 | 31 | tsan.__tsan_release(addr); |
| 32 | 32 | }, |
| ... | ... | @@ -149,20 +149,20 @@ test Value { |
| 149 | 149 | |
| 150 | 150 | fn ref(rc: *RefCount) void { |
| 151 | 151 | // No ordering necessary; just updating a counter. |
| 152 | _ = rc.count.fetchAdd(1, .Monotonic); | |
| 152 | _ = rc.count.fetchAdd(1, .monotonic); | |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | fn unref(rc: *RefCount) void { |
| 156 | 156 | // Release ensures code before unref() happens-before the |
| 157 | 157 | // count is decremented as dropFn could be called by then. |
| 158 | if (rc.count.fetchSub(1, .Release) == 1) { | |
| 159 | // Acquire ensures count decrement and code before | |
| 158 | if (rc.count.fetchSub(1, .release) == 1) { | |
| 159 | // acquire ensures count decrement and code before | |
| 160 | 160 | // previous unrefs()s happens-before we call dropFn |
| 161 | 161 | // below. |
| 162 | 162 | // Another alternative is to use .AcqRel on the |
| 163 | 163 | // fetchSub count decrement but it's extra barrier in |
| 164 | 164 | // possibly hot path. |
| 165 | rc.count.fence(.Acquire); | |
| 165 | rc.count.fence(.acquire); | |
| 166 | 166 | (rc.dropFn)(rc); |
| 167 | 167 | } |
| 168 | 168 | } |
| ... | ... | @@ -182,118 +182,118 @@ test Value { |
| 182 | 182 | |
| 183 | 183 | test "Value.swap" { |
| 184 | 184 | var x = Value(usize).init(5); |
| 185 | try testing.expectEqual(@as(usize, 5), x.swap(10, .SeqCst)); | |
| 186 | try testing.expectEqual(@as(usize, 10), x.load(.SeqCst)); | |
| 185 | try testing.expectEqual(@as(usize, 5), x.swap(10, .seq_cst)); | |
| 186 | try testing.expectEqual(@as(usize, 10), x.load(.seq_cst)); | |
| 187 | 187 | |
| 188 | 188 | const E = enum(usize) { a, b, c }; |
| 189 | 189 | var y = Value(E).init(.c); |
| 190 | try testing.expectEqual(E.c, y.swap(.a, .SeqCst)); | |
| 191 | try testing.expectEqual(E.a, y.load(.SeqCst)); | |
| 190 | try testing.expectEqual(E.c, y.swap(.a, .seq_cst)); | |
| 191 | try testing.expectEqual(E.a, y.load(.seq_cst)); | |
| 192 | 192 | |
| 193 | 193 | var z = Value(f32).init(5.0); |
| 194 | try testing.expectEqual(@as(f32, 5.0), z.swap(10.0, .SeqCst)); | |
| 195 | try testing.expectEqual(@as(f32, 10.0), z.load(.SeqCst)); | |
| 194 | try testing.expectEqual(@as(f32, 5.0), z.swap(10.0, .seq_cst)); | |
| 195 | try testing.expectEqual(@as(f32, 10.0), z.load(.seq_cst)); | |
| 196 | 196 | |
| 197 | 197 | var a = Value(bool).init(false); |
| 198 | try testing.expectEqual(false, a.swap(true, .SeqCst)); | |
| 199 | try testing.expectEqual(true, a.load(.SeqCst)); | |
| 198 | try testing.expectEqual(false, a.swap(true, .seq_cst)); | |
| 199 | try testing.expectEqual(true, a.load(.seq_cst)); | |
| 200 | 200 | |
| 201 | 201 | var b = Value(?*u8).init(null); |
| 202 | try testing.expectEqual(@as(?*u8, null), b.swap(@as(?*u8, @ptrFromInt(@alignOf(u8))), .SeqCst)); | |
| 203 | try testing.expectEqual(@as(?*u8, @ptrFromInt(@alignOf(u8))), b.load(.SeqCst)); | |
| 202 | try testing.expectEqual(@as(?*u8, null), b.swap(@as(?*u8, @ptrFromInt(@alignOf(u8))), .seq_cst)); | |
| 203 | try testing.expectEqual(@as(?*u8, @ptrFromInt(@alignOf(u8))), b.load(.seq_cst)); | |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | test "Value.store" { |
| 207 | 207 | var x = Value(usize).init(5); |
| 208 | x.store(10, .SeqCst); | |
| 209 | try testing.expectEqual(@as(usize, 10), x.load(.SeqCst)); | |
| 208 | x.store(10, .seq_cst); | |
| 209 | try testing.expectEqual(@as(usize, 10), x.load(.seq_cst)); | |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | test "Value.cmpxchgWeak" { |
| 213 | 213 | var x = Value(usize).init(0); |
| 214 | 214 | |
| 215 | try testing.expectEqual(@as(?usize, 0), x.cmpxchgWeak(1, 0, .SeqCst, .SeqCst)); | |
| 216 | try testing.expectEqual(@as(usize, 0), x.load(.SeqCst)); | |
| 215 | try testing.expectEqual(@as(?usize, 0), x.cmpxchgWeak(1, 0, .seq_cst, .seq_cst)); | |
| 216 | try testing.expectEqual(@as(usize, 0), x.load(.seq_cst)); | |
| 217 | 217 | |
| 218 | while (x.cmpxchgWeak(0, 1, .SeqCst, .SeqCst)) |_| {} | |
| 219 | try testing.expectEqual(@as(usize, 1), x.load(.SeqCst)); | |
| 218 | while (x.cmpxchgWeak(0, 1, .seq_cst, .seq_cst)) |_| {} | |
| 219 | try testing.expectEqual(@as(usize, 1), x.load(.seq_cst)); | |
| 220 | 220 | |
| 221 | while (x.cmpxchgWeak(1, 0, .SeqCst, .SeqCst)) |_| {} | |
| 222 | try testing.expectEqual(@as(usize, 0), x.load(.SeqCst)); | |
| 221 | while (x.cmpxchgWeak(1, 0, .seq_cst, .seq_cst)) |_| {} | |
| 222 | try testing.expectEqual(@as(usize, 0), x.load(.seq_cst)); | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | test "Value.cmpxchgStrong" { |
| 226 | 226 | var x = Value(usize).init(0); |
| 227 | try testing.expectEqual(@as(?usize, 0), x.cmpxchgStrong(1, 0, .SeqCst, .SeqCst)); | |
| 228 | try testing.expectEqual(@as(usize, 0), x.load(.SeqCst)); | |
| 229 | try testing.expectEqual(@as(?usize, null), x.cmpxchgStrong(0, 1, .SeqCst, .SeqCst)); | |
| 230 | try testing.expectEqual(@as(usize, 1), x.load(.SeqCst)); | |
| 231 | try testing.expectEqual(@as(?usize, null), x.cmpxchgStrong(1, 0, .SeqCst, .SeqCst)); | |
| 232 | try testing.expectEqual(@as(usize, 0), x.load(.SeqCst)); | |
| 227 | try testing.expectEqual(@as(?usize, 0), x.cmpxchgStrong(1, 0, .seq_cst, .seq_cst)); | |
| 228 | try testing.expectEqual(@as(usize, 0), x.load(.seq_cst)); | |
| 229 | try testing.expectEqual(@as(?usize, null), x.cmpxchgStrong(0, 1, .seq_cst, .seq_cst)); | |
| 230 | try testing.expectEqual(@as(usize, 1), x.load(.seq_cst)); | |
| 231 | try testing.expectEqual(@as(?usize, null), x.cmpxchgStrong(1, 0, .seq_cst, .seq_cst)); | |
| 232 | try testing.expectEqual(@as(usize, 0), x.load(.seq_cst)); | |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | test "Value.fetchAdd" { |
| 236 | 236 | var x = Value(usize).init(5); |
| 237 | try testing.expectEqual(@as(usize, 5), x.fetchAdd(5, .SeqCst)); | |
| 238 | try testing.expectEqual(@as(usize, 10), x.load(.SeqCst)); | |
| 239 | try testing.expectEqual(@as(usize, 10), x.fetchAdd(std.math.maxInt(usize), .SeqCst)); | |
| 240 | try testing.expectEqual(@as(usize, 9), x.load(.SeqCst)); | |
| 237 | try testing.expectEqual(@as(usize, 5), x.fetchAdd(5, .seq_cst)); | |
| 238 | try testing.expectEqual(@as(usize, 10), x.load(.seq_cst)); | |
| 239 | try testing.expectEqual(@as(usize, 10), x.fetchAdd(std.math.maxInt(usize), .seq_cst)); | |
| 240 | try testing.expectEqual(@as(usize, 9), x.load(.seq_cst)); | |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | test "Value.fetchSub" { |
| 244 | 244 | var x = Value(usize).init(5); |
| 245 | try testing.expectEqual(@as(usize, 5), x.fetchSub(5, .SeqCst)); | |
| 246 | try testing.expectEqual(@as(usize, 0), x.load(.SeqCst)); | |
| 247 | try testing.expectEqual(@as(usize, 0), x.fetchSub(1, .SeqCst)); | |
| 248 | try testing.expectEqual(@as(usize, std.math.maxInt(usize)), x.load(.SeqCst)); | |
| 245 | try testing.expectEqual(@as(usize, 5), x.fetchSub(5, .seq_cst)); | |
| 246 | try testing.expectEqual(@as(usize, 0), x.load(.seq_cst)); | |
| 247 | try testing.expectEqual(@as(usize, 0), x.fetchSub(1, .seq_cst)); | |
| 248 | try testing.expectEqual(@as(usize, std.math.maxInt(usize)), x.load(.seq_cst)); | |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | test "Value.fetchMin" { |
| 252 | 252 | var x = Value(usize).init(5); |
| 253 | try testing.expectEqual(@as(usize, 5), x.fetchMin(0, .SeqCst)); | |
| 254 | try testing.expectEqual(@as(usize, 0), x.load(.SeqCst)); | |
| 255 | try testing.expectEqual(@as(usize, 0), x.fetchMin(10, .SeqCst)); | |
| 256 | try testing.expectEqual(@as(usize, 0), x.load(.SeqCst)); | |
| 253 | try testing.expectEqual(@as(usize, 5), x.fetchMin(0, .seq_cst)); | |
| 254 | try testing.expectEqual(@as(usize, 0), x.load(.seq_cst)); | |
| 255 | try testing.expectEqual(@as(usize, 0), x.fetchMin(10, .seq_cst)); | |
| 256 | try testing.expectEqual(@as(usize, 0), x.load(.seq_cst)); | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | test "Value.fetchMax" { |
| 260 | 260 | var x = Value(usize).init(5); |
| 261 | try testing.expectEqual(@as(usize, 5), x.fetchMax(10, .SeqCst)); | |
| 262 | try testing.expectEqual(@as(usize, 10), x.load(.SeqCst)); | |
| 263 | try testing.expectEqual(@as(usize, 10), x.fetchMax(5, .SeqCst)); | |
| 264 | try testing.expectEqual(@as(usize, 10), x.load(.SeqCst)); | |
| 261 | try testing.expectEqual(@as(usize, 5), x.fetchMax(10, .seq_cst)); | |
| 262 | try testing.expectEqual(@as(usize, 10), x.load(.seq_cst)); | |
| 263 | try testing.expectEqual(@as(usize, 10), x.fetchMax(5, .seq_cst)); | |
| 264 | try testing.expectEqual(@as(usize, 10), x.load(.seq_cst)); | |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | test "Value.fetchAnd" { |
| 268 | 268 | var x = Value(usize).init(0b11); |
| 269 | try testing.expectEqual(@as(usize, 0b11), x.fetchAnd(0b10, .SeqCst)); | |
| 270 | try testing.expectEqual(@as(usize, 0b10), x.load(.SeqCst)); | |
| 271 | try testing.expectEqual(@as(usize, 0b10), x.fetchAnd(0b00, .SeqCst)); | |
| 272 | try testing.expectEqual(@as(usize, 0b00), x.load(.SeqCst)); | |
| 269 | try testing.expectEqual(@as(usize, 0b11), x.fetchAnd(0b10, .seq_cst)); | |
| 270 | try testing.expectEqual(@as(usize, 0b10), x.load(.seq_cst)); | |
| 271 | try testing.expectEqual(@as(usize, 0b10), x.fetchAnd(0b00, .seq_cst)); | |
| 272 | try testing.expectEqual(@as(usize, 0b00), x.load(.seq_cst)); | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | test "Value.fetchNand" { |
| 276 | 276 | var x = Value(usize).init(0b11); |
| 277 | try testing.expectEqual(@as(usize, 0b11), x.fetchNand(0b10, .SeqCst)); | |
| 278 | try testing.expectEqual(~@as(usize, 0b10), x.load(.SeqCst)); | |
| 279 | try testing.expectEqual(~@as(usize, 0b10), x.fetchNand(0b00, .SeqCst)); | |
| 280 | try testing.expectEqual(~@as(usize, 0b00), x.load(.SeqCst)); | |
| 277 | try testing.expectEqual(@as(usize, 0b11), x.fetchNand(0b10, .seq_cst)); | |
| 278 | try testing.expectEqual(~@as(usize, 0b10), x.load(.seq_cst)); | |
| 279 | try testing.expectEqual(~@as(usize, 0b10), x.fetchNand(0b00, .seq_cst)); | |
| 280 | try testing.expectEqual(~@as(usize, 0b00), x.load(.seq_cst)); | |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | test "Value.fetchOr" { |
| 284 | 284 | var x = Value(usize).init(0b11); |
| 285 | try testing.expectEqual(@as(usize, 0b11), x.fetchOr(0b100, .SeqCst)); | |
| 286 | try testing.expectEqual(@as(usize, 0b111), x.load(.SeqCst)); | |
| 287 | try testing.expectEqual(@as(usize, 0b111), x.fetchOr(0b010, .SeqCst)); | |
| 288 | try testing.expectEqual(@as(usize, 0b111), x.load(.SeqCst)); | |
| 285 | try testing.expectEqual(@as(usize, 0b11), x.fetchOr(0b100, .seq_cst)); | |
| 286 | try testing.expectEqual(@as(usize, 0b111), x.load(.seq_cst)); | |
| 287 | try testing.expectEqual(@as(usize, 0b111), x.fetchOr(0b010, .seq_cst)); | |
| 288 | try testing.expectEqual(@as(usize, 0b111), x.load(.seq_cst)); | |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | test "Value.fetchXor" { |
| 292 | 292 | var x = Value(usize).init(0b11); |
| 293 | try testing.expectEqual(@as(usize, 0b11), x.fetchXor(0b10, .SeqCst)); | |
| 294 | try testing.expectEqual(@as(usize, 0b01), x.load(.SeqCst)); | |
| 295 | try testing.expectEqual(@as(usize, 0b01), x.fetchXor(0b01, .SeqCst)); | |
| 296 | try testing.expectEqual(@as(usize, 0b00), x.load(.SeqCst)); | |
| 293 | try testing.expectEqual(@as(usize, 0b11), x.fetchXor(0b10, .seq_cst)); | |
| 294 | try testing.expectEqual(@as(usize, 0b01), x.load(.seq_cst)); | |
| 295 | try testing.expectEqual(@as(usize, 0b01), x.fetchXor(0b01, .seq_cst)); | |
| 296 | try testing.expectEqual(@as(usize, 0b00), x.load(.seq_cst)); | |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | test "Value.bitSet" { |
| ... | ... | @@ -304,19 +304,19 @@ test "Value.bitSet" { |
| 304 | 304 | const mask = @as(usize, 1) << bit; |
| 305 | 305 | |
| 306 | 306 | // setting the bit should change the bit |
| 307 | try testing.expect(x.load(.SeqCst) & mask == 0); | |
| 308 | try testing.expectEqual(@as(u1, 0), x.bitSet(bit, .SeqCst)); | |
| 309 | try testing.expect(x.load(.SeqCst) & mask != 0); | |
| 307 | try testing.expect(x.load(.seq_cst) & mask == 0); | |
| 308 | try testing.expectEqual(@as(u1, 0), x.bitSet(bit, .seq_cst)); | |
| 309 | try testing.expect(x.load(.seq_cst) & mask != 0); | |
| 310 | 310 | |
| 311 | 311 | // setting it again shouldn't change the bit |
| 312 | try testing.expectEqual(@as(u1, 1), x.bitSet(bit, .SeqCst)); | |
| 313 | try testing.expect(x.load(.SeqCst) & mask != 0); | |
| 312 | try testing.expectEqual(@as(u1, 1), x.bitSet(bit, .seq_cst)); | |
| 313 | try testing.expect(x.load(.seq_cst) & mask != 0); | |
| 314 | 314 | |
| 315 | 315 | // all the previous bits should have not changed (still be set) |
| 316 | 316 | for (0..bit_index) |prev_bit_index| { |
| 317 | 317 | const prev_bit = @as(std.math.Log2Int(usize), @intCast(prev_bit_index)); |
| 318 | 318 | const prev_mask = @as(usize, 1) << prev_bit; |
| 319 | try testing.expect(x.load(.SeqCst) & prev_mask != 0); | |
| 319 | try testing.expect(x.load(.seq_cst) & prev_mask != 0); | |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | } |
| ... | ... | @@ -330,19 +330,19 @@ test "Value.bitReset" { |
| 330 | 330 | x.raw |= mask; |
| 331 | 331 | |
| 332 | 332 | // unsetting the bit should change the bit |
| 333 | try testing.expect(x.load(.SeqCst) & mask != 0); | |
| 334 | try testing.expectEqual(@as(u1, 1), x.bitReset(bit, .SeqCst)); | |
| 335 | try testing.expect(x.load(.SeqCst) & mask == 0); | |
| 333 | try testing.expect(x.load(.seq_cst) & mask != 0); | |
| 334 | try testing.expectEqual(@as(u1, 1), x.bitReset(bit, .seq_cst)); | |
| 335 | try testing.expect(x.load(.seq_cst) & mask == 0); | |
| 336 | 336 | |
| 337 | 337 | // unsetting it again shouldn't change the bit |
| 338 | try testing.expectEqual(@as(u1, 0), x.bitReset(bit, .SeqCst)); | |
| 339 | try testing.expect(x.load(.SeqCst) & mask == 0); | |
| 338 | try testing.expectEqual(@as(u1, 0), x.bitReset(bit, .seq_cst)); | |
| 339 | try testing.expect(x.load(.seq_cst) & mask == 0); | |
| 340 | 340 | |
| 341 | 341 | // all the previous bits should have not changed (still be reset) |
| 342 | 342 | for (0..bit_index) |prev_bit_index| { |
| 343 | 343 | const prev_bit = @as(std.math.Log2Int(usize), @intCast(prev_bit_index)); |
| 344 | 344 | const prev_mask = @as(usize, 1) << prev_bit; |
| 345 | try testing.expect(x.load(.SeqCst) & prev_mask == 0); | |
| 345 | try testing.expect(x.load(.seq_cst) & prev_mask == 0); | |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | } |
| ... | ... | @@ -355,19 +355,19 @@ test "Value.bitToggle" { |
| 355 | 355 | const mask = @as(usize, 1) << bit; |
| 356 | 356 | |
| 357 | 357 | // toggling the bit should change the bit |
| 358 | try testing.expect(x.load(.SeqCst) & mask == 0); | |
| 359 | try testing.expectEqual(@as(u1, 0), x.bitToggle(bit, .SeqCst)); | |
| 360 | try testing.expect(x.load(.SeqCst) & mask != 0); | |
| 358 | try testing.expect(x.load(.seq_cst) & mask == 0); | |
| 359 | try testing.expectEqual(@as(u1, 0), x.bitToggle(bit, .seq_cst)); | |
| 360 | try testing.expect(x.load(.seq_cst) & mask != 0); | |
| 361 | 361 | |
| 362 | 362 | // toggling it again *should* change the bit |
| 363 | try testing.expectEqual(@as(u1, 1), x.bitToggle(bit, .SeqCst)); | |
| 364 | try testing.expect(x.load(.SeqCst) & mask == 0); | |
| 363 | try testing.expectEqual(@as(u1, 1), x.bitToggle(bit, .seq_cst)); | |
| 364 | try testing.expect(x.load(.seq_cst) & mask == 0); | |
| 365 | 365 | |
| 366 | 366 | // all the previous bits should have not changed (still be toggled back) |
| 367 | 367 | for (0..bit_index) |prev_bit_index| { |
| 368 | 368 | const prev_bit = @as(std.math.Log2Int(usize), @intCast(prev_bit_index)); |
| 369 | 369 | const prev_mask = @as(usize, 1) << prev_bit; |
| 370 | try testing.expect(x.load(.SeqCst) & prev_mask == 0); | |
| 370 | try testing.expect(x.load(.seq_cst) & prev_mask == 0); | |
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | } |
lib/std/builtin.zig+20-20| ... | ... | @@ -64,10 +64,10 @@ pub const StackTrace = struct { |
| 64 | 64 | /// This data structure is used by the Zig language code generation and |
| 65 | 65 | /// therefore must be kept in sync with the compiler implementation. |
| 66 | 66 | pub const GlobalLinkage = enum { |
| 67 | Internal, | |
| 68 | Strong, | |
| 69 | Weak, | |
| 70 | LinkOnce, | |
| 67 | internal, | |
| 68 | strong, | |
| 69 | weak, | |
| 70 | link_once, | |
| 71 | 71 | }; |
| 72 | 72 | |
| 73 | 73 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -81,12 +81,12 @@ pub const SymbolVisibility = enum { |
| 81 | 81 | /// This data structure is used by the Zig language code generation and |
| 82 | 82 | /// therefore must be kept in sync with the compiler implementation. |
| 83 | 83 | pub const AtomicOrder = enum { |
| 84 | Unordered, | |
| 85 | Monotonic, | |
| 86 | Acquire, | |
| 87 | Release, | |
| 88 | AcqRel, | |
| 89 | SeqCst, | |
| 84 | unordered, | |
| 85 | monotonic, | |
| 86 | acquire, | |
| 87 | release, | |
| 88 | acq_rel, | |
| 89 | seq_cst, | |
| 90 | 90 | }; |
| 91 | 91 | |
| 92 | 92 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -334,9 +334,9 @@ pub const Type = union(enum) { |
| 334 | 334 | /// This data structure is used by the Zig language code generation and |
| 335 | 335 | /// therefore must be kept in sync with the compiler implementation. |
| 336 | 336 | pub const ContainerLayout = enum(u2) { |
| 337 | Auto, | |
| 338 | Extern, | |
| 339 | Packed, | |
| 337 | auto, | |
| 338 | @"extern", | |
| 339 | @"packed", | |
| 340 | 340 | }; |
| 341 | 341 | |
| 342 | 342 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -353,7 +353,7 @@ pub const Type = union(enum) { |
| 353 | 353 | /// therefore must be kept in sync with the compiler implementation. |
| 354 | 354 | pub const Struct = struct { |
| 355 | 355 | layout: ContainerLayout, |
| 356 | /// Only valid if layout is .Packed | |
| 356 | /// Only valid if layout is .@"packed" | |
| 357 | 357 | backing_integer: ?type = null, |
| 358 | 358 | fields: []const StructField, |
| 359 | 359 | decls: []const Declaration, |
| ... | ... | @@ -471,8 +471,8 @@ pub const Type = union(enum) { |
| 471 | 471 | /// This data structure is used by the Zig language code generation and |
| 472 | 472 | /// therefore must be kept in sync with the compiler implementation. |
| 473 | 473 | pub const FloatMode = enum { |
| 474 | Strict, | |
| 475 | Optimized, | |
| 474 | strict, | |
| 475 | optimized, | |
| 476 | 476 | }; |
| 477 | 477 | |
| 478 | 478 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -500,8 +500,8 @@ pub const OutputMode = enum { |
| 500 | 500 | /// This data structure is used by the Zig language code generation and |
| 501 | 501 | /// therefore must be kept in sync with the compiler implementation. |
| 502 | 502 | pub const LinkMode = enum { |
| 503 | Static, | |
| 504 | Dynamic, | |
| 503 | static, | |
| 504 | dynamic, | |
| 505 | 505 | }; |
| 506 | 506 | |
| 507 | 507 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -659,7 +659,7 @@ pub const PrefetchOptions = struct { |
| 659 | 659 | /// therefore must be kept in sync with the compiler implementation. |
| 660 | 660 | pub const ExportOptions = struct { |
| 661 | 661 | name: []const u8, |
| 662 | linkage: GlobalLinkage = .Strong, | |
| 662 | linkage: GlobalLinkage = .strong, | |
| 663 | 663 | section: ?[]const u8 = null, |
| 664 | 664 | visibility: SymbolVisibility = .default, |
| 665 | 665 | }; |
| ... | ... | @@ -669,7 +669,7 @@ pub const ExportOptions = struct { |
| 669 | 669 | pub const ExternOptions = struct { |
| 670 | 670 | name: []const u8, |
| 671 | 671 | library_name: ?[]const u8 = null, |
| 672 | linkage: GlobalLinkage = .Strong, | |
| 672 | linkage: GlobalLinkage = .strong, | |
| 673 | 673 | is_thread_local: bool = false, |
| 674 | 674 | }; |
| 675 | 675 |
lib/std/c/darwin.zig+1-1| ... | ... | @@ -202,7 +202,7 @@ var dummy_execute_header: mach_hdr = undefined; |
| 202 | 202 | pub extern var _mh_execute_header: mach_hdr; |
| 203 | 203 | comptime { |
| 204 | 204 | if (builtin.target.isDarwin()) { |
| 205 | @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .Weak }); | |
| 205 | @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak }); | |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 |
lib/std/child_process.zig+1-1| ... | ... | @@ -1420,7 +1420,7 @@ fn windowsMakeAsyncPipe(rd: *?windows.HANDLE, wr: *?windows.HANDLE, sattr: *cons |
| 1420 | 1420 | const pipe_path = std.fmt.bufPrintZ( |
| 1421 | 1421 | &tmp_buf, |
| 1422 | 1422 | "\\\\.\\pipe\\zig-childprocess-{d}-{d}", |
| 1423 | .{ windows.kernel32.GetCurrentProcessId(), pipe_name_counter.fetchAdd(1, .Monotonic) }, | |
| 1423 | .{ windows.kernel32.GetCurrentProcessId(), pipe_name_counter.fetchAdd(1, .monotonic) }, | |
| 1424 | 1424 | ) catch unreachable; |
| 1425 | 1425 | const len = std.unicode.wtf8ToWtf16Le(&tmp_bufw, pipe_path) catch unreachable; |
| 1426 | 1426 | tmp_bufw[len] = 0; |
lib/std/debug.zig+4-4| ... | ... | @@ -461,7 +461,7 @@ pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize |
| 461 | 461 | 0 => { |
| 462 | 462 | panic_stage = 1; |
| 463 | 463 | |
| 464 | _ = panicking.fetchAdd(1, .SeqCst); | |
| 464 | _ = panicking.fetchAdd(1, .seq_cst); | |
| 465 | 465 | |
| 466 | 466 | // Make sure to release the mutex when done |
| 467 | 467 | { |
| ... | ... | @@ -503,7 +503,7 @@ pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize |
| 503 | 503 | |
| 504 | 504 | /// Must be called only after adding 1 to `panicking`. There are three callsites. |
| 505 | 505 | fn waitForOtherThreadToFinishPanicking() void { |
| 506 | if (panicking.fetchSub(1, .SeqCst) != 1) { | |
| 506 | if (panicking.fetchSub(1, .seq_cst) != 1) { | |
| 507 | 507 | // Another thread is panicking, wait for the last one to finish |
| 508 | 508 | // and call abort() |
| 509 | 509 | if (builtin.single_threaded) unreachable; |
| ... | ... | @@ -2587,7 +2587,7 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any |
| 2587 | 2587 | nosuspend switch (panic_stage) { |
| 2588 | 2588 | 0 => { |
| 2589 | 2589 | panic_stage = 1; |
| 2590 | _ = panicking.fetchAdd(1, .SeqCst); | |
| 2590 | _ = panicking.fetchAdd(1, .seq_cst); | |
| 2591 | 2591 | |
| 2592 | 2592 | { |
| 2593 | 2593 | panic_mutex.lock(); |
| ... | ... | @@ -2663,7 +2663,7 @@ fn handleSegfaultWindowsExtra( |
| 2663 | 2663 | nosuspend switch (panic_stage) { |
| 2664 | 2664 | 0 => { |
| 2665 | 2665 | panic_stage = 1; |
| 2666 | _ = panicking.fetchAdd(1, .SeqCst); | |
| 2666 | _ = panicking.fetchAdd(1, .seq_cst); | |
| 2667 | 2667 | |
| 2668 | 2668 | { |
| 2669 | 2669 | panic_mutex.lock(); |
lib/std/dynamic_library.zig+2-2| ... | ... | @@ -8,7 +8,7 @@ const windows = std.os.windows; |
| 8 | 8 | const system = std.os.system; |
| 9 | 9 | |
| 10 | 10 | pub const DynLib = switch (builtin.os.tag) { |
| 11 | .linux => if (!builtin.link_libc or builtin.abi == .musl and builtin.link_mode == .Static) | |
| 11 | .linux => if (!builtin.link_libc or builtin.abi == .musl and builtin.link_mode == .static) | |
| 12 | 12 | ElfDynLib |
| 13 | 13 | else |
| 14 | 14 | DlDynLib, |
| ... | ... | @@ -56,7 +56,7 @@ const RDebug = extern struct { |
| 56 | 56 | /// TODO make it possible to reference this same external symbol 2x so we don't need this |
| 57 | 57 | /// helper function. |
| 58 | 58 | pub fn get_DYNAMIC() ?[*]elf.Dyn { |
| 59 | return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .Weak }); | |
| 59 | return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .weak }); | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator { |
lib/std/enums.zig+1-1| ... | ... | @@ -22,7 +22,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def |
| 22 | 22 | }}; |
| 23 | 23 | } |
| 24 | 24 | return @Type(.{ .Struct = .{ |
| 25 | .layout = .Auto, | |
| 25 | .layout = .auto, | |
| 26 | 26 | .fields = fields, |
| 27 | 27 | .decls = &.{}, |
| 28 | 28 | .is_tuple = false, |
lib/std/heap.zig+4-4| ... | ... | @@ -303,11 +303,11 @@ pub const HeapAllocator = switch (builtin.os.tag) { |
| 303 | 303 | |
| 304 | 304 | const ptr_align = @as(usize, 1) << @as(Allocator.Log2Align, @intCast(log2_ptr_align)); |
| 305 | 305 | const amt = n + ptr_align - 1 + @sizeOf(usize); |
| 306 | const optional_heap_handle = @atomicLoad(?HeapHandle, &self.heap_handle, .SeqCst); | |
| 306 | const optional_heap_handle = @atomicLoad(?HeapHandle, &self.heap_handle, .seq_cst); | |
| 307 | 307 | const heap_handle = optional_heap_handle orelse blk: { |
| 308 | 308 | const options = if (builtin.single_threaded) os.windows.HEAP_NO_SERIALIZE else 0; |
| 309 | 309 | const hh = os.windows.kernel32.HeapCreate(options, amt, 0) orelse return null; |
| 310 | const other_hh = @cmpxchgStrong(?HeapHandle, &self.heap_handle, null, hh, .SeqCst, .SeqCst) orelse break :blk hh; | |
| 310 | const other_hh = @cmpxchgStrong(?HeapHandle, &self.heap_handle, null, hh, .seq_cst, .seq_cst) orelse break :blk hh; | |
| 311 | 311 | os.windows.HeapDestroy(hh); |
| 312 | 312 | break :blk other_hh.?; // can't be null because of the cmpxchg |
| 313 | 313 | }; |
| ... | ... | @@ -482,13 +482,13 @@ pub const FixedBufferAllocator = struct { |
| 482 | 482 | const self: *FixedBufferAllocator = @ptrCast(@alignCast(ctx)); |
| 483 | 483 | _ = ra; |
| 484 | 484 | const ptr_align = @as(usize, 1) << @as(Allocator.Log2Align, @intCast(log2_ptr_align)); |
| 485 | var end_index = @atomicLoad(usize, &self.end_index, .SeqCst); | |
| 485 | var end_index = @atomicLoad(usize, &self.end_index, .seq_cst); | |
| 486 | 486 | while (true) { |
| 487 | 487 | const adjust_off = mem.alignPointerOffset(self.buffer.ptr + end_index, ptr_align) orelse return null; |
| 488 | 488 | const adjusted_index = end_index + adjust_off; |
| 489 | 489 | const new_end_index = adjusted_index + n; |
| 490 | 490 | if (new_end_index > self.buffer.len) return null; |
| 491 | end_index = @cmpxchgWeak(usize, &self.end_index, end_index, new_end_index, .SeqCst, .SeqCst) orelse | |
| 491 | end_index = @cmpxchgWeak(usize, &self.end_index, end_index, new_end_index, .seq_cst, .seq_cst) orelse | |
| 492 | 492 | return self.buffer[adjusted_index..new_end_index].ptr; |
| 493 | 493 | } |
| 494 | 494 | } |
lib/std/heap/PageAllocator.zig+2-2| ... | ... | @@ -30,7 +30,7 @@ fn alloc(_: *anyopaque, n: usize, log2_align: u8, ra: usize) ?[*]u8 { |
| 30 | 30 | return @ptrCast(addr); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | const hint = @atomicLoad(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, .Unordered); | |
| 33 | const hint = @atomicLoad(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, .unordered); | |
| 34 | 34 | const slice = os.mmap( |
| 35 | 35 | hint, |
| 36 | 36 | aligned_len, |
| ... | ... | @@ -41,7 +41,7 @@ fn alloc(_: *anyopaque, n: usize, log2_align: u8, ra: usize) ?[*]u8 { |
| 41 | 41 | ) catch return null; |
| 42 | 42 | assert(mem.isAligned(@intFromPtr(slice.ptr), mem.page_size)); |
| 43 | 43 | const new_hint: [*]align(mem.page_size) u8 = @alignCast(slice.ptr + aligned_len); |
| 44 | _ = @cmpxchgStrong(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, hint, new_hint, .Monotonic, .Monotonic); | |
| 44 | _ = @cmpxchgStrong(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, hint, new_hint, .monotonic, .monotonic); | |
| 45 | 45 | return slice.ptr; |
| 46 | 46 | } |
| 47 | 47 |
lib/std/http/Client.zig+2-2| ... | ... | @@ -1642,7 +1642,7 @@ pub fn open( |
| 1642 | 1642 | |
| 1643 | 1643 | const host = uri.host orelse return error.UriMissingHost; |
| 1644 | 1644 | |
| 1645 | if (protocol == .tls and @atomicLoad(bool, &client.next_https_rescan_certs, .Acquire)) { | |
| 1645 | if (protocol == .tls and @atomicLoad(bool, &client.next_https_rescan_certs, .acquire)) { | |
| 1646 | 1646 | if (disable_tls) unreachable; |
| 1647 | 1647 | |
| 1648 | 1648 | client.ca_bundle_mutex.lock(); |
| ... | ... | @@ -1650,7 +1650,7 @@ pub fn open( |
| 1650 | 1650 | |
| 1651 | 1651 | if (client.next_https_rescan_certs) { |
| 1652 | 1652 | client.ca_bundle.rescan(client.allocator) catch return error.CertificateBundleLoadFailure; |
| 1653 | @atomicStore(bool, &client.next_https_rescan_certs, false, .Release); | |
| 1653 | @atomicStore(bool, &client.next_https_rescan_certs, false, .release); | |
| 1654 | 1654 | } |
| 1655 | 1655 | } |
| 1656 | 1656 |
lib/std/io.zig+1-1| ... | ... | @@ -688,7 +688,7 @@ pub fn PollFiles(comptime StreamEnum: type) type { |
| 688 | 688 | }; |
| 689 | 689 | } |
| 690 | 690 | return @Type(.{ .Struct = .{ |
| 691 | .layout = .Auto, | |
| 691 | .layout = .auto, | |
| 692 | 692 | .fields = &struct_fields, |
| 693 | 693 | .decls = &.{}, |
| 694 | 694 | .is_tuple = false, |
lib/std/io/Reader.zig+1-1| ... | ... | @@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool { |
| 326 | 326 | |
| 327 | 327 | pub fn readStruct(self: Self, comptime T: type) anyerror!T { |
| 328 | 328 | // Only extern and packed structs have defined in-memory layout. |
| 329 | comptime assert(@typeInfo(T).Struct.layout != .Auto); | |
| 329 | comptime assert(@typeInfo(T).Struct.layout != .auto); | |
| 330 | 330 | var res: [1]T = undefined; |
| 331 | 331 | try self.readNoEof(mem.sliceAsBytes(res[0..])); |
| 332 | 332 | return res[0]; |
lib/std/io/Writer.zig+1-1| ... | ... | @@ -55,7 +55,7 @@ pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.built |
| 55 | 55 | |
| 56 | 56 | pub fn writeStruct(self: Self, value: anytype) anyerror!void { |
| 57 | 57 | // Only extern and packed structs have defined in-memory layout. |
| 58 | comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .Auto); | |
| 58 | comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .auto); | |
| 59 | 59 | return self.writeAll(mem.asBytes(&value)); |
| 60 | 60 | } |
| 61 | 61 |
lib/std/mem.zig+3-3| ... | ... | @@ -238,7 +238,7 @@ pub fn zeroes(comptime T: type) T { |
| 238 | 238 | }, |
| 239 | 239 | .Struct => |struct_info| { |
| 240 | 240 | if (@sizeOf(T) == 0) return undefined; |
| 241 | if (struct_info.layout == .Extern) { | |
| 241 | if (struct_info.layout == .@"extern") { | |
| 242 | 242 | var item: T = undefined; |
| 243 | 243 | @memset(asBytes(&item), 0); |
| 244 | 244 | return item; |
| ... | ... | @@ -284,7 +284,7 @@ pub fn zeroes(comptime T: type) T { |
| 284 | 284 | return @splat(zeroes(info.child)); |
| 285 | 285 | }, |
| 286 | 286 | .Union => |info| { |
| 287 | if (info.layout == .Extern) { | |
| 287 | if (info.layout == .@"extern") { | |
| 288 | 288 | var item: T = undefined; |
| 289 | 289 | @memset(asBytes(&item), 0); |
| 290 | 290 | return item; |
| ... | ... | @@ -429,7 +429,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | var value: T = if (struct_info.layout == .Extern) zeroes(T) else undefined; | |
| 432 | var value: T = if (struct_info.layout == .@"extern") zeroes(T) else undefined; | |
| 433 | 433 | |
| 434 | 434 | inline for (struct_info.fields, 0..) |field, i| { |
| 435 | 435 | if (field.is_comptime) { |
lib/std/meta.zig+7-7| ... | ... | @@ -269,12 +269,12 @@ test containerLayout { |
| 269 | 269 | a: u8, |
| 270 | 270 | }; |
| 271 | 271 | |
| 272 | try testing.expect(containerLayout(S1) == .Auto); | |
| 273 | try testing.expect(containerLayout(S2) == .Packed); | |
| 274 | try testing.expect(containerLayout(S3) == .Extern); | |
| 275 | try testing.expect(containerLayout(U1) == .Auto); | |
| 276 | try testing.expect(containerLayout(U2) == .Packed); | |
| 277 | try testing.expect(containerLayout(U3) == .Extern); | |
| 272 | try testing.expect(containerLayout(S1) == .auto); | |
| 273 | try testing.expect(containerLayout(S2) == .@"packed"); | |
| 274 | try testing.expect(containerLayout(S3) == .@"extern"); | |
| 275 | try testing.expect(containerLayout(U1) == .auto); | |
| 276 | try testing.expect(containerLayout(U2) == .@"packed"); | |
| 277 | try testing.expect(containerLayout(U3) == .@"extern"); | |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /// Instead of this function, prefer to use e.g. `@typeInfo(foo).Struct.decls` |
| ... | ... | @@ -1025,7 +1025,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { |
| 1025 | 1025 | return @Type(.{ |
| 1026 | 1026 | .Struct = .{ |
| 1027 | 1027 | .is_tuple = true, |
| 1028 | .layout = .Auto, | |
| 1028 | .layout = .auto, | |
| 1029 | 1029 | .decls = &.{}, |
| 1030 | 1030 | .fields = &tuple_fields, |
| 1031 | 1031 | }, |
lib/std/meta/trailer_flags.zig+1-1| ... | ... | @@ -32,7 +32,7 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 32 | 32 | } |
| 33 | 33 | break :blk @Type(.{ |
| 34 | 34 | .Struct = .{ |
| 35 | .layout = .Auto, | |
| 35 | .layout = .auto, | |
| 36 | 36 | .fields = &fields, |
| 37 | 37 | .decls = &.{}, |
| 38 | 38 | .is_tuple = false, |
lib/std/multi_array_list.zig+1-1| ... | ... | @@ -558,7 +558,7 @@ pub fn MultiArrayList(comptime T: type) type { |
| 558 | 558 | .alignment = fields[i].alignment, |
| 559 | 559 | }; |
| 560 | 560 | break :entry @Type(.{ .Struct = .{ |
| 561 | .layout = .Extern, | |
| 561 | .layout = .@"extern", | |
| 562 | 562 | .fields = &entry_fields, |
| 563 | 563 | .decls = &.{}, |
| 564 | 564 | .is_tuple = false, |
lib/std/once.zig+2-2| ... | ... | @@ -17,7 +17,7 @@ pub fn Once(comptime f: fn () void) type { |
| 17 | 17 | /// first time. |
| 18 | 18 | /// The invocations are thread-safe. |
| 19 | 19 | pub fn call(self: *@This()) void { |
| 20 | if (@atomicLoad(bool, &self.done, .Acquire)) | |
| 20 | if (@atomicLoad(bool, &self.done, .acquire)) | |
| 21 | 21 | return; |
| 22 | 22 | |
| 23 | 23 | return self.callSlow(); |
| ... | ... | @@ -32,7 +32,7 @@ pub fn Once(comptime f: fn () void) type { |
| 32 | 32 | // The first thread to acquire the mutex gets to run the initializer |
| 33 | 33 | if (!self.done) { |
| 34 | 34 | f(); |
| 35 | @atomicStore(bool, &self.done, true, .Release); | |
| 35 | @atomicStore(bool, &self.done, true, .release); | |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | }; |
lib/std/os.zig+5-5| ... | ... | @@ -436,7 +436,7 @@ fn fchmodat1(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr |
| 436 | 436 | fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtError!void { |
| 437 | 437 | const path_c = try toPosixPath(path); |
| 438 | 438 | const use_fchmodat2 = (builtin.os.isAtLeast(.linux, .{ .major = 6, .minor = 6, .patch = 0 }) orelse false) and |
| 439 | has_fchmodat2_syscall.load(.Monotonic); | |
| 439 | has_fchmodat2_syscall.load(.monotonic); | |
| 440 | 440 | while (use_fchmodat2) { |
| 441 | 441 | // Later on this should be changed to `system.fchmodat2` |
| 442 | 442 | // when the musl/glibc add a wrapper. |
| ... | ... | @@ -458,7 +458,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr |
| 458 | 458 | .ROFS => return error.ReadOnlyFileSystem, |
| 459 | 459 | |
| 460 | 460 | .NOSYS => { // Use fallback. |
| 461 | has_fchmodat2_syscall.store(false, .Monotonic); | |
| 461 | has_fchmodat2_syscall.store(false, .monotonic); | |
| 462 | 462 | break; |
| 463 | 463 | }, |
| 464 | 464 | else => |err| return unexpectedErrno(err), |
| ... | ... | @@ -729,7 +729,7 @@ pub fn abort() noreturn { |
| 729 | 729 | const global = struct { |
| 730 | 730 | var abort_entered: bool = false; |
| 731 | 731 | }; |
| 732 | while (@cmpxchgWeak(bool, &global.abort_entered, false, true, .SeqCst, .SeqCst)) |_| {} | |
| 732 | while (@cmpxchgWeak(bool, &global.abort_entered, false, true, .seq_cst, .seq_cst)) |_| {} | |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | // Install default handler so that the tkill below will terminate. |
| ... | ... | @@ -6809,7 +6809,7 @@ pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len |
| 6809 | 6809 | if ((comptime builtin.os.isAtLeast(.freebsd, .{ .major = 13, .minor = 0, .patch = 0 }) orelse false) or |
| 6810 | 6810 | ((comptime builtin.os.isAtLeast(.linux, .{ .major = 4, .minor = 5, .patch = 0 }) orelse false and |
| 6811 | 6811 | std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 })) and |
| 6812 | has_copy_file_range_syscall.load(.Monotonic))) | |
| 6812 | has_copy_file_range_syscall.load(.monotonic))) | |
| 6813 | 6813 | { |
| 6814 | 6814 | var off_in_copy: i64 = @bitCast(off_in); |
| 6815 | 6815 | var off_out_copy: i64 = @bitCast(off_out); |
| ... | ... | @@ -6844,7 +6844,7 @@ pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len |
| 6844 | 6844 | .TXTBSY => return error.SwapFile, |
| 6845 | 6845 | .XDEV => break, // support for cross-filesystem copy added in Linux 5.3, use fallback |
| 6846 | 6846 | .NOSYS => { // syscall added in Linux 4.5, use fallback |
| 6847 | has_copy_file_range_syscall.store(false, .Monotonic); | |
| 6847 | has_copy_file_range_syscall.store(false, .monotonic); | |
| 6848 | 6848 | break; |
| 6849 | 6849 | }, |
| 6850 | 6850 | else => |err| return unexpectedErrno(err), |
lib/std/os/linux.zig+3-3| ... | ... | @@ -394,7 +394,7 @@ const extern_getauxval = switch (builtin.zig_backend) { |
| 394 | 394 | |
| 395 | 395 | comptime { |
| 396 | 396 | if (extern_getauxval) { |
| 397 | @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .Weak }); | |
| 397 | @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); | |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | |
| ... | ... | @@ -1334,7 +1334,7 @@ const vdso_clock_gettime_ty = *align(1) const fn (i32, *timespec) callconv(.C) u |
| 1334 | 1334 | |
| 1335 | 1335 | pub fn clock_gettime(clk_id: i32, tp: *timespec) usize { |
| 1336 | 1336 | if (@hasDecl(VDSO, "CGT_SYM")) { |
| 1337 | const ptr = @atomicLoad(?*const anyopaque, &vdso_clock_gettime, .Unordered); | |
| 1337 | const ptr = @atomicLoad(?*const anyopaque, &vdso_clock_gettime, .unordered); | |
| 1338 | 1338 | if (ptr) |fn_ptr| { |
| 1339 | 1339 | const f = @as(vdso_clock_gettime_ty, @ptrCast(fn_ptr)); |
| 1340 | 1340 | const rc = f(clk_id, tp); |
| ... | ... | @@ -1351,7 +1351,7 @@ fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize { |
| 1351 | 1351 | const ptr = @as(?*const anyopaque, @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM))); |
| 1352 | 1352 | // Note that we may not have a VDSO at all, update the stub address anyway |
| 1353 | 1353 | // so that clock_gettime will fall back on the good old (and slow) syscall |
| 1354 | @atomicStore(?*const anyopaque, &vdso_clock_gettime, ptr, .Monotonic); | |
| 1354 | @atomicStore(?*const anyopaque, &vdso_clock_gettime, ptr, .monotonic); | |
| 1355 | 1355 | // Call into the VDSO if available |
| 1356 | 1356 | if (ptr) |fn_ptr| { |
| 1357 | 1357 | const f = @as(vdso_clock_gettime_ty, @ptrCast(fn_ptr)); |
lib/std/os/linux/IoUring.zig+7-7| ... | ... | @@ -133,7 +133,7 @@ pub fn deinit(self: *IoUring) void { |
| 133 | 133 | /// alternative. In Zig, we have first-class error handling... so let's use it. |
| 134 | 134 | /// Matches the implementation of io_uring_get_sqe() in liburing. |
| 135 | 135 | pub fn get_sqe(self: *IoUring) !*linux.io_uring_sqe { |
| 136 | const head = @atomicLoad(u32, self.sq.head, .Acquire); | |
| 136 | const head = @atomicLoad(u32, self.sq.head, .acquire); | |
| 137 | 137 | // Remember that these head and tail offsets wrap around every four billion operations. |
| 138 | 138 | // We must therefore use wrapping addition and subtraction to avoid a runtime crash. |
| 139 | 139 | const next = self.sq.sqe_tail +% 1; |
| ... | ... | @@ -222,7 +222,7 @@ pub fn flush_sq(self: *IoUring) u32 { |
| 222 | 222 | self.sq.sqe_head +%= 1; |
| 223 | 223 | } |
| 224 | 224 | // Ensure that the kernel can actually see the SQE updates when it sees the tail update. |
| 225 | @atomicStore(u32, self.sq.tail, tail, .Release); | |
| 225 | @atomicStore(u32, self.sq.tail, tail, .release); | |
| 226 | 226 | } |
| 227 | 227 | return self.sq_ready(); |
| 228 | 228 | } |
| ... | ... | @@ -234,7 +234,7 @@ pub fn flush_sq(self: *IoUring) u32 { |
| 234 | 234 | pub fn sq_ring_needs_enter(self: *IoUring, flags: *u32) bool { |
| 235 | 235 | assert(flags.* == 0); |
| 236 | 236 | if ((self.flags & linux.IORING_SETUP_SQPOLL) == 0) return true; |
| 237 | if ((@atomicLoad(u32, self.sq.flags, .Unordered) & linux.IORING_SQ_NEED_WAKEUP) != 0) { | |
| 237 | if ((@atomicLoad(u32, self.sq.flags, .unordered) & linux.IORING_SQ_NEED_WAKEUP) != 0) { | |
| 238 | 238 | flags.* |= linux.IORING_ENTER_SQ_WAKEUP; |
| 239 | 239 | return true; |
| 240 | 240 | } |
| ... | ... | @@ -248,14 +248,14 @@ pub fn sq_ring_needs_enter(self: *IoUring, flags: *u32) bool { |
| 248 | 248 | pub fn sq_ready(self: *IoUring) u32 { |
| 249 | 249 | // Always use the shared ring state (i.e. head and not sqe_head) to avoid going out of sync, |
| 250 | 250 | // see https://github.com/axboe/liburing/issues/92. |
| 251 | return self.sq.sqe_tail -% @atomicLoad(u32, self.sq.head, .Acquire); | |
| 251 | return self.sq.sqe_tail -% @atomicLoad(u32, self.sq.head, .acquire); | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /// Returns the number of CQEs in the completion queue, i.e. its length. |
| 255 | 255 | /// These are CQEs that the application is yet to consume. |
| 256 | 256 | /// Matches the implementation of io_uring_cq_ready in liburing. |
| 257 | 257 | pub fn cq_ready(self: *IoUring) u32 { |
| 258 | return @atomicLoad(u32, self.cq.tail, .Acquire) -% self.cq.head.*; | |
| 258 | return @atomicLoad(u32, self.cq.tail, .acquire) -% self.cq.head.*; | |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /// Copies as many CQEs as are ready, and that can fit into the destination `cqes` slice. |
| ... | ... | @@ -313,7 +313,7 @@ pub fn copy_cqe(ring: *IoUring) !linux.io_uring_cqe { |
| 313 | 313 | |
| 314 | 314 | /// Matches the implementation of cq_ring_needs_flush() in liburing. |
| 315 | 315 | pub fn cq_ring_needs_flush(self: *IoUring) bool { |
| 316 | return (@atomicLoad(u32, self.sq.flags, .Unordered) & linux.IORING_SQ_CQ_OVERFLOW) != 0; | |
| 316 | return (@atomicLoad(u32, self.sq.flags, .unordered) & linux.IORING_SQ_CQ_OVERFLOW) != 0; | |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /// For advanced use cases only that implement custom completion queue methods. |
| ... | ... | @@ -331,7 +331,7 @@ pub fn cqe_seen(self: *IoUring, cqe: *linux.io_uring_cqe) void { |
| 331 | 331 | pub fn cq_advance(self: *IoUring, count: u32) void { |
| 332 | 332 | if (count > 0) { |
| 333 | 333 | // Ensure the kernel only sees the new head value after the CQEs have been read. |
| 334 | @atomicStore(u32, self.cq.head, self.cq.head.* +% count, .Release); | |
| 334 | @atomicStore(u32, self.cq.head, self.cq.head.* +% count, .release); | |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 |
lib/std/os/test.zig+1-1| ... | ... | @@ -425,7 +425,7 @@ fn start1() u8 { |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | fn start2(ctx: *i32) u8 { |
| 428 | _ = @atomicRmw(i32, ctx, AtomicRmwOp.Add, 1, AtomicOrder.SeqCst); | |
| 428 | _ = @atomicRmw(i32, ctx, AtomicRmwOp.Add, 1, AtomicOrder.seq_cst); | |
| 429 | 429 | return 0; |
| 430 | 430 | } |
| 431 | 431 |
lib/std/start.zig+1-1| ... | ... | @@ -50,7 +50,7 @@ comptime { |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | } else { |
| 53 | if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) { | |
| 53 | if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) { | |
| 54 | 54 | if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) { |
| 55 | 55 | @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" }); |
| 56 | 56 | } |
lib/std/zig.zig+12-12| ... | ... | @@ -155,9 +155,9 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe |
| 155 | 155 | .coff => switch (options.output_mode) { |
| 156 | 156 | .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }), |
| 157 | 157 | .Lib => { |
| 158 | const suffix = switch (options.link_mode orelse .Static) { | |
| 159 | .Static => ".lib", | |
| 160 | .Dynamic => ".dll", | |
| 158 | const suffix = switch (options.link_mode orelse .static) { | |
| 159 | .static => ".lib", | |
| 160 | .dynamic => ".dll", | |
| 161 | 161 | }; |
| 162 | 162 | return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, suffix }); |
| 163 | 163 | }, |
| ... | ... | @@ -166,11 +166,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe |
| 166 | 166 | .elf => switch (options.output_mode) { |
| 167 | 167 | .Exe => return allocator.dupe(u8, root_name), |
| 168 | 168 | .Lib => { |
| 169 | switch (options.link_mode orelse .Static) { | |
| 170 | .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ | |
| 169 | switch (options.link_mode orelse .static) { | |
| 170 | .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ | |
| 171 | 171 | t.libPrefix(), root_name, |
| 172 | 172 | }), |
| 173 | .Dynamic => { | |
| 173 | .dynamic => { | |
| 174 | 174 | if (options.version) |ver| { |
| 175 | 175 | return std.fmt.allocPrint(allocator, "{s}{s}.so.{d}.{d}.{d}", .{ |
| 176 | 176 | t.libPrefix(), root_name, ver.major, ver.minor, ver.patch, |
| ... | ... | @@ -188,11 +188,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe |
| 188 | 188 | .macho => switch (options.output_mode) { |
| 189 | 189 | .Exe => return allocator.dupe(u8, root_name), |
| 190 | 190 | .Lib => { |
| 191 | switch (options.link_mode orelse .Static) { | |
| 192 | .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ | |
| 191 | switch (options.link_mode orelse .static) { | |
| 192 | .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ | |
| 193 | 193 | t.libPrefix(), root_name, |
| 194 | 194 | }), |
| 195 | .Dynamic => { | |
| 195 | .dynamic => { | |
| 196 | 196 | if (options.version) |ver| { |
| 197 | 197 | return std.fmt.allocPrint(allocator, "{s}{s}.{d}.{d}.{d}.dylib", .{ |
| 198 | 198 | t.libPrefix(), root_name, ver.major, ver.minor, ver.patch, |
| ... | ... | @@ -210,11 +210,11 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe |
| 210 | 210 | .wasm => switch (options.output_mode) { |
| 211 | 211 | .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, t.exeFileExt() }), |
| 212 | 212 | .Lib => { |
| 213 | switch (options.link_mode orelse .Static) { | |
| 214 | .Static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ | |
| 213 | switch (options.link_mode orelse .static) { | |
| 214 | .static => return std.fmt.allocPrint(allocator, "{s}{s}.a", .{ | |
| 215 | 215 | t.libPrefix(), root_name, |
| 216 | 216 | }), |
| 217 | .Dynamic => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}), | |
| 217 | .dynamic => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}), | |
| 218 | 218 | } |
| 219 | 219 | }, |
| 220 | 220 | .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}), |
lib/std/zig/AstGen.zig+21-22| ... | ... | @@ -175,7 +175,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { |
| 175 | 175 | &gen_scope.base, |
| 176 | 176 | 0, |
| 177 | 177 | tree.containerDeclRoot(), |
| 178 | .Auto, | |
| 178 | .auto, | |
| 179 | 179 | 0, |
| 180 | 180 | )) |struct_decl_ref| { |
| 181 | 181 | assert(struct_decl_ref.toIndex().? == .main_struct_inst); |
| ... | ... | @@ -4907,7 +4907,7 @@ fn structDeclInner( |
| 4907 | 4907 | var backing_int_body_len: usize = 0; |
| 4908 | 4908 | const backing_int_ref: Zir.Inst.Ref = blk: { |
| 4909 | 4909 | if (backing_int_node != 0) { |
| 4910 | if (layout != .Packed) { | |
| 4910 | if (layout != .@"packed") { | |
| 4911 | 4911 | return astgen.failNode(backing_int_node, "non-packed struct does not support backing integer type", .{}); |
| 4912 | 4912 | } else { |
| 4913 | 4913 | const backing_int_ref = try typeExpr(&block_scope, &namespace.base, backing_int_node); |
| ... | ... | @@ -4958,9 +4958,9 @@ fn structDeclInner( |
| 4958 | 4958 | } else false; |
| 4959 | 4959 | |
| 4960 | 4960 | if (is_tuple) switch (layout) { |
| 4961 | .Auto => {}, | |
| 4962 | .Extern => return astgen.failNode(node, "extern tuples are not supported", .{}), | |
| 4963 | .Packed => return astgen.failNode(node, "packed tuples are not supported", .{}), | |
| 4961 | .auto => {}, | |
| 4962 | .@"extern" => return astgen.failNode(node, "extern tuples are not supported", .{}), | |
| 4963 | .@"packed" => return astgen.failNode(node, "packed tuples are not supported", .{}), | |
| 4964 | 4964 | }; |
| 4965 | 4965 | |
| 4966 | 4966 | if (is_tuple) for (container_decl.ast.members) |member_node| { |
| ... | ... | @@ -5055,9 +5055,9 @@ fn structDeclInner( |
| 5055 | 5055 | |
| 5056 | 5056 | if (is_comptime) { |
| 5057 | 5057 | switch (layout) { |
| 5058 | .Packed => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}), | |
| 5059 | .Extern => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}), | |
| 5060 | .Auto => any_comptime_fields = true, | |
| 5058 | .@"packed" => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}), | |
| 5059 | .@"extern" => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}), | |
| 5060 | .auto => any_comptime_fields = true, | |
| 5061 | 5061 | } |
| 5062 | 5062 | } else { |
| 5063 | 5063 | known_non_opv = known_non_opv or |
| ... | ... | @@ -5082,7 +5082,7 @@ fn structDeclInner( |
| 5082 | 5082 | } |
| 5083 | 5083 | |
| 5084 | 5084 | if (have_align) { |
| 5085 | if (layout == .Packed) { | |
| 5085 | if (layout == .@"packed") { | |
| 5086 | 5086 | try astgen.appendErrorNode(member.ast.align_expr, "unable to override alignment of packed struct fields", .{}); |
| 5087 | 5087 | } |
| 5088 | 5088 | any_aligned_fields = true; |
| ... | ... | @@ -5229,12 +5229,11 @@ fn unionDeclInner( |
| 5229 | 5229 | const decl_count = try astgen.scanDecls(&namespace, members); |
| 5230 | 5230 | const field_count: u32 = @intCast(members.len - decl_count); |
| 5231 | 5231 | |
| 5232 | if (layout != .Auto and (auto_enum_tok != null or arg_node != 0)) { | |
| 5233 | const layout_str = if (layout == .Extern) "extern" else "packed"; | |
| 5232 | if (layout != .auto and (auto_enum_tok != null or arg_node != 0)) { | |
| 5234 | 5233 | if (arg_node != 0) { |
| 5235 | return astgen.failNode(arg_node, "{s} union does not support enum tag type", .{layout_str}); | |
| 5234 | return astgen.failNode(arg_node, "{s} union does not support enum tag type", .{@tagName(layout)}); | |
| 5236 | 5235 | } else { |
| 5237 | return astgen.failTok(auto_enum_tok.?, "{s} union does not support enum tag type", .{layout_str}); | |
| 5236 | return astgen.failTok(auto_enum_tok.?, "{s} union does not support enum tag type", .{@tagName(layout)}); | |
| 5238 | 5237 | } |
| 5239 | 5238 | } |
| 5240 | 5239 | |
| ... | ... | @@ -5429,21 +5428,21 @@ fn containerDecl( |
| 5429 | 5428 | |
| 5430 | 5429 | switch (token_tags[container_decl.ast.main_token]) { |
| 5431 | 5430 | .keyword_struct => { |
| 5432 | const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) { | |
| 5433 | .keyword_packed => std.builtin.Type.ContainerLayout.Packed, | |
| 5434 | .keyword_extern => std.builtin.Type.ContainerLayout.Extern, | |
| 5431 | const layout: std.builtin.Type.ContainerLayout = if (container_decl.layout_token) |t| switch (token_tags[t]) { | |
| 5432 | .keyword_packed => .@"packed", | |
| 5433 | .keyword_extern => .@"extern", | |
| 5435 | 5434 | else => unreachable, |
| 5436 | } else std.builtin.Type.ContainerLayout.Auto; | |
| 5435 | } else .auto; | |
| 5437 | 5436 | |
| 5438 | 5437 | const result = try structDeclInner(gz, scope, node, container_decl, layout, container_decl.ast.arg); |
| 5439 | 5438 | return rvalue(gz, ri, result, node); |
| 5440 | 5439 | }, |
| 5441 | 5440 | .keyword_union => { |
| 5442 | const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) { | |
| 5443 | .keyword_packed => std.builtin.Type.ContainerLayout.Packed, | |
| 5444 | .keyword_extern => std.builtin.Type.ContainerLayout.Extern, | |
| 5441 | const layout: std.builtin.Type.ContainerLayout = if (container_decl.layout_token) |t| switch (token_tags[t]) { | |
| 5442 | .keyword_packed => .@"packed", | |
| 5443 | .keyword_extern => .@"extern", | |
| 5445 | 5444 | else => unreachable, |
| 5446 | } else std.builtin.Type.ContainerLayout.Auto; | |
| 5445 | } else .auto; | |
| 5447 | 5446 | |
| 5448 | 5447 | const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, container_decl.ast.arg, container_decl.ast.enum_token); |
| 5449 | 5448 | return rvalue(gz, ri, result, node); |
| ... | ... | @@ -8588,7 +8587,7 @@ fn numberLiteral(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index, source_node: |
| 8588 | 8587 | .positive => unsigned_float_number, |
| 8589 | 8588 | }; |
| 8590 | 8589 | // If the value fits into a f64 without losing any precision, store it that way. |
| 8591 | @setFloatMode(.Strict); | |
| 8590 | @setFloatMode(.strict); | |
| 8592 | 8591 | const smaller_float: f64 = @floatCast(float_number); |
| 8593 | 8592 | const bigger_again: f128 = smaller_float; |
| 8594 | 8593 | if (bigger_again == float_number) { |
lib/std/zig/Server.zig+3-3| ... | ... | @@ -250,18 +250,18 @@ fn bswap(x: anytype) @TypeOf(x) { |
| 250 | 250 | .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))), |
| 251 | 251 | .Int => return @byteSwap(x), |
| 252 | 252 | .Struct => |info| switch (info.layout) { |
| 253 | .Extern => { | |
| 253 | .@"extern" => { | |
| 254 | 254 | var result: T = undefined; |
| 255 | 255 | inline for (info.fields) |field| { |
| 256 | 256 | @field(result, field.name) = bswap(@field(x, field.name)); |
| 257 | 257 | } |
| 258 | 258 | return result; |
| 259 | 259 | }, |
| 260 | .Packed => { | |
| 260 | .@"packed" => { | |
| 261 | 261 | const I = info.backing_integer.?; |
| 262 | 262 | return @as(T, @bitCast(@byteSwap(@as(I, @bitCast(x))))); |
| 263 | 263 | }, |
| 264 | .Auto => @compileError("auto layout struct"), | |
| 264 | .auto => @compileError("auto layout struct"), | |
| 265 | 265 | }, |
| 266 | 266 | else => @compileError("bswap on type " ++ @typeName(T)), |
| 267 | 267 | } |
src/Compilation.zig+6-6| ... | ... | @@ -1201,7 +1201,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1201 | 1201 | const output_mode = options.config.output_mode; |
| 1202 | 1202 | const is_dyn_lib = switch (output_mode) { |
| 1203 | 1203 | .Obj, .Exe => false, |
| 1204 | .Lib => options.config.link_mode == .Dynamic, | |
| 1204 | .Lib => options.config.link_mode == .dynamic, | |
| 1205 | 1205 | }; |
| 1206 | 1206 | const is_exe_or_dyn_lib = switch (output_mode) { |
| 1207 | 1207 | .Obj => false, |
| ... | ... | @@ -1806,8 +1806,8 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1806 | 1806 | .{ .musl_crt_file = .scrt1_o }, |
| 1807 | 1807 | .{ .musl_crt_file = .rcrt1_o }, |
| 1808 | 1808 | switch (comp.config.link_mode) { |
| 1809 | .Static => .{ .musl_crt_file = .libc_a }, | |
| 1810 | .Dynamic => .{ .musl_crt_file = .libc_so }, | |
| 1809 | .static => .{ .musl_crt_file = .libc_a }, | |
| 1810 | .dynamic => .{ .musl_crt_file = .libc_so }, | |
| 1811 | 1811 | }, |
| 1812 | 1812 | }); |
| 1813 | 1813 | } |
| ... | ... | @@ -6087,7 +6087,7 @@ pub fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const |
| 6087 | 6087 | fn wantBuildLibCFromSource(comp: Compilation) bool { |
| 6088 | 6088 | const is_exe_or_dyn_lib = switch (comp.config.output_mode) { |
| 6089 | 6089 | .Obj => false, |
| 6090 | .Lib => comp.config.link_mode == .Dynamic, | |
| 6090 | .Lib => comp.config.link_mode == .dynamic, | |
| 6091 | 6091 | .Exe => true, |
| 6092 | 6092 | }; |
| 6093 | 6093 | const ofmt = comp.root_mod.resolved_target.result.ofmt; |
| ... | ... | @@ -6116,7 +6116,7 @@ fn wantBuildMinGWFromSource(comp: Compilation) bool { |
| 6116 | 6116 | fn wantBuildLibUnwindFromSource(comp: *Compilation) bool { |
| 6117 | 6117 | const is_exe_or_dyn_lib = switch (comp.config.output_mode) { |
| 6118 | 6118 | .Obj => false, |
| 6119 | .Lib => comp.config.link_mode == .Dynamic, | |
| 6119 | .Lib => comp.config.link_mode == .dynamic, | |
| 6120 | 6120 | .Exe => true, |
| 6121 | 6121 | }; |
| 6122 | 6122 | const ofmt = comp.root_mod.resolved_target.result.ofmt; |
| ... | ... | @@ -6310,7 +6310,7 @@ fn buildOutputFromZig( |
| 6310 | 6310 | |
| 6311 | 6311 | const config = try Config.resolve(.{ |
| 6312 | 6312 | .output_mode = output_mode, |
| 6313 | .link_mode = .Static, | |
| 6313 | .link_mode = .static, | |
| 6314 | 6314 | .resolved_target = comp.root_mod.resolved_target, |
| 6315 | 6315 | .is_test = false, |
| 6316 | 6316 | .have_zcu = true, |
src/Compilation/Config.zig+12-12| ... | ... | @@ -348,26 +348,26 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 348 | 348 | const link_mode = b: { |
| 349 | 349 | const explicitly_exe_or_dyn_lib = switch (options.output_mode) { |
| 350 | 350 | .Obj => false, |
| 351 | .Lib => (options.link_mode orelse .Static) == .Dynamic, | |
| 351 | .Lib => (options.link_mode orelse .static) == .dynamic, | |
| 352 | 352 | .Exe => true, |
| 353 | 353 | }; |
| 354 | 354 | |
| 355 | 355 | if (target_util.cannotDynamicLink(target)) { |
| 356 | if (options.link_mode == .Dynamic) return error.TargetCannotDynamicLink; | |
| 357 | break :b .Static; | |
| 356 | if (options.link_mode == .dynamic) return error.TargetCannotDynamicLink; | |
| 357 | break :b .static; | |
| 358 | 358 | } |
| 359 | 359 | if (explicitly_exe_or_dyn_lib and link_libc and |
| 360 | 360 | (target.isGnuLibC() or target_util.osRequiresLibC(target))) |
| 361 | 361 | { |
| 362 | if (options.link_mode == .Static) return error.LibCRequiresDynamicLinking; | |
| 363 | break :b .Dynamic; | |
| 362 | if (options.link_mode == .static) return error.LibCRequiresDynamicLinking; | |
| 363 | break :b .dynamic; | |
| 364 | 364 | } |
| 365 | 365 | // When creating a executable that links to system libraries, we |
| 366 | 366 | // require dynamic linking, but we must not link static libraries |
| 367 | 367 | // or object files dynamically! |
| 368 | 368 | if (options.any_dyn_libs and options.output_mode == .Exe) { |
| 369 | if (options.link_mode == .Static) return error.SharedLibrariesRequireDynamicLinking; | |
| 370 | break :b .Dynamic; | |
| 369 | if (options.link_mode == .static) return error.SharedLibrariesRequireDynamicLinking; | |
| 370 | break :b .dynamic; | |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | if (options.link_mode) |link_mode| break :b link_mode; |
| ... | ... | @@ -377,16 +377,16 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 377 | 377 | { |
| 378 | 378 | // If targeting the system's native ABI and the system's libc is |
| 379 | 379 | // musl, link dynamically by default. |
| 380 | break :b .Dynamic; | |
| 380 | break :b .dynamic; | |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | // Static is generally a better default. Fight me. |
| 384 | break :b .Static; | |
| 384 | break :b .static; | |
| 385 | 385 | }; |
| 386 | 386 | |
| 387 | 387 | const import_memory = options.import_memory orelse (options.output_mode == .Obj); |
| 388 | 388 | const export_memory = b: { |
| 389 | if (link_mode == .Dynamic) { | |
| 389 | if (link_mode == .dynamic) { | |
| 390 | 390 | if (options.export_memory == true) return error.ExportMemoryAndDynamicIncompatible; |
| 391 | 391 | break :b false; |
| 392 | 392 | } |
| ... | ... | @@ -397,7 +397,7 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 397 | 397 | const pie: bool = b: { |
| 398 | 398 | switch (options.output_mode) { |
| 399 | 399 | .Obj, .Exe => {}, |
| 400 | .Lib => if (link_mode == .Dynamic) { | |
| 400 | .Lib => if (link_mode == .dynamic) { | |
| 401 | 401 | if (options.pie == true) return error.DynamicLibraryPrecludesPie; |
| 402 | 402 | break :b false; |
| 403 | 403 | }, |
| ... | ... | @@ -467,7 +467,7 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 467 | 467 | if (rdynamic) break :b true; |
| 468 | 468 | break :b switch (options.output_mode) { |
| 469 | 469 | .Obj, .Exe => false, |
| 470 | .Lib => link_mode == .Dynamic, | |
| 470 | .Lib => link_mode == .dynamic, | |
| 471 | 471 | }; |
| 472 | 472 | }; |
| 473 | 473 |
src/InternPool.zig+35-36| ... | ... | @@ -2025,15 +2025,15 @@ pub const LoadedStructType = struct { |
| 2025 | 2025 | /// complicated logic. |
| 2026 | 2026 | pub fn knownNonOpv(s: @This(), ip: *InternPool) bool { |
| 2027 | 2027 | return switch (s.layout) { |
| 2028 | .Packed => false, | |
| 2029 | .Auto, .Extern => s.flagsPtr(ip).known_non_opv, | |
| 2028 | .@"packed" => false, | |
| 2029 | .auto, .@"extern" => s.flagsPtr(ip).known_non_opv, | |
| 2030 | 2030 | }; |
| 2031 | 2031 | } |
| 2032 | 2032 | |
| 2033 | 2033 | /// The returned pointer expires with any addition to the `InternPool`. |
| 2034 | 2034 | /// Asserts the struct is not packed. |
| 2035 | 2035 | pub fn flagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStruct.Flags { |
| 2036 | assert(self.layout != .Packed); | |
| 2036 | assert(self.layout != .@"packed"); | |
| 2037 | 2037 | const flags_field_index = std.meta.fieldIndex(Tag.TypeStruct, "flags").?; |
| 2038 | 2038 | return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]); |
| 2039 | 2039 | } |
| ... | ... | @@ -2041,13 +2041,13 @@ pub const LoadedStructType = struct { |
| 2041 | 2041 | /// The returned pointer expires with any addition to the `InternPool`. |
| 2042 | 2042 | /// Asserts that the struct is packed. |
| 2043 | 2043 | pub fn packedFlagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStructPacked.Flags { |
| 2044 | assert(self.layout == .Packed); | |
| 2044 | assert(self.layout == .@"packed"); | |
| 2045 | 2045 | const flags_field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?; |
| 2046 | 2046 | return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]); |
| 2047 | 2047 | } |
| 2048 | 2048 | |
| 2049 | 2049 | pub fn assumeRuntimeBitsIfFieldTypesWip(s: @This(), ip: *InternPool) bool { |
| 2050 | if (s.layout == .Packed) return false; | |
| 2050 | if (s.layout == .@"packed") return false; | |
| 2051 | 2051 | const flags_ptr = s.flagsPtr(ip); |
| 2052 | 2052 | if (flags_ptr.field_types_wip) { |
| 2053 | 2053 | flags_ptr.assumed_runtime_bits = true; |
| ... | ... | @@ -2057,7 +2057,7 @@ pub const LoadedStructType = struct { |
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | 2059 | pub fn setTypesWip(s: @This(), ip: *InternPool) bool { |
| 2060 | if (s.layout == .Packed) return false; | |
| 2060 | if (s.layout == .@"packed") return false; | |
| 2061 | 2061 | const flags_ptr = s.flagsPtr(ip); |
| 2062 | 2062 | if (flags_ptr.field_types_wip) return true; |
| 2063 | 2063 | flags_ptr.field_types_wip = true; |
| ... | ... | @@ -2065,12 +2065,12 @@ pub const LoadedStructType = struct { |
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | pub fn clearTypesWip(s: @This(), ip: *InternPool) void { |
| 2068 | if (s.layout == .Packed) return; | |
| 2068 | if (s.layout == .@"packed") return; | |
| 2069 | 2069 | s.flagsPtr(ip).field_types_wip = false; |
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | pub fn setLayoutWip(s: @This(), ip: *InternPool) bool { |
| 2073 | if (s.layout == .Packed) return false; | |
| 2073 | if (s.layout == .@"packed") return false; | |
| 2074 | 2074 | const flags_ptr = s.flagsPtr(ip); |
| 2075 | 2075 | if (flags_ptr.layout_wip) return true; |
| 2076 | 2076 | flags_ptr.layout_wip = true; |
| ... | ... | @@ -2078,12 +2078,12 @@ pub const LoadedStructType = struct { |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | pub fn clearLayoutWip(s: @This(), ip: *InternPool) void { |
| 2081 | if (s.layout == .Packed) return; | |
| 2081 | if (s.layout == .@"packed") return; | |
| 2082 | 2082 | s.flagsPtr(ip).layout_wip = false; |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | pub fn setAlignmentWip(s: @This(), ip: *InternPool) bool { |
| 2086 | if (s.layout == .Packed) return false; | |
| 2086 | if (s.layout == .@"packed") return false; | |
| 2087 | 2087 | const flags_ptr = s.flagsPtr(ip); |
| 2088 | 2088 | if (flags_ptr.alignment_wip) return true; |
| 2089 | 2089 | flags_ptr.alignment_wip = true; |
| ... | ... | @@ -2091,19 +2091,19 @@ pub const LoadedStructType = struct { |
| 2091 | 2091 | } |
| 2092 | 2092 | |
| 2093 | 2093 | pub fn clearAlignmentWip(s: @This(), ip: *InternPool) void { |
| 2094 | if (s.layout == .Packed) return; | |
| 2094 | if (s.layout == .@"packed") return; | |
| 2095 | 2095 | s.flagsPtr(ip).alignment_wip = false; |
| 2096 | 2096 | } |
| 2097 | 2097 | |
| 2098 | 2098 | pub fn setInitsWip(s: @This(), ip: *InternPool) bool { |
| 2099 | 2099 | switch (s.layout) { |
| 2100 | .Packed => { | |
| 2100 | .@"packed" => { | |
| 2101 | 2101 | const flag = &s.packedFlagsPtr(ip).field_inits_wip; |
| 2102 | 2102 | if (flag.*) return true; |
| 2103 | 2103 | flag.* = true; |
| 2104 | 2104 | return false; |
| 2105 | 2105 | }, |
| 2106 | .Auto, .Extern => { | |
| 2106 | .auto, .@"extern" => { | |
| 2107 | 2107 | const flag = &s.flagsPtr(ip).field_inits_wip; |
| 2108 | 2108 | if (flag.*) return true; |
| 2109 | 2109 | flag.* = true; |
| ... | ... | @@ -2114,13 +2114,13 @@ pub const LoadedStructType = struct { |
| 2114 | 2114 | |
| 2115 | 2115 | pub fn clearInitsWip(s: @This(), ip: *InternPool) void { |
| 2116 | 2116 | switch (s.layout) { |
| 2117 | .Packed => s.packedFlagsPtr(ip).field_inits_wip = false, | |
| 2118 | .Auto, .Extern => s.flagsPtr(ip).field_inits_wip = false, | |
| 2117 | .@"packed" => s.packedFlagsPtr(ip).field_inits_wip = false, | |
| 2118 | .auto, .@"extern" => s.flagsPtr(ip).field_inits_wip = false, | |
| 2119 | 2119 | } |
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | 2122 | pub fn setFullyResolved(s: @This(), ip: *InternPool) bool { |
| 2123 | if (s.layout == .Packed) return true; | |
| 2123 | if (s.layout == .@"packed") return true; | |
| 2124 | 2124 | const flags_ptr = s.flagsPtr(ip); |
| 2125 | 2125 | if (flags_ptr.fully_resolved) return true; |
| 2126 | 2126 | flags_ptr.fully_resolved = true; |
| ... | ... | @@ -2134,7 +2134,7 @@ pub const LoadedStructType = struct { |
| 2134 | 2134 | /// The returned pointer expires with any addition to the `InternPool`. |
| 2135 | 2135 | /// Asserts the struct is not packed. |
| 2136 | 2136 | pub fn size(self: @This(), ip: *InternPool) *u32 { |
| 2137 | assert(self.layout != .Packed); | |
| 2137 | assert(self.layout != .@"packed"); | |
| 2138 | 2138 | const size_field_index = std.meta.fieldIndex(Tag.TypeStruct, "size").?; |
| 2139 | 2139 | return @ptrCast(&ip.extra.items[self.extra_index + size_field_index]); |
| 2140 | 2140 | } |
| ... | ... | @@ -2144,14 +2144,14 @@ pub const LoadedStructType = struct { |
| 2144 | 2144 | /// set to `none` until the layout is resolved. |
| 2145 | 2145 | /// Asserts the struct is packed. |
| 2146 | 2146 | pub fn backingIntType(s: @This(), ip: *const InternPool) *Index { |
| 2147 | assert(s.layout == .Packed); | |
| 2147 | assert(s.layout == .@"packed"); | |
| 2148 | 2148 | const field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "backing_int_ty").?; |
| 2149 | 2149 | return @ptrCast(&ip.extra.items[s.extra_index + field_index]); |
| 2150 | 2150 | } |
| 2151 | 2151 | |
| 2152 | 2152 | /// Asserts the struct is not packed. |
| 2153 | 2153 | pub fn setZirIndex(s: @This(), ip: *InternPool, new_zir_index: TrackedInst.Index.Optional) void { |
| 2154 | assert(s.layout != .Packed); | |
| 2154 | assert(s.layout != .@"packed"); | |
| 2155 | 2155 | const field_index = std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?; |
| 2156 | 2156 | ip.extra.items[s.extra_index + field_index] = @intFromEnum(new_zir_index); |
| 2157 | 2157 | } |
| ... | ... | @@ -2163,31 +2163,31 @@ pub const LoadedStructType = struct { |
| 2163 | 2163 | |
| 2164 | 2164 | pub fn haveFieldInits(s: @This(), ip: *const InternPool) bool { |
| 2165 | 2165 | return switch (s.layout) { |
| 2166 | .Packed => s.packedFlagsPtr(ip).inits_resolved, | |
| 2167 | .Auto, .Extern => s.flagsPtr(ip).inits_resolved, | |
| 2166 | .@"packed" => s.packedFlagsPtr(ip).inits_resolved, | |
| 2167 | .auto, .@"extern" => s.flagsPtr(ip).inits_resolved, | |
| 2168 | 2168 | }; |
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | 2171 | pub fn setHaveFieldInits(s: @This(), ip: *InternPool) void { |
| 2172 | 2172 | switch (s.layout) { |
| 2173 | .Packed => s.packedFlagsPtr(ip).inits_resolved = true, | |
| 2174 | .Auto, .Extern => s.flagsPtr(ip).inits_resolved = true, | |
| 2173 | .@"packed" => s.packedFlagsPtr(ip).inits_resolved = true, | |
| 2174 | .auto, .@"extern" => s.flagsPtr(ip).inits_resolved = true, | |
| 2175 | 2175 | } |
| 2176 | 2176 | } |
| 2177 | 2177 | |
| 2178 | 2178 | pub fn haveLayout(s: @This(), ip: *InternPool) bool { |
| 2179 | 2179 | return switch (s.layout) { |
| 2180 | .Packed => s.backingIntType(ip).* != .none, | |
| 2181 | .Auto, .Extern => s.flagsPtr(ip).layout_resolved, | |
| 2180 | .@"packed" => s.backingIntType(ip).* != .none, | |
| 2181 | .auto, .@"extern" => s.flagsPtr(ip).layout_resolved, | |
| 2182 | 2182 | }; |
| 2183 | 2183 | } |
| 2184 | 2184 | |
| 2185 | 2185 | pub fn isTuple(s: @This(), ip: *InternPool) bool { |
| 2186 | return s.layout != .Packed and s.flagsPtr(ip).is_tuple; | |
| 2186 | return s.layout != .@"packed" and s.flagsPtr(ip).is_tuple; | |
| 2187 | 2187 | } |
| 2188 | 2188 | |
| 2189 | 2189 | pub fn hasReorderedFields(s: @This()) bool { |
| 2190 | return s.layout == .Auto; | |
| 2190 | return s.layout == .auto; | |
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | 2193 | pub const RuntimeOrderIterator = struct { |
| ... | ... | @@ -2221,7 +2221,7 @@ pub const LoadedStructType = struct { |
| 2221 | 2221 | /// May or may not include zero-bit fields. |
| 2222 | 2222 | /// Asserts the struct is not packed. |
| 2223 | 2223 | pub fn iterateRuntimeOrder(s: @This(), ip: *InternPool) RuntimeOrderIterator { |
| 2224 | assert(s.layout != .Packed); | |
| 2224 | assert(s.layout != .@"packed"); | |
| 2225 | 2225 | return .{ |
| 2226 | 2226 | .ip = ip, |
| 2227 | 2227 | .field_index = 0, |
| ... | ... | @@ -2239,7 +2239,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { |
| 2239 | 2239 | .decl = .none, |
| 2240 | 2240 | .namespace = .none, |
| 2241 | 2241 | .zir_index = .none, |
| 2242 | .layout = .Auto, | |
| 2242 | .layout = .auto, | |
| 2243 | 2243 | .field_names = .{ .start = 0, .len = 0 }, |
| 2244 | 2244 | .field_types = .{ .start = 0, .len = 0 }, |
| 2245 | 2245 | .field_inits = .{ .start = 0, .len = 0 }, |
| ... | ... | @@ -2314,7 +2314,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { |
| 2314 | 2314 | .decl = extra.data.decl.toOptional(), |
| 2315 | 2315 | .namespace = namespace, |
| 2316 | 2316 | .zir_index = extra.data.zir_index.toOptional(), |
| 2317 | .layout = if (extra.data.flags.is_extern) .Extern else .Auto, | |
| 2317 | .layout = if (extra.data.flags.is_extern) .@"extern" else .auto, | |
| 2318 | 2318 | .field_names = names, |
| 2319 | 2319 | .field_types = field_types, |
| 2320 | 2320 | .field_inits = inits, |
| ... | ... | @@ -2367,7 +2367,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { |
| 2367 | 2367 | .decl = extra.data.decl.toOptional(), |
| 2368 | 2368 | .namespace = extra.data.namespace, |
| 2369 | 2369 | .zir_index = extra.data.zir_index.toOptional(), |
| 2370 | .layout = .Packed, | |
| 2370 | .layout = .@"packed", | |
| 2371 | 2371 | .field_names = field_names, |
| 2372 | 2372 | .field_types = field_types, |
| 2373 | 2373 | .field_inits = field_inits, |
| ... | ... | @@ -4455,7 +4455,6 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { |
| 4455 | 4455 | } else .{ .start = 0, .len = 0 } }, |
| 4456 | 4456 | } }; |
| 4457 | 4457 | } }, |
| 4458 | ||
| 4459 | 4458 | .type_struct_anon => .{ .anon_struct_type = extraTypeStructAnon(ip, data) }, |
| 4460 | 4459 | .type_tuple_anon => .{ .anon_struct_type = extraTypeTupleAnon(ip, data) }, |
| 4461 | 4460 | .type_union => .{ .union_type = ns: { |
| ... | ... | @@ -6009,9 +6008,9 @@ pub fn getStructType( |
| 6009 | 6008 | }; |
| 6010 | 6009 | |
| 6011 | 6010 | const is_extern = switch (ini.layout) { |
| 6012 | .Auto => false, | |
| 6013 | .Extern => true, | |
| 6014 | .Packed => { | |
| 6011 | .auto => false, | |
| 6012 | .@"extern" => true, | |
| 6013 | .@"packed" => { | |
| 6015 | 6014 | try ip.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.TypeStructPacked).Struct.fields.len + |
| 6016 | 6015 | // TODO: fmt bug |
| 6017 | 6016 | // zig fmt: off |
| ... | ... | @@ -6140,7 +6139,7 @@ pub fn getStructType( |
| 6140 | 6139 | if (ini.any_comptime_fields) { |
| 6141 | 6140 | ip.extra.appendNTimesAssumeCapacity(0, comptime_elements_len); |
| 6142 | 6141 | } |
| 6143 | if (ini.layout == .Auto) { | |
| 6142 | if (ini.layout == .auto) { | |
| 6144 | 6143 | ip.extra.appendNTimesAssumeCapacity(@intFromEnum(LoadedStructType.RuntimeOrder.unresolved), ini.fields_len); |
| 6145 | 6144 | } |
| 6146 | 6145 | ip.extra.appendNTimesAssumeCapacity(std.math.maxInt(u32), ini.fields_len); |
src/Module.zig+9-9| ... | ... | @@ -279,7 +279,7 @@ pub const Export = struct { |
| 279 | 279 | |
| 280 | 280 | pub const Options = struct { |
| 281 | 281 | name: InternPool.NullTerminatedString, |
| 282 | linkage: std.builtin.GlobalLinkage = .Strong, | |
| 282 | linkage: std.builtin.GlobalLinkage = .strong, | |
| 283 | 283 | section: InternPool.OptionalNullTerminatedString = .none, |
| 284 | 284 | visibility: std.builtin.SymbolVisibility = .default, |
| 285 | 285 | }; |
| ... | ... | @@ -3310,7 +3310,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa |
| 3310 | 3310 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 3311 | 3311 | assert(!small.has_captures_len); |
| 3312 | 3312 | assert(!small.has_backing_int); |
| 3313 | assert(small.layout == .Auto); | |
| 3313 | assert(small.layout == .auto); | |
| 3314 | 3314 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len; |
| 3315 | 3315 | const fields_len = if (small.has_fields_len) blk: { |
| 3316 | 3316 | const fields_len = file.zir.extra[extra_index]; |
| ... | ... | @@ -3327,7 +3327,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa |
| 3327 | 3327 | |
| 3328 | 3328 | const tracked_inst = try ip.trackZir(gpa, file, .main_struct_inst); |
| 3329 | 3329 | const wip_ty = switch (try ip.getStructType(gpa, .{ |
| 3330 | .layout = .Auto, | |
| 3330 | .layout = .auto, | |
| 3331 | 3331 | .fields_len = fields_len, |
| 3332 | 3332 | .known_non_opv = small.known_non_opv, |
| 3333 | 3333 | .requires_comptime = if (small.known_comptime_only) .yes else .unknown, |
| ... | ... | @@ -5969,7 +5969,7 @@ pub fn typeToStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType { |
| 5969 | 5969 | |
| 5970 | 5970 | pub fn typeToPackedStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType { |
| 5971 | 5971 | const s = mod.typeToStruct(ty) orelse return null; |
| 5972 | if (s.layout != .Packed) return null; | |
| 5972 | if (s.layout != .@"packed") return null; | |
| 5973 | 5973 | return s; |
| 5974 | 5974 | } |
| 5975 | 5975 | |
| ... | ... | @@ -6185,18 +6185,18 @@ pub fn structFieldAlignment( |
| 6185 | 6185 | field_ty: Type, |
| 6186 | 6186 | layout: std.builtin.Type.ContainerLayout, |
| 6187 | 6187 | ) Alignment { |
| 6188 | assert(layout != .Packed); | |
| 6188 | assert(layout != .@"packed"); | |
| 6189 | 6189 | if (explicit_alignment != .none) return explicit_alignment; |
| 6190 | 6190 | switch (layout) { |
| 6191 | .Packed => unreachable, | |
| 6192 | .Auto => { | |
| 6191 | .@"packed" => unreachable, | |
| 6192 | .auto => { | |
| 6193 | 6193 | if (mod.getTarget().ofmt == .c) { |
| 6194 | 6194 | return structFieldAlignmentExtern(mod, field_ty); |
| 6195 | 6195 | } else { |
| 6196 | 6196 | return field_ty.abiAlignment(mod); |
| 6197 | 6197 | } |
| 6198 | 6198 | }, |
| 6199 | .Extern => return structFieldAlignmentExtern(mod, field_ty), | |
| 6199 | .@"extern" => return structFieldAlignmentExtern(mod, field_ty), | |
| 6200 | 6200 | } |
| 6201 | 6201 | } |
| 6202 | 6202 | |
| ... | ... | @@ -6224,7 +6224,7 @@ pub fn structPackedFieldBitOffset( |
| 6224 | 6224 | field_index: u32, |
| 6225 | 6225 | ) u16 { |
| 6226 | 6226 | const ip = &mod.intern_pool; |
| 6227 | assert(struct_type.layout == .Packed); | |
| 6227 | assert(struct_type.layout == .@"packed"); | |
| 6228 | 6228 | assert(struct_type.haveLayout(ip)); |
| 6229 | 6229 | var bit_sum: u64 = 0; |
| 6230 | 6230 | for (0..struct_type.field_types.len) |i| { |
src/Package/Module.zig+1-1| ... | ... | @@ -178,7 +178,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 178 | 178 | return error.PieRequiresPic; |
| 179 | 179 | break :b true; |
| 180 | 180 | } |
| 181 | if (options.global.link_mode == .Dynamic) { | |
| 181 | if (options.global.link_mode == .dynamic) { | |
| 182 | 182 | if (options.inherited.pic == false) |
| 183 | 183 | return error.DynamicLinkingRequiresPic; |
| 184 | 184 | break :b true; |
src/Sema.zig+117-117| ... | ... | @@ -357,7 +357,7 @@ pub const Block = struct { |
| 357 | 357 | want_safety: ?bool = null, |
| 358 | 358 | |
| 359 | 359 | /// What mode to generate float operations in, set by @setFloatMode |
| 360 | float_mode: std.builtin.FloatMode = .Strict, | |
| 360 | float_mode: std.builtin.FloatMode = .strict, | |
| 361 | 361 | |
| 362 | 362 | c_import_buf: ?*std.ArrayList(u8) = null, |
| 363 | 363 | |
| ... | ... | @@ -686,7 +686,7 @@ pub const Block = struct { |
| 686 | 686 | const sema = block.sema; |
| 687 | 687 | const mod = sema.mod; |
| 688 | 688 | return block.addInst(.{ |
| 689 | .tag = if (block.float_mode == .Optimized) .cmp_vector_optimized else .cmp_vector, | |
| 689 | .tag = if (block.float_mode == .optimized) .cmp_vector_optimized else .cmp_vector, | |
| 690 | 690 | .data = .{ .ty_pl = .{ |
| 691 | 691 | .ty = Air.internedToRef((try mod.vectorType(.{ |
| 692 | 692 | .len = sema.typeOf(lhs).vectorLen(mod), |
| ... | ... | @@ -1020,10 +1020,10 @@ fn analyzeBodyInner( |
| 1020 | 1020 | .field_call => try sema.zirCall(block, inst, .field), |
| 1021 | 1021 | .cmp_lt => try sema.zirCmp(block, inst, .lt), |
| 1022 | 1022 | .cmp_lte => try sema.zirCmp(block, inst, .lte), |
| 1023 | .cmp_eq => try sema.zirCmpEq(block, inst, .eq, Air.Inst.Tag.fromCmpOp(.eq, block.float_mode == .Optimized)), | |
| 1023 | .cmp_eq => try sema.zirCmpEq(block, inst, .eq, Air.Inst.Tag.fromCmpOp(.eq, block.float_mode == .optimized)), | |
| 1024 | 1024 | .cmp_gte => try sema.zirCmp(block, inst, .gte), |
| 1025 | 1025 | .cmp_gt => try sema.zirCmp(block, inst, .gt), |
| 1026 | .cmp_neq => try sema.zirCmpEq(block, inst, .neq, Air.Inst.Tag.fromCmpOp(.neq, block.float_mode == .Optimized)), | |
| 1026 | .cmp_neq => try sema.zirCmpEq(block, inst, .neq, Air.Inst.Tag.fromCmpOp(.neq, block.float_mode == .optimized)), | |
| 1027 | 1027 | .decl_ref => try sema.zirDeclRef(block, inst), |
| 1028 | 1028 | .decl_val => try sema.zirDeclVal(block, inst), |
| 1029 | 1029 | .load => try sema.zirLoad(block, inst), |
| ... | ... | @@ -3236,7 +3236,7 @@ fn zirUnionDecl( |
| 3236 | 3236 | .status = .none, |
| 3237 | 3237 | .runtime_tag = if (small.has_tag_type or small.auto_enum_tag) |
| 3238 | 3238 | .tagged |
| 3239 | else if (small.layout != .Auto) | |
| 3239 | else if (small.layout != .auto) | |
| 3240 | 3240 | .none |
| 3241 | 3241 | else switch (block.wantSafety()) { |
| 3242 | 3242 | true => .safety, |
| ... | ... | @@ -6274,7 +6274,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 6274 | 6274 | .needed_comptime_reason = "export target must be comptime-known", |
| 6275 | 6275 | }); |
| 6276 | 6276 | const options = try sema.resolveExportOptions(block, options_src, extra.options); |
| 6277 | if (options.linkage == .Internal) | |
| 6277 | if (options.linkage == .internal) | |
| 6278 | 6278 | return; |
| 6279 | 6279 | if (operand.val.getFunction(mod)) |function| { |
| 6280 | 6280 | const decl_index = function.owner_decl; |
| ... | ... | @@ -6301,7 +6301,7 @@ pub fn analyzeExport( |
| 6301 | 6301 | const gpa = sema.gpa; |
| 6302 | 6302 | const mod = sema.mod; |
| 6303 | 6303 | |
| 6304 | if (options.linkage == .Internal) | |
| 6304 | if (options.linkage == .internal) | |
| 6305 | 6305 | return; |
| 6306 | 6306 | |
| 6307 | 6307 | try mod.ensureDeclAnalyzed(exported_decl_index); |
| ... | ... | @@ -6450,8 +6450,8 @@ fn zirFence(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) Co |
| 6450 | 6450 | .needed_comptime_reason = "atomic order of @fence must be comptime-known", |
| 6451 | 6451 | }); |
| 6452 | 6452 | |
| 6453 | if (@intFromEnum(order) < @intFromEnum(std.builtin.AtomicOrder.Acquire)) { | |
| 6454 | return sema.fail(block, order_src, "atomic ordering must be Acquire or stricter", .{}); | |
| 6453 | if (@intFromEnum(order) < @intFromEnum(std.builtin.AtomicOrder.acquire)) { | |
| 6454 | return sema.fail(block, order_src, "atomic ordering must be acquire or stricter", .{}); | |
| 6455 | 6455 | } |
| 6456 | 6456 | |
| 6457 | 6457 | _ = try block.addInst(.{ |
| ... | ... | @@ -10264,7 +10264,7 @@ fn intCast( |
| 10264 | 10264 | const ok = if (is_vector) ok: { |
| 10265 | 10265 | const is_in_range = try block.addCmpVector(diff_unsigned, dest_range, .lte); |
| 10266 | 10266 | const all_in_range = try block.addInst(.{ |
| 10267 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, | |
| 10267 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, | |
| 10268 | 10268 | .data = .{ .reduce = .{ |
| 10269 | 10269 | .operand = is_in_range, |
| 10270 | 10270 | .operation = .And, |
| ... | ... | @@ -10281,7 +10281,7 @@ fn intCast( |
| 10281 | 10281 | const ok = if (is_vector) ok: { |
| 10282 | 10282 | const is_in_range = try block.addCmpVector(diff, dest_max, .lte); |
| 10283 | 10283 | const all_in_range = try block.addInst(.{ |
| 10284 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, | |
| 10284 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, | |
| 10285 | 10285 | .data = .{ .reduce = .{ |
| 10286 | 10286 | .operand = is_in_range, |
| 10287 | 10287 | .operation = .And, |
| ... | ... | @@ -10303,7 +10303,7 @@ fn intCast( |
| 10303 | 10303 | const zero_inst = Air.internedToRef(zero_val.toIntern()); |
| 10304 | 10304 | const is_in_range = try block.addCmpVector(operand, zero_inst, .gte); |
| 10305 | 10305 | const all_in_range = try block.addInst(.{ |
| 10306 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, | |
| 10306 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, | |
| 10307 | 10307 | .data = .{ .reduce = .{ |
| 10308 | 10308 | .operand = is_in_range, |
| 10309 | 10309 | .operation = .And, |
| ... | ... | @@ -10380,7 +10380,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10380 | 10380 | }; |
| 10381 | 10381 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10382 | 10382 | }, |
| 10383 | .Struct, .Union => if (dest_ty.containerLayout(mod) == .Auto) { | |
| 10383 | .Struct, .Union => if (dest_ty.containerLayout(mod) == .auto) { | |
| 10384 | 10384 | const container = switch (dest_ty.zigTypeTag(mod)) { |
| 10385 | 10385 | .Struct => "struct", |
| 10386 | 10386 | .Union => "union", |
| ... | ... | @@ -10443,7 +10443,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10443 | 10443 | }; |
| 10444 | 10444 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10445 | 10445 | }, |
| 10446 | .Struct, .Union => if (operand_ty.containerLayout(mod) == .Auto) { | |
| 10446 | .Struct, .Union => if (operand_ty.containerLayout(mod) == .auto) { | |
| 10447 | 10447 | const container = switch (operand_ty.zigTypeTag(mod)) { |
| 10448 | 10448 | .Struct => "struct", |
| 10449 | 10449 | .Union => "union", |
| ... | ... | @@ -12530,7 +12530,7 @@ fn analyzeSwitchRuntimeBlock( |
| 12530 | 12530 | cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items)); |
| 12531 | 12531 | } else { |
| 12532 | 12532 | for (items) |item| { |
| 12533 | const cmp_ok = try case_block.addBinOp(if (case_block.float_mode == .Optimized) .cmp_eq_optimized else .cmp_eq, operand, item); | |
| 12533 | const cmp_ok = try case_block.addBinOp(if (case_block.float_mode == .optimized) .cmp_eq_optimized else .cmp_eq, operand, item); | |
| 12534 | 12534 | if (any_ok != .none) { |
| 12535 | 12535 | any_ok = try case_block.addBinOp(.bool_or, any_ok, cmp_ok); |
| 12536 | 12536 | } else { |
| ... | ... | @@ -12549,12 +12549,12 @@ fn analyzeSwitchRuntimeBlock( |
| 12549 | 12549 | |
| 12550 | 12550 | // operand >= first and operand <= last |
| 12551 | 12551 | const range_first_ok = try case_block.addBinOp( |
| 12552 | if (case_block.float_mode == .Optimized) .cmp_gte_optimized else .cmp_gte, | |
| 12552 | if (case_block.float_mode == .optimized) .cmp_gte_optimized else .cmp_gte, | |
| 12553 | 12553 | operand, |
| 12554 | 12554 | item_first, |
| 12555 | 12555 | ); |
| 12556 | 12556 | const range_last_ok = try case_block.addBinOp( |
| 12557 | if (case_block.float_mode == .Optimized) .cmp_lte_optimized else .cmp_lte, | |
| 12557 | if (case_block.float_mode == .optimized) .cmp_lte_optimized else .cmp_lte, | |
| 12558 | 12558 | operand, |
| 12559 | 12559 | item_last, |
| 12560 | 12560 | ); |
| ... | ... | @@ -13904,7 +13904,7 @@ fn zirShl( |
| 13904 | 13904 | const ov_bit = try sema.tupleFieldValByIndex(block, src, op_ov, 1, op_ov_tuple_ty); |
| 13905 | 13905 | const any_ov_bit = if (lhs_ty.zigTypeTag(mod) == .Vector) |
| 13906 | 13906 | try block.addInst(.{ |
| 13907 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, | |
| 13907 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, | |
| 13908 | 13908 | .data = .{ .reduce = .{ |
| 13909 | 13909 | .operand = ov_bit, |
| 13910 | 13910 | .operation = .Or, |
| ... | ... | @@ -14044,7 +14044,7 @@ fn zirShr( |
| 14044 | 14044 | const ok = if (rhs_ty.zigTypeTag(mod) == .Vector) ok: { |
| 14045 | 14045 | const eql = try block.addCmpVector(lhs, back, .eq); |
| 14046 | 14046 | break :ok try block.addInst(.{ |
| 14047 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, | |
| 14047 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, | |
| 14048 | 14048 | .data = .{ .reduce = .{ |
| 14049 | 14049 | .operand = eql, |
| 14050 | 14050 | .operation = .And, |
| ... | ... | @@ -14811,7 +14811,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 14811 | 14811 | return Air.internedToRef((try rhs_val.floatNeg(rhs_ty, sema.arena, mod)).toIntern()); |
| 14812 | 14812 | } |
| 14813 | 14813 | try sema.requireRuntimeBlock(block, src, null); |
| 14814 | return block.addUnOp(if (block.float_mode == .Optimized) .neg_optimized else .neg, rhs); | |
| 14814 | return block.addUnOp(if (block.float_mode == .optimized) .neg_optimized else .neg, rhs); | |
| 14815 | 14815 | } |
| 14816 | 14816 | |
| 14817 | 14817 | const lhs = Air.internedToRef((try sema.splat(rhs_ty, try mod.intValue(rhs_scalar_ty, 0))).toIntern()); |
| ... | ... | @@ -15018,8 +15018,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 15018 | 15018 | } |
| 15019 | 15019 | break :blk Air.Inst.Tag.div_trunc; |
| 15020 | 15020 | } else switch (block.float_mode) { |
| 15021 | .Optimized => Air.Inst.Tag.div_float_optimized, | |
| 15022 | .Strict => Air.Inst.Tag.div_float, | |
| 15021 | .optimized => Air.Inst.Tag.div_float_optimized, | |
| 15022 | .strict => Air.Inst.Tag.div_float, | |
| 15023 | 15023 | }; |
| 15024 | 15024 | return block.addBinOp(air_tag, casted_lhs, casted_rhs); |
| 15025 | 15025 | } |
| ... | ... | @@ -15142,8 +15142,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15142 | 15142 | const eql = try block.addCmpVector(result, floored, .eq); |
| 15143 | 15143 | break :ok try block.addInst(.{ |
| 15144 | 15144 | .tag = switch (block.float_mode) { |
| 15145 | .Strict => .reduce, | |
| 15146 | .Optimized => .reduce_optimized, | |
| 15145 | .strict => .reduce, | |
| 15146 | .optimized => .reduce_optimized, | |
| 15147 | 15147 | }, |
| 15148 | 15148 | .data = .{ .reduce = .{ |
| 15149 | 15149 | .operand = eql, |
| ... | ... | @@ -15152,8 +15152,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 15152 | 15152 | }); |
| 15153 | 15153 | } else { |
| 15154 | 15154 | const is_in_range = try block.addBinOp(switch (block.float_mode) { |
| 15155 | .Strict => .cmp_eq, | |
| 15156 | .Optimized => .cmp_eq_optimized, | |
| 15155 | .strict => .cmp_eq, | |
| 15156 | .optimized => .cmp_eq_optimized, | |
| 15157 | 15157 | }, result, floored); |
| 15158 | 15158 | break :ok is_in_range; |
| 15159 | 15159 | } |
| ... | ... | @@ -15503,7 +15503,7 @@ fn addDivByZeroSafety( |
| 15503 | 15503 | is_int: bool, |
| 15504 | 15504 | ) CompileError!void { |
| 15505 | 15505 | // Strict IEEE floats have well-defined division by zero. |
| 15506 | if (!is_int and block.float_mode == .Strict) return; | |
| 15506 | if (!is_int and block.float_mode == .strict) return; | |
| 15507 | 15507 | |
| 15508 | 15508 | // If rhs was comptime-known to be zero a compile error would have been |
| 15509 | 15509 | // emitted above. |
| ... | ... | @@ -15535,8 +15535,8 @@ fn addDivByZeroSafety( |
| 15535 | 15535 | fn airTag(block: *Block, is_int: bool, normal: Air.Inst.Tag, optimized: Air.Inst.Tag) Air.Inst.Tag { |
| 15536 | 15536 | if (is_int) return normal; |
| 15537 | 15537 | return switch (block.float_mode) { |
| 15538 | .Strict => normal, | |
| 15539 | .Optimized => optimized, | |
| 15538 | .strict => normal, | |
| 15539 | .optimized => optimized, | |
| 15540 | 15540 | }; |
| 15541 | 15541 | } |
| 15542 | 15542 | |
| ... | ... | @@ -16228,7 +16228,7 @@ fn analyzeArithmetic( |
| 16228 | 16228 | return casted_lhs; |
| 16229 | 16229 | } |
| 16230 | 16230 | } |
| 16231 | const air_tag: Air.Inst.Tag = if (block.float_mode == .Optimized) .add_optimized else .add; | |
| 16231 | const air_tag: Air.Inst.Tag = if (block.float_mode == .optimized) .add_optimized else .add; | |
| 16232 | 16232 | if (maybe_lhs_val) |lhs_val| { |
| 16233 | 16233 | if (lhs_val.isUndef(mod)) { |
| 16234 | 16234 | if (is_int) { |
| ... | ... | @@ -16330,7 +16330,7 @@ fn analyzeArithmetic( |
| 16330 | 16330 | return casted_lhs; |
| 16331 | 16331 | } |
| 16332 | 16332 | } |
| 16333 | const air_tag: Air.Inst.Tag = if (block.float_mode == .Optimized) .sub_optimized else .sub; | |
| 16333 | const air_tag: Air.Inst.Tag = if (block.float_mode == .optimized) .sub_optimized else .sub; | |
| 16334 | 16334 | if (maybe_lhs_val) |lhs_val| { |
| 16335 | 16335 | if (lhs_val.isUndef(mod)) { |
| 16336 | 16336 | if (is_int) { |
| ... | ... | @@ -16448,7 +16448,7 @@ fn analyzeArithmetic( |
| 16448 | 16448 | } |
| 16449 | 16449 | } |
| 16450 | 16450 | } |
| 16451 | const air_tag: Air.Inst.Tag = if (block.float_mode == .Optimized) .mul_optimized else .mul; | |
| 16451 | const air_tag: Air.Inst.Tag = if (block.float_mode == .optimized) .mul_optimized else .mul; | |
| 16452 | 16452 | if (maybe_rhs_val) |rhs_val| { |
| 16453 | 16453 | if (rhs_val.isUndef(mod)) { |
| 16454 | 16454 | if (is_int) { |
| ... | ... | @@ -16625,7 +16625,7 @@ fn analyzeArithmetic( |
| 16625 | 16625 | const ov_bit = try sema.tupleFieldValByIndex(block, src, op_ov, 1, op_ov_tuple_ty); |
| 16626 | 16626 | const any_ov_bit = if (resolved_type.zigTypeTag(mod) == .Vector) |
| 16627 | 16627 | try block.addInst(.{ |
| 16628 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, | |
| 16628 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, | |
| 16629 | 16629 | .data = .{ .reduce = .{ |
| 16630 | 16630 | .operand = ov_bit, |
| 16631 | 16631 | .operation = .Or, |
| ... | ... | @@ -17168,7 +17168,7 @@ fn cmpSelf( |
| 17168 | 17168 | if (resolved_type.zigTypeTag(mod) == .Vector) { |
| 17169 | 17169 | return block.addCmpVector(casted_lhs, casted_rhs, op); |
| 17170 | 17170 | } |
| 17171 | const tag = Air.Inst.Tag.fromCmpOp(op, block.float_mode == .Optimized); | |
| 17171 | const tag = Air.Inst.Tag.fromCmpOp(op, block.float_mode == .optimized); | |
| 17172 | 17172 | return block.addBinOp(tag, casted_lhs, casted_rhs); |
| 17173 | 17173 | } |
| 17174 | 17174 | |
| ... | ... | @@ -18131,8 +18131,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18131 | 18131 | }; |
| 18132 | 18132 | |
| 18133 | 18133 | const alignment = switch (layout) { |
| 18134 | .Auto, .Extern => try sema.unionFieldAlignment(union_obj, @intCast(i)), | |
| 18135 | .Packed => .none, | |
| 18134 | .auto, .@"extern" => try sema.unionFieldAlignment(union_obj, @intCast(i)), | |
| 18135 | .@"packed" => .none, | |
| 18136 | 18136 | }; |
| 18137 | 18137 | |
| 18138 | 18138 | const field_ty = union_obj.field_types.get(ip)[i]; |
| ... | ... | @@ -18350,7 +18350,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18350 | 18350 | const opt_default_val = if (field_init == .none) null else Value.fromInterned(field_init); |
| 18351 | 18351 | const default_val_ptr = try sema.optRefValue(opt_default_val); |
| 18352 | 18352 | const alignment = switch (struct_type.layout) { |
| 18353 | .Packed => .none, | |
| 18353 | .@"packed" => .none, | |
| 18354 | 18354 | else => try sema.structFieldAlignment( |
| 18355 | 18355 | struct_type.fieldAlign(ip, i), |
| 18356 | 18356 | field_ty, |
| ... | ... | @@ -19906,7 +19906,7 @@ fn zirStructInit( |
| 19906 | 19906 | var field_i: u32 = 0; |
| 19907 | 19907 | var extra_index = extra.end; |
| 19908 | 19908 | |
| 19909 | const is_packed = resolved_ty.containerLayout(mod) == .Packed; | |
| 19909 | const is_packed = resolved_ty.containerLayout(mod) == .@"packed"; | |
| 19910 | 19910 | while (field_i < extra.data.fields_len) : (field_i += 1) { |
| 19911 | 19911 | const item = sema.code.extraData(Zir.Inst.StructInit.Item, extra_index); |
| 19912 | 19912 | extra_index = item.end; |
| ... | ... | @@ -21302,7 +21302,7 @@ fn zirReify( |
| 21302 | 21302 | return sema.fail(block, src, "reified structs must have no decls", .{}); |
| 21303 | 21303 | } |
| 21304 | 21304 | |
| 21305 | if (layout != .Packed and !backing_integer_val.isNull(mod)) { | |
| 21305 | if (layout != .@"packed" and !backing_integer_val.isNull(mod)) { | |
| 21306 | 21306 | return sema.fail(block, src, "non-packed struct does not support backing integer type", .{}); |
| 21307 | 21307 | } |
| 21308 | 21308 | |
| ... | ... | @@ -21665,7 +21665,7 @@ fn reifyUnion( |
| 21665 | 21665 | .status = .none, |
| 21666 | 21666 | .runtime_tag = if (opt_tag_type_val.optionalValue(mod) != null) |
| 21667 | 21667 | .tagged |
| 21668 | else if (layout != .Auto) | |
| 21668 | else if (layout != .auto) | |
| 21669 | 21669 | .none |
| 21670 | 21670 | else switch (block.wantSafety()) { |
| 21671 | 21671 | true => .safety, |
| ... | ... | @@ -21804,7 +21804,7 @@ fn reifyUnion( |
| 21804 | 21804 | break :msg msg; |
| 21805 | 21805 | }); |
| 21806 | 21806 | } |
| 21807 | if (layout == .Extern and !try sema.validateExternType(field_ty, .union_field)) { | |
| 21807 | if (layout == .@"extern" and !try sema.validateExternType(field_ty, .union_field)) { | |
| 21808 | 21808 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21809 | 21809 | const msg = try sema.errMsg(block, src, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)}); |
| 21810 | 21810 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -21815,7 +21815,7 @@ fn reifyUnion( |
| 21815 | 21815 | try sema.addDeclaredHereNote(msg, field_ty); |
| 21816 | 21816 | break :msg msg; |
| 21817 | 21817 | }); |
| 21818 | } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) { | |
| 21818 | } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) { | |
| 21819 | 21819 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21820 | 21820 | const msg = try sema.errMsg(block, src, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)}); |
| 21821 | 21821 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -21938,9 +21938,9 @@ fn reifyStruct( |
| 21938 | 21938 | errdefer wip_ty.cancel(ip); |
| 21939 | 21939 | |
| 21940 | 21940 | if (is_tuple) switch (layout) { |
| 21941 | .Extern => return sema.fail(block, src, "extern tuples are not supported", .{}), | |
| 21942 | .Packed => return sema.fail(block, src, "packed tuples are not supported", .{}), | |
| 21943 | .Auto => {}, | |
| 21941 | .@"extern" => return sema.fail(block, src, "extern tuples are not supported", .{}), | |
| 21942 | .@"packed" => return sema.fail(block, src, "packed tuples are not supported", .{}), | |
| 21943 | .auto => {}, | |
| 21944 | 21944 | }; |
| 21945 | 21945 | |
| 21946 | 21946 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| ... | ... | @@ -21990,11 +21990,11 @@ fn reifyStruct( |
| 21990 | 21990 | |
| 21991 | 21991 | const byte_align = try field_alignment_val.toUnsignedIntAdvanced(sema); |
| 21992 | 21992 | if (byte_align == 0) { |
| 21993 | if (layout != .Packed) { | |
| 21993 | if (layout != .@"packed") { | |
| 21994 | 21994 | struct_type.field_aligns.get(ip)[field_idx] = .none; |
| 21995 | 21995 | } |
| 21996 | 21996 | } else { |
| 21997 | if (layout == .Packed) return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{}); | |
| 21997 | if (layout == .@"packed") return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{}); | |
| 21998 | 21998 | if (!math.isPowerOfTwo(byte_align)) return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align}); |
| 21999 | 21999 | struct_type.field_aligns.get(ip)[field_idx] = Alignment.fromNonzeroByteUnits(byte_align); |
| 22000 | 22000 | } |
| ... | ... | @@ -22004,9 +22004,9 @@ fn reifyStruct( |
| 22004 | 22004 | if (field_is_comptime) { |
| 22005 | 22005 | assert(any_comptime_fields); |
| 22006 | 22006 | switch (layout) { |
| 22007 | .Extern => return sema.fail(block, src, "extern struct fields cannot be marked comptime", .{}), | |
| 22008 | .Packed => return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}), | |
| 22009 | .Auto => struct_type.setFieldComptime(ip, field_idx), | |
| 22007 | .@"extern" => return sema.fail(block, src, "extern struct fields cannot be marked comptime", .{}), | |
| 22008 | .@"packed" => return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}), | |
| 22009 | .auto => struct_type.setFieldComptime(ip, field_idx), | |
| 22010 | 22010 | } |
| 22011 | 22011 | } |
| 22012 | 22012 | |
| ... | ... | @@ -22047,7 +22047,7 @@ fn reifyStruct( |
| 22047 | 22047 | break :msg msg; |
| 22048 | 22048 | }); |
| 22049 | 22049 | } |
| 22050 | if (layout == .Extern and !try sema.validateExternType(field_ty, .struct_field)) { | |
| 22050 | if (layout == .@"extern" and !try sema.validateExternType(field_ty, .struct_field)) { | |
| 22051 | 22051 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22052 | 22052 | const msg = try sema.errMsg(block, src, "extern structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)}); |
| 22053 | 22053 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -22058,7 +22058,7 @@ fn reifyStruct( |
| 22058 | 22058 | try sema.addDeclaredHereNote(msg, field_ty); |
| 22059 | 22059 | break :msg msg; |
| 22060 | 22060 | }); |
| 22061 | } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) { | |
| 22061 | } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) { | |
| 22062 | 22062 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22063 | 22063 | const msg = try sema.errMsg(block, src, "packed structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)}); |
| 22064 | 22064 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -22072,7 +22072,7 @@ fn reifyStruct( |
| 22072 | 22072 | } |
| 22073 | 22073 | } |
| 22074 | 22074 | |
| 22075 | if (layout == .Packed) { | |
| 22075 | if (layout == .@"packed") { | |
| 22076 | 22076 | var fields_bit_sum: u64 = 0; |
| 22077 | 22077 | for (0..struct_type.field_types.len) |field_idx| { |
| 22078 | 22078 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_idx]); |
| ... | ... | @@ -22226,7 +22226,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22226 | 22226 | if (dest_scalar_ty.intInfo(mod).bits == 0) { |
| 22227 | 22227 | if (!is_vector) { |
| 22228 | 22228 | if (block.wantSafety()) { |
| 22229 | const ok = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_eq_optimized else .cmp_eq, operand, Air.internedToRef((try mod.floatValue(operand_ty, 0.0)).toIntern())); | |
| 22229 | const ok = try block.addBinOp(if (block.float_mode == .optimized) .cmp_eq_optimized else .cmp_eq, operand, Air.internedToRef((try mod.floatValue(operand_ty, 0.0)).toIntern())); | |
| 22230 | 22230 | try sema.addSafetyCheck(block, src, ok, .integer_part_out_of_bounds); |
| 22231 | 22231 | } |
| 22232 | 22232 | return Air.internedToRef((try mod.intValue(dest_ty, 0)).toIntern()); |
| ... | ... | @@ -22236,7 +22236,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22236 | 22236 | for (0..len) |i| { |
| 22237 | 22237 | const idx_ref = try mod.intRef(Type.usize, i); |
| 22238 | 22238 | const elem_ref = try block.addBinOp(.array_elem_val, operand, idx_ref); |
| 22239 | const ok = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_eq_optimized else .cmp_eq, elem_ref, Air.internedToRef((try mod.floatValue(operand_scalar_ty, 0.0)).toIntern())); | |
| 22239 | const ok = try block.addBinOp(if (block.float_mode == .optimized) .cmp_eq_optimized else .cmp_eq, elem_ref, Air.internedToRef((try mod.floatValue(operand_scalar_ty, 0.0)).toIntern())); | |
| 22240 | 22240 | try sema.addSafetyCheck(block, src, ok, .integer_part_out_of_bounds); |
| 22241 | 22241 | } |
| 22242 | 22242 | } |
| ... | ... | @@ -22246,12 +22246,12 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22246 | 22246 | } })); |
| 22247 | 22247 | } |
| 22248 | 22248 | if (!is_vector) { |
| 22249 | const result = try block.addTyOp(if (block.float_mode == .Optimized) .int_from_float_optimized else .int_from_float, dest_ty, operand); | |
| 22249 | const result = try block.addTyOp(if (block.float_mode == .optimized) .int_from_float_optimized else .int_from_float, dest_ty, operand); | |
| 22250 | 22250 | if (block.wantSafety()) { |
| 22251 | 22251 | const back = try block.addTyOp(.float_from_int, operand_ty, result); |
| 22252 | 22252 | const diff = try block.addBinOp(.sub, operand, back); |
| 22253 | const ok_pos = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_lt_optimized else .cmp_lt, diff, Air.internedToRef((try mod.floatValue(operand_ty, 1.0)).toIntern())); | |
| 22254 | const ok_neg = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_gt_optimized else .cmp_gt, diff, Air.internedToRef((try mod.floatValue(operand_ty, -1.0)).toIntern())); | |
| 22253 | const ok_pos = try block.addBinOp(if (block.float_mode == .optimized) .cmp_lt_optimized else .cmp_lt, diff, Air.internedToRef((try mod.floatValue(operand_ty, 1.0)).toIntern())); | |
| 22254 | const ok_neg = try block.addBinOp(if (block.float_mode == .optimized) .cmp_gt_optimized else .cmp_gt, diff, Air.internedToRef((try mod.floatValue(operand_ty, -1.0)).toIntern())); | |
| 22255 | 22255 | const ok = try block.addBinOp(.bool_and, ok_pos, ok_neg); |
| 22256 | 22256 | try sema.addSafetyCheck(block, src, ok, .integer_part_out_of_bounds); |
| 22257 | 22257 | } |
| ... | ... | @@ -22262,12 +22262,12 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 22262 | 22262 | for (new_elems, 0..) |*new_elem, i| { |
| 22263 | 22263 | const idx_ref = try mod.intRef(Type.usize, i); |
| 22264 | 22264 | const old_elem = try block.addBinOp(.array_elem_val, operand, idx_ref); |
| 22265 | const result = try block.addTyOp(if (block.float_mode == .Optimized) .int_from_float_optimized else .int_from_float, dest_scalar_ty, old_elem); | |
| 22265 | const result = try block.addTyOp(if (block.float_mode == .optimized) .int_from_float_optimized else .int_from_float, dest_scalar_ty, old_elem); | |
| 22266 | 22266 | if (block.wantSafety()) { |
| 22267 | 22267 | const back = try block.addTyOp(.float_from_int, operand_scalar_ty, result); |
| 22268 | 22268 | const diff = try block.addBinOp(.sub, old_elem, back); |
| 22269 | const ok_pos = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_lt_optimized else .cmp_lt, diff, Air.internedToRef((try mod.floatValue(operand_scalar_ty, 1.0)).toIntern())); | |
| 22270 | const ok_neg = try block.addBinOp(if (block.float_mode == .Optimized) .cmp_gt_optimized else .cmp_gt, diff, Air.internedToRef((try mod.floatValue(operand_scalar_ty, -1.0)).toIntern())); | |
| 22269 | const ok_pos = try block.addBinOp(if (block.float_mode == .optimized) .cmp_lt_optimized else .cmp_lt, diff, Air.internedToRef((try mod.floatValue(operand_scalar_ty, 1.0)).toIntern())); | |
| 22270 | const ok_neg = try block.addBinOp(if (block.float_mode == .optimized) .cmp_gt_optimized else .cmp_gt, diff, Air.internedToRef((try mod.floatValue(operand_scalar_ty, -1.0)).toIntern())); | |
| 22271 | 22271 | const ok = try block.addBinOp(.bool_and, ok_pos, ok_neg); |
| 22272 | 22272 | try sema.addSafetyCheck(block, src, ok, .integer_part_out_of_bounds); |
| 22273 | 22273 | } |
| ... | ... | @@ -23311,7 +23311,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 |
| 23311 | 23311 | } |
| 23312 | 23312 | |
| 23313 | 23313 | switch (ty.containerLayout(mod)) { |
| 23314 | .Packed => { | |
| 23314 | .@"packed" => { | |
| 23315 | 23315 | var bit_sum: u64 = 0; |
| 23316 | 23316 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 23317 | 23317 | for (0..struct_type.field_types.len) |i| { |
| ... | ... | @@ -23802,7 +23802,7 @@ fn resolveExportOptions( |
| 23802 | 23802 | return sema.fail(block, name_src, "exported symbol name cannot be empty", .{}); |
| 23803 | 23803 | } |
| 23804 | 23804 | |
| 23805 | if (visibility != .default and linkage == .Internal) { | |
| 23805 | if (visibility != .default and linkage == .internal) { | |
| 23806 | 23806 | return sema.fail(block, visibility_src, "symbol '{s}' exported with internal linkage has non-default visibility {s}", .{ |
| 23807 | 23807 | name, @tagName(visibility), |
| 23808 | 23808 | }); |
| ... | ... | @@ -23894,17 +23894,17 @@ fn zirCmpxchg( |
| 23894 | 23894 | .needed_comptime_reason = "atomic order of cmpxchg failure must be comptime-known", |
| 23895 | 23895 | }); |
| 23896 | 23896 | |
| 23897 | if (@intFromEnum(success_order) < @intFromEnum(std.builtin.AtomicOrder.Monotonic)) { | |
| 23898 | return sema.fail(block, success_order_src, "success atomic ordering must be Monotonic or stricter", .{}); | |
| 23897 | if (@intFromEnum(success_order) < @intFromEnum(std.builtin.AtomicOrder.monotonic)) { | |
| 23898 | return sema.fail(block, success_order_src, "success atomic ordering must be monotonic or stricter", .{}); | |
| 23899 | 23899 | } |
| 23900 | if (@intFromEnum(failure_order) < @intFromEnum(std.builtin.AtomicOrder.Monotonic)) { | |
| 23901 | return sema.fail(block, failure_order_src, "failure atomic ordering must be Monotonic or stricter", .{}); | |
| 23900 | if (@intFromEnum(failure_order) < @intFromEnum(std.builtin.AtomicOrder.monotonic)) { | |
| 23901 | return sema.fail(block, failure_order_src, "failure atomic ordering must be monotonic or stricter", .{}); | |
| 23902 | 23902 | } |
| 23903 | 23903 | if (@intFromEnum(failure_order) > @intFromEnum(success_order)) { |
| 23904 | 23904 | return sema.fail(block, failure_order_src, "failure atomic ordering must be no stricter than success", .{}); |
| 23905 | 23905 | } |
| 23906 | if (failure_order == .Release or failure_order == .AcqRel) { | |
| 23907 | return sema.fail(block, failure_order_src, "failure atomic ordering must not be Release or AcqRel", .{}); | |
| 23906 | if (failure_order == .release or failure_order == .acq_rel) { | |
| 23907 | return sema.fail(block, failure_order_src, "failure atomic ordering must not be release or acq_rel", .{}); | |
| 23908 | 23908 | } |
| 23909 | 23909 | |
| 23910 | 23910 | const result_ty = try mod.optionalType(elem_ty.toIntern()); |
| ... | ... | @@ -24042,7 +24042,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 24042 | 24042 | |
| 24043 | 24043 | try sema.requireRuntimeBlock(block, inst_data.src(), operand_src); |
| 24044 | 24044 | return block.addInst(.{ |
| 24045 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, | |
| 24045 | .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce, | |
| 24046 | 24046 | .data = .{ .reduce = .{ |
| 24047 | 24047 | .operand = operand, |
| 24048 | 24048 | .operation = operation, |
| ... | ... | @@ -24346,11 +24346,11 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 24346 | 24346 | }); |
| 24347 | 24347 | |
| 24348 | 24348 | switch (order) { |
| 24349 | .Release, .AcqRel => { | |
| 24349 | .release, .acq_rel => { | |
| 24350 | 24350 | return sema.fail( |
| 24351 | 24351 | block, |
| 24352 | 24352 | order_src, |
| 24353 | "@atomicLoad atomic ordering must not be Release or AcqRel", | |
| 24353 | "@atomicLoad atomic ordering must not be release or acq_rel", | |
| 24354 | 24354 | .{}, |
| 24355 | 24355 | ); |
| 24356 | 24356 | }, |
| ... | ... | @@ -24412,8 +24412,8 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 24412 | 24412 | .needed_comptime_reason = "atomic order of @atomicRmW must be comptime-known", |
| 24413 | 24413 | }); |
| 24414 | 24414 | |
| 24415 | if (order == .Unordered) { | |
| 24416 | return sema.fail(block, order_src, "@atomicRmw atomic ordering must not be Unordered", .{}); | |
| 24415 | if (order == .unordered) { | |
| 24416 | return sema.fail(block, order_src, "@atomicRmw atomic ordering must not be unordered", .{}); | |
| 24417 | 24417 | } |
| 24418 | 24418 | |
| 24419 | 24419 | // special case zero bit types |
| ... | ... | @@ -24482,18 +24482,18 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 24482 | 24482 | }); |
| 24483 | 24483 | |
| 24484 | 24484 | const air_tag: Air.Inst.Tag = switch (order) { |
| 24485 | .Acquire, .AcqRel => { | |
| 24485 | .acquire, .acq_rel => { | |
| 24486 | 24486 | return sema.fail( |
| 24487 | 24487 | block, |
| 24488 | 24488 | order_src, |
| 24489 | "@atomicStore atomic ordering must not be Acquire or AcqRel", | |
| 24489 | "@atomicStore atomic ordering must not be acquire or acq_rel", | |
| 24490 | 24490 | .{}, |
| 24491 | 24491 | ); |
| 24492 | 24492 | }, |
| 24493 | .Unordered => .atomic_store_unordered, | |
| 24494 | .Monotonic => .atomic_store_monotonic, | |
| 24495 | .Release => .atomic_store_release, | |
| 24496 | .SeqCst => .atomic_store_seq_cst, | |
| 24493 | .unordered => .atomic_store_unordered, | |
| 24494 | .monotonic => .atomic_store_monotonic, | |
| 24495 | .release => .atomic_store_release, | |
| 24496 | .seq_cst => .atomic_store_seq_cst, | |
| 24497 | 24497 | }; |
| 24498 | 24498 | |
| 24499 | 24499 | return sema.storePtr2(block, src, ptr, ptr_src, operand, operand_src, air_tag); |
| ... | ... | @@ -24710,7 +24710,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 24710 | 24710 | }, |
| 24711 | 24711 | }; |
| 24712 | 24712 | |
| 24713 | if (parent_ty.containerLayout(mod) == .Packed) { | |
| 24713 | if (parent_ty.containerLayout(mod) == .@"packed") { | |
| 24714 | 24714 | return sema.fail(block, src, "TODO handle packed structs/unions with @fieldParentPtr", .{}); |
| 24715 | 24715 | } else { |
| 24716 | 24716 | ptr_ty_data.flags.alignment = blk: { |
| ... | ... | @@ -25888,7 +25888,7 @@ fn resolveExternOptions( |
| 25888 | 25888 | ) CompileError!struct { |
| 25889 | 25889 | name: InternPool.NullTerminatedString, |
| 25890 | 25890 | library_name: InternPool.OptionalNullTerminatedString = .none, |
| 25891 | linkage: std.builtin.GlobalLinkage = .Strong, | |
| 25891 | linkage: std.builtin.GlobalLinkage = .strong, | |
| 25892 | 25892 | is_thread_local: bool = false, |
| 25893 | 25893 | } { |
| 25894 | 25894 | const mod = sema.mod; |
| ... | ... | @@ -25938,7 +25938,7 @@ fn resolveExternOptions( |
| 25938 | 25938 | return sema.fail(block, name_src, "extern symbol name cannot be empty", .{}); |
| 25939 | 25939 | } |
| 25940 | 25940 | |
| 25941 | if (linkage != .Weak and linkage != .Strong) { | |
| 25941 | if (linkage != .weak and linkage != .strong) { | |
| 25942 | 25942 | return sema.fail(block, linkage_src, "extern symbol must use strong or weak linkage", .{}); |
| 25943 | 25943 | } |
| 25944 | 25944 | |
| ... | ... | @@ -25984,7 +25984,7 @@ fn zirBuiltinExtern( |
| 25984 | 25984 | else => |e| return e, |
| 25985 | 25985 | }; |
| 25986 | 25986 | |
| 25987 | if (options.linkage == .Weak and !ty.ptrAllowsZero(mod)) { | |
| 25987 | if (options.linkage == .weak and !ty.ptrAllowsZero(mod)) { | |
| 25988 | 25988 | ty = try mod.optionalType(ty.toIntern()); |
| 25989 | 25989 | } |
| 25990 | 25990 | const ptr_info = ty.ptrInfo(mod); |
| ... | ... | @@ -26010,7 +26010,7 @@ fn zirBuiltinExtern( |
| 26010 | 26010 | .is_extern = true, |
| 26011 | 26011 | .is_const = ptr_info.flags.is_const, |
| 26012 | 26012 | .is_threadlocal = options.is_thread_local, |
| 26013 | .is_weak_linkage = options.linkage == .Weak, | |
| 26013 | .is_weak_linkage = options.linkage == .weak, | |
| 26014 | 26014 | } }), |
| 26015 | 26015 | ), |
| 26016 | 26016 | }, options.name); |
| ... | ... | @@ -26328,15 +26328,15 @@ fn validateExternType( |
| 26328 | 26328 | return sema.validateExternType(ty.intTagType(mod), position); |
| 26329 | 26329 | }, |
| 26330 | 26330 | .Struct, .Union => switch (ty.containerLayout(mod)) { |
| 26331 | .Extern => return true, | |
| 26332 | .Packed => { | |
| 26331 | .@"extern" => return true, | |
| 26332 | .@"packed" => { | |
| 26333 | 26333 | const bit_size = try ty.bitSizeAdvanced(mod, sema); |
| 26334 | 26334 | switch (bit_size) { |
| 26335 | 26335 | 0, 8, 16, 32, 64, 128 => return true, |
| 26336 | 26336 | else => return false, |
| 26337 | 26337 | } |
| 26338 | 26338 | }, |
| 26339 | .Auto => return !(try sema.typeHasRuntimeBits(ty)), | |
| 26339 | .auto => return !(try sema.typeHasRuntimeBits(ty)), | |
| 26340 | 26340 | }, |
| 26341 | 26341 | .Array => { |
| 26342 | 26342 | if (position == .ret_ty or position == .param_ty) return false; |
| ... | ... | @@ -26456,7 +26456,7 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool { |
| 26456 | 26456 | .Enum, |
| 26457 | 26457 | => return true, |
| 26458 | 26458 | .Pointer => return !ty.isSlice(mod) and !try sema.typeRequiresComptime(ty), |
| 26459 | .Struct, .Union => return ty.containerLayout(mod) == .Packed, | |
| 26459 | .Struct, .Union => return ty.containerLayout(mod) == .@"packed", | |
| 26460 | 26460 | } |
| 26461 | 26461 | } |
| 26462 | 26462 | |
| ... | ... | @@ -27596,7 +27596,7 @@ fn structFieldPtrByIndex( |
| 27596 | 27596 | else |
| 27597 | 27597 | try sema.typeAbiAlignment(Type.fromInterned(struct_ptr_ty_info.child)); |
| 27598 | 27598 | |
| 27599 | if (struct_type.layout == .Packed) { | |
| 27599 | if (struct_type.layout == .@"packed") { | |
| 27600 | 27600 | comptime assert(Type.packed_struct_layout_version == 2); |
| 27601 | 27601 | |
| 27602 | 27602 | var running_bits: u16 = 0; |
| ... | ... | @@ -27641,7 +27641,7 @@ fn structFieldPtrByIndex( |
| 27641 | 27641 | ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 }; |
| 27642 | 27642 | } |
| 27643 | 27643 | } |
| 27644 | } else if (struct_type.layout == .Extern) { | |
| 27644 | } else if (struct_type.layout == .@"extern") { | |
| 27645 | 27645 | // For extern structs, field alignment might be bigger than type's |
| 27646 | 27646 | // natural alignment. Eg, in `extern struct { x: u32, y: u16 }` the |
| 27647 | 27647 | // second field is aligned as u32. |
| ... | ... | @@ -27846,7 +27846,7 @@ fn unionFieldPtr( |
| 27846 | 27846 | .is_const = union_ptr_info.flags.is_const, |
| 27847 | 27847 | .is_volatile = union_ptr_info.flags.is_volatile, |
| 27848 | 27848 | .address_space = union_ptr_info.flags.address_space, |
| 27849 | .alignment = if (union_obj.getLayout(ip) == .Auto) blk: { | |
| 27849 | .alignment = if (union_obj.getLayout(ip) == .auto) blk: { | |
| 27850 | 27850 | const union_align = if (union_ptr_info.flags.alignment != .none) |
| 27851 | 27851 | union_ptr_info.flags.alignment |
| 27852 | 27852 | else |
| ... | ... | @@ -27875,7 +27875,7 @@ fn unionFieldPtr( |
| 27875 | 27875 | |
| 27876 | 27876 | if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| ct: { |
| 27877 | 27877 | switch (union_obj.getLayout(ip)) { |
| 27878 | .Auto => if (!initializing) { | |
| 27878 | .auto => if (!initializing) { | |
| 27879 | 27879 | const union_val = (try sema.pointerDeref(block, src, union_ptr_val, union_ptr_ty)) orelse |
| 27880 | 27880 | break :ct; |
| 27881 | 27881 | if (union_val.isUndef(mod)) { |
| ... | ... | @@ -27899,7 +27899,7 @@ fn unionFieldPtr( |
| 27899 | 27899 | return sema.failWithOwnedErrorMsg(block, msg); |
| 27900 | 27900 | } |
| 27901 | 27901 | }, |
| 27902 | .Packed, .Extern => {}, | |
| 27902 | .@"packed", .@"extern" => {}, | |
| 27903 | 27903 | } |
| 27904 | 27904 | return Air.internedToRef((try mod.intern(.{ .ptr = .{ |
| 27905 | 27905 | .ty = ptr_field_ty.toIntern(), |
| ... | ... | @@ -27911,7 +27911,7 @@ fn unionFieldPtr( |
| 27911 | 27911 | } |
| 27912 | 27912 | |
| 27913 | 27913 | try sema.requireRuntimeBlock(block, src, null); |
| 27914 | if (!initializing and union_obj.getLayout(ip) == .Auto and block.wantSafety() and | |
| 27914 | if (!initializing and union_obj.getLayout(ip) == .auto and block.wantSafety() and | |
| 27915 | 27915 | union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1) |
| 27916 | 27916 | { |
| 27917 | 27917 | const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| ... | ... | @@ -27954,7 +27954,7 @@ fn unionFieldVal( |
| 27954 | 27954 | const field_tag = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| 27955 | 27955 | const tag_matches = un.tag == field_tag.toIntern(); |
| 27956 | 27956 | switch (union_obj.getLayout(ip)) { |
| 27957 | .Auto => { | |
| 27957 | .auto => { | |
| 27958 | 27958 | if (tag_matches) { |
| 27959 | 27959 | return Air.internedToRef(un.val); |
| 27960 | 27960 | } else { |
| ... | ... | @@ -27971,7 +27971,7 @@ fn unionFieldVal( |
| 27971 | 27971 | return sema.failWithOwnedErrorMsg(block, msg); |
| 27972 | 27972 | } |
| 27973 | 27973 | }, |
| 27974 | .Packed, .Extern => |layout| { | |
| 27974 | .@"packed", .@"extern" => |layout| { | |
| 27975 | 27975 | if (tag_matches) { |
| 27976 | 27976 | return Air.internedToRef(un.val); |
| 27977 | 27977 | } else { |
| ... | ... | @@ -27989,7 +27989,7 @@ fn unionFieldVal( |
| 27989 | 27989 | } |
| 27990 | 27990 | |
| 27991 | 27991 | try sema.requireRuntimeBlock(block, src, null); |
| 27992 | if (union_obj.getLayout(ip) == .Auto and block.wantSafety() and | |
| 27992 | if (union_obj.getLayout(ip) == .auto and block.wantSafety() and | |
| 27993 | 27993 | union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1) |
| 27994 | 27994 | { |
| 27995 | 27995 | const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| ... | ... | @@ -30961,7 +30961,7 @@ fn beginComptimePtrMutation( |
| 30961 | 30961 | |
| 30962 | 30962 | const tag_type = base_child_ty.unionTagTypeHypothetical(mod); |
| 30963 | 30963 | const hypothetical_tag = try mod.enumValueFieldIndex(tag_type, field_index); |
| 30964 | if (layout == .Auto or (payload.tag != null and hypothetical_tag.eql(payload.tag.?, tag_type, mod))) { | |
| 30964 | if (layout == .auto or (payload.tag != null and hypothetical_tag.eql(payload.tag.?, tag_type, mod))) { | |
| 30965 | 30965 | // We need to set the active field of the union. |
| 30966 | 30966 | payload.tag = hypothetical_tag; |
| 30967 | 30967 | |
| ... | ... | @@ -30988,7 +30988,7 @@ fn beginComptimePtrMutation( |
| 30988 | 30988 | .pointee = .{ .reinterpret = .{ |
| 30989 | 30989 | .val_ptr = val_ptr, |
| 30990 | 30990 | .byte_offset = 0, |
| 30991 | .write_packed = layout == .Packed, | |
| 30991 | .write_packed = layout == .@"packed", | |
| 30992 | 30992 | } }, |
| 30993 | 30993 | .ty = parent.ty, |
| 30994 | 30994 | }; |
| ... | ... | @@ -31395,7 +31395,7 @@ fn beginComptimePtrLoad( |
| 31395 | 31395 | |
| 31396 | 31396 | if (container_ty.hasWellDefinedLayout(mod)) { |
| 31397 | 31397 | const struct_obj = mod.typeToStruct(container_ty); |
| 31398 | if (struct_obj != null and struct_obj.?.layout == .Packed) { | |
| 31398 | if (struct_obj != null and struct_obj.?.layout == .@"packed") { | |
| 31399 | 31399 | // packed structs are not byte addressable |
| 31400 | 31400 | deref.parent = null; |
| 31401 | 31401 | } else if (deref.parent) |*parent| { |
| ... | ... | @@ -31551,7 +31551,7 @@ fn bitCastUnionFieldVal( |
| 31551 | 31551 | |
| 31552 | 31552 | // Reading a larger value means we need to reinterpret from undefined bytes. |
| 31553 | 31553 | const offset = switch (layout) { |
| 31554 | .Extern => offset: { | |
| 31554 | .@"extern" => offset: { | |
| 31555 | 31555 | if (field_size > old_size) @memset(buffer[old_size..], 0xaa); |
| 31556 | 31556 | val.writeToMemory(old_ty, mod, buffer) catch |err| switch (err) { |
| 31557 | 31557 | error.OutOfMemory => return error.OutOfMemory, |
| ... | ... | @@ -31561,7 +31561,7 @@ fn bitCastUnionFieldVal( |
| 31561 | 31561 | }; |
| 31562 | 31562 | break :offset 0; |
| 31563 | 31563 | }, |
| 31564 | .Packed => offset: { | |
| 31564 | .@"packed" => offset: { | |
| 31565 | 31565 | if (field_size > old_size) { |
| 31566 | 31566 | const min_size = @max(old_size, 1); |
| 31567 | 31567 | switch (endian) { |
| ... | ... | @@ -31577,7 +31577,7 @@ fn bitCastUnionFieldVal( |
| 31577 | 31577 | |
| 31578 | 31578 | break :offset if (endian == .big) buffer.len - field_size else 0; |
| 31579 | 31579 | }, |
| 31580 | .Auto => unreachable, | |
| 31580 | .auto => unreachable, | |
| 31581 | 31581 | }; |
| 31582 | 31582 | |
| 31583 | 31583 | return Value.readFromMemory(field_ty, mod, buffer[offset..], sema.arena) catch |err| switch (err) { |
| ... | ... | @@ -33506,7 +33506,7 @@ fn cmpNumeric( |
| 33506 | 33506 | }; |
| 33507 | 33507 | const casted_lhs = try sema.coerce(block, dest_ty, lhs, lhs_src); |
| 33508 | 33508 | const casted_rhs = try sema.coerce(block, dest_ty, rhs, rhs_src); |
| 33509 | return block.addBinOp(Air.Inst.Tag.fromCmpOp(op, block.float_mode == .Optimized), casted_lhs, casted_rhs); | |
| 33509 | return block.addBinOp(Air.Inst.Tag.fromCmpOp(op, block.float_mode == .optimized), casted_lhs, casted_rhs); | |
| 33510 | 33510 | } |
| 33511 | 33511 | // For mixed unsigned integer sizes, implicit cast both operands to the larger integer. |
| 33512 | 33512 | // For mixed signed and unsigned integers, implicit cast both operands to a signed |
| ... | ... | @@ -33651,7 +33651,7 @@ fn cmpNumeric( |
| 33651 | 33651 | const casted_lhs = try sema.coerce(block, dest_ty, lhs, lhs_src); |
| 33652 | 33652 | const casted_rhs = try sema.coerce(block, dest_ty, rhs, rhs_src); |
| 33653 | 33653 | |
| 33654 | return block.addBinOp(Air.Inst.Tag.fromCmpOp(op, block.float_mode == .Optimized), casted_lhs, casted_rhs); | |
| 33654 | return block.addBinOp(Air.Inst.Tag.fromCmpOp(op, block.float_mode == .optimized), casted_lhs, casted_rhs); | |
| 33655 | 33655 | } |
| 33656 | 33656 | |
| 33657 | 33657 | /// Asserts that LHS value is an int or comptime int and not undefined, and |
| ... | ... | @@ -35608,7 +35608,7 @@ pub fn resolveStructAlignment( |
| 35608 | 35608 | const target = mod.getTarget(); |
| 35609 | 35609 | |
| 35610 | 35610 | assert(struct_type.flagsPtr(ip).alignment == .none); |
| 35611 | assert(struct_type.layout != .Packed); | |
| 35611 | assert(struct_type.layout != .@"packed"); | |
| 35612 | 35612 | |
| 35613 | 35613 | if (struct_type.flagsPtr(ip).field_types_wip) { |
| 35614 | 35614 | // We'll guess "pointer-aligned", if the struct has an |
| ... | ... | @@ -35661,7 +35661,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { |
| 35661 | 35661 | |
| 35662 | 35662 | try sema.resolveTypeFields(ty); |
| 35663 | 35663 | |
| 35664 | if (struct_type.layout == .Packed) { | |
| 35664 | if (struct_type.layout == .@"packed") { | |
| 35665 | 35665 | try semaBackingIntType(mod, struct_type); |
| 35666 | 35666 | return; |
| 35667 | 35667 | } |
| ... | ... | @@ -36625,11 +36625,11 @@ fn semaStructFields( |
| 36625 | 36625 | const fields_len, const small, var extra_index = structZirInfo(zir, zir_index); |
| 36626 | 36626 | |
| 36627 | 36627 | if (fields_len == 0) switch (struct_type.layout) { |
| 36628 | .Packed => { | |
| 36628 | .@"packed" => { | |
| 36629 | 36629 | try semaBackingIntType(mod, struct_type); |
| 36630 | 36630 | return; |
| 36631 | 36631 | }, |
| 36632 | .Auto, .Extern => { | |
| 36632 | .auto, .@"extern" => { | |
| 36633 | 36633 | struct_type.size(ip).* = 0; |
| 36634 | 36634 | struct_type.flagsPtr(ip).layout_resolved = true; |
| 36635 | 36635 | return; |
| ... | ... | @@ -36810,7 +36810,7 @@ fn semaStructFields( |
| 36810 | 36810 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| 36811 | 36811 | } |
| 36812 | 36812 | switch (struct_type.layout) { |
| 36813 | .Extern => if (!try sema.validateExternType(field_ty, .struct_field)) { | |
| 36813 | .@"extern" => if (!try sema.validateExternType(field_ty, .struct_field)) { | |
| 36814 | 36814 | const msg = msg: { |
| 36815 | 36815 | const ty_src = mod.fieldSrcLoc(decl_index, .{ |
| 36816 | 36816 | .index = field_i, |
| ... | ... | @@ -36826,7 +36826,7 @@ fn semaStructFields( |
| 36826 | 36826 | }; |
| 36827 | 36827 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| 36828 | 36828 | }, |
| 36829 | .Packed => if (!try sema.validatePackedType(field_ty)) { | |
| 36829 | .@"packed" => if (!try sema.validatePackedType(field_ty)) { | |
| 36830 | 36830 | const msg = msg: { |
| 36831 | 36831 | const ty_src = mod.fieldSrcLoc(decl_index, .{ |
| 36832 | 36832 | .index = field_i, |
| ... | ... | @@ -37350,7 +37350,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded |
| 37350 | 37350 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| 37351 | 37351 | } |
| 37352 | 37352 | const layout = union_type.getLayout(ip); |
| 37353 | if (layout == .Extern and | |
| 37353 | if (layout == .@"extern" and | |
| 37354 | 37354 | !try sema.validateExternType(field_ty, .union_field)) |
| 37355 | 37355 | { |
| 37356 | 37356 | const msg = msg: { |
| ... | ... | @@ -37367,7 +37367,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded |
| 37367 | 37367 | break :msg msg; |
| 37368 | 37368 | }; |
| 37369 | 37369 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| 37370 | } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) { | |
| 37370 | } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) { | |
| 37371 | 37371 | const msg = msg: { |
| 37372 | 37372 | const ty_src = mod.fieldSrcLoc(union_type.decl, .{ |
| 37373 | 37373 | .index = field_i, |
| ... | ... | @@ -38286,9 +38286,9 @@ fn structFieldAlignment( |
| 38286 | 38286 | return explicit_alignment; |
| 38287 | 38287 | const mod = sema.mod; |
| 38288 | 38288 | switch (layout) { |
| 38289 | .Packed => return .none, | |
| 38290 | .Auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty), | |
| 38291 | .Extern => {}, | |
| 38289 | .@"packed" => return .none, | |
| 38290 | .auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty), | |
| 38291 | .@"extern" => {}, | |
| 38292 | 38292 | } |
| 38293 | 38293 | // extern |
| 38294 | 38294 | const ty_abi_align = try sema.typeAbiAlignment(field_ty); |
src/Value.zig+18-18| ... | ... | @@ -676,8 +676,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ |
| 676 | 676 | .Struct => { |
| 677 | 677 | const struct_type = mod.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout; |
| 678 | 678 | switch (struct_type.layout) { |
| 679 | .Auto => return error.IllDefinedMemoryLayout, | |
| 680 | .Extern => for (0..struct_type.field_types.len) |i| { | |
| 679 | .auto => return error.IllDefinedMemoryLayout, | |
| 680 | .@"extern" => for (0..struct_type.field_types.len) |i| { | |
| 681 | 681 | const off: usize = @intCast(ty.structFieldOffset(i, mod)); |
| 682 | 682 | const field_val = switch (val.ip_index) { |
| 683 | 683 | .none => switch (val.tag()) { |
| ... | ... | @@ -701,7 +701,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ |
| 701 | 701 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); |
| 702 | 702 | try writeToMemory(field_val, field_ty, mod, buffer[off..]); |
| 703 | 703 | }, |
| 704 | .Packed => { | |
| 704 | .@"packed" => { | |
| 705 | 705 | const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; |
| 706 | 706 | return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0); |
| 707 | 707 | }, |
| ... | ... | @@ -724,8 +724,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ |
| 724 | 724 | bigint.writeTwosComplement(buffer[0..byte_count], endian); |
| 725 | 725 | }, |
| 726 | 726 | .Union => switch (ty.containerLayout(mod)) { |
| 727 | .Auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already | |
| 728 | .Extern => { | |
| 727 | .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already | |
| 728 | .@"extern" => { | |
| 729 | 729 | if (val.unionTag(mod)) |union_tag| { |
| 730 | 730 | const union_obj = mod.typeToUnion(ty).?; |
| 731 | 731 | const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?; |
| ... | ... | @@ -739,7 +739,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ |
| 739 | 739 | return writeToMemory(val.unionValue(mod), backing_ty, mod, buffer[0..byte_count]); |
| 740 | 740 | } |
| 741 | 741 | }, |
| 742 | .Packed => { | |
| 742 | .@"packed" => { | |
| 743 | 743 | const backing_ty = try ty.unionBackingType(mod); |
| 744 | 744 | const byte_count: usize = @intCast(backing_ty.abiSize(mod)); |
| 745 | 745 | return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0); |
| ... | ... | @@ -841,7 +841,7 @@ pub fn writeToPackedMemory( |
| 841 | 841 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 842 | 842 | // Sema is supposed to have emitted a compile error already in the case of Auto, |
| 843 | 843 | // and Extern is handled in non-packed writeToMemory. |
| 844 | assert(struct_type.layout == .Packed); | |
| 844 | assert(struct_type.layout == .@"packed"); | |
| 845 | 845 | var bits: u16 = 0; |
| 846 | 846 | for (0..struct_type.field_types.len) |i| { |
| 847 | 847 | const field_val = switch (val.ip_index) { |
| ... | ... | @@ -866,8 +866,8 @@ pub fn writeToPackedMemory( |
| 866 | 866 | .Union => { |
| 867 | 867 | const union_obj = mod.typeToUnion(ty).?; |
| 868 | 868 | switch (union_obj.getLayout(ip)) { |
| 869 | .Auto, .Extern => unreachable, // Handled in non-packed writeToMemory | |
| 870 | .Packed => { | |
| 869 | .auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory | |
| 870 | .@"packed" => { | |
| 871 | 871 | if (val.unionTag(mod)) |union_tag| { |
| 872 | 872 | const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?; |
| 873 | 873 | const field_type = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| ... | ... | @@ -991,8 +991,8 @@ pub fn readFromMemory( |
| 991 | 991 | .Struct => { |
| 992 | 992 | const struct_type = mod.typeToStruct(ty).?; |
| 993 | 993 | switch (struct_type.layout) { |
| 994 | .Auto => unreachable, // Sema is supposed to have emitted a compile error already | |
| 995 | .Extern => { | |
| 994 | .auto => unreachable, // Sema is supposed to have emitted a compile error already | |
| 995 | .@"extern" => { | |
| 996 | 996 | const field_types = struct_type.field_types; |
| 997 | 997 | const field_vals = try arena.alloc(InternPool.Index, field_types.len); |
| 998 | 998 | for (field_vals, 0..) |*field_val, i| { |
| ... | ... | @@ -1006,7 +1006,7 @@ pub fn readFromMemory( |
| 1006 | 1006 | .storage = .{ .elems = field_vals }, |
| 1007 | 1007 | } }))); |
| 1008 | 1008 | }, |
| 1009 | .Packed => { | |
| 1009 | .@"packed" => { | |
| 1010 | 1010 | const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; |
| 1011 | 1011 | return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena); |
| 1012 | 1012 | }, |
| ... | ... | @@ -1025,8 +1025,8 @@ pub fn readFromMemory( |
| 1025 | 1025 | } }))); |
| 1026 | 1026 | }, |
| 1027 | 1027 | .Union => switch (ty.containerLayout(mod)) { |
| 1028 | .Auto => return error.IllDefinedMemoryLayout, | |
| 1029 | .Extern => { | |
| 1028 | .auto => return error.IllDefinedMemoryLayout, | |
| 1029 | .@"extern" => { | |
| 1030 | 1030 | const union_size = ty.abiSize(mod); |
| 1031 | 1031 | const array_ty = try mod.arrayType(.{ .len = union_size, .child = .u8_type }); |
| 1032 | 1032 | const val = try (try readFromMemory(array_ty, mod, buffer, arena)).intern(array_ty, mod); |
| ... | ... | @@ -1036,7 +1036,7 @@ pub fn readFromMemory( |
| 1036 | 1036 | .val = val, |
| 1037 | 1037 | } }))); |
| 1038 | 1038 | }, |
| 1039 | .Packed => { | |
| 1039 | .@"packed" => { | |
| 1040 | 1040 | const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; |
| 1041 | 1041 | return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena); |
| 1042 | 1042 | }, |
| ... | ... | @@ -1177,8 +1177,8 @@ pub fn readFromPackedMemory( |
| 1177 | 1177 | } }))); |
| 1178 | 1178 | }, |
| 1179 | 1179 | .Union => switch (ty.containerLayout(mod)) { |
| 1180 | .Auto, .Extern => unreachable, // Handled by non-packed readFromMemory | |
| 1181 | .Packed => { | |
| 1180 | .auto, .@"extern" => unreachable, // Handled by non-packed readFromMemory | |
| 1181 | .@"packed" => { | |
| 1182 | 1182 | const backing_ty = try ty.unionBackingType(mod); |
| 1183 | 1183 | const val = (try readFromPackedMemory(backing_ty, mod, buffer, bit_offset, arena)).toIntern(); |
| 1184 | 1184 | return Value.fromInterned((try mod.intern(.{ .un = .{ |
| ... | ... | @@ -4064,7 +4064,7 @@ fn dbHelper(self: *Value, tag_to_payload_map: *map: { |
| 4064 | 4064 | .alignment = 0, |
| 4065 | 4065 | }; |
| 4066 | 4066 | break :map @Type(.{ .Struct = .{ |
| 4067 | .layout = .Extern, | |
| 4067 | .layout = .@"extern", | |
| 4068 | 4068 | .fields = &fields, |
| 4069 | 4069 | .decls = &.{}, |
| 4070 | 4070 | .is_tuple = false, |
src/arch/aarch64/CodeGen.zig+4-4| ... | ... | @@ -815,10 +815,10 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 815 | 815 | .call_never_tail => try self.airCall(inst, .never_tail), |
| 816 | 816 | .call_never_inline => try self.airCall(inst, .never_inline), |
| 817 | 817 | |
| 818 | .atomic_store_unordered => try self.airAtomicStore(inst, .Unordered), | |
| 819 | .atomic_store_monotonic => try self.airAtomicStore(inst, .Monotonic), | |
| 820 | .atomic_store_release => try self.airAtomicStore(inst, .Release), | |
| 821 | .atomic_store_seq_cst => try self.airAtomicStore(inst, .SeqCst), | |
| 818 | .atomic_store_unordered => try self.airAtomicStore(inst, .unordered), | |
| 819 | .atomic_store_monotonic => try self.airAtomicStore(inst, .monotonic), | |
| 820 | .atomic_store_release => try self.airAtomicStore(inst, .release), | |
| 821 | .atomic_store_seq_cst => try self.airAtomicStore(inst, .seq_cst), | |
| 822 | 822 | |
| 823 | 823 | .struct_field_ptr_index_0 => try self.airStructFieldPtrIndex(inst, 0), |
| 824 | 824 | .struct_field_ptr_index_1 => try self.airStructFieldPtrIndex(inst, 1), |
src/arch/aarch64/abi.zig+2-2| ... | ... | @@ -21,7 +21,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { |
| 21 | 21 | var maybe_float_bits: ?u16 = null; |
| 22 | 22 | switch (ty.zigTypeTag(mod)) { |
| 23 | 23 | .Struct => { |
| 24 | if (ty.containerLayout(mod) == .Packed) return .byval; | |
| 24 | if (ty.containerLayout(mod) == .@"packed") return .byval; | |
| 25 | 25 | const float_count = countFloats(ty, mod, &maybe_float_bits); |
| 26 | 26 | if (float_count <= sret_float_count) return .{ .float_array = float_count }; |
| 27 | 27 | |
| ... | ... | @@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { |
| 31 | 31 | return .integer; |
| 32 | 32 | }, |
| 33 | 33 | .Union => { |
| 34 | if (ty.containerLayout(mod) == .Packed) return .byval; | |
| 34 | if (ty.containerLayout(mod) == .@"packed") return .byval; | |
| 35 | 35 | const float_count = countFloats(ty, mod, &maybe_float_bits); |
| 36 | 36 | if (float_count <= sret_float_count) return .{ .float_array = float_count }; |
| 37 | 37 |
src/arch/arm/CodeGen.zig+4-4| ... | ... | @@ -801,10 +801,10 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 801 | 801 | .call_never_tail => try self.airCall(inst, .never_tail), |
| 802 | 802 | .call_never_inline => try self.airCall(inst, .never_inline), |
| 803 | 803 | |
| 804 | .atomic_store_unordered => try self.airAtomicStore(inst, .Unordered), | |
| 805 | .atomic_store_monotonic => try self.airAtomicStore(inst, .Monotonic), | |
| 806 | .atomic_store_release => try self.airAtomicStore(inst, .Release), | |
| 807 | .atomic_store_seq_cst => try self.airAtomicStore(inst, .SeqCst), | |
| 804 | .atomic_store_unordered => try self.airAtomicStore(inst, .unordered), | |
| 805 | .atomic_store_monotonic => try self.airAtomicStore(inst, .monotonic), | |
| 806 | .atomic_store_release => try self.airAtomicStore(inst, .release), | |
| 807 | .atomic_store_seq_cst => try self.airAtomicStore(inst, .seq_cst), | |
| 808 | 808 | |
| 809 | 809 | .struct_field_ptr_index_0 => try self.airStructFieldPtrIndex(inst, 0), |
| 810 | 810 | .struct_field_ptr_index_1 => try self.airStructFieldPtrIndex(inst, 1), |
src/arch/arm/abi.zig+2-2| ... | ... | @@ -33,7 +33,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class { |
| 33 | 33 | switch (ty.zigTypeTag(mod)) { |
| 34 | 34 | .Struct => { |
| 35 | 35 | const bit_size = ty.bitSize(mod); |
| 36 | if (ty.containerLayout(mod) == .Packed) { | |
| 36 | if (ty.containerLayout(mod) == .@"packed") { | |
| 37 | 37 | if (bit_size > 64) return .memory; |
| 38 | 38 | return .byval; |
| 39 | 39 | } |
| ... | ... | @@ -56,7 +56,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class { |
| 56 | 56 | .Union => { |
| 57 | 57 | const bit_size = ty.bitSize(mod); |
| 58 | 58 | const union_obj = mod.typeToUnion(ty).?; |
| 59 | if (union_obj.getLayout(ip) == .Packed) { | |
| 59 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 60 | 60 | if (bit_size > 64) return .memory; |
| 61 | 61 | return .byval; |
| 62 | 62 | } |
src/arch/riscv64/CodeGen.zig+4-4| ... | ... | @@ -634,10 +634,10 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 634 | 634 | .call_never_tail => try self.airCall(inst, .never_tail), |
| 635 | 635 | .call_never_inline => try self.airCall(inst, .never_inline), |
| 636 | 636 | |
| 637 | .atomic_store_unordered => try self.airAtomicStore(inst, .Unordered), | |
| 638 | .atomic_store_monotonic => try self.airAtomicStore(inst, .Monotonic), | |
| 639 | .atomic_store_release => try self.airAtomicStore(inst, .Release), | |
| 640 | .atomic_store_seq_cst => try self.airAtomicStore(inst, .SeqCst), | |
| 637 | .atomic_store_unordered => try self.airAtomicStore(inst, .unordered), | |
| 638 | .atomic_store_monotonic => try self.airAtomicStore(inst, .monotonic), | |
| 639 | .atomic_store_release => try self.airAtomicStore(inst, .release), | |
| 640 | .atomic_store_seq_cst => try self.airAtomicStore(inst, .seq_cst), | |
| 641 | 641 | |
| 642 | 642 | .struct_field_ptr_index_0 => try self.airStructFieldPtrIndex(inst, 0), |
| 643 | 643 | .struct_field_ptr_index_1 => try self.airStructFieldPtrIndex(inst, 1), |
src/arch/riscv64/abi.zig+2-2| ... | ... | @@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { |
| 15 | 15 | switch (ty.zigTypeTag(mod)) { |
| 16 | 16 | .Struct => { |
| 17 | 17 | const bit_size = ty.bitSize(mod); |
| 18 | if (ty.containerLayout(mod) == .Packed) { | |
| 18 | if (ty.containerLayout(mod) == .@"packed") { | |
| 19 | 19 | if (bit_size > max_byval_size) return .memory; |
| 20 | 20 | return .byval; |
| 21 | 21 | } |
| ... | ... | @@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { |
| 44 | 44 | }, |
| 45 | 45 | .Union => { |
| 46 | 46 | const bit_size = ty.bitSize(mod); |
| 47 | if (ty.containerLayout(mod) == .Packed) { | |
| 47 | if (ty.containerLayout(mod) == .@"packed") { | |
| 48 | 48 | if (bit_size > max_byval_size) return .memory; |
| 49 | 49 | return .byval; |
| 50 | 50 | } |
src/arch/wasm/CodeGen.zig+7-7| ... | ... | @@ -1018,7 +1018,7 @@ fn typeToValtype(ty: Type, mod: *Module) wasm.Valtype { |
| 1018 | 1018 | .unrolled => wasm.Valtype.i32, |
| 1019 | 1019 | }, |
| 1020 | 1020 | .Union => switch (ty.containerLayout(mod)) { |
| 1021 | .Packed => { | |
| 1021 | .@"packed" => { | |
| 1022 | 1022 | const int_ty = mod.intType(.unsigned, @as(u16, @intCast(ty.bitSize(mod)))) catch @panic("out of memory"); |
| 1023 | 1023 | return typeToValtype(int_ty, mod); |
| 1024 | 1024 | }, |
| ... | ... | @@ -1737,7 +1737,7 @@ fn isByRef(ty: Type, mod: *Module) bool { |
| 1737 | 1737 | => return ty.hasRuntimeBitsIgnoreComptime(mod), |
| 1738 | 1738 | .Union => { |
| 1739 | 1739 | if (mod.typeToUnion(ty)) |union_obj| { |
| 1740 | if (union_obj.getLayout(ip) == .Packed) { | |
| 1740 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 1741 | 1741 | return ty.abiSize(mod) > 8; |
| 1742 | 1742 | } |
| 1743 | 1743 | } |
| ... | ... | @@ -3097,7 +3097,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue |
| 3097 | 3097 | break :blk parent_ty.structFieldOffset(field_index, mod); |
| 3098 | 3098 | }, |
| 3099 | 3099 | .Union => switch (parent_ty.containerLayout(mod)) { |
| 3100 | .Packed => 0, | |
| 3100 | .@"packed" => 0, | |
| 3101 | 3101 | else => blk: { |
| 3102 | 3102 | const layout: Module.UnionLayout = parent_ty.unionGetLayout(mod); |
| 3103 | 3103 | if (layout.payload_size == 0) break :blk 0; |
| ... | ... | @@ -3358,7 +3358,7 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue { |
| 3358 | 3358 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3359 | 3359 | // non-packed structs are not handled in this function because they |
| 3360 | 3360 | // are by-ref types. |
| 3361 | assert(struct_type.layout == .Packed); | |
| 3361 | assert(struct_type.layout == .@"packed"); | |
| 3362 | 3362 | var buf: [8]u8 = .{0} ** 8; // zero the buffer so we do not read 0xaa as integer |
| 3363 | 3363 | val.writeToPackedMemory(ty, mod, &buf, 0) catch unreachable; |
| 3364 | 3364 | const backing_int_ty = Type.fromInterned(struct_type.backingIntType(ip).*); |
| ... | ... | @@ -3890,7 +3890,7 @@ fn structFieldPtr( |
| 3890 | 3890 | const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod); |
| 3891 | 3891 | |
| 3892 | 3892 | const offset = switch (struct_ty.containerLayout(mod)) { |
| 3893 | .Packed => switch (struct_ty.zigTypeTag(mod)) { | |
| 3893 | .@"packed" => switch (struct_ty.zigTypeTag(mod)) { | |
| 3894 | 3894 | .Struct => offset: { |
| 3895 | 3895 | if (result_ty.ptrInfo(mod).packed_offset.host_size != 0) { |
| 3896 | 3896 | break :offset @as(u32, 0); |
| ... | ... | @@ -3928,7 +3928,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3928 | 3928 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return func.finishAir(inst, .none, &.{struct_field.struct_operand}); |
| 3929 | 3929 | |
| 3930 | 3930 | const result = switch (struct_ty.containerLayout(mod)) { |
| 3931 | .Packed => switch (struct_ty.zigTypeTag(mod)) { | |
| 3931 | .@"packed" => switch (struct_ty.zigTypeTag(mod)) { | |
| 3932 | 3932 | .Struct => result: { |
| 3933 | 3933 | const packed_struct = mod.typeToPackedStruct(struct_ty).?; |
| 3934 | 3934 | const offset = mod.structPackedFieldBitOffset(packed_struct, field_index); |
| ... | ... | @@ -5321,7 +5321,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5321 | 5321 | break :result_value result; |
| 5322 | 5322 | }, |
| 5323 | 5323 | .Struct => switch (result_ty.containerLayout(mod)) { |
| 5324 | .Packed => { | |
| 5324 | .@"packed" => { | |
| 5325 | 5325 | if (isByRef(result_ty, mod)) { |
| 5326 | 5326 | return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{}); |
| 5327 | 5327 | } |
src/arch/wasm/abi.zig+3-3| ... | ... | @@ -29,7 +29,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class { |
| 29 | 29 | switch (ty.zigTypeTag(mod)) { |
| 30 | 30 | .Struct => { |
| 31 | 31 | const struct_type = mod.typeToStruct(ty).?; |
| 32 | if (struct_type.layout == .Packed) { | |
| 32 | if (struct_type.layout == .@"packed") { | |
| 33 | 33 | if (ty.bitSize(mod) <= 64) return direct; |
| 34 | 34 | return .{ .direct, .direct }; |
| 35 | 35 | } |
| ... | ... | @@ -70,7 +70,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class { |
| 70 | 70 | }, |
| 71 | 71 | .Union => { |
| 72 | 72 | const union_obj = mod.typeToUnion(ty).?; |
| 73 | if (union_obj.getLayout(ip) == .Packed) { | |
| 73 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 74 | 74 | if (ty.bitSize(mod) <= 64) return direct; |
| 75 | 75 | return .{ .direct, .direct }; |
| 76 | 76 | } |
| ... | ... | @@ -113,7 +113,7 @@ pub fn scalarType(ty: Type, mod: *Module) Type { |
| 113 | 113 | }, |
| 114 | 114 | .Union => { |
| 115 | 115 | const union_obj = mod.typeToUnion(ty).?; |
| 116 | if (union_obj.getLayout(ip) != .Packed) { | |
| 116 | if (union_obj.getLayout(ip) != .@"packed") { | |
| 117 | 117 | const layout = mod.getUnionLayout(union_obj); |
| 118 | 118 | if (layout.payload_size == 0 and layout.tag_size != 0) { |
| 119 | 119 | return scalarType(ty.unionTagTypeSafety(mod).?, mod); |
src/arch/x86_64/CodeGen.zig+13-13| ... | ... | @@ -2111,10 +2111,10 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 2111 | 2111 | .call_never_tail => try self.airCall(inst, .never_tail), |
| 2112 | 2112 | .call_never_inline => try self.airCall(inst, .never_inline), |
| 2113 | 2113 | |
| 2114 | .atomic_store_unordered => try self.airAtomicStore(inst, .Unordered), | |
| 2115 | .atomic_store_monotonic => try self.airAtomicStore(inst, .Monotonic), | |
| 2116 | .atomic_store_release => try self.airAtomicStore(inst, .Release), | |
| 2117 | .atomic_store_seq_cst => try self.airAtomicStore(inst, .SeqCst), | |
| 2114 | .atomic_store_unordered => try self.airAtomicStore(inst, .unordered), | |
| 2115 | .atomic_store_monotonic => try self.airAtomicStore(inst, .monotonic), | |
| 2116 | .atomic_store_release => try self.airAtomicStore(inst, .release), | |
| 2117 | .atomic_store_seq_cst => try self.airAtomicStore(inst, .seq_cst), | |
| 2118 | 2118 | |
| 2119 | 2119 | .struct_field_ptr_index_0 => try self.airStructFieldPtrIndex(inst, 0), |
| 2120 | 2120 | .struct_field_ptr_index_1 => try self.airStructFieldPtrIndex(inst, 1), |
| ... | ... | @@ -7962,8 +7962,8 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { |
| 7962 | 7962 | |
| 7963 | 7963 | const src_mcv = try self.resolveInst(operand); |
| 7964 | 7964 | const field_off: u32 = switch (container_ty.containerLayout(mod)) { |
| 7965 | .Auto, .Extern => @intCast(container_ty.structFieldOffset(index, mod) * 8), | |
| 7966 | .Packed => if (mod.typeToStruct(container_ty)) |struct_type| | |
| 7965 | .auto, .@"extern" => @intCast(container_ty.structFieldOffset(index, mod) * 8), | |
| 7966 | .@"packed" => if (mod.typeToStruct(container_ty)) |struct_type| | |
| 7967 | 7967 | mod.structPackedFieldBitOffset(struct_type, index) |
| 7968 | 7968 | else |
| 7969 | 7969 | 0, |
| ... | ... | @@ -11977,9 +11977,9 @@ fn airFrameAddress(self: *Self, inst: Air.Inst.Index) !void { |
| 11977 | 11977 | fn airFence(self: *Self, inst: Air.Inst.Index) !void { |
| 11978 | 11978 | const order = self.air.instructions.items(.data)[@intFromEnum(inst)].fence; |
| 11979 | 11979 | switch (order) { |
| 11980 | .Unordered, .Monotonic => unreachable, | |
| 11981 | .Acquire, .Release, .AcqRel => {}, | |
| 11982 | .SeqCst => try self.asmOpOnly(.{ ._, .mfence }), | |
| 11980 | .unordered, .monotonic => unreachable, | |
| 11981 | .acquire, .release, .acq_rel => {}, | |
| 11982 | .seq_cst => try self.asmOpOnly(.{ ._, .mfence }), | |
| 11983 | 11983 | } |
| 11984 | 11984 | self.finishAirBookkeeping(); |
| 11985 | 11985 | } |
| ... | ... | @@ -15747,9 +15747,9 @@ fn atomicOp( |
| 15747 | 15747 | .Xor => .xor, |
| 15748 | 15748 | else => unreachable, |
| 15749 | 15749 | } else switch (order) { |
| 15750 | .Unordered, .Monotonic, .Release, .AcqRel => .mov, | |
| 15751 | .Acquire => unreachable, | |
| 15752 | .SeqCst => .xchg, | |
| 15750 | .unordered, .monotonic, .release, .acq_rel => .mov, | |
| 15751 | .acquire => unreachable, | |
| 15752 | .seq_cst => .xchg, | |
| 15753 | 15753 | }; |
| 15754 | 15754 | |
| 15755 | 15755 | const dst_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp); |
| ... | ... | @@ -17979,7 +17979,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void { |
| 17979 | 17979 | switch (result_ty.zigTypeTag(mod)) { |
| 17980 | 17980 | .Struct => { |
| 17981 | 17981 | const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, mod)); |
| 17982 | if (result_ty.containerLayout(mod) == .Packed) { | |
| 17982 | if (result_ty.containerLayout(mod) == .@"packed") { | |
| 17983 | 17983 | const struct_type = mod.typeToStruct(result_ty).?; |
| 17984 | 17984 | try self.genInlineMemset( |
| 17985 | 17985 | .{ .lea_frame = .{ .index = frame_index } }, |
src/arch/x86_64/Emit.zig+2-2| ... | ... | @@ -110,7 +110,7 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 110 | 110 | const is_obj_or_static_lib = switch (emit.lower.output_mode) { |
| 111 | 111 | .Exe => false, |
| 112 | 112 | .Obj => true, |
| 113 | .Lib => emit.lower.link_mode == .Static, | |
| 113 | .Lib => emit.lower.link_mode == .static, | |
| 114 | 114 | }; |
| 115 | 115 | const atom = elf_file.symbol(data.atom_index).atom(elf_file).?; |
| 116 | 116 | const sym_index = elf_file.zigObjectPtr().?.symbol(data.sym_index); |
| ... | ... | @@ -158,7 +158,7 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 158 | 158 | const is_obj_or_static_lib = switch (emit.lower.output_mode) { |
| 159 | 159 | .Exe => false, |
| 160 | 160 | .Obj => true, |
| 161 | .Lib => emit.lower.link_mode == .Static, | |
| 161 | .Lib => emit.lower.link_mode == .static, | |
| 162 | 162 | }; |
| 163 | 163 | const atom = macho_file.getSymbol(data.atom_index).getAtom(macho_file).?; |
| 164 | 164 | const sym_index = macho_file.getZigObject().?.symbols.items[data.sym_index]; |
src/arch/x86_64/Lower.zig+1-1| ... | ... | @@ -329,7 +329,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand) |
| 329 | 329 | const is_obj_or_static_lib = switch (lower.output_mode) { |
| 330 | 330 | .Exe => false, |
| 331 | 331 | .Obj => true, |
| 332 | .Lib => lower.link_mode == .Static, | |
| 332 | .Lib => lower.link_mode == .static, | |
| 333 | 333 | }; |
| 334 | 334 | |
| 335 | 335 | const emit_prefix = prefix; |
src/arch/x86_64/abi.zig+3-3| ... | ... | @@ -42,7 +42,7 @@ pub fn classifyWindows(ty: Type, mod: *Module) Class { |
| 42 | 42 | 1, 2, 4, 8 => return .integer, |
| 43 | 43 | else => switch (ty.zigTypeTag(mod)) { |
| 44 | 44 | .Int => return .win_i128, |
| 45 | .Struct, .Union => if (ty.containerLayout(mod) == .Packed) { | |
| 45 | .Struct, .Union => if (ty.containerLayout(mod) == .@"packed") { | |
| 46 | 46 | return .win_i128; |
| 47 | 47 | } else { |
| 48 | 48 | return .memory; |
| ... | ... | @@ -238,7 +238,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class { |
| 238 | 238 | // separately.". |
| 239 | 239 | const struct_type = mod.typeToStruct(ty).?; |
| 240 | 240 | const ty_size = ty.abiSize(mod); |
| 241 | if (struct_type.layout == .Packed) { | |
| 241 | if (struct_type.layout == .@"packed") { | |
| 242 | 242 | assert(ty_size <= 16); |
| 243 | 243 | result[0] = .integer; |
| 244 | 244 | if (ty_size > 8) result[1] = .integer; |
| ... | ... | @@ -356,7 +356,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class { |
| 356 | 356 | // separately.". |
| 357 | 357 | const union_obj = mod.typeToUnion(ty).?; |
| 358 | 358 | const ty_size = mod.unionAbiSize(union_obj); |
| 359 | if (union_obj.getLayout(ip) == .Packed) { | |
| 359 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 360 | 360 | assert(ty_size <= 16); |
| 361 | 361 | result[0] = .integer; |
| 362 | 362 | if (ty_size > 8) result[1] = .integer; |
src/codegen.zig+4-4| ... | ... | @@ -513,7 +513,7 @@ pub fn generateSymbol( |
| 513 | 513 | .struct_type => { |
| 514 | 514 | const struct_type = ip.loadStructType(typed_value.ty.toIntern()); |
| 515 | 515 | switch (struct_type.layout) { |
| 516 | .Packed => { | |
| 516 | .@"packed" => { | |
| 517 | 517 | const abi_size = math.cast(usize, typed_value.ty.abiSize(mod)) orelse |
| 518 | 518 | return error.Overflow; |
| 519 | 519 | const current_pos = code.items.len; |
| ... | ... | @@ -550,7 +550,7 @@ pub fn generateSymbol( |
| 550 | 550 | bits += @as(u16, @intCast(Type.fromInterned(field_ty).bitSize(mod))); |
| 551 | 551 | } |
| 552 | 552 | }, |
| 553 | .Auto, .Extern => { | |
| 553 | .auto, .@"extern" => { | |
| 554 | 554 | const struct_begin = code.items.len; |
| 555 | 555 | const field_types = struct_type.field_types.get(ip); |
| 556 | 556 | const offsets = struct_type.offsets.get(ip); |
| ... | ... | @@ -736,11 +736,11 @@ fn lowerParentPtr( |
| 736 | 736 | .anon_struct_type, |
| 737 | 737 | .union_type, |
| 738 | 738 | => switch (Type.fromInterned(base_ty).containerLayout(mod)) { |
| 739 | .Auto, .Extern => @intCast(Type.fromInterned(base_ty).structFieldOffset( | |
| 739 | .auto, .@"extern" => @intCast(Type.fromInterned(base_ty).structFieldOffset( | |
| 740 | 740 | @intCast(field.index), |
| 741 | 741 | mod, |
| 742 | 742 | )), |
| 743 | .Packed => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj| | |
| 743 | .@"packed" => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj| | |
| 744 | 744 | if (Type.fromInterned(ptr.ty).ptrInfo(mod).packed_offset.host_size == 0) |
| 745 | 745 | @divExact(Type.fromInterned(base_ptr_ty).ptrInfo(mod) |
| 746 | 746 | .packed_offset.bit_offset + mod.structPackedFieldBitOffset( |
src/codegen/c.zig+28-28| ... | ... | @@ -890,7 +890,7 @@ pub const DeclGen = struct { |
| 890 | 890 | return writer.writeAll(" }"); |
| 891 | 891 | }, |
| 892 | 892 | .Struct => switch (ty.containerLayout(mod)) { |
| 893 | .Auto, .Extern => { | |
| 893 | .auto, .@"extern" => { | |
| 894 | 894 | if (!location.isInitializer()) { |
| 895 | 895 | try writer.writeByte('('); |
| 896 | 896 | try dg.renderType(writer, ty); |
| ... | ... | @@ -912,7 +912,7 @@ pub const DeclGen = struct { |
| 912 | 912 | |
| 913 | 913 | return writer.writeByte('}'); |
| 914 | 914 | }, |
| 915 | .Packed => return writer.print("{x}", .{try dg.fmtIntLiteral(ty, Value.undef, .Other)}), | |
| 915 | .@"packed" => return writer.print("{x}", .{try dg.fmtIntLiteral(ty, Value.undef, .Other)}), | |
| 916 | 916 | }, |
| 917 | 917 | .Union => { |
| 918 | 918 | if (!location.isInitializer()) { |
| ... | ... | @@ -1379,7 +1379,7 @@ pub const DeclGen = struct { |
| 1379 | 1379 | .struct_type => { |
| 1380 | 1380 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 1381 | 1381 | switch (struct_type.layout) { |
| 1382 | .Auto, .Extern => { | |
| 1382 | .auto, .@"extern" => { | |
| 1383 | 1383 | if (!location.isInitializer()) { |
| 1384 | 1384 | try writer.writeByte('('); |
| 1385 | 1385 | try dg.renderType(writer, ty); |
| ... | ... | @@ -1408,7 +1408,7 @@ pub const DeclGen = struct { |
| 1408 | 1408 | } |
| 1409 | 1409 | try writer.writeByte('}'); |
| 1410 | 1410 | }, |
| 1411 | .Packed => { | |
| 1411 | .@"packed" => { | |
| 1412 | 1412 | const int_info = ty.intInfo(mod); |
| 1413 | 1413 | |
| 1414 | 1414 | const bits = Type.smallestUnsignedBits(int_info.bits - 1); |
| ... | ... | @@ -1517,7 +1517,7 @@ pub const DeclGen = struct { |
| 1517 | 1517 | if (un.tag == .none) { |
| 1518 | 1518 | const backing_ty = try ty.unionBackingType(mod); |
| 1519 | 1519 | switch (union_obj.getLayout(ip)) { |
| 1520 | .Packed => { | |
| 1520 | .@"packed" => { | |
| 1521 | 1521 | if (!location.isInitializer()) { |
| 1522 | 1522 | try writer.writeByte('('); |
| 1523 | 1523 | try dg.renderType(writer, backing_ty); |
| ... | ... | @@ -1525,7 +1525,7 @@ pub const DeclGen = struct { |
| 1525 | 1525 | } |
| 1526 | 1526 | try dg.renderValue(writer, backing_ty, Value.fromInterned(un.val), initializer_type); |
| 1527 | 1527 | }, |
| 1528 | .Extern => { | |
| 1528 | .@"extern" => { | |
| 1529 | 1529 | if (location == .StaticInitializer) { |
| 1530 | 1530 | return dg.fail("TODO: C backend: implement extern union backing type rendering in static initializers", .{}); |
| 1531 | 1531 | } |
| ... | ... | @@ -1551,7 +1551,7 @@ pub const DeclGen = struct { |
| 1551 | 1551 | const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?; |
| 1552 | 1552 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 1553 | 1553 | const field_name = union_obj.loadTagType(ip).names.get(ip)[field_index]; |
| 1554 | if (union_obj.getLayout(ip) == .Packed) { | |
| 1554 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 1555 | 1555 | if (field_ty.hasRuntimeBits(mod)) { |
| 1556 | 1556 | if (field_ty.isPtrAtRuntime(mod)) { |
| 1557 | 1557 | try writer.writeByte('('); |
| ... | ... | @@ -1999,7 +1999,7 @@ pub const DeclGen = struct { |
| 1999 | 1999 | try fwd.writeAll(if (is_global) "zig_extern " else "static "); |
| 2000 | 2000 | const maybe_exports = dg.module.decl_exports.get(decl_index); |
| 2001 | 2001 | const export_weak_linkage = if (maybe_exports) |exports| |
| 2002 | exports.items[0].opts.linkage == .Weak | |
| 2002 | exports.items[0].opts.linkage == .weak | |
| 2003 | 2003 | else |
| 2004 | 2004 | false; |
| 2005 | 2005 | if (variable.is_weak_linkage or export_weak_linkage) try fwd.writeAll("zig_weak_linkage "); |
| ... | ... | @@ -2689,7 +2689,7 @@ fn genExports(o: *Object) !void { |
| 2689 | 2689 | const is_variable_const = switch (ip.indexToKey(tv.val.toIntern())) { |
| 2690 | 2690 | .func => return for (exports.items[1..], 1..) |@"export", i| { |
| 2691 | 2691 | try fwd.writeAll("zig_extern "); |
| 2692 | if (@"export".opts.linkage == .Weak) try fwd.writeAll("zig_weak_linkage_fn "); | |
| 2692 | if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage_fn "); | |
| 2693 | 2693 | try o.dg.renderFunctionSignature( |
| 2694 | 2694 | fwd, |
| 2695 | 2695 | decl_index, |
| ... | ... | @@ -2707,7 +2707,7 @@ fn genExports(o: *Object) !void { |
| 2707 | 2707 | }; |
| 2708 | 2708 | for (exports.items[1..]) |@"export"| { |
| 2709 | 2709 | try fwd.writeAll("zig_extern "); |
| 2710 | if (@"export".opts.linkage == .Weak) try fwd.writeAll("zig_weak_linkage "); | |
| 2710 | if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage "); | |
| 2711 | 2711 | const export_name = ip.stringToSlice(@"export".opts.name); |
| 2712 | 2712 | try o.dg.renderTypeAndName( |
| 2713 | 2713 | fwd, |
| ... | ... | @@ -2842,7 +2842,7 @@ pub fn genFunc(f: *Function) !void { |
| 2842 | 2842 | try fwd_decl_writer.writeAll(if (is_global) "zig_extern " else "static "); |
| 2843 | 2843 | |
| 2844 | 2844 | if (mod.decl_exports.get(decl_index)) |exports| |
| 2845 | if (exports.items[0].opts.linkage == .Weak) try fwd_decl_writer.writeAll("zig_weak_linkage_fn "); | |
| 2845 | if (exports.items[0].opts.linkage == .weak) try fwd_decl_writer.writeAll("zig_weak_linkage_fn "); | |
| 2846 | 2846 | try o.dg.renderFunctionSignature(fwd_decl_writer, decl_index, .forward, .{ .export_index = 0 }); |
| 2847 | 2847 | try fwd_decl_writer.writeAll(";\n"); |
| 2848 | 2848 | try genExports(o); |
| ... | ... | @@ -3278,10 +3278,10 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, |
| 3278 | 3278 | |
| 3279 | 3279 | .int_from_ptr => try airIntFromPtr(f, inst), |
| 3280 | 3280 | |
| 3281 | .atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.Unordered)), | |
| 3282 | .atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.Monotonic)), | |
| 3283 | .atomic_store_release => try airAtomicStore(f, inst, toMemoryOrder(.Release)), | |
| 3284 | .atomic_store_seq_cst => try airAtomicStore(f, inst, toMemoryOrder(.SeqCst)), | |
| 3281 | .atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.unordered)), | |
| 3282 | .atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.monotonic)), | |
| 3283 | .atomic_store_release => try airAtomicStore(f, inst, toMemoryOrder(.release)), | |
| 3284 | .atomic_store_seq_cst => try airAtomicStore(f, inst, toMemoryOrder(.seq_cst)), | |
| 3285 | 3285 | |
| 3286 | 3286 | .struct_field_ptr_index_0 => try airStructFieldPtrIndex(f, inst, 0), |
| 3287 | 3287 | .struct_field_ptr_index_1 => try airStructFieldPtrIndex(f, inst, 1), |
| ... | ... | @@ -5497,7 +5497,7 @@ fn fieldLocation( |
| 5497 | 5497 | .Union => { |
| 5498 | 5498 | const union_obj = mod.typeToUnion(container_ty).?; |
| 5499 | 5499 | return switch (union_obj.getLayout(ip)) { |
| 5500 | .Auto, .Extern => { | |
| 5500 | .auto, .@"extern" => { | |
| 5501 | 5501 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 5502 | 5502 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) |
| 5503 | 5503 | return if (container_ty.unionTagTypeSafety(mod) != null and |
| ... | ... | @@ -5511,7 +5511,7 @@ fn fieldLocation( |
| 5511 | 5511 | else |
| 5512 | 5512 | .{ .identifier = ip.stringToSlice(field_name) } }; |
| 5513 | 5513 | }, |
| 5514 | .Packed => .begin, | |
| 5514 | .@"packed" => .begin, | |
| 5515 | 5515 | }; |
| 5516 | 5516 | }, |
| 5517 | 5517 | .Pointer => switch (container_ty.ptrSize(mod)) { |
| ... | ... | @@ -5671,11 +5671,11 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5671 | 5671 | |
| 5672 | 5672 | const field_name: CValue = switch (mod.intern_pool.indexToKey(struct_ty.ip_index)) { |
| 5673 | 5673 | .struct_type => switch (struct_ty.containerLayout(mod)) { |
| 5674 | .Auto, .Extern => if (struct_ty.isSimpleTuple(mod)) | |
| 5674 | .auto, .@"extern" => if (struct_ty.isSimpleTuple(mod)) | |
| 5675 | 5675 | .{ .field = extra.field_index } |
| 5676 | 5676 | else |
| 5677 | 5677 | .{ .identifier = ip.stringToSlice(struct_ty.legacyStructFieldName(extra.field_index, mod)) }, |
| 5678 | .Packed => { | |
| 5678 | .@"packed" => { | |
| 5679 | 5679 | const struct_type = mod.typeToStruct(struct_ty).?; |
| 5680 | 5680 | const int_info = struct_ty.intInfo(mod); |
| 5681 | 5681 | |
| ... | ... | @@ -5740,7 +5740,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5740 | 5740 | |
| 5741 | 5741 | .union_type => field_name: { |
| 5742 | 5742 | const union_obj = ip.loadUnionType(struct_ty.toIntern()); |
| 5743 | if (union_obj.flagsPtr(ip).layout == .Packed) { | |
| 5743 | if (union_obj.flagsPtr(ip).layout == .@"packed") { | |
| 5744 | 5744 | const operand_lval = if (struct_byval == .constant) blk: { |
| 5745 | 5745 | const operand_local = try f.allocLocal(inst, struct_ty); |
| 5746 | 5746 | try f.writeCValue(writer, operand_local, .Other); |
| ... | ... | @@ -7081,7 +7081,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7081 | 7081 | } |
| 7082 | 7082 | }, |
| 7083 | 7083 | .Struct => switch (inst_ty.containerLayout(mod)) { |
| 7084 | .Auto, .Extern => for (resolved_elements, 0..) |element, field_index| { | |
| 7084 | .auto, .@"extern" => for (resolved_elements, 0..) |element, field_index| { | |
| 7085 | 7085 | if (inst_ty.structFieldIsComptime(field_index, mod)) continue; |
| 7086 | 7086 | const field_ty = inst_ty.structFieldType(field_index, mod); |
| 7087 | 7087 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) continue; |
| ... | ... | @@ -7095,7 +7095,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7095 | 7095 | try f.writeCValue(writer, element, .Other); |
| 7096 | 7096 | try a.end(f, writer); |
| 7097 | 7097 | }, |
| 7098 | .Packed => { | |
| 7098 | .@"packed" => { | |
| 7099 | 7099 | try f.writeCValue(writer, local, .Other); |
| 7100 | 7100 | try writer.writeAll(" = "); |
| 7101 | 7101 | const int_info = inst_ty.intInfo(mod); |
| ... | ... | @@ -7181,7 +7181,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7181 | 7181 | |
| 7182 | 7182 | const writer = f.object.writer(); |
| 7183 | 7183 | const local = try f.allocLocal(inst, union_ty); |
| 7184 | if (union_obj.getLayout(ip) == .Packed) { | |
| 7184 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 7185 | 7185 | try f.writeCValue(writer, local, .Other); |
| 7186 | 7186 | try writer.writeAll(" = "); |
| 7187 | 7187 | try f.writeCValue(writer, payload, .Initializer); |
| ... | ... | @@ -7482,11 +7482,11 @@ fn airCVaCopy(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7482 | 7482 | fn toMemoryOrder(order: std.builtin.AtomicOrder) [:0]const u8 { |
| 7483 | 7483 | return switch (order) { |
| 7484 | 7484 | // Note: unordered is actually even less atomic than relaxed |
| 7485 | .Unordered, .Monotonic => "zig_memory_order_relaxed", | |
| 7486 | .Acquire => "zig_memory_order_acquire", | |
| 7487 | .Release => "zig_memory_order_release", | |
| 7488 | .AcqRel => "zig_memory_order_acq_rel", | |
| 7489 | .SeqCst => "zig_memory_order_seq_cst", | |
| 7485 | .unordered, .monotonic => "zig_memory_order_relaxed", | |
| 7486 | .acquire => "zig_memory_order_acquire", | |
| 7487 | .release => "zig_memory_order_release", | |
| 7488 | .acq_rel => "zig_memory_order_acq_rel", | |
| 7489 | .seq_cst => "zig_memory_order_seq_cst", | |
| 7490 | 7490 | }; |
| 7491 | 7491 | } |
| 7492 | 7492 |
src/codegen/c/type.zig+1-1| ... | ... | @@ -1495,7 +1495,7 @@ pub const CType = extern union { |
| 1495 | 1495 | } |
| 1496 | 1496 | }, |
| 1497 | 1497 | |
| 1498 | .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .Packed) { | |
| 1498 | .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .@"packed") { | |
| 1499 | 1499 | if (mod.typeToPackedStruct(ty)) |packed_struct| { |
| 1500 | 1500 | try self.initType(Type.fromInterned(packed_struct.backingIntType(ip).*), kind, lookup); |
| 1501 | 1501 | } else { |
src/codegen/llvm.zig+28-28| ... | ... | @@ -1278,7 +1278,7 @@ pub const Object = struct { |
| 1278 | 1278 | |
| 1279 | 1279 | const reloc_mode: llvm.RelocMode = if (pic) |
| 1280 | 1280 | .PIC |
| 1281 | else if (self.module.comp.config.link_mode == .Dynamic) | |
| 1281 | else if (self.module.comp.config.link_mode == .dynamic) | |
| 1282 | 1282 | llvm.RelocMode.DynamicNoPIC |
| 1283 | 1283 | else |
| 1284 | 1284 | .Static; |
| ... | ... | @@ -1873,10 +1873,10 @@ pub const Object = struct { |
| 1873 | 1873 | if (comp.config.dll_export_fns) |
| 1874 | 1874 | global_index.setDllStorageClass(.dllexport, &o.builder); |
| 1875 | 1875 | global_index.setLinkage(switch (exports[0].opts.linkage) { |
| 1876 | .Internal => unreachable, | |
| 1877 | .Strong => .external, | |
| 1878 | .Weak => .weak_odr, | |
| 1879 | .LinkOnce => .linkonce_odr, | |
| 1876 | .internal => unreachable, | |
| 1877 | .strong => .external, | |
| 1878 | .weak => .weak_odr, | |
| 1879 | .link_once => .linkonce_odr, | |
| 1880 | 1880 | }, &o.builder); |
| 1881 | 1881 | global_index.setVisibility(switch (exports[0].opts.visibility) { |
| 1882 | 1882 | .default => .default, |
| ... | ... | @@ -3327,7 +3327,7 @@ pub const Object = struct { |
| 3327 | 3327 | |
| 3328 | 3328 | const struct_type = ip.loadStructType(t.toIntern()); |
| 3329 | 3329 | |
| 3330 | if (struct_type.layout == .Packed) { | |
| 3330 | if (struct_type.layout == .@"packed") { | |
| 3331 | 3331 | const int_ty = try o.lowerType(Type.fromInterned(struct_type.backingIntType(ip).*)); |
| 3332 | 3332 | try o.type_map.put(o.gpa, t.toIntern(), int_ty); |
| 3333 | 3333 | return int_ty; |
| ... | ... | @@ -3477,7 +3477,7 @@ pub const Object = struct { |
| 3477 | 3477 | const union_obj = ip.loadUnionType(t.toIntern()); |
| 3478 | 3478 | const layout = mod.getUnionLayout(union_obj); |
| 3479 | 3479 | |
| 3480 | if (union_obj.flagsPtr(ip).layout == .Packed) { | |
| 3480 | if (union_obj.flagsPtr(ip).layout == .@"packed") { | |
| 3481 | 3481 | const int_ty = try o.builder.intType(@intCast(t.bitSize(mod))); |
| 3482 | 3482 | try o.type_map.put(o.gpa, t.toIntern(), int_ty); |
| 3483 | 3483 | return int_ty; |
| ... | ... | @@ -4038,7 +4038,7 @@ pub const Object = struct { |
| 4038 | 4038 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 4039 | 4039 | assert(struct_type.haveLayout(ip)); |
| 4040 | 4040 | const struct_ty = try o.lowerType(ty); |
| 4041 | if (struct_type.layout == .Packed) { | |
| 4041 | if (struct_type.layout == .@"packed") { | |
| 4042 | 4042 | comptime assert(Type.packed_struct_layout_version == 2); |
| 4043 | 4043 | var running_int = try o.builder.intConst(struct_ty, 0); |
| 4044 | 4044 | var running_bits: u16 = 0; |
| ... | ... | @@ -4154,7 +4154,7 @@ pub const Object = struct { |
| 4154 | 4154 | const payload = if (un.tag != .none) p: { |
| 4155 | 4155 | const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?; |
| 4156 | 4156 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 4157 | if (container_layout == .Packed) { | |
| 4157 | if (container_layout == .@"packed") { | |
| 4158 | 4158 | if (!field_ty.hasRuntimeBits(mod)) return o.builder.intConst(union_ty, 0); |
| 4159 | 4159 | const small_int_val = try o.builder.castConst( |
| 4160 | 4160 | if (field_ty.isPtrAtRuntime(mod)) .ptrtoint else .bitcast, |
| ... | ... | @@ -4190,7 +4190,7 @@ pub const Object = struct { |
| 4190 | 4190 | } else p: { |
| 4191 | 4191 | assert(layout.tag_size == 0); |
| 4192 | 4192 | const union_val = try o.lowerValue(un.val); |
| 4193 | if (container_layout == .Packed) { | |
| 4193 | if (container_layout == .@"packed") { | |
| 4194 | 4194 | const bitcast_val = try o.builder.castConst( |
| 4195 | 4195 | .bitcast, |
| 4196 | 4196 | union_val, |
| ... | ... | @@ -4324,7 +4324,7 @@ pub const Object = struct { |
| 4324 | 4324 | const field_index: u32 = @intCast(field_ptr.index); |
| 4325 | 4325 | switch (parent_ty.zigTypeTag(mod)) { |
| 4326 | 4326 | .Union => { |
| 4327 | if (parent_ty.containerLayout(mod) == .Packed) { | |
| 4327 | if (parent_ty.containerLayout(mod) == .@"packed") { | |
| 4328 | 4328 | return parent_ptr; |
| 4329 | 4329 | } |
| 4330 | 4330 | |
| ... | ... | @@ -6531,7 +6531,7 @@ pub const FuncGen = struct { |
| 6531 | 6531 | assert(!isByRef(field_ty, mod)); |
| 6532 | 6532 | switch (struct_ty.zigTypeTag(mod)) { |
| 6533 | 6533 | .Struct => switch (struct_ty.containerLayout(mod)) { |
| 6534 | .Packed => { | |
| 6534 | .@"packed" => { | |
| 6535 | 6535 | const struct_type = mod.typeToStruct(struct_ty).?; |
| 6536 | 6536 | const bit_offset = mod.structPackedFieldBitOffset(struct_type, field_index); |
| 6537 | 6537 | const containing_int = struct_llvm_val; |
| ... | ... | @@ -6558,7 +6558,7 @@ pub const FuncGen = struct { |
| 6558 | 6558 | }, |
| 6559 | 6559 | }, |
| 6560 | 6560 | .Union => { |
| 6561 | assert(struct_ty.containerLayout(mod) == .Packed); | |
| 6561 | assert(struct_ty.containerLayout(mod) == .@"packed"); | |
| 6562 | 6562 | const containing_int = struct_llvm_val; |
| 6563 | 6563 | const elem_llvm_ty = try o.lowerType(field_ty); |
| 6564 | 6564 | if (field_ty.zigTypeTag(mod) == .Float or field_ty.zigTypeTag(mod) == .Vector) { |
| ... | ... | @@ -6581,7 +6581,7 @@ pub const FuncGen = struct { |
| 6581 | 6581 | switch (struct_ty.zigTypeTag(mod)) { |
| 6582 | 6582 | .Struct => { |
| 6583 | 6583 | const layout = struct_ty.containerLayout(mod); |
| 6584 | assert(layout != .Packed); | |
| 6584 | assert(layout != .@"packed"); | |
| 6585 | 6585 | const struct_llvm_ty = try o.lowerType(struct_ty); |
| 6586 | 6586 | const llvm_field_index = o.llvmFieldIndex(struct_ty, field_index).?; |
| 6587 | 6587 | const field_ptr = |
| ... | ... | @@ -9995,7 +9995,7 @@ pub const FuncGen = struct { |
| 9995 | 9995 | return running_int; |
| 9996 | 9996 | } |
| 9997 | 9997 | |
| 9998 | assert(result_ty.containerLayout(mod) != .Packed); | |
| 9998 | assert(result_ty.containerLayout(mod) != .@"packed"); | |
| 9999 | 9999 | |
| 10000 | 10000 | if (isByRef(result_ty, mod)) { |
| 10001 | 10001 | // TODO in debug builds init to undef so that the padding will be 0xaa |
| ... | ... | @@ -10080,7 +10080,7 @@ pub const FuncGen = struct { |
| 10080 | 10080 | const layout = union_ty.unionGetLayout(mod); |
| 10081 | 10081 | const union_obj = mod.typeToUnion(union_ty).?; |
| 10082 | 10082 | |
| 10083 | if (union_obj.getLayout(ip) == .Packed) { | |
| 10083 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 10084 | 10084 | const big_bits = union_ty.bitSize(mod); |
| 10085 | 10085 | const int_llvm_ty = try o.builder.intType(@intCast(big_bits)); |
| 10086 | 10086 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[extra.field_index]); |
| ... | ... | @@ -10420,7 +10420,7 @@ pub const FuncGen = struct { |
| 10420 | 10420 | const struct_ty = struct_ptr_ty.childType(mod); |
| 10421 | 10421 | switch (struct_ty.zigTypeTag(mod)) { |
| 10422 | 10422 | .Struct => switch (struct_ty.containerLayout(mod)) { |
| 10423 | .Packed => { | |
| 10423 | .@"packed" => { | |
| 10424 | 10424 | const result_ty = self.typeOfIndex(inst); |
| 10425 | 10425 | const result_ty_info = result_ty.ptrInfo(mod); |
| 10426 | 10426 | const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod); |
| ... | ... | @@ -10462,7 +10462,7 @@ pub const FuncGen = struct { |
| 10462 | 10462 | }, |
| 10463 | 10463 | .Union => { |
| 10464 | 10464 | const layout = struct_ty.unionGetLayout(mod); |
| 10465 | if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .Packed) return struct_ptr; | |
| 10465 | if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .@"packed") return struct_ptr; | |
| 10466 | 10466 | const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align)); |
| 10467 | 10467 | const union_llvm_ty = try o.lowerType(struct_ty); |
| 10468 | 10468 | return self.wip.gepStruct(union_llvm_ty, struct_ptr, payload_index, ""); |
| ... | ... | @@ -10801,12 +10801,12 @@ pub const FuncGen = struct { |
| 10801 | 10801 | |
| 10802 | 10802 | fn toLlvmAtomicOrdering(atomic_order: std.builtin.AtomicOrder) Builder.AtomicOrdering { |
| 10803 | 10803 | return switch (atomic_order) { |
| 10804 | .Unordered => .unordered, | |
| 10805 | .Monotonic => .monotonic, | |
| 10806 | .Acquire => .acquire, | |
| 10807 | .Release => .release, | |
| 10808 | .AcqRel => .acq_rel, | |
| 10809 | .SeqCst => .seq_cst, | |
| 10804 | .unordered => .unordered, | |
| 10805 | .monotonic => .monotonic, | |
| 10806 | .acquire => .acquire, | |
| 10807 | .release => .release, | |
| 10808 | .acq_rel => .acq_rel, | |
| 10809 | .seq_cst => .seq_cst, | |
| 10810 | 10810 | }; |
| 10811 | 10811 | } |
| 10812 | 10812 | |
| ... | ... | @@ -11572,7 +11572,7 @@ fn isByRef(ty: Type, mod: *Module) bool { |
| 11572 | 11572 | }; |
| 11573 | 11573 | |
| 11574 | 11574 | // Packed structs are represented to LLVM as integers. |
| 11575 | if (struct_type.layout == .Packed) return false; | |
| 11575 | if (struct_type.layout == .@"packed") return false; | |
| 11576 | 11576 | |
| 11577 | 11577 | const field_types = struct_type.field_types.get(ip); |
| 11578 | 11578 | var it = struct_type.iterateRuntimeOrder(ip); |
| ... | ... | @@ -11586,7 +11586,7 @@ fn isByRef(ty: Type, mod: *Module) bool { |
| 11586 | 11586 | return false; |
| 11587 | 11587 | }, |
| 11588 | 11588 | .Union => switch (ty.containerLayout(mod)) { |
| 11589 | .Packed => return false, | |
| 11589 | .@"packed" => return false, | |
| 11590 | 11590 | else => return ty.hasRuntimeBits(mod), |
| 11591 | 11591 | }, |
| 11592 | 11592 | .ErrorUnion => { |
| ... | ... | @@ -11624,8 +11624,8 @@ fn isScalar(mod: *Module, ty: Type) bool { |
| 11624 | 11624 | .Vector, |
| 11625 | 11625 | => true, |
| 11626 | 11626 | |
| 11627 | .Struct => ty.containerLayout(mod) == .Packed, | |
| 11628 | .Union => ty.containerLayout(mod) == .Packed, | |
| 11627 | .Struct => ty.containerLayout(mod) == .@"packed", | |
| 11628 | .Union => ty.containerLayout(mod) == .@"packed", | |
| 11629 | 11629 | else => false, |
| 11630 | 11630 | }; |
| 11631 | 11631 | } |
src/codegen/llvm/Builder.zig+1-1| ... | ... | @@ -8398,7 +8398,7 @@ pub const Metadata = enum(u32) { |
| 8398 | 8398 | fmt_str = fmt_str ++ ")\n"; |
| 8399 | 8399 | |
| 8400 | 8400 | var fmt_args: @Type(.{ .Struct = .{ |
| 8401 | .layout = .Auto, | |
| 8401 | .layout = .auto, | |
| 8402 | 8402 | .fields = &fields, |
| 8403 | 8403 | .decls = &.{}, |
| 8404 | 8404 | .is_tuple = false, |
src/codegen/llvm/bitcode_writer.zig+2-2| ... | ... | @@ -415,8 +415,8 @@ fn BufType(comptime T: type, comptime min_len: usize) type { |
| 415 | 415 | .Enum => |info| info.tag_type, |
| 416 | 416 | .Bool => u1, |
| 417 | 417 | .Struct => |info| switch (info.layout) { |
| 418 | .Auto, .Extern => @compileError("Unsupported type: " ++ @typeName(T)), | |
| 419 | .Packed => std.meta.Int(.unsigned, @bitSizeOf(T)), | |
| 418 | .auto, .@"extern" => @compileError("Unsupported type: " ++ @typeName(T)), | |
| 419 | .@"packed" => std.meta.Int(.unsigned, @bitSizeOf(T)), | |
| 420 | 420 | }, |
| 421 | 421 | else => @compileError("Unsupported type: " ++ @typeName(T)), |
| 422 | 422 | }))); |
src/codegen/spirv.zig+8-8| ... | ... | @@ -979,7 +979,7 @@ const DeclGen = struct { |
| 979 | 979 | }, |
| 980 | 980 | .struct_type => { |
| 981 | 981 | const struct_type = mod.typeToStruct(ty).?; |
| 982 | if (struct_type.layout == .Packed) { | |
| 982 | if (struct_type.layout == .@"packed") { | |
| 983 | 983 | return self.todo("packed struct constants", .{}); |
| 984 | 984 | } |
| 985 | 985 | |
| ... | ... | @@ -1275,7 +1275,7 @@ const DeclGen = struct { |
| 1275 | 1275 | const ip = &mod.intern_pool; |
| 1276 | 1276 | const union_obj = mod.typeToUnion(ty).?; |
| 1277 | 1277 | |
| 1278 | if (union_obj.getLayout(ip) == .Packed) { | |
| 1278 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 1279 | 1279 | return self.todo("packed union types", .{}); |
| 1280 | 1280 | } |
| 1281 | 1281 | |
| ... | ... | @@ -1532,7 +1532,7 @@ const DeclGen = struct { |
| 1532 | 1532 | else => unreachable, |
| 1533 | 1533 | }; |
| 1534 | 1534 | |
| 1535 | if (struct_type.layout == .Packed) { | |
| 1535 | if (struct_type.layout == .@"packed") { | |
| 1536 | 1536 | return try self.resolveType(Type.fromInterned(struct_type.backingIntType(ip).*), .direct); |
| 1537 | 1537 | } |
| 1538 | 1538 | |
| ... | ... | @@ -3904,7 +3904,7 @@ const DeclGen = struct { |
| 3904 | 3904 | const union_ty = mod.typeToUnion(ty).?; |
| 3905 | 3905 | const tag_ty = Type.fromInterned(union_ty.enum_tag_ty); |
| 3906 | 3906 | |
| 3907 | if (union_ty.getLayout(ip) == .Packed) { | |
| 3907 | if (union_ty.getLayout(ip) == .@"packed") { | |
| 3908 | 3908 | unreachable; // TODO |
| 3909 | 3909 | } |
| 3910 | 3910 | |
| ... | ... | @@ -3984,11 +3984,11 @@ const DeclGen = struct { |
| 3984 | 3984 | |
| 3985 | 3985 | switch (object_ty.zigTypeTag(mod)) { |
| 3986 | 3986 | .Struct => switch (object_ty.containerLayout(mod)) { |
| 3987 | .Packed => unreachable, // TODO | |
| 3987 | .@"packed" => unreachable, // TODO | |
| 3988 | 3988 | else => return try self.extractField(field_ty, object_id, field_index), |
| 3989 | 3989 | }, |
| 3990 | 3990 | .Union => switch (object_ty.containerLayout(mod)) { |
| 3991 | .Packed => unreachable, // TODO | |
| 3991 | .@"packed" => unreachable, // TODO | |
| 3992 | 3992 | else => { |
| 3993 | 3993 | // Store, ptr-elem-ptr, pointer-cast, load |
| 3994 | 3994 | const layout = self.unionLayout(object_ty); |
| ... | ... | @@ -4058,13 +4058,13 @@ const DeclGen = struct { |
| 4058 | 4058 | const object_ty = object_ptr_ty.childType(mod); |
| 4059 | 4059 | switch (object_ty.zigTypeTag(mod)) { |
| 4060 | 4060 | .Struct => switch (object_ty.containerLayout(mod)) { |
| 4061 | .Packed => unreachable, // TODO | |
| 4061 | .@"packed" => unreachable, // TODO | |
| 4062 | 4062 | else => { |
| 4063 | 4063 | return try self.accessChain(result_ty_ref, object_ptr, &.{field_index}); |
| 4064 | 4064 | }, |
| 4065 | 4065 | }, |
| 4066 | 4066 | .Union => switch (object_ty.containerLayout(mod)) { |
| 4067 | .Packed => unreachable, // TODO | |
| 4067 | .@"packed" => unreachable, // TODO | |
| 4068 | 4068 | else => { |
| 4069 | 4069 | const layout = self.unionLayout(object_ty); |
| 4070 | 4070 | if (!layout.has_payload) { |
src/codegen/spirv/Section.zig+2-2| ... | ... | @@ -154,7 +154,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand) |
| 154 | 154 | } |
| 155 | 155 | }, |
| 156 | 156 | .Struct => |info| { |
| 157 | if (info.layout == .Packed) { | |
| 157 | if (info.layout == .@"packed") { | |
| 158 | 158 | section.writeWord(@as(Word, @bitCast(operand))); |
| 159 | 159 | } else { |
| 160 | 160 | section.writeExtendedMask(Operand, operand); |
| ... | ... | @@ -288,7 +288,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { |
| 288 | 288 | } |
| 289 | 289 | break :blk total; |
| 290 | 290 | }, |
| 291 | .Struct => |info| if (info.layout == .Packed) 1 else extendedMaskSize(Operand, operand), | |
| 291 | .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand), | |
| 292 | 292 | .Union => extendedUnionSize(Operand, operand), |
| 293 | 293 | else => unreachable, |
| 294 | 294 | }, |
src/crash_report.zig+2-2| ... | ... | @@ -376,7 +376,7 @@ const PanicSwitch = struct { |
| 376 | 376 | }; |
| 377 | 377 | state.* = new_state; |
| 378 | 378 | |
| 379 | _ = panicking.fetchAdd(1, .SeqCst); | |
| 379 | _ = panicking.fetchAdd(1, .seq_cst); | |
| 380 | 380 | |
| 381 | 381 | state.recover_stage = .release_ref_count; |
| 382 | 382 | |
| ... | ... | @@ -458,7 +458,7 @@ const PanicSwitch = struct { |
| 458 | 458 | noinline fn releaseRefCount(state: *volatile PanicState) noreturn { |
| 459 | 459 | state.recover_stage = .abort; |
| 460 | 460 | |
| 461 | if (panicking.fetchSub(1, .SeqCst) != 1) { | |
| 461 | if (panicking.fetchSub(1, .seq_cst) != 1) { | |
| 462 | 462 | // Another thread is panicking, wait for the last one to finish |
| 463 | 463 | // and call abort() |
| 464 | 464 |
src/glibc.zig+1-1| ... | ... | @@ -1084,7 +1084,7 @@ fn buildSharedLib( |
| 1084 | 1084 | const strip = comp.compilerRtStrip(); |
| 1085 | 1085 | const config = try Compilation.Config.resolve(.{ |
| 1086 | 1086 | .output_mode = .Lib, |
| 1087 | .link_mode = .Dynamic, | |
| 1087 | .link_mode = .dynamic, | |
| 1088 | 1088 | .resolved_target = comp.root_mod.resolved_target, |
| 1089 | 1089 | .is_test = false, |
| 1090 | 1090 | .have_zcu = false, |
src/libcxx.zig+2-2| ... | ... | @@ -115,7 +115,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 115 | 115 | |
| 116 | 116 | const root_name = "c++"; |
| 117 | 117 | const output_mode = .Lib; |
| 118 | const link_mode = .Static; | |
| 118 | const link_mode = .static; | |
| 119 | 119 | const target = comp.root_mod.resolved_target.result; |
| 120 | 120 | const basename = try std.zig.binNameAlloc(arena, .{ |
| 121 | 121 | .root_name = root_name, |
| ... | ... | @@ -327,7 +327,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 327 | 327 | |
| 328 | 328 | const root_name = "c++abi"; |
| 329 | 329 | const output_mode = .Lib; |
| 330 | const link_mode = .Static; | |
| 330 | const link_mode = .static; | |
| 331 | 331 | const target = comp.root_mod.resolved_target.result; |
| 332 | 332 | const basename = try std.zig.binNameAlloc(arena, .{ |
| 333 | 333 | .root_name = root_name, |
src/libtsan.zig+1-1| ... | ... | @@ -27,7 +27,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) BuildError!v |
| 27 | 27 | |
| 28 | 28 | const root_name = "tsan"; |
| 29 | 29 | const output_mode = .Lib; |
| 30 | const link_mode = .Static; | |
| 30 | const link_mode = .static; | |
| 31 | 31 | const target = comp.getTarget(); |
| 32 | 32 | const basename = try std.zig.binNameAlloc(arena, .{ |
| 33 | 33 | .root_name = root_name, |
src/libunwind.zig+1-1| ... | ... | @@ -62,7 +62,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 62 | 62 | }); |
| 63 | 63 | |
| 64 | 64 | const root_name = "unwind"; |
| 65 | const link_mode = .Static; | |
| 65 | const link_mode = .static; | |
| 66 | 66 | const target = comp.root_mod.resolved_target.result; |
| 67 | 67 | const basename = try std.zig.binNameAlloc(arena, .{ |
| 68 | 68 | .root_name = root_name, |
src/link.zig+6-6| ... | ... | @@ -287,8 +287,8 @@ pub const File = struct { |
| 287 | 287 | switch (output_mode) { |
| 288 | 288 | .Obj => return, |
| 289 | 289 | .Lib => switch (link_mode) { |
| 290 | .Static => return, | |
| 291 | .Dynamic => {}, | |
| 290 | .static => return, | |
| 291 | .dynamic => {}, | |
| 292 | 292 | }, |
| 293 | 293 | .Exe => {}, |
| 294 | 294 | } |
| ... | ... | @@ -582,7 +582,7 @@ pub const File = struct { |
| 582 | 582 | const use_lld = build_options.have_llvm and comp.config.use_lld; |
| 583 | 583 | const output_mode = comp.config.output_mode; |
| 584 | 584 | const link_mode = comp.config.link_mode; |
| 585 | if (use_lld and output_mode == .Lib and link_mode == .Static) { | |
| 585 | if (use_lld and output_mode == .Lib and link_mode == .static) { | |
| 586 | 586 | return base.linkAsArchive(arena, prog_node); |
| 587 | 587 | } |
| 588 | 588 | switch (base.tag) { |
| ... | ... | @@ -957,8 +957,8 @@ pub const File = struct { |
| 957 | 957 | const executable_mode = if (builtin.target.os.tag == .windows) 0 else 0o777; |
| 958 | 958 | switch (effectiveOutputMode(use_lld, output_mode)) { |
| 959 | 959 | .Lib => return switch (link_mode) { |
| 960 | .Dynamic => executable_mode, | |
| 961 | .Static => fs.File.default_mode, | |
| 960 | .dynamic => executable_mode, | |
| 961 | .static => fs.File.default_mode, | |
| 962 | 962 | }, |
| 963 | 963 | .Exe => return executable_mode, |
| 964 | 964 | .Obj => return fs.File.default_mode, |
| ... | ... | @@ -966,7 +966,7 @@ pub const File = struct { |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | pub fn isStatic(self: File) bool { |
| 969 | return self.comp.config.link_mode == .Static; | |
| 969 | return self.comp.config.link_mode == .static; | |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | pub fn isObject(self: File) bool { |
src/link/Coff.zig+6-6| ... | ... | @@ -1599,11 +1599,11 @@ pub fn updateExports( |
| 1599 | 1599 | } |
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | if (exp.opts.linkage == .LinkOnce) { | |
| 1602 | if (exp.opts.linkage == .link_once) { | |
| 1603 | 1603 | try mod.failed_exports.putNoClobber(gpa, exp, try Module.ErrorMsg.create( |
| 1604 | 1604 | gpa, |
| 1605 | 1605 | exp.getSrcLoc(mod), |
| 1606 | "Unimplemented: GlobalLinkage.LinkOnce", | |
| 1606 | "Unimplemented: GlobalLinkage.link_once", | |
| 1607 | 1607 | .{}, |
| 1608 | 1608 | )); |
| 1609 | 1609 | continue; |
| ... | ... | @@ -1633,11 +1633,11 @@ pub fn updateExports( |
| 1633 | 1633 | sym.type = atom.getSymbol(self).type; |
| 1634 | 1634 | |
| 1635 | 1635 | switch (exp.opts.linkage) { |
| 1636 | .Strong => { | |
| 1636 | .strong => { | |
| 1637 | 1637 | sym.storage_class = .EXTERNAL; |
| 1638 | 1638 | }, |
| 1639 | .Internal => @panic("TODO Internal"), | |
| 1640 | .Weak => @panic("TODO WeakExternal"), | |
| 1639 | .internal => @panic("TODO Internal"), | |
| 1640 | .weak => @panic("TODO WeakExternal"), | |
| 1641 | 1641 | else => unreachable, |
| 1642 | 1642 | } |
| 1643 | 1643 | |
| ... | ... | @@ -2275,7 +2275,7 @@ fn writeHeader(self: *Coff) !void { |
| 2275 | 2275 | .p32 => flags.@"32BIT_MACHINE" = 1, |
| 2276 | 2276 | .p64 => flags.LARGE_ADDRESS_AWARE = 1, |
| 2277 | 2277 | } |
| 2278 | if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .Dynamic) { | |
| 2278 | if (self.base.comp.config.output_mode == .Lib and self.base.comp.config.link_mode == .dynamic) { | |
| 2279 | 2279 | flags.DLL = 1; |
| 2280 | 2280 | } |
| 2281 | 2281 |
src/link/Coff/lld.zig+5-5| ... | ... | @@ -45,7 +45,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) |
| 45 | 45 | defer sub_prog_node.end(); |
| 46 | 46 | |
| 47 | 47 | const is_lib = comp.config.output_mode == .Lib; |
| 48 | const is_dyn_lib = comp.config.link_mode == .Dynamic and is_lib; | |
| 48 | const is_dyn_lib = comp.config.link_mode == .dynamic and is_lib; | |
| 49 | 49 | const is_exe_or_dyn_lib = is_dyn_lib or comp.config.output_mode == .Exe; |
| 50 | 50 | const link_in_crt = comp.config.link_libc and is_exe_or_dyn_lib; |
| 51 | 51 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -411,16 +411,16 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) |
| 411 | 411 | try argv.append(try comp.get_libc_crt_file(arena, "mingwex.lib")); |
| 412 | 412 | } else { |
| 413 | 413 | const lib_str = switch (comp.config.link_mode) { |
| 414 | .Dynamic => "", | |
| 415 | .Static => "lib", | |
| 414 | .dynamic => "", | |
| 415 | .static => "lib", | |
| 416 | 416 | }; |
| 417 | 417 | const d_str = switch (optimize_mode) { |
| 418 | 418 | .Debug => "d", |
| 419 | 419 | else => "", |
| 420 | 420 | }; |
| 421 | 421 | switch (comp.config.link_mode) { |
| 422 | .Static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})), | |
| 423 | .Dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})), | |
| 422 | .static => try argv.append(try allocPrint(arena, "libcmt{s}.lib", .{d_str})), | |
| 423 | .dynamic => try argv.append(try allocPrint(arena, "msvcrt{s}.lib", .{d_str})), | |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | try argv.append(try allocPrint(arena, "{s}vcruntime{s}.lib", .{ lib_str, d_str })); |
src/link/Dwarf.zig+1-1| ... | ... | @@ -317,7 +317,7 @@ pub const DeclState = struct { |
| 317 | 317 | try ty.print(dbg_info_buffer.writer(), mod); |
| 318 | 318 | try dbg_info_buffer.append(0); |
| 319 | 319 | |
| 320 | if (struct_type.layout == .Packed) { | |
| 320 | if (struct_type.layout == .@"packed") { | |
| 321 | 321 | log.debug("TODO implement .debug_info for packed structs", .{}); |
| 322 | 322 | break :blk; |
| 323 | 323 | } |
src/link/Elf.zig+26-26| ... | ... | @@ -262,7 +262,7 @@ pub fn createEmpty( |
| 262 | 262 | .sparc64 => 0x2000, |
| 263 | 263 | else => 0x1000, |
| 264 | 264 | }; |
| 265 | const is_dyn_lib = output_mode == .Lib and link_mode == .Dynamic; | |
| 265 | const is_dyn_lib = output_mode == .Lib and link_mode == .dynamic; | |
| 266 | 266 | const default_sym_version: elf.Elf64_Versym = if (is_dyn_lib or comp.config.rdynamic) |
| 267 | 267 | elf.VER_NDX_GLOBAL |
| 268 | 268 | else |
| ... | ... | @@ -349,7 +349,7 @@ pub fn createEmpty( |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | const is_obj = output_mode == .Obj; |
| 352 | const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .Static); | |
| 352 | const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .static); | |
| 353 | 353 | |
| 354 | 354 | // What path should this ELF linker code output to? |
| 355 | 355 | // If using LLD to link, this code should produce an object file so that it |
| ... | ... | @@ -1180,10 +1180,10 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) |
| 1180 | 1180 | |
| 1181 | 1181 | success: { |
| 1182 | 1182 | if (!self.base.isStatic()) { |
| 1183 | if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .Dynamic)) | |
| 1183 | if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .dynamic)) | |
| 1184 | 1184 | break :success; |
| 1185 | 1185 | } |
| 1186 | if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .Static)) | |
| 1186 | if (try self.accessLibPath(arena, &test_path, &checked_paths, lc.crt_dir.?, lib_name, .static)) | |
| 1187 | 1187 | break :success; |
| 1188 | 1188 | |
| 1189 | 1189 | try self.reportMissingLibraryError( |
| ... | ... | @@ -1211,8 +1211,8 @@ pub fn flushModule(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) |
| 1211 | 1211 | }); |
| 1212 | 1212 | } else if (target.isMusl()) { |
| 1213 | 1213 | const path = try comp.get_libc_crt_file(arena, switch (link_mode) { |
| 1214 | .Static => "libc.a", | |
| 1215 | .Dynamic => "libc.so", | |
| 1214 | .static => "libc.a", | |
| 1215 | .dynamic => "libc.so", | |
| 1216 | 1216 | }); |
| 1217 | 1217 | try system_libs.append(.{ .path = path }); |
| 1218 | 1218 | } else { |
| ... | ... | @@ -1628,7 +1628,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { |
| 1628 | 1628 | // libc dep |
| 1629 | 1629 | if (comp.config.link_libc) { |
| 1630 | 1630 | if (self.base.comp.libc_installation != null) { |
| 1631 | const needs_grouping = link_mode == .Static; | |
| 1631 | const needs_grouping = link_mode == .static; | |
| 1632 | 1632 | if (needs_grouping) try argv.append("--start-group"); |
| 1633 | 1633 | try argv.appendSlice(target_util.libcFullLinkFlags(target)); |
| 1634 | 1634 | if (needs_grouping) try argv.append("--end-group"); |
| ... | ... | @@ -1642,8 +1642,8 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { |
| 1642 | 1642 | try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a")); |
| 1643 | 1643 | } else if (target.isMusl()) { |
| 1644 | 1644 | try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) { |
| 1645 | .Static => "libc.a", | |
| 1646 | .Dynamic => "libc.so", | |
| 1645 | .static => "libc.a", | |
| 1646 | .dynamic => "libc.so", | |
| 1647 | 1647 | })); |
| 1648 | 1648 | } |
| 1649 | 1649 | } |
| ... | ... | @@ -1797,10 +1797,10 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void { |
| 1797 | 1797 | // Maybe we should hoist search-strategy all the way here? |
| 1798 | 1798 | for (self.lib_dirs) |lib_dir| { |
| 1799 | 1799 | if (!self.base.isStatic()) { |
| 1800 | if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .Dynamic)) | |
| 1800 | if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .dynamic)) | |
| 1801 | 1801 | break :success; |
| 1802 | 1802 | } |
| 1803 | if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .Static)) | |
| 1803 | if (try self.accessLibPath(arena, &test_path, &checked_paths, lib_dir, lib_name, .static)) | |
| 1804 | 1804 | break :success; |
| 1805 | 1805 | } |
| 1806 | 1806 | } else { |
| ... | ... | @@ -1858,8 +1858,8 @@ fn accessLibPath( |
| 1858 | 1858 | test_path.clearRetainingCapacity(); |
| 1859 | 1859 | const prefix = if (link_mode != null) "lib" else ""; |
| 1860 | 1860 | const suffix = if (link_mode) |mode| switch (mode) { |
| 1861 | .Static => target.staticLibSuffix(), | |
| 1862 | .Dynamic => target.dynamicLibSuffix(), | |
| 1861 | .static => target.staticLibSuffix(), | |
| 1862 | .dynamic => target.dynamicLibSuffix(), | |
| 1863 | 1863 | } else ""; |
| 1864 | 1864 | try test_path.writer().print("{s}" ++ sep ++ "{s}{s}{s}", .{ |
| 1865 | 1865 | lib_dir_path, |
| ... | ... | @@ -2150,10 +2150,10 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2150 | 2150 | const is_obj = output_mode == .Obj; |
| 2151 | 2151 | const is_lib = output_mode == .Lib; |
| 2152 | 2152 | const link_mode = comp.config.link_mode; |
| 2153 | const is_dyn_lib = link_mode == .Dynamic and is_lib; | |
| 2153 | const is_dyn_lib = link_mode == .dynamic and is_lib; | |
| 2154 | 2154 | const is_exe_or_dyn_lib = is_dyn_lib or output_mode == .Exe; |
| 2155 | 2155 | const have_dynamic_linker = comp.config.link_libc and |
| 2156 | link_mode == .Dynamic and is_exe_or_dyn_lib; | |
| 2156 | link_mode == .dynamic and is_exe_or_dyn_lib; | |
| 2157 | 2157 | const target = comp.root_mod.resolved_target.result; |
| 2158 | 2158 | const compiler_rt_path: ?[]const u8 = blk: { |
| 2159 | 2159 | if (comp.compiler_rt_lib) |x| break :blk x.full_object_path; |
| ... | ... | @@ -2463,7 +2463,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2463 | 2463 | try argv.append(arg); |
| 2464 | 2464 | } |
| 2465 | 2465 | |
| 2466 | if (link_mode == .Static) { | |
| 2466 | if (link_mode == .static) { | |
| 2467 | 2467 | if (target.cpu.arch.isArmOrThumb()) { |
| 2468 | 2468 | try argv.append("-Bstatic"); |
| 2469 | 2469 | } else { |
| ... | ... | @@ -2647,7 +2647,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2647 | 2647 | comp.link_error_flags.missing_libc = false; |
| 2648 | 2648 | if (comp.config.link_libc) { |
| 2649 | 2649 | if (comp.libc_installation != null) { |
| 2650 | const needs_grouping = link_mode == .Static; | |
| 2650 | const needs_grouping = link_mode == .static; | |
| 2651 | 2651 | if (needs_grouping) try argv.append("--start-group"); |
| 2652 | 2652 | try argv.appendSlice(target_util.libcFullLinkFlags(target)); |
| 2653 | 2653 | if (needs_grouping) try argv.append("--end-group"); |
| ... | ... | @@ -2661,8 +2661,8 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi |
| 2661 | 2661 | try argv.append(try comp.get_libc_crt_file(arena, "libc_nonshared.a")); |
| 2662 | 2662 | } else if (target.isMusl()) { |
| 2663 | 2663 | try argv.append(try comp.get_libc_crt_file(arena, switch (link_mode) { |
| 2664 | .Static => "libc.a", | |
| 2665 | .Dynamic => "libc.so", | |
| 2664 | .static => "libc.a", | |
| 2665 | .dynamic => "libc.so", | |
| 2666 | 2666 | })); |
| 2667 | 2667 | } else { |
| 2668 | 2668 | comp.link_error_flags.missing_libc = true; |
| ... | ... | @@ -2928,8 +2928,8 @@ pub fn writeElfHeader(self: *Elf) !void { |
| 2928 | 2928 | .Exe => if (comp.config.pie) .DYN else .EXEC, |
| 2929 | 2929 | .Obj => .REL, |
| 2930 | 2930 | .Lib => switch (link_mode) { |
| 2931 | .Static => @as(elf.ET, .REL), | |
| 2932 | .Dynamic => .DYN, | |
| 2931 | .static => @as(elf.ET, .REL), | |
| 2932 | .dynamic => .DYN, | |
| 2933 | 2933 | }, |
| 2934 | 2934 | }; |
| 2935 | 2935 | mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(elf_type), endian); |
| ... | ... | @@ -3216,7 +3216,7 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void { |
| 3216 | 3216 | |
| 3217 | 3217 | // __rela_iplt_start, __rela_iplt_end |
| 3218 | 3218 | if (self.rela_dyn_section_index) |shndx| blk: { |
| 3219 | if (link_mode != .Static or comp.config.pie) break :blk; | |
| 3219 | if (link_mode != .static or comp.config.pie) break :blk; | |
| 3220 | 3220 | const shdr = &self.shdrs.items[shndx]; |
| 3221 | 3221 | const end_addr = shdr.sh_addr + shdr.sh_size; |
| 3222 | 3222 | const start_addr = end_addr - self.calcNumIRelativeRelocs() * @sizeOf(elf.Elf64_Rela); |
| ... | ... | @@ -5061,12 +5061,12 @@ const CsuObjects = struct { |
| 5061 | 5061 | } = switch (comp.config.output_mode) { |
| 5062 | 5062 | .Obj => return CsuObjects{}, |
| 5063 | 5063 | .Lib => switch (comp.config.link_mode) { |
| 5064 | .Dynamic => .dynamic_lib, | |
| 5065 | .Static => return CsuObjects{}, | |
| 5064 | .dynamic => .dynamic_lib, | |
| 5065 | .static => return CsuObjects{}, | |
| 5066 | 5066 | }, |
| 5067 | 5067 | .Exe => switch (comp.config.link_mode) { |
| 5068 | .Dynamic => if (comp.config.pie) .dynamic_pie else .dynamic_exe, | |
| 5069 | .Static => if (comp.config.pie) .static_pie else .static_exe, | |
| 5068 | .dynamic => if (comp.config.pie) .dynamic_pie else .dynamic_exe, | |
| 5069 | .static => if (comp.config.pie) .static_pie else .static_exe, | |
| 5070 | 5070 | }, |
| 5071 | 5071 | }; |
| 5072 | 5072 |
src/link/Elf/ZigObject.zig+4-4| ... | ... | @@ -1436,10 +1436,10 @@ pub fn updateExports( |
| 1436 | 1436 | } |
| 1437 | 1437 | } |
| 1438 | 1438 | const stb_bits: u8 = switch (exp.opts.linkage) { |
| 1439 | .Internal => elf.STB_LOCAL, | |
| 1440 | .Strong => elf.STB_GLOBAL, | |
| 1441 | .Weak => elf.STB_WEAK, | |
| 1442 | .LinkOnce => { | |
| 1439 | .internal => elf.STB_LOCAL, | |
| 1440 | .strong => elf.STB_GLOBAL, | |
| 1441 | .weak => elf.STB_WEAK, | |
| 1442 | .link_once => { | |
| 1443 | 1443 | try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1); |
| 1444 | 1444 | mod.failed_exports.putAssumeCapacityNoClobber(exp, try Module.ErrorMsg.create( |
| 1445 | 1445 | gpa, |
src/link/MachO/ZigObject.zig+5-5| ... | ... | @@ -1216,11 +1216,11 @@ pub fn updateExports( |
| 1216 | 1216 | continue; |
| 1217 | 1217 | } |
| 1218 | 1218 | } |
| 1219 | if (exp.opts.linkage == .LinkOnce) { | |
| 1219 | if (exp.opts.linkage == .link_once) { | |
| 1220 | 1220 | try mod.failed_exports.putNoClobber(mod.gpa, exp, try Module.ErrorMsg.create( |
| 1221 | 1221 | gpa, |
| 1222 | 1222 | exp.getSrcLoc(mod), |
| 1223 | "Unimplemented: GlobalLinkage.LinkOnce", | |
| 1223 | "Unimplemented: GlobalLinkage.link_once", | |
| 1224 | 1224 | .{}, |
| 1225 | 1225 | )); |
| 1226 | 1226 | continue; |
| ... | ... | @@ -1242,12 +1242,12 @@ pub fn updateExports( |
| 1242 | 1242 | self.symtab.items(.atom)[global_nlist_index] = self.symtab.items(.atom)[nlist_idx]; |
| 1243 | 1243 | |
| 1244 | 1244 | switch (exp.opts.linkage) { |
| 1245 | .Internal => { | |
| 1245 | .internal => { | |
| 1246 | 1246 | // Symbol should be hidden, or in MachO lingo, private extern. |
| 1247 | 1247 | global_nlist.n_type |= macho.N_PEXT; |
| 1248 | 1248 | }, |
| 1249 | .Strong => {}, | |
| 1250 | .Weak => { | |
| 1249 | .strong => {}, | |
| 1250 | .weak => { | |
| 1251 | 1251 | // Weak linkage is specified as part of n_desc field. |
| 1252 | 1252 | // Symbol's n_type is like for a symbol with strong linkage. |
| 1253 | 1253 | global_nlist.n_desc |= macho.N_WEAK_DEF; |
src/link/MachO/load_commands.zig+1-1| ... | ... | @@ -222,7 +222,7 @@ pub fn writeDylibLC(ctx: WriteDylibLCCtx, writer: anytype) !void { |
| 222 | 222 | pub fn writeDylibIdLC(macho_file: *MachO, writer: anytype) !void { |
| 223 | 223 | const comp = macho_file.base.comp; |
| 224 | 224 | const gpa = comp.gpa; |
| 225 | assert(comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic); | |
| 225 | assert(comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic); | |
| 226 | 226 | const emit = macho_file.base.emit; |
| 227 | 227 | const install_name = macho_file.install_name orelse |
| 228 | 228 | try emit.directory.join(gpa, &.{emit.sub_path}); |
src/link/Wasm.zig+3-3| ... | ... | @@ -2518,7 +2518,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) |
| 2518 | 2518 | // When the target os is WASI, we allow linking with WASI-LIBC |
| 2519 | 2519 | if (target.os.tag == .wasi) { |
| 2520 | 2520 | const is_exe_or_dyn_lib = output_mode == .Exe or |
| 2521 | (output_mode == .Lib and link_mode == .Dynamic); | |
| 2521 | (output_mode == .Lib and link_mode == .dynamic); | |
| 2522 | 2522 | if (is_exe_or_dyn_lib) { |
| 2523 | 2523 | for (comp.wasi_emulated_libs) |crt_file| { |
| 2524 | 2524 | try positionals.append(try comp.get_libc_crt_file( |
| ... | ... | @@ -3549,7 +3549,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo |
| 3549 | 3549 | try argv.append("--allow-undefined"); |
| 3550 | 3550 | } |
| 3551 | 3551 | |
| 3552 | if (comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic) { | |
| 3552 | if (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic) { | |
| 3553 | 3553 | try argv.append("--shared"); |
| 3554 | 3554 | } |
| 3555 | 3555 | if (comp.config.pie) { |
| ... | ... | @@ -3569,7 +3569,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, prog_node: *std.Progress.Node) !vo |
| 3569 | 3569 | |
| 3570 | 3570 | if (target.os.tag == .wasi) { |
| 3571 | 3571 | const is_exe_or_dyn_lib = comp.config.output_mode == .Exe or |
| 3572 | (comp.config.output_mode == .Lib and comp.config.link_mode == .Dynamic); | |
| 3572 | (comp.config.output_mode == .Lib and comp.config.link_mode == .dynamic); | |
| 3573 | 3573 | if (is_exe_or_dyn_lib) { |
| 3574 | 3574 | for (comp.wasi_emulated_libs) |crt_file| { |
| 3575 | 3575 | try argv.append(try comp.get_libc_crt_file( |
src/link/Wasm/ZigObject.zig+4-4| ... | ... | @@ -896,14 +896,14 @@ pub fn updateExports( |
| 896 | 896 | sym.name = export_name; |
| 897 | 897 | |
| 898 | 898 | switch (exp.opts.linkage) { |
| 899 | .Internal => { | |
| 899 | .internal => { | |
| 900 | 900 | sym.setFlag(.WASM_SYM_VISIBILITY_HIDDEN); |
| 901 | 901 | }, |
| 902 | .Weak => { | |
| 902 | .weak => { | |
| 903 | 903 | sym.setFlag(.WASM_SYM_BINDING_WEAK); |
| 904 | 904 | }, |
| 905 | .Strong => {}, // symbols are strong by default | |
| 906 | .LinkOnce => { | |
| 905 | .strong => {}, // symbols are strong by default | |
| 906 | .link_once => { | |
| 907 | 907 | try mod.failed_exports.putNoClobber(gpa, exp, try Module.ErrorMsg.create( |
| 908 | 908 | gpa, |
| 909 | 909 | decl.srcLoc(mod), |
src/main.zig+35-35| ... | ... | @@ -755,8 +755,8 @@ const SystemLib = struct { |
| 755 | 755 | fn fallbackMode(this: SystemLib) std.builtin.LinkMode { |
| 756 | 756 | assert(this.search_strategy != .no_fallback); |
| 757 | 757 | return switch (this.preferred_mode) { |
| 758 | .Dynamic => .Static, | |
| 759 | .Static => .Dynamic, | |
| 758 | .dynamic => .static, | |
| 759 | .static => .dynamic, | |
| 760 | 760 | }; |
| 761 | 761 | } |
| 762 | 762 | }; |
| ... | ... | @@ -892,7 +892,7 @@ fn buildOutputType( |
| 892 | 892 | var entitlements: ?[]const u8 = null; |
| 893 | 893 | var pagezero_size: ?u64 = null; |
| 894 | 894 | var lib_search_strategy: SystemLib.SearchStrategy = .paths_first; |
| 895 | var lib_preferred_mode: std.builtin.LinkMode = .Dynamic; | |
| 895 | var lib_preferred_mode: std.builtin.LinkMode = .dynamic; | |
| 896 | 896 | var headerpad_size: ?u32 = null; |
| 897 | 897 | var headerpad_max_install_names: bool = false; |
| 898 | 898 | var dead_strip_dylibs: bool = false; |
| ... | ... | @@ -1166,22 +1166,22 @@ fn buildOutputType( |
| 1166 | 1166 | }; |
| 1167 | 1167 | } else if (mem.eql(u8, arg, "-search_paths_first")) { |
| 1168 | 1168 | lib_search_strategy = .paths_first; |
| 1169 | lib_preferred_mode = .Dynamic; | |
| 1169 | lib_preferred_mode = .dynamic; | |
| 1170 | 1170 | } else if (mem.eql(u8, arg, "-search_paths_first_static")) { |
| 1171 | 1171 | lib_search_strategy = .paths_first; |
| 1172 | lib_preferred_mode = .Static; | |
| 1172 | lib_preferred_mode = .static; | |
| 1173 | 1173 | } else if (mem.eql(u8, arg, "-search_dylibs_first")) { |
| 1174 | 1174 | lib_search_strategy = .mode_first; |
| 1175 | lib_preferred_mode = .Dynamic; | |
| 1175 | lib_preferred_mode = .dynamic; | |
| 1176 | 1176 | } else if (mem.eql(u8, arg, "-search_static_first")) { |
| 1177 | 1177 | lib_search_strategy = .mode_first; |
| 1178 | lib_preferred_mode = .Static; | |
| 1178 | lib_preferred_mode = .static; | |
| 1179 | 1179 | } else if (mem.eql(u8, arg, "-search_dylibs_only")) { |
| 1180 | 1180 | lib_search_strategy = .no_fallback; |
| 1181 | lib_preferred_mode = .Dynamic; | |
| 1181 | lib_preferred_mode = .dynamic; | |
| 1182 | 1182 | } else if (mem.eql(u8, arg, "-search_static_only")) { |
| 1183 | 1183 | lib_search_strategy = .no_fallback; |
| 1184 | lib_preferred_mode = .Static; | |
| 1184 | lib_preferred_mode = .static; | |
| 1185 | 1185 | } else if (mem.eql(u8, arg, "-headerpad")) { |
| 1186 | 1186 | const next_arg = args_iter.nextOrFatal(); |
| 1187 | 1187 | headerpad_size = std.fmt.parseUnsigned(u32, eatIntPrefix(next_arg, 16), 16) catch |err| { |
| ... | ... | @@ -1478,12 +1478,12 @@ fn buildOutputType( |
| 1478 | 1478 | emit_implib = .no; |
| 1479 | 1479 | emit_implib_arg_provided = true; |
| 1480 | 1480 | } else if (mem.eql(u8, arg, "-dynamic")) { |
| 1481 | create_module.opts.link_mode = .Dynamic; | |
| 1482 | lib_preferred_mode = .Dynamic; | |
| 1481 | create_module.opts.link_mode = .dynamic; | |
| 1482 | lib_preferred_mode = .dynamic; | |
| 1483 | 1483 | lib_search_strategy = .mode_first; |
| 1484 | 1484 | } else if (mem.eql(u8, arg, "-static")) { |
| 1485 | create_module.opts.link_mode = .Static; | |
| 1486 | lib_preferred_mode = .Static; | |
| 1485 | create_module.opts.link_mode = .static; | |
| 1486 | lib_preferred_mode = .static; | |
| 1487 | 1487 | lib_search_strategy = .no_fallback; |
| 1488 | 1488 | } else if (mem.eql(u8, arg, "-fdll-export-fns")) { |
| 1489 | 1489 | create_module.opts.dll_export_fns = true; |
| ... | ... | @@ -1904,7 +1904,7 @@ fn buildOutputType( |
| 1904 | 1904 | }, |
| 1905 | 1905 | .nostdlib_cpp => create_module.opts.ensure_libcpp_on_non_freestanding = false, |
| 1906 | 1906 | .shared => { |
| 1907 | create_module.opts.link_mode = .Dynamic; | |
| 1907 | create_module.opts.link_mode = .dynamic; | |
| 1908 | 1908 | is_shared_lib = true; |
| 1909 | 1909 | }, |
| 1910 | 1910 | .rdynamic => create_module.opts.rdynamic = true, |
| ... | ... | @@ -1961,20 +1961,20 @@ fn buildOutputType( |
| 1961 | 1961 | mem.eql(u8, linker_arg, "-call_shared")) |
| 1962 | 1962 | { |
| 1963 | 1963 | lib_search_strategy = .no_fallback; |
| 1964 | lib_preferred_mode = .Dynamic; | |
| 1964 | lib_preferred_mode = .dynamic; | |
| 1965 | 1965 | } else if (mem.eql(u8, linker_arg, "-Bstatic") or |
| 1966 | 1966 | mem.eql(u8, linker_arg, "-dn") or |
| 1967 | 1967 | mem.eql(u8, linker_arg, "-non_shared") or |
| 1968 | 1968 | mem.eql(u8, linker_arg, "-static")) |
| 1969 | 1969 | { |
| 1970 | 1970 | lib_search_strategy = .no_fallback; |
| 1971 | lib_preferred_mode = .Static; | |
| 1971 | lib_preferred_mode = .static; | |
| 1972 | 1972 | } else if (mem.eql(u8, linker_arg, "-search_paths_first")) { |
| 1973 | 1973 | lib_search_strategy = .paths_first; |
| 1974 | lib_preferred_mode = .Dynamic; | |
| 1974 | lib_preferred_mode = .dynamic; | |
| 1975 | 1975 | } else if (mem.eql(u8, linker_arg, "-search_dylibs_first")) { |
| 1976 | 1976 | lib_search_strategy = .mode_first; |
| 1977 | lib_preferred_mode = .Dynamic; | |
| 1977 | lib_preferred_mode = .dynamic; | |
| 1978 | 1978 | } else { |
| 1979 | 1979 | try linker_args.append(linker_arg); |
| 1980 | 1980 | } |
| ... | ... | @@ -3033,7 +3033,7 @@ fn buildOutputType( |
| 3033 | 3033 | |
| 3034 | 3034 | const is_exe_or_dyn_lib = switch (create_module.resolved_options.output_mode) { |
| 3035 | 3035 | .Obj => false, |
| 3036 | .Lib => create_module.resolved_options.link_mode == .Dynamic, | |
| 3036 | .Lib => create_module.resolved_options.link_mode == .dynamic, | |
| 3037 | 3037 | .Exe => true, |
| 3038 | 3038 | }; |
| 3039 | 3039 | // Note that cmake when targeting Windows will try to execute |
| ... | ... | @@ -3770,8 +3770,8 @@ fn createModule( |
| 3770 | 3770 | )) { |
| 3771 | 3771 | const path = try arena.dupe(u8, test_path.items); |
| 3772 | 3772 | switch (info.preferred_mode) { |
| 3773 | .Static => try create_module.link_objects.append(arena, .{ .path = path }), | |
| 3774 | .Dynamic => try create_module.resolved_system_libs.append(arena, .{ | |
| 3773 | .static => try create_module.link_objects.append(arena, .{ .path = path }), | |
| 3774 | .dynamic => try create_module.resolved_system_libs.append(arena, .{ | |
| 3775 | 3775 | .name = lib_name, |
| 3776 | 3776 | .lib = .{ |
| 3777 | 3777 | .needed = info.needed, |
| ... | ... | @@ -3804,8 +3804,8 @@ fn createModule( |
| 3804 | 3804 | )) { |
| 3805 | 3805 | const path = try arena.dupe(u8, test_path.items); |
| 3806 | 3806 | switch (info.fallbackMode()) { |
| 3807 | .Static => try create_module.link_objects.append(arena, .{ .path = path }), | |
| 3808 | .Dynamic => try create_module.resolved_system_libs.append(arena, .{ | |
| 3807 | .static => try create_module.link_objects.append(arena, .{ .path = path }), | |
| 3808 | .dynamic => try create_module.resolved_system_libs.append(arena, .{ | |
| 3809 | 3809 | .name = lib_name, |
| 3810 | 3810 | .lib = .{ |
| 3811 | 3811 | .needed = info.needed, |
| ... | ... | @@ -3838,8 +3838,8 @@ fn createModule( |
| 3838 | 3838 | )) { |
| 3839 | 3839 | const path = try arena.dupe(u8, test_path.items); |
| 3840 | 3840 | switch (info.preferred_mode) { |
| 3841 | .Static => try create_module.link_objects.append(arena, .{ .path = path }), | |
| 3842 | .Dynamic => try create_module.resolved_system_libs.append(arena, .{ | |
| 3841 | .static => try create_module.link_objects.append(arena, .{ .path = path }), | |
| 3842 | .dynamic => try create_module.resolved_system_libs.append(arena, .{ | |
| 3843 | 3843 | .name = lib_name, |
| 3844 | 3844 | .lib = .{ |
| 3845 | 3845 | .needed = info.needed, |
| ... | ... | @@ -3862,8 +3862,8 @@ fn createModule( |
| 3862 | 3862 | )) { |
| 3863 | 3863 | const path = try arena.dupe(u8, test_path.items); |
| 3864 | 3864 | switch (info.fallbackMode()) { |
| 3865 | .Static => try create_module.link_objects.append(arena, .{ .path = path }), | |
| 3866 | .Dynamic => try create_module.resolved_system_libs.append(arena, .{ | |
| 3865 | .static => try create_module.link_objects.append(arena, .{ .path = path }), | |
| 3866 | .dynamic => try create_module.resolved_system_libs.append(arena, .{ | |
| 3867 | 3867 | .name = lib_name, |
| 3868 | 3868 | .lib = .{ |
| 3869 | 3869 | .needed = info.needed, |
| ... | ... | @@ -4145,8 +4145,8 @@ fn progressThread(progress: *std.Progress, server: *const Server, reset: *std.Th |
| 4145 | 4145 | buf.appendSlice("... ") catch {}; |
| 4146 | 4146 | } |
| 4147 | 4147 | need_ellipse = false; |
| 4148 | const eti = @atomicLoad(usize, &node.unprotected_estimated_total_items, .Monotonic); | |
| 4149 | const completed_items = @atomicLoad(usize, &node.unprotected_completed_items, .Monotonic); | |
| 4148 | const eti = @atomicLoad(usize, &node.unprotected_estimated_total_items, .monotonic); | |
| 4149 | const completed_items = @atomicLoad(usize, &node.unprotected_completed_items, .monotonic); | |
| 4150 | 4150 | const current_item = completed_items + 1; |
| 4151 | 4151 | if (node.name.len != 0 or eti > 0) { |
| 4152 | 4152 | if (node.name.len != 0) { |
| ... | ... | @@ -4163,7 +4163,7 @@ fn progressThread(progress: *std.Progress, server: *const Server, reset: *std.Th |
| 4163 | 4163 | need_ellipse = false; |
| 4164 | 4164 | } |
| 4165 | 4165 | } |
| 4166 | maybe_node = @atomicLoad(?*std.Progress.Node, &node.recently_updated_child, .Acquire); | |
| 4166 | maybe_node = @atomicLoad(?*std.Progress.Node, &node.recently_updated_child, .acquire); | |
| 4167 | 4167 | } |
| 4168 | 4168 | } |
| 4169 | 4169 | |
| ... | ... | @@ -6842,7 +6842,7 @@ fn accessLibPath( |
| 6842 | 6842 | ) !bool { |
| 6843 | 6843 | const sep = fs.path.sep_str; |
| 6844 | 6844 | |
| 6845 | if (target.isDarwin() and link_mode == .Dynamic) tbd: { | |
| 6845 | if (target.isDarwin() and link_mode == .dynamic) tbd: { | |
| 6846 | 6846 | // Prefer .tbd over .dylib. |
| 6847 | 6847 | test_path.clearRetainingCapacity(); |
| 6848 | 6848 | try test_path.writer().print("{s}" ++ sep ++ "lib{s}.tbd", .{ lib_dir_path, lib_name }); |
| ... | ... | @@ -6863,8 +6863,8 @@ fn accessLibPath( |
| 6863 | 6863 | target.libPrefix(), |
| 6864 | 6864 | lib_name, |
| 6865 | 6865 | switch (link_mode) { |
| 6866 | .Static => target.staticLibSuffix(), | |
| 6867 | .Dynamic => target.dynamicLibSuffix(), | |
| 6866 | .static => target.staticLibSuffix(), | |
| 6867 | .dynamic => target.dynamicLibSuffix(), | |
| 6868 | 6868 | }, |
| 6869 | 6869 | }); |
| 6870 | 6870 | try checked_paths.writer().print("\n {s}", .{test_path.items}); |
| ... | ... | @@ -6879,7 +6879,7 @@ fn accessLibPath( |
| 6879 | 6879 | |
| 6880 | 6880 | // In the case of Darwin, the main check will be .dylib, so here we |
| 6881 | 6881 | // additionally check for .so files. |
| 6882 | if (target.isDarwin() and link_mode == .Dynamic) so: { | |
| 6882 | if (target.isDarwin() and link_mode == .dynamic) so: { | |
| 6883 | 6883 | test_path.clearRetainingCapacity(); |
| 6884 | 6884 | try test_path.writer().print("{s}" ++ sep ++ "lib{s}.so", .{ lib_dir_path, lib_name }); |
| 6885 | 6885 | try checked_paths.writer().print("\n {s}", .{test_path.items}); |
| ... | ... | @@ -6894,7 +6894,7 @@ fn accessLibPath( |
| 6894 | 6894 | |
| 6895 | 6895 | // In the case of MinGW, the main check will be .lib but we also need to |
| 6896 | 6896 | // look for `libfoo.a`. |
| 6897 | if (target.isMinGW() and link_mode == .Static) mingw: { | |
| 6897 | if (target.isMinGW() and link_mode == .static) mingw: { | |
| 6898 | 6898 | test_path.clearRetainingCapacity(); |
| 6899 | 6899 | try test_path.writer().print("{s}" ++ sep ++ "lib{s}.a", .{ |
| 6900 | 6900 | lib_dir_path, lib_name, |
src/musl.zig+1-1| ... | ... | @@ -207,7 +207,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 207 | 207 | const strip = comp.compilerRtStrip(); |
| 208 | 208 | const config = try Compilation.Config.resolve(.{ |
| 209 | 209 | .output_mode = .Lib, |
| 210 | .link_mode = .Dynamic, | |
| 210 | .link_mode = .dynamic, | |
| 211 | 211 | .resolved_target = comp.root_mod.resolved_target, |
| 212 | 212 | .is_test = false, |
| 213 | 213 | .have_zcu = false, |
src/print_air.zig+4-4| ... | ... | @@ -303,10 +303,10 @@ const Writer = struct { |
| 303 | 303 | .fence => try w.writeFence(s, inst), |
| 304 | 304 | .atomic_load => try w.writeAtomicLoad(s, inst), |
| 305 | 305 | .prefetch => try w.writePrefetch(s, inst), |
| 306 | .atomic_store_unordered => try w.writeAtomicStore(s, inst, .Unordered), | |
| 307 | .atomic_store_monotonic => try w.writeAtomicStore(s, inst, .Monotonic), | |
| 308 | .atomic_store_release => try w.writeAtomicStore(s, inst, .Release), | |
| 309 | .atomic_store_seq_cst => try w.writeAtomicStore(s, inst, .SeqCst), | |
| 306 | .atomic_store_unordered => try w.writeAtomicStore(s, inst, .unordered), | |
| 307 | .atomic_store_monotonic => try w.writeAtomicStore(s, inst, .monotonic), | |
| 308 | .atomic_store_release => try w.writeAtomicStore(s, inst, .release), | |
| 309 | .atomic_store_seq_cst => try w.writeAtomicStore(s, inst, .seq_cst), | |
| 310 | 310 | .atomic_rmw => try w.writeAtomicRmw(s, inst), |
| 311 | 311 | .field_parent_ptr => try w.writeFieldParentPtr(s, inst), |
| 312 | 312 | .wasm_memory_size => try w.writeWasmMemorySize(s, inst), |
src/print_zir.zig+1-1| ... | ... | @@ -1440,7 +1440,7 @@ const Writer = struct { |
| 1440 | 1440 | if (small.has_backing_int) { |
| 1441 | 1441 | const backing_int_body_len = self.code.extra[extra_index]; |
| 1442 | 1442 | extra_index += 1; |
| 1443 | try stream.writeAll("Packed("); | |
| 1443 | try stream.writeAll("packed("); | |
| 1444 | 1444 | if (backing_int_body_len == 0) { |
| 1445 | 1445 | const backing_int_ref: Zir.Inst.Ref = @enumFromInt(self.code.extra[extra_index]); |
| 1446 | 1446 | extra_index += 1; |
src/type.zig+19-19| ... | ... | @@ -741,12 +741,12 @@ pub const Type = struct { |
| 741 | 741 | .struct_type => { |
| 742 | 742 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 743 | 743 | // Struct with no fields have a well-defined layout of no bits. |
| 744 | return struct_type.layout != .Auto or struct_type.field_types.len == 0; | |
| 744 | return struct_type.layout != .auto or struct_type.field_types.len == 0; | |
| 745 | 745 | }, |
| 746 | 746 | .union_type => { |
| 747 | 747 | const union_type = ip.loadUnionType(ty.toIntern()); |
| 748 | 748 | return switch (union_type.flagsPtr(ip).runtime_tag) { |
| 749 | .none, .safety => union_type.flagsPtr(ip).layout != .Auto, | |
| 749 | .none, .safety => union_type.flagsPtr(ip).layout != .auto, | |
| 750 | 750 | .tagged => false, |
| 751 | 751 | }; |
| 752 | 752 | }, |
| ... | ... | @@ -1027,7 +1027,7 @@ pub const Type = struct { |
| 1027 | 1027 | }, |
| 1028 | 1028 | .struct_type => { |
| 1029 | 1029 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 1030 | if (struct_type.layout == .Packed) { | |
| 1030 | if (struct_type.layout == .@"packed") { | |
| 1031 | 1031 | switch (strat) { |
| 1032 | 1032 | .sema => |sema| try sema.resolveTypeLayout(ty), |
| 1033 | 1033 | .lazy => if (struct_type.backingIntType(ip).* == .none) return .{ |
| ... | ... | @@ -1407,7 +1407,7 @@ pub const Type = struct { |
| 1407 | 1407 | switch (strat) { |
| 1408 | 1408 | .sema => |sema| try sema.resolveTypeLayout(ty), |
| 1409 | 1409 | .lazy => switch (struct_type.layout) { |
| 1410 | .Packed => { | |
| 1410 | .@"packed" => { | |
| 1411 | 1411 | if (struct_type.backingIntType(ip).* == .none) return .{ |
| 1412 | 1412 | .val = Value.fromInterned((try mod.intern(.{ .int = .{ |
| 1413 | 1413 | .ty = .comptime_int_type, |
| ... | ... | @@ -1415,7 +1415,7 @@ pub const Type = struct { |
| 1415 | 1415 | } }))), |
| 1416 | 1416 | }; |
| 1417 | 1417 | }, |
| 1418 | .Auto, .Extern => { | |
| 1418 | .auto, .@"extern" => { | |
| 1419 | 1419 | if (!struct_type.haveLayout(ip)) return .{ |
| 1420 | 1420 | .val = Value.fromInterned((try mod.intern(.{ .int = .{ |
| 1421 | 1421 | .ty = .comptime_int_type, |
| ... | ... | @@ -1427,10 +1427,10 @@ pub const Type = struct { |
| 1427 | 1427 | .eager => {}, |
| 1428 | 1428 | } |
| 1429 | 1429 | switch (struct_type.layout) { |
| 1430 | .Packed => return .{ | |
| 1430 | .@"packed" => return .{ | |
| 1431 | 1431 | .scalar = Type.fromInterned(struct_type.backingIntType(ip).*).abiSize(mod), |
| 1432 | 1432 | }, |
| 1433 | .Auto, .Extern => { | |
| 1433 | .auto, .@"extern" => { | |
| 1434 | 1434 | assert(struct_type.haveLayout(ip)); |
| 1435 | 1435 | return .{ .scalar = struct_type.size(ip).* }; |
| 1436 | 1436 | }, |
| ... | ... | @@ -1656,7 +1656,7 @@ pub const Type = struct { |
| 1656 | 1656 | }, |
| 1657 | 1657 | .struct_type => { |
| 1658 | 1658 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 1659 | const is_packed = struct_type.layout == .Packed; | |
| 1659 | const is_packed = struct_type.layout == .@"packed"; | |
| 1660 | 1660 | if (opt_sema) |sema| { |
| 1661 | 1661 | try sema.resolveTypeFields(ty); |
| 1662 | 1662 | if (is_packed) try sema.resolveTypeLayout(ty); |
| ... | ... | @@ -1674,7 +1674,7 @@ pub const Type = struct { |
| 1674 | 1674 | |
| 1675 | 1675 | .union_type => { |
| 1676 | 1676 | const union_type = ip.loadUnionType(ty.toIntern()); |
| 1677 | const is_packed = ty.containerLayout(mod) == .Packed; | |
| 1677 | const is_packed = ty.containerLayout(mod) == .@"packed"; | |
| 1678 | 1678 | if (opt_sema) |sema| { |
| 1679 | 1679 | try sema.resolveTypeFields(ty); |
| 1680 | 1680 | if (is_packed) try sema.resolveTypeLayout(ty); |
| ... | ... | @@ -1987,9 +1987,9 @@ pub const Type = struct { |
| 1987 | 1987 | /// Asserts the type is either an extern or packed union. |
| 1988 | 1988 | pub fn unionBackingType(ty: Type, mod: *Module) !Type { |
| 1989 | 1989 | return switch (ty.containerLayout(mod)) { |
| 1990 | .Extern => try mod.arrayType(.{ .len = ty.abiSize(mod), .child = .u8_type }), | |
| 1991 | .Packed => try mod.intType(.unsigned, @intCast(ty.bitSize(mod))), | |
| 1992 | .Auto => unreachable, | |
| 1990 | .@"extern" => try mod.arrayType(.{ .len = ty.abiSize(mod), .child = .u8_type }), | |
| 1991 | .@"packed" => try mod.intType(.unsigned, @intCast(ty.bitSize(mod))), | |
| 1992 | .auto => unreachable, | |
| 1993 | 1993 | }; |
| 1994 | 1994 | } |
| 1995 | 1995 | |
| ... | ... | @@ -2003,7 +2003,7 @@ pub const Type = struct { |
| 2003 | 2003 | const ip = &mod.intern_pool; |
| 2004 | 2004 | return switch (ip.indexToKey(ty.toIntern())) { |
| 2005 | 2005 | .struct_type => ip.loadStructType(ty.toIntern()).layout, |
| 2006 | .anon_struct_type => .Auto, | |
| 2006 | .anon_struct_type => .auto, | |
| 2007 | 2007 | .union_type => ip.loadUnionType(ty.toIntern()).flagsPtr(ip).layout, |
| 2008 | 2008 | else => unreachable, |
| 2009 | 2009 | }; |
| ... | ... | @@ -2177,7 +2177,7 @@ pub const Type = struct { |
| 2177 | 2177 | pub fn isAbiInt(ty: Type, mod: *Module) bool { |
| 2178 | 2178 | return switch (ty.zigTypeTag(mod)) { |
| 2179 | 2179 | .Int, .Enum, .ErrorSet => true, |
| 2180 | .Struct => ty.containerLayout(mod) == .Packed, | |
| 2180 | .Struct => ty.containerLayout(mod) == .@"packed", | |
| 2181 | 2181 | else => false, |
| 2182 | 2182 | }; |
| 2183 | 2183 | } |
| ... | ... | @@ -2690,7 +2690,7 @@ pub const Type = struct { |
| 2690 | 2690 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 2691 | 2691 | // packed structs cannot be comptime-only because they have a well-defined |
| 2692 | 2692 | // memory layout and every field has a well-defined bit pattern. |
| 2693 | if (struct_type.layout == .Packed) | |
| 2693 | if (struct_type.layout == .@"packed") | |
| 2694 | 2694 | return false; |
| 2695 | 2695 | |
| 2696 | 2696 | // A struct with no fields is not comptime-only. |
| ... | ... | @@ -3051,7 +3051,7 @@ pub const Type = struct { |
| 3051 | 3051 | switch (ip.indexToKey(ty.toIntern())) { |
| 3052 | 3052 | .struct_type => { |
| 3053 | 3053 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3054 | assert(struct_type.layout != .Packed); | |
| 3054 | assert(struct_type.layout != .@"packed"); | |
| 3055 | 3055 | const explicit_align = struct_type.fieldAlign(ip, index); |
| 3056 | 3056 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[index]); |
| 3057 | 3057 | return mod.structFieldAlignment(explicit_align, field_ty, struct_type.layout); |
| ... | ... | @@ -3132,7 +3132,7 @@ pub const Type = struct { |
| 3132 | 3132 | .struct_type => { |
| 3133 | 3133 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3134 | 3134 | assert(struct_type.haveLayout(ip)); |
| 3135 | assert(struct_type.layout != .Packed); | |
| 3135 | assert(struct_type.layout != .@"packed"); | |
| 3136 | 3136 | return struct_type.offsets.get(ip)[index]; |
| 3137 | 3137 | }, |
| 3138 | 3138 | |
| ... | ... | @@ -3208,7 +3208,7 @@ pub const Type = struct { |
| 3208 | 3208 | return switch (ip.indexToKey(ty.toIntern())) { |
| 3209 | 3209 | .struct_type => { |
| 3210 | 3210 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3211 | if (struct_type.layout == .Packed) return false; | |
| 3211 | if (struct_type.layout == .@"packed") return false; | |
| 3212 | 3212 | if (struct_type.decl == .none) return false; |
| 3213 | 3213 | return struct_type.flagsPtr(ip).is_tuple; |
| 3214 | 3214 | }, |
| ... | ... | @@ -3230,7 +3230,7 @@ pub const Type = struct { |
| 3230 | 3230 | return switch (ip.indexToKey(ty.toIntern())) { |
| 3231 | 3231 | .struct_type => { |
| 3232 | 3232 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3233 | if (struct_type.layout == .Packed) return false; | |
| 3233 | if (struct_type.layout == .@"packed") return false; | |
| 3234 | 3234 | if (struct_type.decl == .none) return false; |
| 3235 | 3235 | return struct_type.flagsPtr(ip).is_tuple; |
| 3236 | 3236 | }, |
test/behavior/atomics.zig+59-59| ... | ... | @@ -22,18 +22,18 @@ test "cmpxchg" { |
| 22 | 22 | |
| 23 | 23 | fn testCmpxchg() !void { |
| 24 | 24 | var x: i32 = 1234; |
| 25 | if (@cmpxchgWeak(i32, &x, 99, 5678, .SeqCst, .SeqCst)) |x1| { | |
| 25 | if (@cmpxchgWeak(i32, &x, 99, 5678, .seq_cst, .seq_cst)) |x1| { | |
| 26 | 26 | try expect(x1 == 1234); |
| 27 | 27 | } else { |
| 28 | 28 | @panic("cmpxchg should have failed"); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | while (@cmpxchgWeak(i32, &x, 1234, 5678, .SeqCst, .SeqCst)) |x1| { | |
| 31 | while (@cmpxchgWeak(i32, &x, 1234, 5678, .seq_cst, .seq_cst)) |x1| { | |
| 32 | 32 | try expect(x1 == 1234); |
| 33 | 33 | } |
| 34 | 34 | try expect(x == 5678); |
| 35 | 35 | |
| 36 | try expect(@cmpxchgStrong(i32, &x, 5678, 42, .SeqCst, .SeqCst) == null); | |
| 36 | try expect(@cmpxchgStrong(i32, &x, 5678, 42, .seq_cst, .seq_cst) == null); | |
| 37 | 37 | try expect(x == 42); |
| 38 | 38 | } |
| 39 | 39 | |
| ... | ... | @@ -43,7 +43,7 @@ test "fence" { |
| 43 | 43 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 44 | 44 | |
| 45 | 45 | var x: i32 = 1234; |
| 46 | @fence(.SeqCst); | |
| 46 | @fence(.seq_cst); | |
| 47 | 47 | x = 5678; |
| 48 | 48 | } |
| 49 | 49 | |
| ... | ... | @@ -60,18 +60,18 @@ test "atomicrmw and atomicload" { |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | fn testAtomicRmw(ptr: *u8) !void { |
| 63 | const prev_value = @atomicRmw(u8, ptr, .Xchg, 42, .SeqCst); | |
| 63 | const prev_value = @atomicRmw(u8, ptr, .Xchg, 42, .seq_cst); | |
| 64 | 64 | try expect(prev_value == 200); |
| 65 | 65 | comptime { |
| 66 | 66 | var x: i32 = 1234; |
| 67 | 67 | const y: i32 = 12345; |
| 68 | try expect(@atomicLoad(i32, &x, .SeqCst) == 1234); | |
| 69 | try expect(@atomicLoad(i32, &y, .SeqCst) == 12345); | |
| 68 | try expect(@atomicLoad(i32, &x, .seq_cst) == 1234); | |
| 69 | try expect(@atomicLoad(i32, &y, .seq_cst) == 12345); | |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | fn testAtomicLoad(ptr: *u8) !void { |
| 74 | const x = @atomicLoad(u8, ptr, .SeqCst); | |
| 74 | const x = @atomicLoad(u8, ptr, .seq_cst); | |
| 75 | 75 | try expect(x == 42); |
| 76 | 76 | } |
| 77 | 77 | |
| ... | ... | @@ -85,18 +85,18 @@ test "cmpxchg with ptr" { |
| 85 | 85 | var data2: i32 = 5678; |
| 86 | 86 | var data3: i32 = 9101; |
| 87 | 87 | var x: *i32 = &data1; |
| 88 | if (@cmpxchgWeak(*i32, &x, &data2, &data3, .SeqCst, .SeqCst)) |x1| { | |
| 88 | if (@cmpxchgWeak(*i32, &x, &data2, &data3, .seq_cst, .seq_cst)) |x1| { | |
| 89 | 89 | try expect(x1 == &data1); |
| 90 | 90 | } else { |
| 91 | 91 | @panic("cmpxchg should have failed"); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | while (@cmpxchgWeak(*i32, &x, &data1, &data3, .SeqCst, .SeqCst)) |x1| { | |
| 94 | while (@cmpxchgWeak(*i32, &x, &data1, &data3, .seq_cst, .seq_cst)) |x1| { | |
| 95 | 95 | try expect(x1 == &data1); |
| 96 | 96 | } |
| 97 | 97 | try expect(x == &data3); |
| 98 | 98 | |
| 99 | try expect(@cmpxchgStrong(*i32, &x, &data3, &data2, .SeqCst, .SeqCst) == null); | |
| 99 | try expect(@cmpxchgStrong(*i32, &x, &data3, &data2, .seq_cst, .seq_cst) == null); | |
| 100 | 100 | try expect(x == &data2); |
| 101 | 101 | } |
| 102 | 102 | |
| ... | ... | @@ -108,7 +108,7 @@ test "cmpxchg with ignored result" { |
| 108 | 108 | |
| 109 | 109 | var x: i32 = 1234; |
| 110 | 110 | |
| 111 | _ = @cmpxchgStrong(i32, &x, 1234, 5678, .Monotonic, .Monotonic); | |
| 111 | _ = @cmpxchgStrong(i32, &x, 1234, 5678, .monotonic, .monotonic); | |
| 112 | 112 | |
| 113 | 113 | try expect(5678 == x); |
| 114 | 114 | } |
| ... | ... | @@ -127,18 +127,18 @@ test "128-bit cmpxchg" { |
| 127 | 127 | |
| 128 | 128 | fn test_u128_cmpxchg() !void { |
| 129 | 129 | var x: u128 align(16) = 1234; |
| 130 | if (@cmpxchgWeak(u128, &x, 99, 5678, .SeqCst, .SeqCst)) |x1| { | |
| 130 | if (@cmpxchgWeak(u128, &x, 99, 5678, .seq_cst, .seq_cst)) |x1| { | |
| 131 | 131 | try expect(x1 == 1234); |
| 132 | 132 | } else { |
| 133 | 133 | @panic("cmpxchg should have failed"); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | while (@cmpxchgWeak(u128, &x, 1234, 5678, .SeqCst, .SeqCst)) |x1| { | |
| 136 | while (@cmpxchgWeak(u128, &x, 1234, 5678, .seq_cst, .seq_cst)) |x1| { | |
| 137 | 137 | try expect(x1 == 1234); |
| 138 | 138 | } |
| 139 | 139 | try expect(x == 5678); |
| 140 | 140 | |
| 141 | try expect(@cmpxchgStrong(u128, &x, 5678, 42, .SeqCst, .SeqCst) == null); | |
| 141 | try expect(@cmpxchgStrong(u128, &x, 5678, 42, .seq_cst, .seq_cst) == null); | |
| 142 | 142 | try expect(x == 42); |
| 143 | 143 | } |
| 144 | 144 | |
| ... | ... | @@ -155,7 +155,7 @@ test "cmpxchg on a global variable" { |
| 155 | 155 | return error.SkipZigTest; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | _ = @cmpxchgWeak(u32, &a_global_variable, 1234, 42, .Acquire, .Monotonic); | |
| 158 | _ = @cmpxchgWeak(u32, &a_global_variable, 1234, 42, .acquire, .monotonic); | |
| 159 | 159 | try expect(a_global_variable == 42); |
| 160 | 160 | } |
| 161 | 161 | |
| ... | ... | @@ -168,12 +168,12 @@ test "atomic load and rmw with enum" { |
| 168 | 168 | const Value = enum(u8) { a, b, c }; |
| 169 | 169 | var x = Value.a; |
| 170 | 170 | |
| 171 | try expect(@atomicLoad(Value, &x, .SeqCst) != .b); | |
| 171 | try expect(@atomicLoad(Value, &x, .seq_cst) != .b); | |
| 172 | 172 | |
| 173 | _ = @atomicRmw(Value, &x, .Xchg, .c, .SeqCst); | |
| 174 | try expect(@atomicLoad(Value, &x, .SeqCst) == .c); | |
| 175 | try expect(@atomicLoad(Value, &x, .SeqCst) != .a); | |
| 176 | try expect(@atomicLoad(Value, &x, .SeqCst) != .b); | |
| 173 | _ = @atomicRmw(Value, &x, .Xchg, .c, .seq_cst); | |
| 174 | try expect(@atomicLoad(Value, &x, .seq_cst) == .c); | |
| 175 | try expect(@atomicLoad(Value, &x, .seq_cst) != .a); | |
| 176 | try expect(@atomicLoad(Value, &x, .seq_cst) != .b); | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | test "atomic store" { |
| ... | ... | @@ -183,10 +183,10 @@ test "atomic store" { |
| 183 | 183 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 184 | 184 | |
| 185 | 185 | var x: u32 = 0; |
| 186 | @atomicStore(u32, &x, 1, .SeqCst); | |
| 187 | try expect(@atomicLoad(u32, &x, .SeqCst) == 1); | |
| 188 | @atomicStore(u32, &x, 12345678, .SeqCst); | |
| 189 | try expect(@atomicLoad(u32, &x, .SeqCst) == 12345678); | |
| 186 | @atomicStore(u32, &x, 1, .seq_cst); | |
| 187 | try expect(@atomicLoad(u32, &x, .seq_cst) == 1); | |
| 188 | @atomicStore(u32, &x, 12345678, .seq_cst); | |
| 189 | try expect(@atomicLoad(u32, &x, .seq_cst) == 12345678); | |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | test "atomic store comptime" { |
| ... | ... | @@ -201,10 +201,10 @@ test "atomic store comptime" { |
| 201 | 201 | |
| 202 | 202 | fn testAtomicStore() !void { |
| 203 | 203 | var x: u32 = 0; |
| 204 | @atomicStore(u32, &x, 1, .SeqCst); | |
| 205 | try expect(@atomicLoad(u32, &x, .SeqCst) == 1); | |
| 206 | @atomicStore(u32, &x, 12345678, .SeqCst); | |
| 207 | try expect(@atomicLoad(u32, &x, .SeqCst) == 12345678); | |
| 204 | @atomicStore(u32, &x, 1, .seq_cst); | |
| 205 | try expect(@atomicLoad(u32, &x, .seq_cst) == 1); | |
| 206 | @atomicStore(u32, &x, 12345678, .seq_cst); | |
| 207 | try expect(@atomicLoad(u32, &x, .seq_cst) == 12345678); | |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | test "atomicrmw with floats" { |
| ... | ... | @@ -224,15 +224,15 @@ test "atomicrmw with floats" { |
| 224 | 224 | fn testAtomicRmwFloat() !void { |
| 225 | 225 | var x: f32 = 0; |
| 226 | 226 | try expect(x == 0); |
| 227 | _ = @atomicRmw(f32, &x, .Xchg, 1, .SeqCst); | |
| 227 | _ = @atomicRmw(f32, &x, .Xchg, 1, .seq_cst); | |
| 228 | 228 | try expect(x == 1); |
| 229 | _ = @atomicRmw(f32, &x, .Add, 5, .SeqCst); | |
| 229 | _ = @atomicRmw(f32, &x, .Add, 5, .seq_cst); | |
| 230 | 230 | try expect(x == 6); |
| 231 | _ = @atomicRmw(f32, &x, .Sub, 2, .SeqCst); | |
| 231 | _ = @atomicRmw(f32, &x, .Sub, 2, .seq_cst); | |
| 232 | 232 | try expect(x == 4); |
| 233 | _ = @atomicRmw(f32, &x, .Max, 13, .SeqCst); | |
| 233 | _ = @atomicRmw(f32, &x, .Max, 13, .seq_cst); | |
| 234 | 234 | try expect(x == 13); |
| 235 | _ = @atomicRmw(f32, &x, .Min, 42, .SeqCst); | |
| 235 | _ = @atomicRmw(f32, &x, .Min, 42, .seq_cst); | |
| 236 | 236 | try expect(x == 13); |
| 237 | 237 | } |
| 238 | 238 | |
| ... | ... | @@ -266,46 +266,46 @@ fn testAtomicRmwInt(comptime signedness: std.builtin.Signedness, comptime N: usi |
| 266 | 266 | const int = std.meta.Int(signedness, N); |
| 267 | 267 | |
| 268 | 268 | var x: int = 1; |
| 269 | var res = @atomicRmw(int, &x, .Xchg, 3, .SeqCst); | |
| 269 | var res = @atomicRmw(int, &x, .Xchg, 3, .seq_cst); | |
| 270 | 270 | try expect(x == 3 and res == 1); |
| 271 | 271 | |
| 272 | res = @atomicRmw(int, &x, .Add, 3, .SeqCst); | |
| 272 | res = @atomicRmw(int, &x, .Add, 3, .seq_cst); | |
| 273 | 273 | var y: int = 3; |
| 274 | 274 | try expect(res == y); |
| 275 | 275 | y = y + 3; |
| 276 | 276 | try expect(x == y); |
| 277 | 277 | |
| 278 | res = @atomicRmw(int, &x, .Sub, 1, .SeqCst); | |
| 278 | res = @atomicRmw(int, &x, .Sub, 1, .seq_cst); | |
| 279 | 279 | try expect(res == y); |
| 280 | 280 | y = y - 1; |
| 281 | 281 | try expect(x == y); |
| 282 | 282 | |
| 283 | res = @atomicRmw(int, &x, .And, 4, .SeqCst); | |
| 283 | res = @atomicRmw(int, &x, .And, 4, .seq_cst); | |
| 284 | 284 | try expect(res == y); |
| 285 | 285 | y = y & 4; |
| 286 | 286 | try expect(x == y); |
| 287 | 287 | |
| 288 | res = @atomicRmw(int, &x, .Nand, 4, .SeqCst); | |
| 288 | res = @atomicRmw(int, &x, .Nand, 4, .seq_cst); | |
| 289 | 289 | try expect(res == y); |
| 290 | 290 | y = ~(y & 4); |
| 291 | 291 | try expect(x == y); |
| 292 | 292 | |
| 293 | res = @atomicRmw(int, &x, .Or, 6, .SeqCst); | |
| 293 | res = @atomicRmw(int, &x, .Or, 6, .seq_cst); | |
| 294 | 294 | try expect(res == y); |
| 295 | 295 | y = y | 6; |
| 296 | 296 | try expect(x == y); |
| 297 | 297 | |
| 298 | res = @atomicRmw(int, &x, .Xor, 2, .SeqCst); | |
| 298 | res = @atomicRmw(int, &x, .Xor, 2, .seq_cst); | |
| 299 | 299 | try expect(res == y); |
| 300 | 300 | y = y ^ 2; |
| 301 | 301 | try expect(x == y); |
| 302 | 302 | |
| 303 | res = @atomicRmw(int, &x, .Max, 1, .SeqCst); | |
| 303 | res = @atomicRmw(int, &x, .Max, 1, .seq_cst); | |
| 304 | 304 | try expect(res == y); |
| 305 | 305 | y = @max(y, 1); |
| 306 | 306 | try expect(x == y); |
| 307 | 307 | |
| 308 | res = @atomicRmw(int, &x, .Min, 1, .SeqCst); | |
| 308 | res = @atomicRmw(int, &x, .Min, 1, .seq_cst); | |
| 309 | 309 | try expect(res == y); |
| 310 | 310 | y = @min(y, 1); |
| 311 | 311 | try expect(x == y); |
| ... | ... | @@ -333,53 +333,53 @@ fn testAtomicRmwInt128(comptime signedness: std.builtin.Signedness) !void { |
| 333 | 333 | const replacement: int = 0x00000000_00000005_00000000_00000003; |
| 334 | 334 | |
| 335 | 335 | var x: int align(16) = initial; |
| 336 | var res = @atomicRmw(int, &x, .Xchg, replacement, .SeqCst); | |
| 336 | var res = @atomicRmw(int, &x, .Xchg, replacement, .seq_cst); | |
| 337 | 337 | try expect(x == replacement and res == initial); |
| 338 | 338 | |
| 339 | 339 | var operator: int = 0x00000001_00000000_20000000_00000000; |
| 340 | res = @atomicRmw(int, &x, .Add, operator, .SeqCst); | |
| 340 | res = @atomicRmw(int, &x, .Add, operator, .seq_cst); | |
| 341 | 341 | var y: int = replacement; |
| 342 | 342 | try expect(res == y); |
| 343 | 343 | y = y + operator; |
| 344 | 344 | try expect(x == y); |
| 345 | 345 | |
| 346 | 346 | operator = 0x00000000_10000000_00000000_20000000; |
| 347 | res = @atomicRmw(int, &x, .Sub, operator, .SeqCst); | |
| 347 | res = @atomicRmw(int, &x, .Sub, operator, .seq_cst); | |
| 348 | 348 | try expect(res == y); |
| 349 | 349 | y = y - operator; |
| 350 | 350 | try expect(x == y); |
| 351 | 351 | |
| 352 | 352 | operator = 0x12345678_87654321_12345678_87654321; |
| 353 | res = @atomicRmw(int, &x, .And, operator, .SeqCst); | |
| 353 | res = @atomicRmw(int, &x, .And, operator, .seq_cst); | |
| 354 | 354 | try expect(res == y); |
| 355 | 355 | y = y & operator; |
| 356 | 356 | try expect(x == y); |
| 357 | 357 | |
| 358 | 358 | operator = 0x00000000_10000000_00000000_20000000; |
| 359 | res = @atomicRmw(int, &x, .Nand, operator, .SeqCst); | |
| 359 | res = @atomicRmw(int, &x, .Nand, operator, .seq_cst); | |
| 360 | 360 | try expect(res == y); |
| 361 | 361 | y = ~(y & operator); |
| 362 | 362 | try expect(x == y); |
| 363 | 363 | |
| 364 | 364 | operator = 0x12340000_56780000_67890000_98760000; |
| 365 | res = @atomicRmw(int, &x, .Or, operator, .SeqCst); | |
| 365 | res = @atomicRmw(int, &x, .Or, operator, .seq_cst); | |
| 366 | 366 | try expect(res == y); |
| 367 | 367 | y = y | operator; |
| 368 | 368 | try expect(x == y); |
| 369 | 369 | |
| 370 | 370 | operator = 0x0a0b0c0d_0e0f0102_03040506_0708090a; |
| 371 | res = @atomicRmw(int, &x, .Xor, operator, .SeqCst); | |
| 371 | res = @atomicRmw(int, &x, .Xor, operator, .seq_cst); | |
| 372 | 372 | try expect(res == y); |
| 373 | 373 | y = y ^ operator; |
| 374 | 374 | try expect(x == y); |
| 375 | 375 | |
| 376 | 376 | operator = 0x00000000_10000000_00000000_20000000; |
| 377 | res = @atomicRmw(int, &x, .Max, operator, .SeqCst); | |
| 377 | res = @atomicRmw(int, &x, .Max, operator, .seq_cst); | |
| 378 | 378 | try expect(res == y); |
| 379 | 379 | y = @max(y, operator); |
| 380 | 380 | try expect(x == y); |
| 381 | 381 | |
| 382 | res = @atomicRmw(int, &x, .Min, operator, .SeqCst); | |
| 382 | res = @atomicRmw(int, &x, .Min, operator, .seq_cst); | |
| 383 | 383 | try expect(res == y); |
| 384 | 384 | y = @min(y, operator); |
| 385 | 385 | try expect(x == y); |
| ... | ... | @@ -405,13 +405,13 @@ test "atomics with different types" { |
| 405 | 405 | |
| 406 | 406 | fn testAtomicsWithType(comptime T: type, a: T, b: T) !void { |
| 407 | 407 | var x: T = b; |
| 408 | @atomicStore(T, &x, a, .SeqCst); | |
| 408 | @atomicStore(T, &x, a, .seq_cst); | |
| 409 | 409 | try expect(x == a); |
| 410 | try expect(@atomicLoad(T, &x, .SeqCst) == a); | |
| 411 | try expect(@atomicRmw(T, &x, .Xchg, b, .SeqCst) == a); | |
| 412 | try expect(@cmpxchgStrong(T, &x, b, a, .SeqCst, .SeqCst) == null); | |
| 410 | try expect(@atomicLoad(T, &x, .seq_cst) == a); | |
| 411 | try expect(@atomicRmw(T, &x, .Xchg, b, .seq_cst) == a); | |
| 412 | try expect(@cmpxchgStrong(T, &x, b, a, .seq_cst, .seq_cst) == null); | |
| 413 | 413 | if (@sizeOf(T) != 0) |
| 414 | try expect(@cmpxchgStrong(T, &x, b, a, .SeqCst, .SeqCst).? == a); | |
| 414 | try expect(@cmpxchgStrong(T, &x, b, a, .seq_cst, .seq_cst).? == a); | |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | test "return @atomicStore, using it as a void value" { |
| ... | ... | @@ -425,12 +425,12 @@ test "return @atomicStore, using it as a void value" { |
| 425 | 425 | value: usize, |
| 426 | 426 | |
| 427 | 427 | pub fn store(self: *A, value: usize) void { |
| 428 | return @atomicStore(usize, &self.value, value, .Unordered); | |
| 428 | return @atomicStore(usize, &self.value, value, .unordered); | |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | pub fn store2(self: *A, value: usize) void { |
| 432 | 432 | return switch (value) { |
| 433 | else => @atomicStore(usize, &self.value, value, .Unordered), | |
| 433 | else => @atomicStore(usize, &self.value, value, .unordered), | |
| 434 | 434 | }; |
| 435 | 435 | } |
| 436 | 436 | }; |
test/behavior/builtin_functions_returning_void_or_noreturn.zig+3-3| ... | ... | @@ -14,10 +14,10 @@ test { |
| 14 | 14 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 15 | 15 | |
| 16 | 16 | var val: u8 = undefined; |
| 17 | try testing.expectEqual({}, @atomicStore(u8, &val, 0, .Unordered)); | |
| 17 | try testing.expectEqual({}, @atomicStore(u8, &val, 0, .unordered)); | |
| 18 | 18 | try testing.expectEqual(void, @TypeOf(@breakpoint())); |
| 19 | 19 | try testing.expectEqual({}, @export(x, .{ .name = "x" })); |
| 20 | try testing.expectEqual({}, @fence(.Acquire)); | |
| 20 | try testing.expectEqual({}, @fence(.acquire)); | |
| 21 | 21 | try testing.expectEqual({}, @memcpy(@as([*]u8, @ptrFromInt(1))[0..0], @as([*]u8, @ptrFromInt(1))[0..0])); |
| 22 | 22 | try testing.expectEqual({}, @memset(@as([*]u8, @ptrFromInt(1))[0..0], undefined)); |
| 23 | 23 | try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {})); |
| ... | ... | @@ -25,6 +25,6 @@ test { |
| 25 | 25 | try testing.expectEqual({}, @setAlignStack(16)); |
| 26 | 26 | try testing.expectEqual({}, @setCold(true)); |
| 27 | 27 | try testing.expectEqual({}, @setEvalBranchQuota(0)); |
| 28 | try testing.expectEqual({}, @setFloatMode(.Optimized)); | |
| 28 | try testing.expectEqual({}, @setFloatMode(.optimized)); | |
| 29 | 29 | try testing.expectEqual({}, @setRuntimeSafety(true)); |
| 30 | 30 | } |
test/behavior/export_builtin.zig+2-2| ... | ... | @@ -25,7 +25,7 @@ test "exporting with internal linkage" { |
| 25 | 25 | const S = struct { |
| 26 | 26 | fn foo() callconv(.C) void {} |
| 27 | 27 | comptime { |
| 28 | @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .Internal }); | |
| 28 | @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal }); | |
| 29 | 29 | } |
| 30 | 30 | }; |
| 31 | 31 | S.foo(); |
| ... | ... | @@ -41,7 +41,7 @@ test "exporting using field access" { |
| 41 | 41 | const x: u32 = 5; |
| 42 | 42 | }; |
| 43 | 43 | comptime { |
| 44 | @export(Inner.x, .{ .name = "foo", .linkage = .Internal }); | |
| 44 | @export(Inner.x, .{ .name = "foo", .linkage = .internal }); | |
| 45 | 45 | } |
| 46 | 46 | }; |
| 47 | 47 |
test/behavior/floatop.zig+1-1| ... | ... | @@ -1511,7 +1511,7 @@ test "eval @setFloatMode at compile-time" { |
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | fn fnWithFloatMode() f32 { |
| 1514 | @setFloatMode(std.builtin.FloatMode.Strict); | |
| 1514 | @setFloatMode(std.builtin.FloatMode.strict); | |
| 1515 | 1515 | return 1234.0; |
| 1516 | 1516 | } |
| 1517 | 1517 |
test/behavior/tuple.zig+3-3| ... | ... | @@ -135,7 +135,7 @@ test "array-like initializer for tuple types" { |
| 135 | 135 | const T = @Type(.{ |
| 136 | 136 | .Struct = .{ |
| 137 | 137 | .is_tuple = true, |
| 138 | .layout = .Auto, | |
| 138 | .layout = .auto, | |
| 139 | 139 | .decls = &.{}, |
| 140 | 140 | .fields = &.{ |
| 141 | 141 | .{ |
| ... | ... | @@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" { |
| 323 | 323 | data: @Type(.{ |
| 324 | 324 | .Struct = .{ |
| 325 | 325 | .is_tuple = true, |
| 326 | .layout = .Auto, | |
| 326 | .layout = .auto, | |
| 327 | 327 | .decls = &.{}, |
| 328 | 328 | .fields = &.{.{ |
| 329 | 329 | .name = "0", |
| ... | ... | @@ -471,7 +471,7 @@ test "coerce anon tuple to tuple" { |
| 471 | 471 | |
| 472 | 472 | test "empty tuple type" { |
| 473 | 473 | const S = @Type(.{ .Struct = .{ |
| 474 | .layout = .Auto, | |
| 474 | .layout = .auto, | |
| 475 | 475 | .fields = &.{}, |
| 476 | 476 | .decls = &.{}, |
| 477 | 477 | .is_tuple = true, |
test/behavior/tuple_declarations.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ test "tuple declaration type info" { |
| 12 | 12 | const T = struct { comptime u32 align(2) = 1, []const u8 }; |
| 13 | 13 | const info = @typeInfo(T).Struct; |
| 14 | 14 | |
| 15 | try expect(info.layout == .Auto); | |
| 15 | try expect(info.layout == .auto); | |
| 16 | 16 | try expect(info.backing_integer == null); |
| 17 | 17 | try expect(info.fields.len == 2); |
| 18 | 18 | try expect(info.decls.len == 0); |
test/behavior/type.zig+19-19| ... | ... | @@ -263,7 +263,7 @@ test "Type.Struct" { |
| 263 | 263 | |
| 264 | 264 | const A = @Type(@typeInfo(struct { x: u8, y: u32 })); |
| 265 | 265 | const infoA = @typeInfo(A).Struct; |
| 266 | try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout); | |
| 266 | try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout); | |
| 267 | 267 | try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); |
| 268 | 268 | try testing.expectEqual(u8, infoA.fields[0].type); |
| 269 | 269 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value); |
| ... | ... | @@ -281,7 +281,7 @@ test "Type.Struct" { |
| 281 | 281 | |
| 282 | 282 | const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 })); |
| 283 | 283 | const infoB = @typeInfo(B).Struct; |
| 284 | try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout); | |
| 284 | try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout); | |
| 285 | 285 | try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); |
| 286 | 286 | try testing.expectEqual(u8, infoB.fields[0].type); |
| 287 | 287 | try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value); |
| ... | ... | @@ -293,7 +293,7 @@ test "Type.Struct" { |
| 293 | 293 | |
| 294 | 294 | const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 })); |
| 295 | 295 | const infoC = @typeInfo(C).Struct; |
| 296 | try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout); | |
| 296 | try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout); | |
| 297 | 297 | try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); |
| 298 | 298 | try testing.expectEqual(u8, infoC.fields[0].type); |
| 299 | 299 | try testing.expectEqual(@as(u8, 3), @as(*const u8, @ptrCast(infoC.fields[0].default_value.?)).*); |
| ... | ... | @@ -306,7 +306,7 @@ test "Type.Struct" { |
| 306 | 306 | // anon structs |
| 307 | 307 | const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 }))); |
| 308 | 308 | const infoD = @typeInfo(D).Struct; |
| 309 | try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout); | |
| 309 | try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout); | |
| 310 | 310 | try testing.expectEqualSlices(u8, "x", infoD.fields[0].name); |
| 311 | 311 | try testing.expectEqual(comptime_int, infoD.fields[0].type); |
| 312 | 312 | try testing.expectEqual(@as(comptime_int, 3), @as(*const comptime_int, @ptrCast(infoD.fields[0].default_value.?)).*); |
| ... | ... | @@ -319,7 +319,7 @@ test "Type.Struct" { |
| 319 | 319 | // tuples |
| 320 | 320 | const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 }))); |
| 321 | 321 | const infoE = @typeInfo(E).Struct; |
| 322 | try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout); | |
| 322 | try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout); | |
| 323 | 323 | try testing.expectEqualSlices(u8, "0", infoE.fields[0].name); |
| 324 | 324 | try testing.expectEqual(comptime_int, infoE.fields[0].type); |
| 325 | 325 | try testing.expectEqual(@as(comptime_int, 1), @as(*const comptime_int, @ptrCast(infoE.fields[0].default_value.?)).*); |
| ... | ... | @@ -332,14 +332,14 @@ test "Type.Struct" { |
| 332 | 332 | // empty struct |
| 333 | 333 | const F = @Type(@typeInfo(struct {})); |
| 334 | 334 | const infoF = @typeInfo(F).Struct; |
| 335 | try testing.expectEqual(Type.ContainerLayout.Auto, infoF.layout); | |
| 335 | try testing.expectEqual(Type.ContainerLayout.auto, infoF.layout); | |
| 336 | 336 | try testing.expect(infoF.fields.len == 0); |
| 337 | 337 | try testing.expectEqual(@as(bool, false), infoF.is_tuple); |
| 338 | 338 | |
| 339 | 339 | // empty tuple |
| 340 | 340 | const G = @Type(@typeInfo(@TypeOf(.{}))); |
| 341 | 341 | const infoG = @typeInfo(G).Struct; |
| 342 | try testing.expectEqual(Type.ContainerLayout.Auto, infoG.layout); | |
| 342 | try testing.expectEqual(Type.ContainerLayout.auto, infoG.layout); | |
| 343 | 343 | try testing.expect(infoG.fields.len == 0); |
| 344 | 344 | try testing.expectEqual(@as(bool, true), infoG.is_tuple); |
| 345 | 345 | } |
| ... | ... | @@ -386,7 +386,7 @@ test "Type.Union" { |
| 386 | 386 | |
| 387 | 387 | const Untagged = @Type(.{ |
| 388 | 388 | .Union = .{ |
| 389 | .layout = .Extern, | |
| 389 | .layout = .@"extern", | |
| 390 | 390 | .tag_type = null, |
| 391 | 391 | .fields = &.{ |
| 392 | 392 | .{ .name = "int", .type = i32, .alignment = @alignOf(f32) }, |
| ... | ... | @@ -402,7 +402,7 @@ test "Type.Union" { |
| 402 | 402 | |
| 403 | 403 | const PackedUntagged = @Type(.{ |
| 404 | 404 | .Union = .{ |
| 405 | .layout = .Packed, | |
| 405 | .layout = .@"packed", | |
| 406 | 406 | .tag_type = null, |
| 407 | 407 | .fields = &.{ |
| 408 | 408 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
| ... | ... | @@ -429,7 +429,7 @@ test "Type.Union" { |
| 429 | 429 | }); |
| 430 | 430 | const Tagged = @Type(.{ |
| 431 | 431 | .Union = .{ |
| 432 | .layout = .Auto, | |
| 432 | .layout = .auto, | |
| 433 | 433 | .tag_type = Tag, |
| 434 | 434 | .fields = &.{ |
| 435 | 435 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
| ... | ... | @@ -457,7 +457,7 @@ test "Type.Union from Type.Enum" { |
| 457 | 457 | }); |
| 458 | 458 | const T = @Type(.{ |
| 459 | 459 | .Union = .{ |
| 460 | .layout = .Auto, | |
| 460 | .layout = .auto, | |
| 461 | 461 | .tag_type = Tag, |
| 462 | 462 | .fields = &.{ |
| 463 | 463 | .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, |
| ... | ... | @@ -472,7 +472,7 @@ test "Type.Union from regular enum" { |
| 472 | 472 | const E = enum { working_as_expected }; |
| 473 | 473 | const T = @Type(.{ |
| 474 | 474 | .Union = .{ |
| 475 | .layout = .Auto, | |
| 475 | .layout = .auto, | |
| 476 | 476 | .tag_type = E, |
| 477 | 477 | .fields = &.{ |
| 478 | 478 | .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, |
| ... | ... | @@ -487,7 +487,7 @@ test "Type.Union from empty regular enum" { |
| 487 | 487 | const E = enum {}; |
| 488 | 488 | const U = @Type(.{ |
| 489 | 489 | .Union = .{ |
| 490 | .layout = .Auto, | |
| 490 | .layout = .auto, | |
| 491 | 491 | .tag_type = E, |
| 492 | 492 | .fields = &.{}, |
| 493 | 493 | .decls = &.{}, |
| ... | ... | @@ -507,7 +507,7 @@ test "Type.Union from empty Type.Enum" { |
| 507 | 507 | }); |
| 508 | 508 | const U = @Type(.{ |
| 509 | 509 | .Union = .{ |
| 510 | .layout = .Auto, | |
| 510 | .layout = .auto, | |
| 511 | 511 | .tag_type = E, |
| 512 | 512 | .fields = &.{}, |
| 513 | 513 | .decls = &.{}, |
| ... | ... | @@ -553,7 +553,7 @@ test "reified struct field name from optional payload" { |
| 553 | 553 | const m_name: ?[1:0]u8 = "a".*; |
| 554 | 554 | if (m_name) |*name| { |
| 555 | 555 | const T = @Type(.{ .Struct = .{ |
| 556 | .layout = .Auto, | |
| 556 | .layout = .auto, | |
| 557 | 557 | .fields = &.{.{ |
| 558 | 558 | .name = name, |
| 559 | 559 | .type = u8, |
| ... | ... | @@ -575,7 +575,7 @@ test "reified union uses @alignOf" { |
| 575 | 575 | fn CreateUnion(comptime T: type) type { |
| 576 | 576 | return @Type(.{ |
| 577 | 577 | .Union = .{ |
| 578 | .layout = .Auto, | |
| 578 | .layout = .auto, | |
| 579 | 579 | .tag_type = null, |
| 580 | 580 | .fields = &[_]std.builtin.Type.UnionField{ |
| 581 | 581 | .{ |
| ... | ... | @@ -597,7 +597,7 @@ test "reified struct uses @alignOf" { |
| 597 | 597 | fn NamespacedGlobals(comptime modules: anytype) type { |
| 598 | 598 | return @Type(.{ |
| 599 | 599 | .Struct = .{ |
| 600 | .layout = .Auto, | |
| 600 | .layout = .auto, | |
| 601 | 601 | .is_tuple = false, |
| 602 | 602 | .fields = &.{ |
| 603 | 603 | .{ |
| ... | ... | @@ -659,7 +659,7 @@ test "empty struct assigned to reified struct field" { |
| 659 | 659 | fn NamespacedComponents(comptime modules: anytype) type { |
| 660 | 660 | return @Type(.{ |
| 661 | 661 | .Struct = .{ |
| 662 | .layout = .Auto, | |
| 662 | .layout = .auto, | |
| 663 | 663 | .is_tuple = false, |
| 664 | 664 | .fields = &.{.{ |
| 665 | 665 | .name = "components", |
| ... | ... | @@ -721,7 +721,7 @@ test "struct field names sliced at comptime from larger string" { |
| 721 | 721 | |
| 722 | 722 | const T = @Type(.{ |
| 723 | 723 | .Struct = .{ |
| 724 | .layout = .Auto, | |
| 724 | .layout = .auto, | |
| 725 | 725 | .is_tuple = false, |
| 726 | 726 | .fields = fields, |
| 727 | 727 | .decls = &.{}, |
test/behavior/type_info.zig+4-4| ... | ... | @@ -250,7 +250,7 @@ test "type info: union info" { |
| 250 | 250 | fn testUnion() !void { |
| 251 | 251 | const typeinfo_info = @typeInfo(Type); |
| 252 | 252 | try expect(typeinfo_info == .Union); |
| 253 | try expect(typeinfo_info.Union.layout == .Auto); | |
| 253 | try expect(typeinfo_info.Union.layout == .auto); | |
| 254 | 254 | try expect(typeinfo_info.Union.tag_type.? == TypeId); |
| 255 | 255 | try expect(typeinfo_info.Union.fields.len == 24); |
| 256 | 256 | try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int)); |
| ... | ... | @@ -264,7 +264,7 @@ fn testUnion() !void { |
| 264 | 264 | const notag_union_info = @typeInfo(TestNoTagUnion); |
| 265 | 265 | try expect(notag_union_info == .Union); |
| 266 | 266 | try expect(notag_union_info.Union.tag_type == null); |
| 267 | try expect(notag_union_info.Union.layout == .Auto); | |
| 267 | try expect(notag_union_info.Union.layout == .auto); | |
| 268 | 268 | try expect(notag_union_info.Union.fields.len == 2); |
| 269 | 269 | try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void)); |
| 270 | 270 | try expect(notag_union_info.Union.fields[1].type == u32); |
| ... | ... | @@ -275,7 +275,7 @@ fn testUnion() !void { |
| 275 | 275 | }; |
| 276 | 276 | |
| 277 | 277 | const extern_union_info = @typeInfo(TestExternUnion); |
| 278 | try expect(extern_union_info.Union.layout == .Extern); | |
| 278 | try expect(extern_union_info.Union.layout == .@"extern"); | |
| 279 | 279 | try expect(extern_union_info.Union.tag_type == null); |
| 280 | 280 | try expect(extern_union_info.Union.fields[0].type == *anyopaque); |
| 281 | 281 | } |
| ... | ... | @@ -310,7 +310,7 @@ fn testPackedStruct() !void { |
| 310 | 310 | const struct_info = @typeInfo(TestPackedStruct); |
| 311 | 311 | try expect(struct_info == .Struct); |
| 312 | 312 | try expect(struct_info.Struct.is_tuple == false); |
| 313 | try expect(struct_info.Struct.layout == .Packed); | |
| 313 | try expect(struct_info.Struct.layout == .@"packed"); | |
| 314 | 314 | try expect(struct_info.Struct.backing_integer == u128); |
| 315 | 315 | try expect(struct_info.Struct.fields.len == 4); |
| 316 | 316 | try expect(struct_info.Struct.fields[0].alignment == 0); |
test/cases/compile_errors/atomic_orderings_of_atomicStore_Acquire_or_AcqRel.zig+2-2| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | 2 | var x: u32 = 0; |
| 3 | @atomicStore(u32, &x, 1, .Acquire); | |
| 3 | @atomicStore(u32, &x, 1, .acquire); | |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
| 7 | 7 | // backend=stage2 |
| 8 | 8 | // target=native |
| 9 | 9 | // |
| 10 | // :3:31: error: @atomicStore atomic ordering must not be Acquire or AcqRel | |
| 10 | // :3:31: error: @atomicStore atomic ordering must not be acquire or acq_rel |
test/cases/compile_errors/atomic_orderings_of_cmpxchg-failure_stricter_than_success.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; |
| 2 | 2 | export fn f() void { |
| 3 | 3 | var x: i32 = 1234; |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Monotonic, AtomicOrder.SeqCst)) {} | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.monotonic, AtomicOrder.seq_cst)) {} | |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | // error |
test/cases/compile_errors/atomic_orderings_of_cmpxchg-success_Monotonic_or_stricter.zig+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; |
| 2 | 2 | export fn f() void { |
| 3 | 3 | var x: i32 = 1234; |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Unordered, AtomicOrder.Unordered)) {} | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.unordered, AtomicOrder.unordered)) {} | |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | // error |
| 8 | 8 | // backend=stage2 |
| 9 | 9 | // target=native |
| 10 | 10 | // |
| 11 | // :4:58: error: success atomic ordering must be Monotonic or stricter | |
| 11 | // :4:58: error: success atomic ordering must be monotonic or stricter |
test/cases/compile_errors/atomic_orderings_of_fence_Acquire_or_stricter.zig+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | @fence(.Monotonic); | |
| 2 | @fence(.monotonic); | |
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | // error |
| 6 | 6 | // backend=stage2 |
| 7 | 7 | // target=native |
| 8 | 8 | // |
| 9 | // :2:13: error: atomic ordering must be Acquire or stricter | |
| 9 | // :2:13: error: atomic ordering must be acquire or stricter |
test/cases/compile_errors/atomicrmw_with_bool_op_not_.Xchg.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | 2 | var x = false; |
| 3 | _ = @atomicRmw(bool, &x, .Add, true, .SeqCst); | |
| 3 | _ = @atomicRmw(bool, &x, .Add, true, .seq_cst); | |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
test/cases/compile_errors/atomicrmw_with_enum_op_not_.Xchg.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ export fn entry() void { |
| 6 | 6 | d, |
| 7 | 7 | }; |
| 8 | 8 | var x: E = .a; |
| 9 | _ = @atomicRmw(E, &x, .Add, .b, .SeqCst); | |
| 9 | _ = @atomicRmw(E, &x, .Add, .b, .seq_cst); | |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | // error |
test/cases/compile_errors/atomicrmw_with_float_op_not_.Xchg_.Add_.Sub_.Max_or_.Min.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | 2 | var x: f32 = 0; |
| 3 | _ = @atomicRmw(f32, &x, .And, 2, .SeqCst); | |
| 3 | _ = @atomicRmw(f32, &x, .And, 2, .seq_cst); | |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
test/cases/compile_errors/cmpxchg_with_float.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | 2 | var x: f32 = 0; |
| 3 | _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst); | |
| 3 | _ = @cmpxchgWeak(f32, &x, 1, 2, .seq_cst, .seq_cst); | |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // error |
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{ | |
| 2 | _ = @Type(.{ .Struct = .{ .layout = .@"packed", .fields = &.{ | |
| 3 | 3 | .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, |
| 4 | 4 | }, .decls = &.{}, .is_tuple = false } }); |
| 5 | 5 | } |
test/cases/compile_errors/passing_a_not-aligned-enough_pointer_to_cmpxchg.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const AtomicOrder = @import("std").builtin.AtomicOrder; |
| 2 | 2 | export fn entry() bool { |
| 3 | 3 | var x: i32 align(1) = 1234; |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) {} | |
| 4 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.seq_cst, AtomicOrder.seq_cst)) {} | |
| 5 | 5 | return x == 5678; |
| 6 | 6 | } |
| 7 | 7 |
test/cases/compile_errors/reify_struct.zig+5-5| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | comptime { |
| 2 | 2 | @Type(.{ .Struct = .{ |
| 3 | .layout = .Auto, | |
| 3 | .layout = .auto, | |
| 4 | 4 | .fields = &.{.{ |
| 5 | 5 | .name = "foo", |
| 6 | 6 | .type = u32, |
| ... | ... | @@ -14,7 +14,7 @@ comptime { |
| 14 | 14 | } |
| 15 | 15 | comptime { |
| 16 | 16 | @Type(.{ .Struct = .{ |
| 17 | .layout = .Auto, | |
| 17 | .layout = .auto, | |
| 18 | 18 | .fields = &.{.{ |
| 19 | 19 | .name = "3", |
| 20 | 20 | .type = u32, |
| ... | ... | @@ -28,7 +28,7 @@ comptime { |
| 28 | 28 | } |
| 29 | 29 | comptime { |
| 30 | 30 | @Type(.{ .Struct = .{ |
| 31 | .layout = .Auto, | |
| 31 | .layout = .auto, | |
| 32 | 32 | .fields = &.{.{ |
| 33 | 33 | .name = "0", |
| 34 | 34 | .type = u32, |
| ... | ... | @@ -42,7 +42,7 @@ comptime { |
| 42 | 42 | } |
| 43 | 43 | comptime { |
| 44 | 44 | @Type(.{ .Struct = .{ |
| 45 | .layout = .Extern, | |
| 45 | .layout = .@"extern", | |
| 46 | 46 | .fields = &.{.{ |
| 47 | 47 | .name = "0", |
| 48 | 48 | .type = u32, |
| ... | ... | @@ -56,7 +56,7 @@ comptime { |
| 56 | 56 | } |
| 57 | 57 | comptime { |
| 58 | 58 | @Type(.{ .Struct = .{ |
| 59 | .layout = .Packed, | |
| 59 | .layout = .@"packed", | |
| 60 | 60 | .fields = &.{.{ |
| 61 | 61 | .name = "0", |
| 62 | 62 | .type = u32, |
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ const Tag = @Type(.{ |
| 12 | 12 | }); |
| 13 | 13 | const Tagged = @Type(.{ |
| 14 | 14 | .Union = .{ |
| 15 | .layout = .Auto, | |
| 15 | .layout = .auto, | |
| 16 | 16 | .tag_type = Tag, |
| 17 | 17 | .fields = &.{ |
| 18 | 18 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig+1-1| ... | ... | @@ -11,7 +11,7 @@ const Tag = @Type(.{ |
| 11 | 11 | }); |
| 12 | 12 | const Tagged = @Type(.{ |
| 13 | 13 | .Union = .{ |
| 14 | .layout = .Auto, | |
| 14 | .layout = .auto, | |
| 15 | 15 | .tag_type = Tag, |
| 16 | 16 | .fields = &.{ |
| 17 | 17 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig+1-1| ... | ... | @@ -8,7 +8,7 @@ const Tag = @Type(.{ |
| 8 | 8 | }); |
| 9 | 9 | const Tagged = @Type(.{ |
| 10 | 10 | .Union = .{ |
| 11 | .layout = .Auto, | |
| 11 | .layout = .auto, | |
| 12 | 12 | .tag_type = Tag, |
| 13 | 13 | .fields = &.{ |
| 14 | 14 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig+1-1| ... | ... | @@ -11,7 +11,7 @@ const Tag = @Type(.{ |
| 11 | 11 | }); |
| 12 | 12 | const Tagged = @Type(.{ |
| 13 | 13 | .Union = .{ |
| 14 | .layout = .Auto, | |
| 14 | .layout = .auto, | |
| 15 | 15 | .tag_type = Tag, |
| 16 | 16 | .fields = &.{}, |
| 17 | 17 | .decls = &.{}, |
test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const Untagged = @Type(.{ |
| 2 | 2 | .Union = .{ |
| 3 | .layout = .Auto, | |
| 3 | .layout = .auto, | |
| 4 | 4 | .tag_type = null, |
| 5 | 5 | .fields = &.{ |
| 6 | 6 | .{ .name = "foo", .type = opaque {}, .alignment = 1 }, |
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | comptime { |
| 2 | 2 | _ = @Type(.{ |
| 3 | 3 | .Union = .{ |
| 4 | .layout = .Auto, | |
| 4 | .layout = .auto, | |
| 5 | 5 | .tag_type = null, |
| 6 | 6 | .fields = &.{ |
| 7 | 7 | .{ .name = "foo", .type = usize, .alignment = 3 }, |
| ... | ... | @@ -13,7 +13,7 @@ comptime { |
| 13 | 13 | comptime { |
| 14 | 14 | _ = @Type(.{ |
| 15 | 15 | .Struct = .{ |
| 16 | .layout = .Auto, | |
| 16 | .layout = .auto, | |
| 17 | 17 | .fields = &.{.{ |
| 18 | 18 | .name = "0", |
| 19 | 19 | .type = u32, |
test/cases/compile_errors/reify_type_with_undefined.zig+2-2| ... | ... | @@ -7,7 +7,7 @@ comptime { |
| 7 | 7 | .fields = undefined, |
| 8 | 8 | .decls = undefined, |
| 9 | 9 | .is_tuple = false, |
| 10 | .layout = .Auto, | |
| 10 | .layout = .auto, | |
| 11 | 11 | }, |
| 12 | 12 | }); |
| 13 | 13 | } |
| ... | ... | @@ -16,7 +16,7 @@ comptime { |
| 16 | 16 | const fields: [1]std.builtin.Type.StructField = undefined; |
| 17 | 17 | _ = @Type(.{ |
| 18 | 18 | .Struct = .{ |
| 19 | .layout = .Auto, | |
| 19 | .layout = .auto, | |
| 20 | 20 | .fields = &fields, |
| 21 | 21 | .decls = &.{}, |
| 22 | 22 | .is_tuple = false, |
test/link/elf.zig+2-2| ... | ... | @@ -799,8 +799,8 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step { |
| 799 | 799 | \\} |
| 800 | 800 | \\export var strongBar: usize = 100; |
| 801 | 801 | \\comptime { |
| 802 | \\ @export(weakFoo, .{ .name = "weakFoo", .linkage = .Weak }); | |
| 803 | \\ @export(strongBar, .{ .name = "strongBarAlias", .linkage = .Strong }); | |
| 802 | \\ @export(weakFoo, .{ .name = "weakFoo", .linkage = .weak }); | |
| 803 | \\ @export(strongBar, .{ .name = "strongBarAlias", .linkage = .strong }); | |
| 804 | 804 | \\} |
| 805 | 805 | , |
| 806 | 806 | }); |
test/link/macho.zig+1-1| ... | ... | @@ -1153,7 +1153,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step { |
| 1153 | 1153 | \\ return x; |
| 1154 | 1154 | \\} |
| 1155 | 1155 | \\comptime { |
| 1156 | \\ @export(foo, .{ .name = "bar", .linkage = .Strong }); | |
| 1156 | \\ @export(foo, .{ .name = "bar", .linkage = .strong }); | |
| 1157 | 1157 | \\} |
| 1158 | 1158 | }); |
| 1159 | 1159 |
test/standalone/global_linkage/obj1.zig+2-2| ... | ... | @@ -2,6 +2,6 @@ var internal_integer: usize = 1; |
| 2 | 2 | var obj1_integer: usize = 421; |
| 3 | 3 | |
| 4 | 4 | comptime { |
| 5 | @export(internal_integer, .{ .name = "internal_integer", .linkage = .Internal }); | |
| 6 | @export(obj1_integer, .{ .name = "obj1_integer", .linkage = .Strong }); | |
| 5 | @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal }); | |
| 6 | @export(obj1_integer, .{ .name = "obj1_integer", .linkage = .strong }); | |
| 7 | 7 | } |
test/standalone/global_linkage/obj2.zig+2-2| ... | ... | @@ -2,6 +2,6 @@ var internal_integer: usize = 2; |
| 2 | 2 | var obj2_integer: usize = 422; |
| 3 | 3 | |
| 4 | 4 | comptime { |
| 5 | @export(internal_integer, .{ .name = "internal_integer", .linkage = .Internal }); | |
| 6 | @export(obj2_integer, .{ .name = "obj2_integer", .linkage = .Strong }); | |
| 5 | @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal }); | |
| 6 | @export(obj2_integer, .{ .name = "obj2_integer", .linkage = .strong }); | |
| 7 | 7 | } |
tools/docgen.zig+3-3| ... | ... | @@ -629,7 +629,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc { |
| 629 | 629 | } else if (mem.eql(u8, end_tag_name, "link_libc")) { |
| 630 | 630 | link_libc = true; |
| 631 | 631 | } else if (mem.eql(u8, end_tag_name, "link_mode_dynamic")) { |
| 632 | link_mode = .Dynamic; | |
| 632 | link_mode = .dynamic; | |
| 633 | 633 | } else if (mem.eql(u8, end_tag_name, "additonal_option")) { |
| 634 | 634 | _ = try eatToken(tokenizer, .separator); |
| 635 | 635 | const option = try eatToken(tokenizer, .tag_content); |
| ... | ... | @@ -1793,11 +1793,11 @@ fn genHtml( |
| 1793 | 1793 | } |
| 1794 | 1794 | if (code.link_mode) |link_mode| { |
| 1795 | 1795 | switch (link_mode) { |
| 1796 | .Static => { | |
| 1796 | .static => { | |
| 1797 | 1797 | try test_args.append("-static"); |
| 1798 | 1798 | try shell_out.print("-static ", .{}); |
| 1799 | 1799 | }, |
| 1800 | .Dynamic => { | |
| 1800 | .dynamic => { | |
| 1801 | 1801 | try test_args.append("-dynamic"); |
| 1802 | 1802 | try shell_out.print("-dynamic ", .{}); |
| 1803 | 1803 | }, |