Skip to content

Commit 4f782d1

Browse files
authored
Merge pull request #18994 from ExpidusOS/feat/container-layout-rename-fields
std.builtin: make enum fields lowercase
2 parents d0c06ca + 6067d39 commit 4f782d1

File tree

126 files changed

+909
-916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+909
-916
lines changed

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
855855
}
856856

857857
const CMakeConfig = struct {
858-
llvm_linkage: std.Build.Step.Compile.Linkage,
858+
llvm_linkage: std.builtin.LinkMode,
859859
cmake_binary_dir: []const u8,
860860
cmake_prefix_path: []const u8,
861861
cmake_static_library_prefix: []const u8,

doc/langref.html.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ export fn foo_strict(x: f64) f64 {
14531453
}
14541454

14551455
export fn foo_optimized(x: f64) f64 {
1456-
@setFloatMode(.Optimized);
1456+
@setFloatMode(.optimized);
14571457
return x + big - big;
14581458
}
14591459
{#code_end#}
@@ -8356,7 +8356,7 @@ test "main" {
83568356
</p>
83578357
{#code_begin|obj|export_builtin#}
83588358
comptime {
8359-
@export(internalName, .{ .name = "foo", .linkage = .Strong });
8359+
@export(internalName, .{ .name = "foo", .linkage = .strong });
83608360
}
83618361

83628362
fn internalName() callconv(.C) void {}

lib/build_runner.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,10 +892,10 @@ fn workerMakeOneStep(
892892
// then we return without doing the step, relying on another worker to
893893
// queue this step up again when dependencies are met.
894894
for (s.dependencies.items) |dep| {
895-
switch (@atomicLoad(Step.State, &dep.state, .SeqCst)) {
895+
switch (@atomicLoad(Step.State, &dep.state, .seq_cst)) {
896896
.success, .skipped => continue,
897897
.failure, .dependency_failure, .skipped_oom => {
898-
@atomicStore(Step.State, &s.state, .dependency_failure, .SeqCst);
898+
@atomicStore(Step.State, &s.state, .dependency_failure, .seq_cst);
899899
return;
900900
},
901901
.precheck_done, .running => {
@@ -929,7 +929,7 @@ fn workerMakeOneStep(
929929
s.state = .running;
930930
} else {
931931
// 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) {
933933
// Another worker got the job.
934934
return;
935935
}
@@ -956,13 +956,13 @@ fn workerMakeOneStep(
956956

957957
handle_result: {
958958
if (make_result) |_| {
959-
@atomicStore(Step.State, &s.state, .success, .SeqCst);
959+
@atomicStore(Step.State, &s.state, .success, .seq_cst);
960960
} else |err| switch (err) {
961961
error.MakeFailed => {
962-
@atomicStore(Step.State, &s.state, .failure, .SeqCst);
962+
@atomicStore(Step.State, &s.state, .failure, .seq_cst);
963963
break :handle_result;
964964
},
965-
error.MakeSkipped => @atomicStore(Step.State, &s.state, .skipped, .SeqCst),
965+
error.MakeSkipped => @atomicStore(Step.State, &s.state, .skipped, .seq_cst),
966966
}
967967

968968
// Successful completion of a step, so we queue up its dependants as well.

lib/c.zig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ const is_freestanding = switch (native_os) {
2626

2727
comptime {
2828
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 });
3030
}
3131

3232
if (native_os == .linux) {
3333
@export(clone, .{ .name = "clone" });
3434
}
3535

3636
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 });
4545
} else if (is_msvc) {
46-
@export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
46+
@export(_fltused, .{ .name = "_fltused", .linkage = .strong });
4747
}
4848
}
4949

lib/compiler/aro/aro/Attribute.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ pub const Arguments = blk: {
653653

654654
break :blk @Type(.{
655655
.Union = .{
656-
.layout = .Auto,
656+
.layout = .auto,
657657
.tag_type = null,
658658
.fields = &union_fields,
659659
.decls = &.{},

lib/compiler_rt/atomics.zig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const SpinlockTable = struct {
7474
: "memory"
7575
);
7676
} 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);
7878
};
7979

8080
switch (flag) {
@@ -91,7 +91,7 @@ const SpinlockTable = struct {
9191
: "memory"
9292
);
9393
} else {
94-
@atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .Release);
94+
@atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .release);
9595
}
9696
}
9797
};
@@ -172,7 +172,7 @@ inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T {
172172
defer sl.release();
173173
return src.*;
174174
} else {
175-
return @atomicLoad(T, src, .SeqCst);
175+
return @atomicLoad(T, src, .seq_cst);
176176
}
177177
}
178178

@@ -203,7 +203,7 @@ inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void {
203203
defer sl.release();
204204
dst.* = value;
205205
} else {
206-
@atomicStore(T, dst, value, .SeqCst);
206+
@atomicStore(T, dst, value, .seq_cst);
207207
}
208208
}
209209

@@ -239,12 +239,12 @@ fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
239239

240240
const mask = @as(WideAtomic, std.math.maxInt(T)) << inner_shift;
241241

242-
var wide_old = @atomicLoad(WideAtomic, wide_ptr, .SeqCst);
242+
var wide_old = @atomicLoad(WideAtomic, wide_ptr, .seq_cst);
243243
while (true) {
244244
const old = @as(T, @truncate((wide_old & mask) >> inner_shift));
245245
const new = update(val, old);
246246
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| {
248248
wide_old = new_wide_old;
249249
} else {
250250
return old;
@@ -270,7 +270,7 @@ inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T {
270270
};
271271
return wideUpdate(T, ptr, val, Updater.update);
272272
} else {
273-
return @atomicRmw(T, ptr, .Xchg, val, .SeqCst);
273+
return @atomicRmw(T, ptr, .Xchg, val, .seq_cst);
274274
}
275275
}
276276

@@ -315,7 +315,7 @@ inline fn atomic_compare_exchange_N(
315315
expected.* = value;
316316
return 0;
317317
} 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| {
319319
expected.* = old_value;
320320
return 0;
321321
}
@@ -373,7 +373,7 @@ inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr
373373
return wideUpdate(T, ptr, val, Updater.update);
374374
}
375375

376-
return @atomicRmw(T, ptr, op, val, .SeqCst);
376+
return @atomicRmw(T, ptr, op, val, .seq_cst);
377377
}
378378

379379
fn __atomic_fetch_add_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {

lib/compiler_rt/clear_cache.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
162162
}
163163
}
164164

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;
166166

167167
fn exportIt() void {
168168
@export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage });

lib/compiler_rt/common.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ const std = @import("std");
22
const builtin = @import("builtin");
33
const native_endian = builtin.cpu.arch.endian();
44

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;
66
/// Determines the symbol's visibility to other objects.
77
/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
88
/// export it to the host runtime.
99
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;
1111
pub const want_aeabi = switch (builtin.abi) {
1212
.eabi,
1313
.eabihf,

lib/compiler_rt/os_version_check.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const std = @import("std");
22
const testing = std.testing;
33
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;
55
const panic = @import("common.zig").panic;
66

77
const have_availability_version_check = builtin.os.tag.isDarwin() and

lib/compiler_rt/stack_probe.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const is_test = builtin.is_test;
88
const is_gnu = abi.isGnu();
99
const is_mingw = os_tag == .windows and is_gnu;
1010

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;
1313
pub const panic = @import("common.zig").panic;
1414

1515
comptime {

lib/std/Build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ pub const ExecutableOptions = struct {
645645
version: ?std.SemanticVersion = null,
646646
optimize: std.builtin.OptimizeMode = .Debug,
647647
code_model: std.builtin.CodeModel = .default,
648-
linkage: ?Step.Compile.Linkage = null,
648+
linkage: ?std.builtin.LinkMode = null,
649649
max_rss: usize = 0,
650650
link_libc: ?bool = null,
651651
single_threaded: ?bool = null,

lib/std/Build/Module.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ pub const LinkSystemLibraryOptions = struct {
414414
needed: bool = false,
415415
weak: bool = false,
416416
use_pkg_config: SystemLib.UsePkgConfig = .yes,
417-
preferred_link_mode: std.builtin.LinkMode = .Dynamic,
417+
preferred_link_mode: std.builtin.LinkMode = .dynamic,
418418
search_strategy: SystemLib.SearchStrategy = .paths_first,
419419
};
420420

lib/std/Build/Step/Compile.zig

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ linker_script: ?LazyPath = null,
2828
version_script: ?LazyPath = null,
2929
out_filename: []const u8,
3030
out_lib_filename: []const u8,
31-
linkage: ?Linkage = null,
31+
linkage: ?std.builtin.LinkMode = null,
3232
version: ?std.SemanticVersion,
3333
kind: Kind,
3434
major_only_filename: ?[]const u8,
@@ -223,7 +223,7 @@ pub const Options = struct {
223223
name: []const u8,
224224
root_module: Module.CreateOptions,
225225
kind: Kind,
226-
linkage: ?Linkage = null,
226+
linkage: ?std.builtin.LinkMode = null,
227227
version: ?std.SemanticVersion = null,
228228
max_rss: usize = 0,
229229
filters: []const []const u8 = &.{},
@@ -246,8 +246,6 @@ pub const Kind = enum {
246246
@"test",
247247
};
248248

249-
pub const Linkage = enum { dynamic, static };
250-
251249
pub fn create(owner: *std.Build, options: Options) *Compile {
252250
const name = owner.dupe(options.name);
253251
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 {
283281
.obj => .Obj,
284282
.exe, .@"test" => .Exe,
285283
},
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,
290285
.version = options.version,
291286
}) catch @panic("OOM");
292287

@@ -531,11 +526,11 @@ pub fn dependsOnSystemLibrary(self: *const Compile, name: []const u8) bool {
531526
}
532527

533528
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;
535530
}
536531

537532
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;
539534
}
540535

541536
pub fn producesPdbFile(self: *Compile) bool {
@@ -988,7 +983,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
988983
var prev_has_cflags = false;
989984
var prev_has_rcflags = false;
990985
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;
992987
// Track the number of positional arguments so that a nice error can be
993988
// emitted if there is nothing to link.
994989
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 {
10531048
{
10541049
switch (system_lib.search_strategy) {
10551050
.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"),
10581053
},
10591054
.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"),
10621057
},
10631058
.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"),
10661061
},
10671062
}
10681063
prev_search_strategy = system_lib.search_strategy;
@@ -1138,7 +1133,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
11381133
try zig_args.append(full_path_lib);
11391134
total_linker_objects += 1;
11401135

1141-
if (other.linkage == Linkage.dynamic and
1136+
if (other.linkage == .dynamic and
11421137
self.rootModuleTarget().os.tag != .windows)
11431138
{
11441139
if (fs.path.dirname(full_path_lib)) |dirname| {

lib/std/Build/Step/TranslateC.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub const AddExecutableOptions = struct {
5555
version: ?std.SemanticVersion = null,
5656
target: ?std.Build.ResolvedTarget = null,
5757
optimize: ?std.builtin.OptimizeMode = null,
58-
linkage: ?Step.Compile.Linkage = null,
58+
linkage: ?std.builtin.LinkMode = null,
5959
};
6060

6161
pub fn getOutput(self: *TranslateC) std.Build.LazyPath {

0 commit comments

Comments
 (0)