authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-04 23:47:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-04 23:48:55-07:00
log6115cf22404467fd13d0290fc022d51d372d139a
tree26c0bab951c81e89b5f0edcc5dc9f4b8e64df7db
parent78902db68bbd400f6d84b65280c31d417105f2a8

migrate from `std.Target.current` to `@import("builtin").target`

closes #9388 closes #9321

147 files changed, 624 insertions(+), 596 deletions(-)

doc/docgen.zig+2-2
......@@ -1334,7 +1334,7 @@ fn genHtml(
13341334 if (mem.startsWith(u8, triple, "wasm32") or
13351335 mem.startsWith(u8, triple, "riscv64-linux") or
13361336 (mem.startsWith(u8, triple, "x86_64-linux") and
1337 std.Target.current.os.tag != .linux or std.Target.current.cpu.arch != .x86_64))
1337 builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
13381338 {
13391339 // skip execution
13401340 break :code_block;
......@@ -1602,7 +1602,7 @@ fn genHtml(
16021602 Code.Id.Lib => {
16031603 const bin_basename = try std.zig.binNameAlloc(allocator, .{
16041604 .root_name = code.name,
1605 .target = std.Target.current,
1605 .target = builtin.target,
16061606 .output_mode = .Lib,
16071607 });
16081608
doc/langref.html.in+7-4
......@@ -2681,6 +2681,7 @@ test "pointer child type" {
26812681 </p>
26822682 {#code_begin|test|variable_alignment#}
26832683const std = @import("std");
2684const builtin = @import("builtin");
26842685const expect = std.testing.expect;
26852686
26862687test "variable alignment" {
......@@ -2688,7 +2689,7 @@ test "variable alignment" {
26882689 const align_of_i32 = @alignOf(@TypeOf(x));
26892690 try expect(@TypeOf(&x) == *i32);
26902691 try expect(*i32 == *align(align_of_i32) i32);
2691 if (std.Target.current.cpu.arch == .x86_64) {
2692 if (builtin.target.cpu.arch == .x86_64) {
26922693 try expect(@typeInfo(*i32).Pointer.alignment == 4);
26932694 }
26942695}
......@@ -3878,6 +3879,7 @@ test "separate scopes" {
38783879 {#header_open|switch#}
38793880 {#code_begin|test|switch#}
38803881const std = @import("std");
3882const builtin = @import("builtin");
38813883const expect = std.testing.expect;
38823884
38833885test "switch simple" {
......@@ -3922,7 +3924,7 @@ test "switch simple" {
39223924}
39233925
39243926// Switch expressions can be used outside a function:
3925const os_msg = switch (std.Target.current.os.tag) {
3927const os_msg = switch (builtin.target.os.tag) {
39263928 .linux => "we found a linux user",
39273929 else => "not a linux user",
39283930};
......@@ -3930,7 +3932,7 @@ const os_msg = switch (std.Target.current.os.tag) {
39303932// Inside a function, switch statements implicitly are compile-time
39313933// evaluated if the target expression is compile-time known.
39323934test "switch inside function" {
3933 switch (std.Target.current.os.tag) {
3935 switch (builtin.target.os.tag) {
39343936 .fuchsia => {
39353937 // On an OS other than fuchsia, block is not even analyzed,
39363938 // so this compile error is not triggered.
......@@ -5690,6 +5692,7 @@ test "cast *[1][*]const u8 to [*]const ?[*]const u8" {
56905692 </p>
56915693 {#code_begin|test|test_integer_widening#}
56925694const std = @import("std");
5695const builtin = @import("builtin");
56935696const expect = std.testing.expect;
56945697const mem = std.mem;
56955698
......@@ -5712,7 +5715,7 @@ test "implicit unsigned integer to signed integer" {
57125715test "float widening" {
57135716 // Note: there is an open issue preventing this from working on aarch64:
57145717 // https://github.com/ziglang/zig/issues/3282
5715 if (std.Target.current.cpu.arch == .aarch64) return error.SkipZigTest;
5718 if (builtin.target.cpu.arch == .aarch64) return error.SkipZigTest;
57165719
57175720 var a: f16 = 12.34;
57185721 var b: f32 = a;
lib/std/Progress.zig+4-3
......@@ -7,6 +7,7 @@
77//! * `initial_delay_ms`
88
99const std = @import("std");
10const builtin = @import("builtin");
1011const windows = std.os.windows;
1112const testing = std.testing;
1213const assert = std.debug.assert;
......@@ -144,10 +145,10 @@ pub fn start(self: *Progress, name: []const u8, estimated_total_items: usize) !*
144145 if (stderr.supportsAnsiEscapeCodes()) {
145146 self.terminal = stderr;
146147 self.supports_ansi_escape_codes = true;
147 } else if (std.builtin.os.tag == .windows and stderr.isTty()) {
148 } else if (builtin.os.tag == .windows and stderr.isTty()) {
148149 self.is_windows_terminal = true;
149150 self.terminal = stderr;
150 } else if (std.builtin.os.tag != .windows) {
151 } else if (builtin.os.tag != .windows) {
151152 // we are in a "dumb" terminal like in acme or writing to a file
152153 self.terminal = stderr;
153154 }
......@@ -200,7 +201,7 @@ fn refreshWithHeldLock(self: *Progress) void {
200201 if (self.supports_ansi_escape_codes) {
201202 end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{d}D", .{self.columns_written}) catch unreachable).len;
202203 end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;
203 } else if (std.builtin.os.tag == .windows) winapi: {
204 } else if (builtin.os.tag == .windows) winapi: {
204205 std.debug.assert(self.is_windows_terminal);
205206
206207 var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
lib/std/Thread/AutoResetEvent.zig+1-1
......@@ -26,7 +26,7 @@
2626state: usize = UNSET,
2727
2828const std = @import("../std.zig");
29const builtin = std.builtin;
29const builtin = @import("builtin");
3030const testing = std.testing;
3131const assert = std.debug.assert;
3232const StaticResetEvent = std.Thread.StaticResetEvent;
lib/std/Thread/Condition.zig+5-4
......@@ -5,6 +5,7 @@
55impl: Impl = .{},
66
77const std = @import("../std.zig");
8const builtin = @import("builtin");
89const Condition = @This();
910const windows = std.os.windows;
1011const linux = std.os.linux;
......@@ -23,9 +24,9 @@ pub fn broadcast(cond: *Condition) void {
2324 cond.impl.broadcast();
2425}
2526
26const Impl = if (std.builtin.single_threaded)
27const Impl = if (builtin.single_threaded)
2728 SingleThreadedCondition
28else if (std.Target.current.os.tag == .windows)
29else if (builtin.os.tag == .windows)
2930 WindowsCondition
3031else if (std.Thread.use_pthreads)
3132 PthreadCondition
......@@ -101,7 +102,7 @@ pub const AtomicCondition = struct {
101102
102103 fn wait(cond: *@This()) void {
103104 while (@atomicLoad(i32, &cond.futex, .Acquire) == 0) {
104 switch (std.Target.current.os.tag) {
105 switch (builtin.os.tag) {
105106 .linux => {
106107 switch (linux.getErrno(linux.futex_wait(
107108 &cond.futex,
......@@ -123,7 +124,7 @@ pub const AtomicCondition = struct {
123124 fn notify(cond: *@This()) void {
124125 @atomicStore(i32, &cond.futex, 1, .Release);
125126
126 switch (std.Target.current.os.tag) {
127 switch (builtin.os.tag) {
127128 .linux => {
128129 switch (linux.getErrno(linux.futex_wake(
129130 &cond.futex,
lib/std/Thread/Futex.zig+4-3
......@@ -4,10 +4,11 @@
44//! Using Futex, other Thread synchronization primitives can be built which efficiently wait for cross-thread events or signals.
55
66const std = @import("../std.zig");
7const builtin = @import("builtin");
78const Futex = @This();
89
9const target = std.Target.current;
10const single_threaded = std.builtin.single_threaded;
10const target = builtin.target;
11const single_threaded = builtin.single_threaded;
1112
1213const assert = std.debug.assert;
1314const testing = std.testing;
......@@ -70,7 +71,7 @@ else if (target.os.tag == .linux)
7071 LinuxFutex
7172else if (target.isDarwin())
7273 DarwinFutex
73else if (std.builtin.link_libc)
74else if (builtin.link_libc)
7475 PosixFutex
7576else
7677 UnsupportedFutex;
lib/std/Thread/Mutex.zig+3-3
......@@ -24,7 +24,7 @@ impl: Impl = .{},
2424
2525const Mutex = @This();
2626const std = @import("../std.zig");
27const builtin = std.builtin;
27const builtin = @import("builtin");
2828const os = std.os;
2929const assert = std.debug.assert;
3030const windows = os.windows;
......@@ -160,7 +160,7 @@ pub const AtomicMutex = struct {
160160 .unlocked => return,
161161 else => {},
162162 }
163 switch (std.Target.current.os.tag) {
163 switch (builtin.os.tag) {
164164 .linux => {
165165 switch (linux.getErrno(linux.futex_wait(
166166 @ptrCast(*const i32, &m.state),
......@@ -182,7 +182,7 @@ pub const AtomicMutex = struct {
182182 fn unlockSlow(m: *AtomicMutex) void {
183183 @setCold(true);
184184
185 switch (std.Target.current.os.tag) {
185 switch (builtin.os.tag) {
186186 .linux => {
187187 switch (linux.getErrno(linux.futex_wake(
188188 @ptrCast(*const i32, &m.state),
lib/std/Thread/ResetEvent.zig+2-2
......@@ -8,7 +8,7 @@
88
99const ResetEvent = @This();
1010const std = @import("../std.zig");
11const builtin = std.builtin;
11const builtin = @import("builtin");
1212const testing = std.testing;
1313const assert = std.debug.assert;
1414const c = std.c;
......@@ -19,7 +19,7 @@ impl: Impl,
1919
2020pub const Impl = if (builtin.single_threaded)
2121 std.Thread.StaticResetEvent.DebugEvent
22else if (std.Target.current.isDarwin())
22else if (builtin.target.isDarwin())
2323 DarwinEvent
2424else if (std.Thread.use_pthreads)
2525 PosixEvent
lib/std/Thread/StaticResetEvent.zig+4-3
......@@ -8,6 +8,7 @@
88//! the logic needs stronger API guarantees.
99
1010const std = @import("../std.zig");
11const builtin = @import("builtin");
1112const StaticResetEvent = @This();
1213const assert = std.debug.assert;
1314const os = std.os;
......@@ -18,7 +19,7 @@ const testing = std.testing;
1819
1920impl: Impl = .{},
2021
21pub const Impl = if (std.builtin.single_threaded)
22pub const Impl = if (builtin.single_threaded)
2223 DebugEvent
2324else
2425 AtomicEvent;
......@@ -162,7 +163,7 @@ pub const AtomicEvent = struct {
162163 @atomicStore(u32, &ev.waiters, 0, .Monotonic);
163164 }
164165
165 pub const Futex = switch (std.Target.current.os.tag) {
166 pub const Futex = switch (builtin.os.tag) {
166167 .windows => WindowsFutex,
167168 .linux => LinuxFutex,
168169 else => SpinFutex,
......@@ -322,7 +323,7 @@ test "basic usage" {
322323 try testing.expectEqual(TimedWaitResult.event_set, event.timedWait(1));
323324
324325 // test cross-thread signaling
325 if (std.builtin.single_threaded)
326 if (builtin.single_threaded)
326327 return;
327328
328329 const Context = struct {
lib/std/array_hash_map.zig-1
......@@ -9,7 +9,6 @@ const trait = meta.trait;
99const autoHash = std.hash.autoHash;
1010const Wyhash = std.hash.Wyhash;
1111const Allocator = mem.Allocator;
12const builtin = std.builtin;
1312const hash_map = @This();
1413
1514/// An ArrayHashMap with default hash and equal functions.
lib/std/atomic.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std.zig");
2const target = std.Target.current;
2const target = @import("builtin").target;
33
44pub const Ordering = std.builtin.AtomicOrder;
55
lib/std/atomic/Atomic.zig+1-1
......@@ -1,7 +1,7 @@
11const std = @import("../std.zig");
22
33const testing = std.testing;
4const target = std.Target.current;
4const target = @import("builtin").target;
55const Ordering = std.atomic.Ordering;
66
77pub fn Atomic(comptime T: type) type {
lib/std/atomic/queue.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const assert = std.debug.assert;
44const expect = std.testing.expect;
55
lib/std/atomic/stack.zig+2-2
......@@ -1,5 +1,6 @@
1const std = @import("../std.zig");
2const builtin = @import("builtin");
13const assert = std.debug.assert;
2const builtin = std.builtin;
34const expect = std.testing.expect;
45
56/// Many reader, many writer, non-allocating, thread-safe
......@@ -67,7 +68,6 @@ pub fn Stack(comptime T: type) type {
6768 };
6869}
6970
70const std = @import("../std.zig");
7171const Context = struct {
7272 allocator: *std.mem.Allocator,
7373 stack: *Stack(i32),
lib/std/build.zig+21-21
......@@ -1,5 +1,5 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const io = std.io;
44const fs = std.fs;
55const mem = std.mem;
......@@ -62,7 +62,7 @@ pub const Builder = struct {
6262 build_root: []const u8,
6363 cache_root: []const u8,
6464 global_cache_root: []const u8,
65 release_mode: ?builtin.Mode,
65 release_mode: ?std.builtin.Mode,
6666 is_release: bool,
6767 override_lib_dir: ?[]const u8,
6868 vcpkg_root: VcpkgRoot,
......@@ -633,18 +633,18 @@ pub const Builder = struct {
633633 }
634634
635635 /// This provides the -Drelease option to the build user and does not give them the choice.
636 pub fn setPreferredReleaseMode(self: *Builder, mode: builtin.Mode) void {
636 pub fn setPreferredReleaseMode(self: *Builder, mode: std.builtin.Mode) void {
637637 if (self.release_mode != null) {
638638 @panic("setPreferredReleaseMode must be called before standardReleaseOptions and may not be called twice");
639639 }
640640 const description = self.fmt("Create a release build ({s})", .{@tagName(mode)});
641641 self.is_release = self.option(bool, "release", description) orelse false;
642 self.release_mode = if (self.is_release) mode else builtin.Mode.Debug;
642 self.release_mode = if (self.is_release) mode else std.builtin.Mode.Debug;
643643 }
644644
645645 /// If you call this without first calling `setPreferredReleaseMode` then it gives the build user
646646 /// the choice of what kind of release.
647 pub fn standardReleaseOptions(self: *Builder) builtin.Mode {
647 pub fn standardReleaseOptions(self: *Builder) std.builtin.Mode {
648648 if (self.release_mode) |mode| return mode;
649649
650650 const release_safe = self.option(bool, "release-safe", "Optimizations on and safety on") orelse false;
......@@ -652,17 +652,17 @@ pub const Builder = struct {
652652 const release_small = self.option(bool, "release-small", "Size optimizations on and safety off") orelse false;
653653
654654 const mode = if (release_safe and !release_fast and !release_small)
655 builtin.Mode.ReleaseSafe
655 std.builtin.Mode.ReleaseSafe
656656 else if (release_fast and !release_safe and !release_small)
657 builtin.Mode.ReleaseFast
657 std.builtin.Mode.ReleaseFast
658658 else if (release_small and !release_fast and !release_safe)
659 builtin.Mode.ReleaseSmall
659 std.builtin.Mode.ReleaseSmall
660660 else if (!release_fast and !release_safe and !release_small)
661 builtin.Mode.Debug
661 std.builtin.Mode.Debug
662662 else x: {
663663 warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)\n\n", .{});
664664 self.markInvalidUserInput();
665 break :x builtin.Mode.Debug;
665 break :x std.builtin.Mode.Debug;
666666 };
667667 self.is_release = mode != .Debug;
668668 self.release_mode = mode;
......@@ -1290,7 +1290,7 @@ test "builder.findProgram compiles" {
12901290}
12911291
12921292/// Deprecated. Use `std.builtin.Version`.
1293pub const Version = builtin.Version;
1293pub const Version = std.builtin.Version;
12941294
12951295/// Deprecated. Use `std.zig.CrossTarget`.
12961296pub const Target = std.zig.CrossTarget;
......@@ -1417,8 +1417,8 @@ pub const LibExeObjStep = struct {
14171417 version_script: ?[]const u8 = null,
14181418 out_filename: []const u8,
14191419 linkage: ?Linkage = null,
1420 version: ?Version,
1421 build_mode: builtin.Mode,
1420 version: ?std.builtin.Version,
1421 build_mode: std.builtin.Mode,
14221422 kind: Kind,
14231423 major_only_filename: ?[]const u8,
14241424 name_only_filename: ?[]const u8,
......@@ -1447,8 +1447,8 @@ pub const LibExeObjStep = struct {
14471447 filter: ?[]const u8,
14481448 single_threaded: bool,
14491449 test_evented_io: bool = false,
1450 code_model: builtin.CodeModel = .default,
1451 wasi_exec_model: ?builtin.WasiExecModel = null,
1450 code_model: std.builtin.CodeModel = .default,
1451 wasi_exec_model: ?std.builtin.WasiExecModel = null,
14521452
14531453 root_src: ?FileSource,
14541454 out_h_filename: []const u8,
......@@ -1550,7 +1550,7 @@ pub const LibExeObjStep = struct {
15501550 };
15511551
15521552 const SharedLibKind = union(enum) {
1553 versioned: Version,
1553 versioned: std.builtin.Version,
15541554 unversioned: void,
15551555 };
15561556
......@@ -1585,7 +1585,7 @@ pub const LibExeObjStep = struct {
15851585 root_src_raw: ?FileSource,
15861586 kind: Kind,
15871587 linkage: ?Linkage,
1588 ver: ?Version,
1588 ver: ?std.builtin.Version,
15891589 ) *LibExeObjStep {
15901590 const name = builder.dupe(name_raw);
15911591 const root_src: ?FileSource = if (root_src_raw) |rsrc| rsrc.dupe(builder) else null;
......@@ -1599,7 +1599,7 @@ pub const LibExeObjStep = struct {
15991599 .builder = builder,
16001600 .verbose_link = false,
16011601 .verbose_cc = false,
1602 .build_mode = builtin.Mode.Debug,
1602 .build_mode = std.builtin.Mode.Debug,
16031603 .linkage = linkage,
16041604 .kind = kind,
16051605 .root_src = root_src,
......@@ -1988,7 +1988,7 @@ pub const LibExeObjStep = struct {
19881988 self.verbose_cc = value;
19891989 }
19901990
1991 pub fn setBuildMode(self: *LibExeObjStep, mode: builtin.Mode) void {
1991 pub fn setBuildMode(self: *LibExeObjStep, mode: std.builtin.Mode) void {
19921992 self.build_mode = mode;
19931993 }
19941994
......@@ -2553,7 +2553,7 @@ pub const LibExeObjStep = struct {
25532553
25542554 const resolved_include_path = self.builder.pathFromRoot(include_path);
25552555
2556 const common_include_path = if (std.Target.current.os.tag == .windows and builder.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: {
2556 const common_include_path = if (builtin.os.tag == .windows and builder.sysroot != null and fs.path.isAbsolute(resolved_include_path)) blk: {
25572557 // We need to check for disk designator and strip it out from dir path so
25582558 // that zig/clang can concat resolved_include_path with sysroot.
25592559 const disk_designator = fs.path.diskDesignatorWindows(resolved_include_path);
......@@ -3237,7 +3237,7 @@ test "LibExeObjStep.addPackage" {
32373237test {
32383238 // The only purpose of this test is to get all these untested functions
32393239 // to be referenced to avoid regression so it is okay to skip some targets.
3240 if (comptime std.Target.current.cpu.arch.ptrBitWidth() == 64) {
3240 if (comptime builtin.cpu.arch.ptrBitWidth() == 64) {
32413241 std.testing.refAllDecls(@This());
32423242 std.testing.refAllDecls(Builder);
32433243
lib/std/build/OptionsStep.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const build = std.build;
34const fs = std.fs;
45const Step = build.Step;
......@@ -219,7 +220,7 @@ const OptionFileSourceArg = struct {
219220};
220221
221222test "OptionsStep" {
222 if (std.builtin.os.tag == .wasi) return error.SkipZigTest;
223 if (builtin.os.tag == .wasi) return error.SkipZigTest;
223224
224225 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
225226 defer arena.deinit();
lib/std/build/RunStep.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const build = std.build;
44const Step = build.Step;
55const Builder = build.Builder;
lib/std/builtin.zig+23-22
......@@ -1,26 +1,27 @@
11const builtin = @import("builtin");
22
3// These are all deprecated.
4pub const zig_version = builtin.zig_version;
5pub const zig_is_stage2 = builtin.zig_is_stage2;
6pub const output_mode = builtin.output_mode;
7pub const link_mode = builtin.link_mode;
8pub const is_test = builtin.is_test;
9pub const single_threaded = builtin.single_threaded;
10pub const abi = builtin.abi;
11pub const cpu = builtin.cpu;
12pub const os = builtin.os;
13pub const target = builtin.target;
14pub const object_format = builtin.object_format;
15pub const mode = builtin.mode;
16pub const link_libc = builtin.link_libc;
17pub const link_libcpp = builtin.link_libcpp;
18pub const have_error_return_tracing = builtin.have_error_return_tracing;
19pub const valgrind_support = builtin.valgrind_support;
20pub const position_independent_code = builtin.position_independent_code;
21pub const position_independent_executable = builtin.position_independent_executable;
22pub const strip_debug_info = builtin.strip_debug_info;
23pub const code_model = builtin.code_model;
3// TODO delete these after releasing 0.9.0
4
5pub const zig_version = @compileError("get this from @import(\"builtin\") instead of std.builtin");
6pub const zig_is_stage2 = @compileError("get this from @import(\"builtin\") instead of std.builtin");
7pub const output_mode = @compileError("get this from @import(\"builtin\") instead of std.builtin");
8pub const link_mode = @compileError("get this from @import(\"builtin\") instead of std.builtin");
9pub const is_test = @compileError("get this from @import(\"builtin\") instead of std.builtin");
10pub const single_threaded = @compileError("get this from @import(\"builtin\") instead of std.builtin");
11pub const abi = @compileError("get this from @import(\"builtin\") instead of std.builtin");
12pub const cpu = @compileError("get this from @import(\"builtin\") instead of std.builtin");
13pub const os = @compileError("get this from @import(\"builtin\") instead of std.builtin");
14pub const target = @compileError("get this from @import(\"builtin\") instead of std.builtin");
15pub const object_format = @compileError("get this from @import(\"builtin\") instead of std.builtin");
16pub const mode = @compileError("get this from @import(\"builtin\") instead of std.builtin");
17pub const link_libc = @compileError("get this from @import(\"builtin\") instead of std.builtin");
18pub const link_libcpp = @compileError("get this from @import(\"builtin\") instead of std.builtin");
19pub const have_error_return_tracing = @compileError("get this from @import(\"builtin\") instead of std.builtin");
20pub const valgrind_support = @compileError("get this from @import(\"builtin\") instead of std.builtin");
21pub const position_independent_code = @compileError("get this from @import(\"builtin\") instead of std.builtin");
22pub const position_independent_executable = @compileError("get this from @import(\"builtin\") instead of std.builtin");
23pub const strip_debug_info = @compileError("get this from @import(\"builtin\") instead of std.builtin");
24pub const code_model = @compileError("get this from @import(\"builtin\") instead of std.builtin");
2425
2526/// `explicit_subsystem` is missing when the subsystem is automatically detected,
2627/// so Zig standard library has the subsystem detection logic here. This should generally be
......@@ -694,7 +695,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn
694695 @breakpoint();
695696 }
696697 }
697 switch (os.tag) {
698 switch (builtin.os.tag) {
698699 .freestanding => {
699700 while (true) {
700701 @breakpoint();
lib/std/c.zig+2-2
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const c = @This();
44const page_size = std.mem.page_size;
55const iovec = std.os.iovec;
......@@ -20,7 +20,7 @@ pub const Tokenizer = tokenizer.Tokenizer;
2020/// If linking gnu libc (glibc), the `ok` value will be true if the target
2121/// version is greater than or equal to `glibc_version`.
2222/// If linking a libc other than these, returns `false`.
23pub fn versionCheck(glibc_version: builtin.Version) type {
23pub fn versionCheck(glibc_version: std.builtin.Version) type {
2424 return struct {
2525 pub const ok = blk: {
2626 if (!builtin.link_libc) break :blk false;
lib/std/c/darwin.zig+2-2
......@@ -1,6 +1,6 @@
11const std = @import("../std.zig");
2const assert = std.debug.assert;
32const builtin = @import("builtin");
3const assert = std.debug.assert;
44const macho = std.macho;
55const native_arch = builtin.target.cpu.arch;
66const maxInt = std.math.maxInt;
......@@ -72,7 +72,7 @@ const mach_hdr = if (@sizeOf(usize) == 8) mach_header_64 else mach_header;
7272var dummy_execute_header: mach_hdr = undefined;
7373pub extern var _mh_execute_header: mach_hdr;
7474comptime {
75 if (std.Target.current.isDarwin()) {
75 if (builtin.target.isDarwin()) {
7676 @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .Weak });
7777 }
7878}
lib/std/child_process.zig+4-4
......@@ -1,4 +1,5 @@
11const std = @import("std.zig");
2const builtin = @import("builtin");
23const cstr = std.cstr;
34const unicode = std.unicode;
45const io = std.io;
......@@ -12,8 +13,7 @@ const mem = std.mem;
1213const math = std.math;
1314const debug = std.debug;
1415const BufMap = std.BufMap;
15const builtin = std.builtin;
16const Os = builtin.Os;
16const Os = std.builtin.Os;
1717const TailQueue = std.TailQueue;
1818const maxInt = std.math.maxInt;
1919const assert = std.debug.assert;
......@@ -561,9 +561,9 @@ pub const ChildProcess = struct {
561561 if (self.env_map) |env_map| {
562562 const envp_buf = try createNullDelimitedEnvMap(arena, env_map);
563563 break :m envp_buf.ptr;
564 } else if (std.builtin.link_libc) {
564 } else if (builtin.link_libc) {
565565 break :m std.c.environ;
566 } else if (std.builtin.output_mode == .Exe) {
566 } else if (builtin.output_mode == .Exe) {
567567 // Then we have Zig start code and this works.
568568 // TODO type-safety for null-termination of `os.environ`.
569569 break :m @ptrCast([*:null]?[*:0]u8, os.environ.ptr);
lib/std/coff.zig-1
......@@ -1,4 +1,3 @@
1const builtin = std.builtin;
21const std = @import("std.zig");
32const io = std.io;
43const mem = std.mem;
lib/std/crypto.zig+1-1
......@@ -163,7 +163,7 @@ const std = @import("std.zig");
163163pub const errors = @import("crypto/errors.zig");
164164
165165test "crypto" {
166 const please_windows_dont_oom = std.Target.current.os.tag == .windows;
166 const please_windows_dont_oom = @import("builtin").os.tag == .windows;
167167 if (please_windows_dont_oom) return error.SkipZigTest;
168168
169169 inline for (std.meta.declarations(@This())) |decl| {
lib/std/crypto/aes.zig+7-7
......@@ -1,13 +1,13 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const testing = std.testing;
3const builtin = std.builtin;
44
5const has_aesni = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
6const has_avx = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
7const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
8const impl = if (std.Target.current.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
5const has_aesni = std.Target.x86.featureSetHas(builtin.cpu.features, .aes);
6const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx);
7const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
8const impl = if (builtin.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
99 break :impl @import("aes/aesni.zig");
10} else if (std.Target.current.cpu.arch == .aarch64 and has_armaes)
10} else if (builtin.cpu.arch == .aarch64 and has_armaes)
1111impl: {
1212 break :impl @import("aes/armcrypto.zig");
1313} else impl: {
......@@ -41,7 +41,7 @@ test "ctr" {
4141
4242 var out: [exp_out.len]u8 = undefined;
4343 var ctx = Aes128.initEnc(key);
44 ctr(AesEncryptCtx(Aes128), ctx, out[0..], in[0..], iv, builtin.Endian.Big);
44 ctr(AesEncryptCtx(Aes128), ctx, out[0..], in[0..], iv, std.builtin.Endian.Big);
4545 try testing.expectEqualSlices(u8, exp_out[0..], out[0..]);
4646}
4747
lib/std/crypto/aes/aesni.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("../../std.zig");
2const builtin = @import("builtin");
23const mem = std.mem;
34const debug = std.debug;
45const Vector = std.meta.Vector;
......@@ -97,7 +98,7 @@ pub const Block = struct {
9798 const cpu = std.Target.x86.cpu;
9899
99100 /// The recommended number of AES encryption/decryption to perform in parallel for the chosen implementation.
100 pub const optimal_parallel_blocks = switch (std.Target.current.cpu.model) {
101 pub const optimal_parallel_blocks = switch (builtin.cpu.model) {
101102 &cpu.westmere => 6,
102103 &cpu.sandybridge, &cpu.ivybridge => 8,
103104 &cpu.haswell, &cpu.broadwell => 7,
lib/std/crypto/aes_gcm.zig+2-3
......@@ -1,6 +1,5 @@
11const std = @import("std");
22const assert = std.debug.assert;
3const builtin = std.builtin;
43const crypto = std.crypto;
54const debug = std.debug;
65const Ghash = std.crypto.onetimeauth.Ghash;
......@@ -40,7 +39,7 @@ fn AesGcm(comptime Aes: anytype) type {
4039 mac.pad();
4140
4241 mem.writeIntBig(u32, j[nonce_length..][0..4], 2);
43 modes.ctr(@TypeOf(aes), aes, c, m, j, builtin.Endian.Big);
42 modes.ctr(@TypeOf(aes), aes, c, m, j, std.builtin.Endian.Big);
4443 mac.update(c[0..m.len][0..]);
4544 mac.pad();
4645
......@@ -94,7 +93,7 @@ fn AesGcm(comptime Aes: anytype) type {
9493 }
9594
9695 mem.writeIntBig(u32, j[nonce_length..][0..4], 2);
97 modes.ctr(@TypeOf(aes), aes, m, c, j, builtin.Endian.Big);
96 modes.ctr(@TypeOf(aes), aes, m, c, j, std.builtin.Endian.Big);
9897 }
9998 };
10099}
lib/std/crypto/aes_ocb.zig+4-3
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const crypto = std.crypto;
34const aes = crypto.core.aes;
45const assert = std.debug.assert;
......@@ -100,9 +101,9 @@ fn AesOcb(comptime Aes: anytype) type {
100101 return offset;
101102 }
102103
103 const has_aesni = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
104 const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
105 const wb: usize = if ((std.Target.current.cpu.arch == .x86_64 and has_aesni) or (std.Target.current.cpu.arch == .aarch64 and has_armaes)) 4 else 0;
104 const has_aesni = std.Target.x86.featureSetHas(builtin.cpu.features, .aes);
105 const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
106 const wb: usize = if ((builtin.cpu.arch == .x86_64 and has_aesni) or (builtin.cpu.arch == .aarch64 and has_armaes)) 4 else 0;
106107
107108 /// c: ciphertext: output buffer should be of size m.len
108109 /// tag: authentication tag: output MAC
lib/std/crypto/benchmark.zig+1-1
......@@ -1,7 +1,7 @@
11// zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig
22
33const std = @import("../std.zig");
4const builtin = std.builtin;
4const builtin = @import("builtin");
55const mem = std.mem;
66const time = std.time;
77const Timer = time.Timer;
lib/std/crypto/blake3.zig+2-1
......@@ -2,6 +2,7 @@
22// Source: https://github.com/BLAKE3-team/BLAKE3
33
44const std = @import("../std.zig");
5const builtin = @import("builtin");
56const fmt = std.fmt;
67const math = std.math;
78const mem = std.mem;
......@@ -200,7 +201,7 @@ const CompressGeneric = struct {
200201 }
201202};
202203
203const compress = if (std.Target.current.cpu.arch == .x86_64) CompressVectorized.compress else CompressGeneric.compress;
204const compress = if (builtin.cpu.arch == .x86_64) CompressVectorized.compress else CompressGeneric.compress;
204205
205206fn first8Words(words: [16]u32) [8]u32 {
206207 return @ptrCast(*const [8]u32, &words).*;
lib/std/crypto/chacha20.zig+2-1
......@@ -1,6 +1,7 @@
11// Based on public domain Supercop by Daniel J. Bernstein
22
33const std = @import("../std.zig");
4const builtin = @import("builtin");
45const math = std.math;
56const mem = std.mem;
67const assert = std.debug.assert;
......@@ -359,7 +360,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type {
359360}
360361
361362fn ChaChaImpl(comptime rounds_nb: usize) type {
362 return if (std.Target.current.cpu.arch == .x86_64) ChaChaVecImpl(rounds_nb) else ChaChaNonVecImpl(rounds_nb);
363 return if (builtin.cpu.arch == .x86_64) ChaChaVecImpl(rounds_nb) else ChaChaNonVecImpl(rounds_nb);
363364}
364365
365366fn keyToWords(key: [32]u8) [8]u32 {
lib/std/crypto/ghash.zig+8-7
......@@ -2,6 +2,7 @@
22// Adapted from BearSSL's ctmul64 implementation originally written by Thomas Pornin <pornin@bolet.org>
33
44const std = @import("../std.zig");
5const builtin = @import("builtin");
56const assert = std.debug.assert;
67const math = std.math;
78const mem = std.mem;
......@@ -45,7 +46,7 @@ pub const Ghash = struct {
4546 const h2 = h0 ^ h1;
4647 const h2r = h0r ^ h1r;
4748
48 if (std.builtin.mode == .ReleaseSmall) {
49 if (builtin.mode == .ReleaseSmall) {
4950 return Ghash{
5051 .h0 = h0,
5152 .h1 = h1,
......@@ -132,12 +133,12 @@ pub const Ghash = struct {
132133 return z0 | z1 | z2 | z3;
133134 }
134135
135 const has_pclmul = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .pclmul);
136 const has_avx = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
137 const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
138 const clmul = if (std.Target.current.cpu.arch == .x86_64 and has_pclmul and has_avx) impl: {
136 const has_pclmul = std.Target.x86.featureSetHas(builtin.cpu.features, .pclmul);
137 const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx);
138 const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
139 const clmul = if (builtin.cpu.arch == .x86_64 and has_pclmul and has_avx) impl: {
139140 break :impl clmul_pclmul;
140 } else if (std.Target.current.cpu.arch == .aarch64 and has_armaes) impl: {
141 } else if (builtin.cpu.arch == .aarch64 and has_armaes) impl: {
141142 break :impl clmul_pmull;
142143 } else impl: {
143144 break :impl clmul_soft;
......@@ -151,7 +152,7 @@ pub const Ghash = struct {
151152 var i: usize = 0;
152153
153154 // 2-blocks aggregated reduction
154 if (std.builtin.mode != .ReleaseSmall) {
155 if (builtin.mode != .ReleaseSmall) {
155156 while (i + 32 <= msg.len) : (i += 32) {
156157 // B0 * H^2 unreduced
157158 y1 ^= mem.readIntBig(u64, msg[i..][0..8]);
lib/std/crypto/gimli.zig+11-10
......@@ -1,13 +1,14 @@
1// Gimli is a 384-bit permutation designed to achieve high security with high
2// performance across a broad range of platforms, including 64-bit Intel/AMD
3// server CPUs, 64-bit and 32-bit ARM smartphone CPUs, 32-bit ARM
4// microcontrollers, 8-bit AVR microcontrollers, FPGAs, ASICs without
5// side-channel protection, and ASICs with side-channel protection.
6//
7// https://gimli.cr.yp.to/
8// https://csrc.nist.gov/CSRC/media/Projects/Lightweight-Cryptography/documents/round-1/spec-doc/gimli-spec.pdf
1//! Gimli is a 384-bit permutation designed to achieve high security with high
2//! performance across a broad range of platforms, including 64-bit Intel/AMD
3//! server CPUs, 64-bit and 32-bit ARM smartphone CPUs, 32-bit ARM
4//! microcontrollers, 8-bit AVR microcontrollers, FPGAs, ASICs without
5//! side-channel protection, and ASICs with side-channel protection.
6//!
7//! https://gimli.cr.yp.to/
8//! https://csrc.nist.gov/CSRC/media/Projects/Lightweight-Cryptography/documents/round-1/spec-doc/gimli-spec.pdf
99
1010const std = @import("../std.zig");
11const builtin = @import("builtin");
1112const mem = std.mem;
1213const math = std.math;
1314const debug = std.debug;
......@@ -152,9 +153,9 @@ pub const State = struct {
152153 self.endianSwap();
153154 }
154155
155 pub const permute = if (std.Target.current.cpu.arch == .x86_64) impl: {
156 pub const permute = if (builtin.cpu.arch == .x86_64) impl: {
156157 break :impl permute_vectorized;
157 } else if (std.builtin.mode == .ReleaseSmall) impl: {
158 } else if (builtin.mode == .ReleaseSmall) impl: {
158159 break :impl permute_small;
159160 } else impl: {
160161 break :impl permute_unrolled;
lib/std/crypto/modes.zig+1-2
......@@ -1,7 +1,6 @@
11// Based on Go stdlib implementation
22
33const std = @import("../std.zig");
4const builtin = std.builtin;
54const mem = std.mem;
65const debug = std.debug;
76
......@@ -11,7 +10,7 @@ const debug = std.debug;
1110///
1211/// Important: the counter mode doesn't provide authenticated encryption: the ciphertext can be trivially modified without this being detected.
1312/// As a result, applications should generally never use it directly, but only in a construction that includes a MAC.
14pub fn ctr(comptime BlockCipher: anytype, block_cipher: BlockCipher, dst: []u8, src: []const u8, iv: [BlockCipher.block_length]u8, endian: builtin.Endian) void {
13pub fn ctr(comptime BlockCipher: anytype, block_cipher: BlockCipher, dst: []u8, src: []const u8, iv: [BlockCipher.block_length]u8, endian: std.builtin.Endian) void {
1514 debug.assert(dst.len >= src.len);
1615 const block_length = BlockCipher.block_length;
1716 var counter: [BlockCipher.block_length]u8 = undefined;
lib/std/crypto/pcurves/common.zig+3-4
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = std.builtin;
32const crypto = std.crypto;
43const debug = std.debug;
54const mem = std.mem;
......@@ -51,7 +50,7 @@ pub fn Field(comptime params: FieldParams) type {
5150 };
5251
5352 /// Reject non-canonical encodings of an element.
54 pub fn rejectNonCanonical(s_: [encoded_length]u8, endian: builtin.Endian) NonCanonicalError!void {
53 pub fn rejectNonCanonical(s_: [encoded_length]u8, endian: std.builtin.Endian) NonCanonicalError!void {
5554 var s = if (endian == .Little) s_ else orderSwap(s_);
5655 const field_order_s = comptime fos: {
5756 var fos: [encoded_length]u8 = undefined;
......@@ -71,7 +70,7 @@ pub fn Field(comptime params: FieldParams) type {
7170 }
7271
7372 /// Unpack a field element.
74 pub fn fromBytes(s_: [encoded_length]u8, endian: builtin.Endian) NonCanonicalError!Fe {
73 pub fn fromBytes(s_: [encoded_length]u8, endian: std.builtin.Endian) NonCanonicalError!Fe {
7574 var s = if (endian == .Little) s_ else orderSwap(s_);
7675 try rejectNonCanonical(s, .Little);
7776 var limbs_z: NonMontgomeryDomainFieldElement = undefined;
......@@ -82,7 +81,7 @@ pub fn Field(comptime params: FieldParams) type {
8281 }
8382
8483 /// Pack a field element.
85 pub fn toBytes(fe: Fe, endian: builtin.Endian) [encoded_length]u8 {
84 pub fn toBytes(fe: Fe, endian: std.builtin.Endian) [encoded_length]u8 {
8685 var limbs_z: NonMontgomeryDomainFieldElement = undefined;
8786 fiat.fromMontgomery(&limbs_z, fe.limbs);
8887 var s: [encoded_length]u8 = undefined;
lib/std/crypto/pcurves/p256.zig+4-5
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = std.builtin;
32const crypto = std.crypto;
43const mem = std.mem;
54const meta = std.meta;
......@@ -59,7 +58,7 @@ pub const P256 = struct {
5958 }
6059
6160 /// Create a point from serialized affine coordinates.
62 pub fn fromSerializedAffineCoordinates(xs: [32]u8, ys: [32]u8, endian: builtin.Endian) (NonCanonicalError || EncodingError)!P256 {
61 pub fn fromSerializedAffineCoordinates(xs: [32]u8, ys: [32]u8, endian: std.builtin.Endian) (NonCanonicalError || EncodingError)!P256 {
6362 const x = try Fe.fromBytes(xs, endian);
6463 const y = try Fe.fromBytes(ys, endian);
6564 return fromAffineCoordinates(.{ .x = x, .y = y });
......@@ -396,7 +395,7 @@ pub const P256 = struct {
396395
397396 /// Multiply an elliptic curve point by a scalar.
398397 /// Return error.IdentityElement if the result is the identity element.
399 pub fn mul(p: P256, s_: [32]u8, endian: builtin.Endian) IdentityElementError!P256 {
398 pub fn mul(p: P256, s_: [32]u8, endian: std.builtin.Endian) IdentityElementError!P256 {
400399 const s = if (endian == .Little) s_ else Fe.orderSwap(s_);
401400 if (p.is_base) {
402401 return pcMul16(&basePointPc, s, false);
......@@ -408,7 +407,7 @@ pub const P256 = struct {
408407
409408 /// Multiply an elliptic curve point by a *PUBLIC* scalar *IN VARIABLE TIME*
410409 /// This can be used for signature verification.
411 pub fn mulPublic(p: P256, s_: [32]u8, endian: builtin.Endian) IdentityElementError!P256 {
410 pub fn mulPublic(p: P256, s_: [32]u8, endian: std.builtin.Endian) IdentityElementError!P256 {
412411 const s = if (endian == .Little) s_ else Fe.orderSwap(s_);
413412 if (p.is_base) {
414413 return pcMul16(&basePointPc, s, true);
......@@ -420,7 +419,7 @@ pub const P256 = struct {
420419
421420 /// Double-base multiplication of public parameters - Compute (p1*s1)+(p2*s2) *IN VARIABLE TIME*
422421 /// This can be used for signature verification.
423 pub fn mulDoubleBasePublic(p1: P256, s1_: [32]u8, p2: P256, s2_: [32]u8, endian: builtin.Endian) IdentityElementError!P256 {
422 pub fn mulDoubleBasePublic(p1: P256, s1_: [32]u8, p2: P256, s2_: [32]u8, endian: std.builtin.Endian) IdentityElementError!P256 {
424423 const s1 = if (endian == .Little) s1_ else Fe.orderSwap(s1_);
425424 const s2 = if (endian == .Little) s2_ else Fe.orderSwap(s2_);
426425 try p1.rejectIdentity();
lib/std/crypto/pcurves/p256/p256_64.zig+1-1
......@@ -18,7 +18,7 @@
1818// if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256
1919
2020const std = @import("std");
21const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels
21const mode = @import("builtin").mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels
2222
2323// The type MontgomeryDomainFieldElement is a field element in the Montgomery domain.
2424// Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
lib/std/crypto/pcurves/p256/p256_scalar_64.zig+1-1
......@@ -18,7 +18,7 @@
1818// if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256
1919
2020const std = @import("std");
21const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels
21const mode = @import("builtin").mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels
2222
2323// The type MontgomeryDomainFieldElement is a field element in the Montgomery domain.
2424// Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
lib/std/crypto/pcurves/p256/scalar.zig+14-15
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = std.builtin;
32const common = @import("../common.zig");
43const crypto = std.crypto;
54const debug = std.debug;
......@@ -26,47 +25,47 @@ const Fe = Field(.{
2625});
2726
2827/// Reject a scalar whose encoding is not canonical.
29pub fn rejectNonCanonical(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!void {
28pub fn rejectNonCanonical(s: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!void {
3029 return Fe.rejectNonCanonical(s, endian);
3130}
3231
3332/// Reduce a 48-bytes scalar to the field size.
34pub fn reduce48(s: [48]u8, endian: builtin.Endian) CompressedScalar {
33pub fn reduce48(s: [48]u8, endian: std.builtin.Endian) CompressedScalar {
3534 return Scalar.fromBytes48(s, endian).toBytes(endian);
3635}
3736
3837/// Reduce a 64-bytes scalar to the field size.
39pub fn reduce64(s: [64]u8, endian: builtin.Endian) CompressedScalar {
38pub fn reduce64(s: [64]u8, endian: std.builtin.Endian) CompressedScalar {
4039 return ScalarDouble.fromBytes64(s, endian).toBytes(endian);
4140}
4241
4342/// Return a*b (mod L)
44pub fn mul(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {
43pub fn mul(a: CompressedScalar, b: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar {
4544 return (try Scalar.fromBytes(a, endian)).mul(try Scalar.fromBytes(b, endian)).toBytes(endian);
4645}
4746
4847/// Return a*b+c (mod L)
49pub fn mulAdd(a: CompressedScalar, b: CompressedScalar, c: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {
48pub fn mulAdd(a: CompressedScalar, b: CompressedScalar, c: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar {
5049 return (try Scalar.fromBytes(a, endian)).mul(try Scalar.fromBytes(b, endian)).add(try Scalar.fromBytes(c, endian)).toBytes(endian);
5150}
5251
5352/// Return a+b (mod L)
54pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {
53pub fn add(a: CompressedScalar, b: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar {
5554 return (try Scalar.fromBytes(a, endian)).add(try Scalar.fromBytes(b, endian)).toBytes(endian);
5655}
5756
5857/// Return -s (mod L)
59pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {
58pub fn neg(s: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar {
6059 return (try Scalar.fromBytes(s, endian)).neg().toBytes(endian);
6160}
6261
6362/// Return (a-b) (mod L)
64pub fn sub(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {
63pub fn sub(a: CompressedScalar, b: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar {
6564 return (try Scalar.fromBytes(a, endian)).sub(try Scalar.fromBytes(b.endian)).toBytes(endian);
6665}
6766
6867/// Return a random scalar
69pub fn random(endian: builtin.Endian) CompressedScalar {
68pub fn random(endian: std.builtin.Endian) CompressedScalar {
7069 return Scalar.random().toBytes(endian);
7170}
7271
......@@ -81,24 +80,24 @@ pub const Scalar = struct {
8180 pub const one = Scalar{ .fe = Fe.one };
8281
8382 /// Unpack a serialized representation of a scalar.
84 pub fn fromBytes(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!Scalar {
83 pub fn fromBytes(s: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!Scalar {
8584 return Scalar{ .fe = try Fe.fromBytes(s, endian) };
8685 }
8786
8887 /// Reduce a 384 bit input to the field size.
89 pub fn fromBytes48(s: [48]u8, endian: builtin.Endian) Scalar {
88 pub fn fromBytes48(s: [48]u8, endian: std.builtin.Endian) Scalar {
9089 const t = ScalarDouble.fromBytes(384, s, endian);
9190 return t.reduce(384);
9291 }
9392
9493 /// Reduce a 512 bit input to the field size.
95 pub fn fromBytes64(s: [64]u8, endian: builtin.Endian) Scalar {
94 pub fn fromBytes64(s: [64]u8, endian: std.builtin.Endian) Scalar {
9695 const t = ScalarDouble.fromBytes(512, s, endian);
9796 return t.reduce(512);
9897 }
9998
10099 /// Pack a scalar into bytes.
101 pub fn toBytes(n: Scalar, endian: builtin.Endian) CompressedScalar {
100 pub fn toBytes(n: Scalar, endian: std.builtin.Endian) CompressedScalar {
102101 return n.fe.toBytes(endian);
103102 }
104103
......@@ -180,7 +179,7 @@ const ScalarDouble = struct {
180179 x2: Fe,
181180 x3: Fe,
182181
183 fn fromBytes(comptime bits: usize, s_: [bits / 8]u8, endian: builtin.Endian) ScalarDouble {
182 fn fromBytes(comptime bits: usize, s_: [bits / 8]u8, endian: std.builtin.Endian) ScalarDouble {
184183 debug.assert(bits > 0 and bits <= 512 and bits >= Fe.saturated_bits and bits <= Fe.saturated_bits * 3);
185184
186185 var s = s_;
lib/std/crypto/salsa20.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const crypto = std.crypto;
34const debug = std.debug;
45const math = std.math;
......@@ -304,7 +305,7 @@ const Salsa20NonVecImpl = struct {
304305 }
305306};
306307
307const Salsa20Impl = if (std.Target.current.cpu.arch == .x86_64) Salsa20VecImpl else Salsa20NonVecImpl;
308const Salsa20Impl = if (builtin.cpu.arch == .x86_64) Salsa20VecImpl else Salsa20NonVecImpl;
308309
309310fn keyToWords(key: [32]u8) [8]u32 {
310311 var k: [8]u32 = undefined;
lib/std/crypto/tlcsprng.zig+5-4
......@@ -4,6 +4,7 @@
44//! directly to standard library users.
55
66const std = @import("std");
7const builtin = @import("builtin");
78const root = @import("root");
89const mem = std.mem;
910const os = std.os;
......@@ -12,7 +13,7 @@ const os = std.os;
1213/// point to thread-local variables.
1314pub var interface = std.rand.Random{ .fillFn = tlsCsprngFill };
1415
15const os_has_fork = switch (std.Target.current.os.tag) {
16const os_has_fork = switch (builtin.os.tag) {
1617 .dragonfly,
1718 .freebsd,
1819 .ios,
......@@ -29,10 +30,10 @@ const os_has_fork = switch (std.Target.current.os.tag) {
2930
3031 else => false,
3132};
32const os_has_arc4random = std.builtin.link_libc and @hasDecl(std.c, "arc4random_buf");
33const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf");
3334const want_fork_safety = os_has_fork and !os_has_arc4random and
3435 (std.meta.globalOption("crypto_fork_safety", bool) orelse true);
35const maybe_have_wipe_on_fork = std.Target.current.os.isAtLeast(.linux, .{
36const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{
3637 .major = 4,
3738 .minor = 14,
3839}) orelse true;
......@@ -55,7 +56,7 @@ var install_atfork_handler = std.once(struct {
5556threadlocal var wipe_mem: []align(mem.page_size) u8 = &[_]u8{};
5657
5758fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
58 if (std.builtin.link_libc and @hasDecl(std.c, "arc4random_buf")) {
59 if (builtin.link_libc and @hasDecl(std.c, "arc4random_buf")) {
5960 // arc4random is already a thread-local CSPRNG.
6061 return std.c.arc4random_buf(buffer.ptr, buffer.len);
6162 }
lib/std/cstr.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const debug = std.debug;
44const mem = std.mem;
55const testing = std.testing;
lib/std/debug.zig+11-11
......@@ -1,5 +1,5 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const math = std.math;
44const mem = std.mem;
55const io = std.io;
......@@ -16,8 +16,8 @@ const root = @import("root");
1616const maxInt = std.math.maxInt;
1717const File = std.fs.File;
1818const windows = std.os.windows;
19const native_arch = std.Target.current.cpu.arch;
20const native_os = std.Target.current.os.tag;
19const native_arch = builtin.cpu.arch;
20const native_os = builtin.os.tag;
2121const native_endian = native_arch.endian();
2222
2323pub const runtime_safety = switch (builtin.mode) {
......@@ -150,7 +150,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void {
150150/// capture that many stack frames exactly, and then look for the first address,
151151/// chopping off the irrelevant frames and shifting so that the returned addresses pointer
152152/// equals the passed in addresses pointer.
153pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace) void {
153pub fn captureStackTrace(first_address: ?usize, stack_trace: *std.builtin.StackTrace) void {
154154 if (native_os == .windows) {
155155 const addrs = stack_trace.instruction_addresses;
156156 const u32_addrs_len = @intCast(u32, addrs.len);
......@@ -194,7 +194,7 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace
194194
195195/// Tries to print a stack trace to stderr, unbuffered, and ignores any error returned.
196196/// TODO multithreaded awareness
197pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void {
197pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void {
198198 nosuspend {
199199 const stderr = io.getStdErr().writer();
200200 if (builtin.strip_debug_info) {
......@@ -235,7 +235,7 @@ pub fn panic(comptime format: []const u8, args: anytype) noreturn {
235235/// `panicExtra` is useful when you want to print out an `@errorReturnTrace`
236236/// and also print out some values.
237237pub fn panicExtra(
238 trace: ?*builtin.StackTrace,
238 trace: ?*std.builtin.StackTrace,
239239 comptime format: []const u8,
240240 args: anytype,
241241) noreturn {
......@@ -253,7 +253,7 @@ pub fn panicExtra(
253253 break :blk &buf;
254254 },
255255 };
256 builtin.panic(msg, trace);
256 std.builtin.panic(msg, trace);
257257}
258258
259259/// Non-zero whenever the program triggered a panic.
......@@ -269,7 +269,7 @@ threadlocal var panic_stage: usize = 0;
269269
270270// `panicImpl` could be useful in implementing a custom panic handler which
271271// calls the default handler (on supported platforms)
272pub fn panicImpl(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn {
272pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn {
273273 @setCold(true);
274274
275275 if (enable_segfault_handler) {
......@@ -339,7 +339,7 @@ const DIM = "\x1b[2m";
339339const RESET = "\x1b[0m";
340340
341341pub fn writeStackTrace(
342 stack_trace: builtin.StackTrace,
342 stack_trace: std.builtin.StackTrace,
343343 out_stream: anytype,
344344 allocator: *mem.Allocator,
345345 debug_info: *DebugInfo,
......@@ -764,7 +764,7 @@ pub fn readElfDebugInfo(allocator: *mem.Allocator, elf_file: File) !ModuleDebugI
764764 if (!mem.eql(u8, hdr.e_ident[0..4], "\x7fELF")) return error.InvalidElfMagic;
765765 if (hdr.e_ident[elf.EI_VERSION] != 1) return error.InvalidElfVersion;
766766
767 const endian: builtin.Endian = switch (hdr.e_ident[elf.EI_DATA]) {
767 const endian: std.builtin.Endian = switch (hdr.e_ident[elf.EI_DATA]) {
768768 elf.ELFDATA2LSB => .Little,
769769 elf.ELFDATA2MSB => .Big,
770770 else => return error.InvalidElfEndian,
......@@ -1002,7 +1002,7 @@ pub const DebugInfo = struct {
10021002 }
10031003
10041004 pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
1005 if (comptime std.Target.current.isDarwin()) {
1005 if (comptime builtin.target.isDarwin()) {
10061006 return self.lookupModuleDyld(address);
10071007 } else if (native_os == .windows) {
10081008 return self.lookupModuleWin32(address);
lib/std/dwarf.zig+7-8
......@@ -1,5 +1,4 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
32const debug = std.debug;
43const fs = std.fs;
54const io = std.io;
......@@ -454,7 +453,7 @@ const LineNumberProgram = struct {
454453 }
455454};
456455
457fn readUnitLength(in_stream: anytype, endian: builtin.Endian, is_64: *bool) !u64 {
456fn readUnitLength(in_stream: anytype, endian: std.builtin.Endian, is_64: *bool) !u64 {
458457 const first_32_bits = try in_stream.readInt(u32, endian);
459458 is_64.* = (first_32_bits == 0xffffffff);
460459 if (is_64.*) {
......@@ -475,7 +474,7 @@ fn readAllocBytes(allocator: *mem.Allocator, in_stream: anytype, size: usize) ![
475474}
476475
477476// TODO the nosuspends here are workarounds
478fn readAddress(in_stream: anytype, endian: builtin.Endian, is_64: bool) !u64 {
477fn readAddress(in_stream: anytype, endian: std.builtin.Endian, is_64: bool) !u64 {
479478 return nosuspend if (is_64)
480479 try in_stream.readInt(u64, endian)
481480 else
......@@ -488,12 +487,12 @@ fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: anytype, size: u
488487}
489488
490489// TODO the nosuspends here are workarounds
491fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: usize) !FormValue {
490fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: std.builtin.Endian, size: usize) !FormValue {
492491 const block_len = try nosuspend in_stream.readVarInt(usize, endian, size);
493492 return parseFormValueBlockLen(allocator, in_stream, block_len);
494493}
495494
496fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue {
495fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: std.builtin.Endian, comptime size: i32) !FormValue {
497496 _ = allocator;
498497 // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here.
499498 // `nosuspend` should be removed from all the function calls once it is fixed.
......@@ -521,7 +520,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed:
521520}
522521
523522// TODO the nosuspends here are workarounds
524fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue {
523fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: std.builtin.Endian, size: i32) !FormValue {
525524 _ = allocator;
526525 return FormValue{
527526 .Ref = switch (size) {
......@@ -536,7 +535,7 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: buil
536535}
537536
538537// TODO the nosuspends here are workarounds
539fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue {
538fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: std.builtin.Endian, is_64: bool) anyerror!FormValue {
540539 return switch (form_id) {
541540 FORM.addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
542541 FORM.block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
......@@ -593,7 +592,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con
593592}
594593
595594pub const DwarfInfo = struct {
596 endian: builtin.Endian,
595 endian: std.builtin.Endian,
597596 // No memory is owned by the DwarfInfo
598597 debug_info: []const u8,
599598 debug_abbrev: []const u8,
lib/std/dynamic_library.zig+1-2
......@@ -1,6 +1,5 @@
1const builtin = std.builtin;
2
31const std = @import("std.zig");
2const builtin = @import("builtin");
43const mem = std.mem;
54const os = std.os;
65const assert = std.debug.assert;
lib/std/event/channel.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const assert = std.debug.assert;
44const testing = std.testing;
55const Loop = std.event.Loop;
lib/std/event/future.zig+1-1
......@@ -1,7 +1,7 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const assert = std.debug.assert;
34const testing = std.testing;
4const builtin = std.builtin;
55const Lock = std.event.Lock;
66
77/// This is a value that starts out unavailable, until resolve() is called
lib/std/event/group.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const Lock = std.event.Lock;
44const testing = std.testing;
55const Allocator = std.mem.Allocator;
lib/std/event/lock.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const assert = std.debug.assert;
44const testing = std.testing;
55const mem = std.mem;
lib/std/event/loop.zig+4-4
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const root = @import("root");
44const assert = std.debug.assert;
55const testing = std.testing;
......@@ -9,7 +9,7 @@ const windows = os.windows;
99const maxInt = std.math.maxInt;
1010const Thread = std.Thread;
1111
12const is_windows = std.Target.current.os.tag == .windows;
12const is_windows = builtin.os.tag == .windows;
1313
1414pub const Loop = struct {
1515 next_tick_queue: std.atomic.Queue(anyframe),
......@@ -191,7 +191,7 @@ pub const Loop = struct {
191191 self.fs_thread.join();
192192 };
193193
194 if (!std.builtin.single_threaded)
194 if (!builtin.single_threaded)
195195 try self.delay_queue.init();
196196 }
197197
......@@ -825,7 +825,7 @@ pub const Loop = struct {
825825 }
826826
827827 pub fn sleep(self: *Loop, nanoseconds: u64) void {
828 if (std.builtin.single_threaded)
828 if (builtin.single_threaded)
829829 @compileError("TODO: integrate timers with epoll/kevent/iocp for single-threaded");
830830
831831 suspend {
lib/std/event/rwlock.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const assert = std.debug.assert;
44const testing = std.testing;
55const mem = std.mem;
lib/std/event/wait_group.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const Loop = std.event.Loop;
44
55/// A WaitGroup keeps track and waits for a group of async tasks to finish.
lib/std/fs.zig+5-5
......@@ -1,6 +1,6 @@
1const root = @import("root");
2const builtin = std.builtin;
31const std = @import("std.zig");
2const builtin = @import("builtin");
3const root = @import("root");
44const os = std.os;
55const mem = std.mem;
66const base64 = std.base64;
......@@ -9,7 +9,7 @@ const Allocator = std.mem.Allocator;
99const assert = std.debug.assert;
1010const math = std.math;
1111
12const is_darwin = std.Target.current.os.tag.isDarwin();
12const is_darwin = builtin.os.tag.isDarwin();
1313
1414pub const path = @import("fs/path.zig");
1515pub const File = @import("fs/file.zig").File;
......@@ -2607,7 +2607,7 @@ const CopyFileError = error{SystemResources} || os.CopyFileRangeError || os.Send
26072607// The copy starts at offset 0, the initial offsets are preserved.
26082608// No metadata is transferred over.
26092609fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void {
2610 if (comptime std.Target.current.isDarwin()) {
2610 if (comptime builtin.target.isDarwin()) {
26112611 const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA);
26122612 switch (os.errno(rc)) {
26132613 .SUCCESS => return,
......@@ -2620,7 +2620,7 @@ fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void {
26202620 }
26212621 }
26222622
2623 if (std.Target.current.os.tag == .linux) {
2623 if (builtin.os.tag == .linux) {
26242624 // Try copy_file_range first as that works at the FS level and is the
26252625 // most efficient method (if available).
26262626 var offset: u64 = 0;
lib/std/fs/file.zig+3-3
......@@ -1,14 +1,14 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const os = std.os;
44const io = std.io;
55const mem = std.mem;
66const math = std.math;
77const assert = std.debug.assert;
88const windows = os.windows;
9const Os = builtin.Os;
9const Os = std.builtin.Os;
1010const maxInt = std.math.maxInt;
11const is_windows = std.Target.current.os.tag == .windows;
11const is_windows = builtin.os.tag == .windows;
1212
1313pub const File = struct {
1414 /// The OS-specific file descriptor or file handle.
lib/std/fs/get_app_data_dir.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const unicode = std.unicode;
44const mem = std.mem;
55const fs = std.fs;
lib/std/fs/test.zig+1-1
......@@ -1,6 +1,6 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const testing = std.testing;
3const builtin = std.builtin;
44const fs = std.fs;
55const mem = std.mem;
66const wasi = std.os.wasi;
lib/std/fs/wasi.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const os = std.os;
34const mem = std.mem;
45const math = std.math;
......@@ -165,7 +166,7 @@ pub const PreopenList = struct {
165166};
166167
167168test "extracting WASI preopens" {
168 if (std.builtin.os.tag != .wasi or std.builtin.link_libc) return error.SkipZigTest;
169 if (builtin.os.tag != .wasi or builtin.link_libc) return error.SkipZigTest;
169170
170171 var preopens = PreopenList.init(std.testing.allocator);
171172 defer preopens.deinit();
lib/std/fs/watch.zig+2-2
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const event = std.event;
44const assert = std.debug.assert;
55const testing = std.testing;
......@@ -250,7 +250,7 @@ pub fn Watch(comptime V: type) type {
250250 };
251251
252252 // @TODO Can I close this fd and get an error from bsdWaitKev?
253 const flags = if (comptime std.Target.current.isDarwin()) os.O.SYMLINK | os.O.EVTONLY else 0;
253 const flags = if (comptime builtin.target.isDarwin()) os.O.SYMLINK | os.O.EVTONLY else 0;
254254 const fd = try os.open(realpath, flags, 0);
255255 gop.value_ptr.putter_frame = async self.kqPutEvents(fd, gop.key_ptr.*, gop.value_ptr.*);
256256 return null;
lib/std/hash/auto_hash.zig+1-2
......@@ -2,7 +2,6 @@ const std = @import("std");
22const assert = std.debug.assert;
33const mem = std.mem;
44const meta = std.meta;
5const builtin = std.builtin;
65
76/// Describes how pointer types should be hashed.
87pub const HashStrategy = enum {
......@@ -233,7 +232,7 @@ fn testHashDeepRecursive(key: anytype) u64 {
233232
234233test "typeContainsSlice" {
235234 comptime {
236 try testing.expect(!typeContainsSlice(meta.Tag(builtin.TypeInfo)));
235 try testing.expect(!typeContainsSlice(meta.Tag(std.builtin.TypeInfo)));
237236
238237 try testing.expect(typeContainsSlice([]const u8));
239238 try testing.expect(!typeContainsSlice(u8));
lib/std/hash/benchmark.zig+1-1
......@@ -1,7 +1,7 @@
11// zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig
22
3const builtin = std.builtin;
43const std = @import("std");
4const builtin = @import("builtin");
55const time = std.time;
66const Timer = time.Timer;
77const hash = std.hash;
lib/std/hash/cityhash.zig-1
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = std.builtin;
32
43inline fn offsetPtr(ptr: [*]const u8, offset: usize) [*]const u8 {
54 // ptr + offset doesn't work at comptime so we need this instead.
lib/std/hash/crc.zig+2-1
......@@ -6,6 +6,7 @@
66// still moderately fast just slow relative to the slicing approach.
77
88const std = @import("../std.zig");
9const builtin = @import("builtin");
910const debug = std.debug;
1011const testing = std.testing;
1112
......@@ -97,7 +98,7 @@ pub fn Crc32WithPoly(comptime poly: Polynomial) type {
9798 };
9899}
99100
100const please_windows_dont_oom = std.Target.current.os.tag == .windows;
101const please_windows_dont_oom = builtin.os.tag == .windows;
101102
102103test "crc32 ieee" {
103104 if (please_windows_dont_oom) return error.SkipZigTest;
lib/std/heap.zig+10-10
......@@ -1,11 +1,11 @@
11const std = @import("std.zig");
2const builtin = @import("builtin");
23const root = @import("root");
34const debug = std.debug;
45const assert = debug.assert;
56const testing = std.testing;
67const mem = std.mem;
78const os = std.os;
8const builtin = std.builtin;
99const c = std.c;
1010const maxInt = std.math.maxInt;
1111
......@@ -209,9 +209,9 @@ fn rawCResize(
209209
210210/// This allocator makes a syscall directly for every allocation and free.
211211/// Thread-safe and lock-free.
212pub const page_allocator = if (std.Target.current.isWasm())
212pub const page_allocator = if (builtin.target.isWasm())
213213 &wasm_page_allocator_state
214else if (std.Target.current.os.tag == .freestanding)
214else if (builtin.target.os.tag == .freestanding)
215215 root.os.heap.page_allocator
216216else
217217 &page_allocator_state;
......@@ -402,7 +402,7 @@ const PageAllocator = struct {
402402
403403const WasmPageAllocator = struct {
404404 comptime {
405 if (!std.Target.current.isWasm()) {
405 if (!builtin.target.isWasm()) {
406406 @compileError("WasmPageAllocator is only available for wasm32 arch");
407407 }
408408 }
......@@ -608,11 +608,11 @@ pub const HeapAllocator = switch (builtin.os.tag) {
608608 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);
609609
610610 const amt = n + ptr_align - 1 + @sizeOf(usize);
611 const optional_heap_handle = @atomicLoad(?HeapHandle, &self.heap_handle, builtin.AtomicOrder.SeqCst);
611 const optional_heap_handle = @atomicLoad(?HeapHandle, &self.heap_handle, .SeqCst);
612612 const heap_handle = optional_heap_handle orelse blk: {
613613 const options = if (builtin.single_threaded) os.windows.HEAP_NO_SERIALIZE else 0;
614614 const hh = os.windows.kernel32.HeapCreate(options, amt, 0) orelse return error.OutOfMemory;
615 const other_hh = @cmpxchgStrong(?HeapHandle, &self.heap_handle, null, hh, builtin.AtomicOrder.SeqCst, builtin.AtomicOrder.SeqCst) orelse break :blk hh;
615 const other_hh = @cmpxchgStrong(?HeapHandle, &self.heap_handle, null, hh, .SeqCst, .SeqCst) orelse break :blk hh;
616616 os.windows.HeapDestroy(hh);
617617 break :blk other_hh.?; // can't be null because of the cmpxchg
618618 };
......@@ -792,7 +792,7 @@ pub const ThreadSafeFixedBufferAllocator = blk: {
792792 _ = len_align;
793793 _ = ra;
794794 const self = @fieldParentPtr(ThreadSafeFixedBufferAllocator, "allocator", allocator);
795 var end_index = @atomicLoad(usize, &self.end_index, builtin.AtomicOrder.SeqCst);
795 var end_index = @atomicLoad(usize, &self.end_index, .SeqCst);
796796 while (true) {
797797 const adjust_off = mem.alignPointerOffset(self.buffer.ptr + end_index, ptr_align) orelse
798798 return error.OutOfMemory;
......@@ -801,7 +801,7 @@ pub const ThreadSafeFixedBufferAllocator = blk: {
801801 if (new_end_index > self.buffer.len) {
802802 return error.OutOfMemory;
803803 }
804 end_index = @cmpxchgWeak(usize, &self.end_index, end_index, new_end_index, builtin.AtomicOrder.SeqCst, builtin.AtomicOrder.SeqCst) orelse return self.buffer[adjusted_index..new_end_index];
804 end_index = @cmpxchgWeak(usize, &self.end_index, end_index, new_end_index, .SeqCst, .SeqCst) orelse return self.buffer[adjusted_index..new_end_index];
805805 }
806806 }
807807
......@@ -884,7 +884,7 @@ test "raw_c_allocator" {
884884}
885885
886886test "WasmPageAllocator internals" {
887 if (comptime std.Target.current.isWasm()) {
887 if (comptime builtin.target.isWasm()) {
888888 const conventional_memsize = WasmPageAllocator.conventional.totalPages() * mem.page_size;
889889 const initial = try page_allocator.alloc(u8, mem.page_size);
890890 try testing.expect(@ptrToInt(initial.ptr) < conventional_memsize); // If this isn't conventional, the rest of these tests don't make sense. Also we have a serious memory leak in the test suite.
......@@ -924,7 +924,7 @@ test "PageAllocator" {
924924 const allocator = page_allocator;
925925 try testAllocator(allocator);
926926 try testAllocatorAligned(allocator);
927 if (!std.Target.current.isWasm()) {
927 if (!builtin.target.isWasm()) {
928928 try testAllocatorLargeAlignment(allocator);
929929 try testAllocatorAlignedShrink(allocator);
930930 }
lib/std/heap/general_purpose_allocator.zig+8-7
......@@ -93,6 +93,7 @@
9393//! in a `std.HashMap` using the backing allocator.
9494
9595const std = @import("std");
96const builtin = @import("builtin");
9697const log = std.log.scoped(.gpa);
9798const math = std.math;
9899const assert = std.debug.assert;
......@@ -104,7 +105,7 @@ const StackTrace = std.builtin.StackTrace;
104105/// Integer type for pointing to slots in a small allocation
105106const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1);
106107
107const sys_can_stack_trace = switch (std.Target.current.cpu.arch) {
108const sys_can_stack_trace = switch (builtin.cpu.arch) {
108109 // Observed to go into an infinite loop.
109110 // TODO: Make this work.
110111 .mips,
......@@ -115,13 +116,13 @@ const sys_can_stack_trace = switch (std.Target.current.cpu.arch) {
115116 // "Non-Emscripten WebAssembly hasn't implemented __builtin_return_address".
116117 .wasm32,
117118 .wasm64,
118 => std.Target.current.os.tag == .emscripten,
119 => builtin.os.tag == .emscripten,
119120
120121 else => true,
121122};
122const default_test_stack_trace_frames: usize = if (std.builtin.is_test) 8 else 4;
123const default_test_stack_trace_frames: usize = if (builtin.is_test) 8 else 4;
123124const default_sys_stack_trace_frames: usize = if (sys_can_stack_trace) default_test_stack_trace_frames else 0;
124const default_stack_trace_frames: usize = switch (std.builtin.mode) {
125const default_stack_trace_frames: usize = switch (builtin.mode) {
125126 .Debug => default_sys_stack_trace_frames,
126127 else => 0,
127128};
......@@ -141,7 +142,7 @@ pub const Config = struct {
141142 safety: bool = std.debug.runtime_safety,
142143
143144 /// Whether the allocator may be used simultaneously from multiple threads.
144 thread_safe: bool = !std.builtin.single_threaded,
145 thread_safe: bool = !builtin.single_threaded,
145146
146147 /// What type of mutex you'd like to use, for thread safety.
147148 /// when specfied, the mutex type must have the same shape as `std.Thread.Mutex` and
......@@ -988,7 +989,7 @@ test "shrink large object to large object with larger alignment" {
988989 var slice = try allocator.alignedAlloc(u8, 16, alloc_size);
989990 defer allocator.free(slice);
990991
991 const big_alignment: usize = switch (std.Target.current.os.tag) {
992 const big_alignment: usize = switch (builtin.os.tag) {
992993 .windows => page_size * 32, // Windows aligns to 64K.
993994 else => page_size * 2,
994995 };
......@@ -1058,7 +1059,7 @@ test "realloc large object to larger alignment" {
10581059 var slice = try allocator.alignedAlloc(u8, 16, page_size * 2 + 50);
10591060 defer allocator.free(slice);
10601061
1061 const big_alignment: usize = switch (std.Target.current.os.tag) {
1062 const big_alignment: usize = switch (builtin.os.tag) {
10621063 .windows => page_size * 32, // Windows aligns to 64K.
10631064 else => page_size * 2,
10641065 };
lib/std/io.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const root = @import("root");
44const c = std.c;
55
lib/std/io/bit_reader.zig+2-3
......@@ -1,5 +1,4 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
32const io = std.io;
43const assert = std.debug.assert;
54const testing = std.testing;
......@@ -8,7 +7,7 @@ const meta = std.meta;
87const math = std.math;
98
109/// Creates a stream which allows for reading bit fields from another stream
11pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
10pub fn BitReader(endian: std.builtin.Endian, comptime ReaderType: type) type {
1211 return struct {
1312 forward_reader: ReaderType,
1413 bit_buffer: u7,
......@@ -162,7 +161,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
162161}
163162
164163pub fn bitReader(
165 comptime endian: builtin.Endian,
164 comptime endian: std.builtin.Endian,
166165 underlying_stream: anytype,
167166) BitReader(endian, @TypeOf(underlying_stream)) {
168167 return BitReader(endian, @TypeOf(underlying_stream)).init(underlying_stream);
lib/std/io/bit_writer.zig+2-3
......@@ -1,5 +1,4 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
32const io = std.io;
43const testing = std.testing;
54const assert = std.debug.assert;
......@@ -8,7 +7,7 @@ const meta = std.meta;
87const math = std.math;
98
109/// Creates a stream which allows for writing bit fields to another stream
11pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
10pub fn BitWriter(endian: std.builtin.Endian, comptime WriterType: type) type {
1211 return struct {
1312 forward_writer: WriterType,
1413 bit_buffer: u8,
......@@ -138,7 +137,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
138137}
139138
140139pub fn bitWriter(
141 comptime endian: builtin.Endian,
140 comptime endian: std.builtin.Endian,
142141 underlying_stream: anytype,
143142) BitWriter(endian, @TypeOf(underlying_stream)) {
144143 return BitWriter(endian, @TypeOf(underlying_stream)).init(underlying_stream);
lib/std/io/c_writer.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const io = std.io;
44const testing = std.testing;
55const os = std.os;
lib/std/io/reader.zig+4-5
......@@ -1,5 +1,4 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
32const math = std.math;
43const assert = std.debug.assert;
54const mem = std.mem;
......@@ -265,12 +264,12 @@ pub fn Reader(
265264 return mem.readIntBig(T, &bytes);
266265 }
267266
268 pub fn readInt(self: Self, comptime T: type, endian: builtin.Endian) !T {
267 pub fn readInt(self: Self, comptime T: type, endian: std.builtin.Endian) !T {
269268 const bytes = try self.readBytesNoEof((@typeInfo(T).Int.bits + 7) / 8);
270269 return mem.readInt(T, &bytes, endian);
271270 }
272271
273 pub fn readVarInt(self: Self, comptime ReturnType: type, endian: builtin.Endian, size: usize) !ReturnType {
272 pub fn readVarInt(self: Self, comptime ReturnType: type, endian: std.builtin.Endian, size: usize) !ReturnType {
274273 assert(size <= @sizeOf(ReturnType));
275274 var bytes_buf: [@sizeOf(ReturnType)]u8 = undefined;
276275 const bytes = bytes_buf[0..size];
......@@ -310,7 +309,7 @@ pub fn Reader(
310309
311310 pub fn readStruct(self: Self, comptime T: type) !T {
312311 // Only extern and packed structs have defined in-memory layout.
313 comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
312 comptime assert(@typeInfo(T).Struct.layout != std.builtin.TypeInfo.ContainerLayout.Auto);
314313 var res: [1]T = undefined;
315314 try self.readNoEof(mem.sliceAsBytes(res[0..]));
316315 return res[0];
......@@ -319,7 +318,7 @@ pub fn Reader(
319318 /// Reads an integer with the same size as the given enum's tag type. If the integer matches
320319 /// an enum tag, casts the integer to the enum tag and returns it. Otherwise, returns an error.
321320 /// TODO optimization taking advantage of most fields being in order
322 pub fn readEnum(self: Self, comptime Enum: type, endian: builtin.Endian) !Enum {
321 pub fn readEnum(self: Self, comptime Enum: type, endian: std.builtin.Endian) !Enum {
323322 const E = error{
324323 /// An integer was read, but it did not match any of the tags in the supplied enum.
325324 InvalidValue,
lib/std/io/stream_source.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const io = std.io;
34
45/// Provides `io.Reader`, `io.Writer`, and `io.SeekableStream` for in-memory buffers as
......@@ -6,7 +7,7 @@ const io = std.io;
67/// For memory sources, if the supplied byte buffer is const, then `io.Writer` is not available.
78/// The error set of the stream functions is the error set of the corresponding file functions.
89pub const StreamSource = union(enum) {
9 const has_file = (std.builtin.os.tag != .freestanding);
10 const has_file = (builtin.os.tag != .freestanding);
1011
1112 /// The stream access is redirected to this buffer.
1213 buffer: io.FixedBufferStream([]u8),
lib/std/io/writer.zig+2-3
......@@ -1,6 +1,5 @@
11const std = @import("../std.zig");
22const assert = std.debug.assert;
3const builtin = std.builtin;
43const mem = std.mem;
54
65pub fn Writer(
......@@ -77,7 +76,7 @@ pub fn Writer(
7776 }
7877
7978 /// TODO audit non-power-of-two int sizes
80 pub fn writeInt(self: Self, comptime T: type, value: T, endian: builtin.Endian) Error!void {
79 pub fn writeInt(self: Self, comptime T: type, value: T, endian: std.builtin.Endian) Error!void {
8180 var bytes: [(@typeInfo(T).Int.bits + 7) / 8]u8 = undefined;
8281 mem.writeInt(T, &bytes, value, endian);
8382 return self.writeAll(&bytes);
......@@ -85,7 +84,7 @@ pub fn Writer(
8584
8685 pub fn writeStruct(self: Self, value: anytype) Error!void {
8786 // Only extern and packed structs have defined in-memory layout.
88 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
87 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != std.builtin.TypeInfo.ContainerLayout.Auto);
8988 return self.writeAll(mem.asBytes(&value));
9089 }
9190 };
lib/std/log.zig+2-2
......@@ -69,7 +69,7 @@
6969//! ```
7070
7171const std = @import("std.zig");
72const builtin = std.builtin;
72const builtin = @import("builtin");
7373const root = @import("root");
7474
7575pub const Level = enum {
......@@ -170,7 +170,7 @@ pub fn defaultLog(
170170 comptime format: []const u8,
171171 args: anytype,
172172) void {
173 if (std.Target.current.os.tag == .freestanding) {
173 if (builtin.os.tag == .freestanding) {
174174 // On freestanding one must provide a log function; we do not have
175175 // any I/O configured.
176176 return;
lib/std/mem.zig+4-3
......@@ -1,4 +1,5 @@
11const std = @import("std.zig");
2const builtin = @import("builtin");
23const debug = std.debug;
34const assert = debug.assert;
45const math = std.math;
......@@ -7,13 +8,13 @@ const meta = std.meta;
78const trait = meta.trait;
89const testing = std.testing;
910const Endian = std.builtin.Endian;
10const native_endian = std.Target.current.cpu.arch.endian();
11const native_endian = builtin.cpu.arch.endian();
1112
1213/// Compile time known minimum page size.
1314/// https://github.com/ziglang/zig/issues/4082
14pub const page_size = switch (std.Target.current.cpu.arch) {
15pub const page_size = switch (builtin.cpu.arch) {
1516 .wasm32, .wasm64 => 64 * 1024,
16 .aarch64 => switch (std.Target.current.os.tag) {
17 .aarch64 => switch (builtin.os.tag) {
1718 .macos, .ios, .watchos, .tvos => 16 * 1024,
1819 else => 4 * 1024,
1920 },
lib/std/meta.zig+2-3
......@@ -1,5 +1,4 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
32const debug = std.debug;
43const mem = std.mem;
54const math = std.math;
......@@ -9,7 +8,7 @@ const root = @import("root");
98pub const trait = @import("meta/trait.zig");
109pub const TrailerFlags = @import("meta/trailer_flags.zig").TrailerFlags;
1110
12const TypeInfo = builtin.TypeInfo;
11const TypeInfo = std.builtin.TypeInfo;
1312
1413pub fn tagName(v: anytype) []const u8 {
1514 const T = @TypeOf(v);
......@@ -858,7 +857,7 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
858857
859858pub const IntType = @compileError("replaced by std.meta.Int");
860859
861pub fn Int(comptime signedness: builtin.Signedness, comptime bit_count: u16) type {
860pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type {
862861 return @Type(TypeInfo{
863862 .Int = .{
864863 .signedness = signedness,
lib/std/meta/trait.zig+3-4
......@@ -1,5 +1,4 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
32const mem = std.mem;
43const debug = std.debug;
54const testing = std.testing;
......@@ -98,7 +97,7 @@ test "std.meta.trait.hasField" {
9897 try testing.expect(!hasField("value")(u8));
9998}
10099
101pub fn is(comptime id: builtin.TypeId) TraitFn {
100pub fn is(comptime id: std.builtin.TypeId) TraitFn {
102101 const Closure = struct {
103102 pub fn trait(comptime T: type) bool {
104103 return id == @typeInfo(T);
......@@ -115,7 +114,7 @@ test "std.meta.trait.is" {
115114 try testing.expect(!is(.Optional)(anyerror));
116115}
117116
118pub fn isPtrTo(comptime id: builtin.TypeId) TraitFn {
117pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn {
119118 const Closure = struct {
120119 pub fn trait(comptime T: type) bool {
121120 if (!comptime isSingleItemPtr(T)) return false;
......@@ -131,7 +130,7 @@ test "std.meta.trait.isPtrTo" {
131130 try testing.expect(!isPtrTo(.Struct)(**struct {}));
132131}
133132
134pub fn isSliceOf(comptime id: builtin.TypeId) TraitFn {
133pub fn isSliceOf(comptime id: std.builtin.TypeId) TraitFn {
135134 const Closure = struct {
136135 pub fn trait(comptime T: type) bool {
137136 if (!comptime isSlice(T)) return false;
lib/std/net.zig+3-3
......@@ -12,7 +12,7 @@ const native_endian = builtin.target.cpu.arch.endian();
1212// first release to support them.
1313pub const has_unix_sockets = @hasDecl(os.sockaddr, "un") and
1414 (builtin.target.os.tag != .windows or
15 std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false);
15 builtin.os.version_range.windows.isAtLeast(.win10_rs4) orelse false);
1616
1717pub const Address = extern union {
1818 any: os.sockaddr,
......@@ -1623,7 +1623,7 @@ pub const Stream = struct {
16231623 }
16241624
16251625 pub fn read(self: Stream, buffer: []u8) ReadError!usize {
1626 if (std.Target.current.os.tag == .windows) {
1626 if (builtin.os.tag == .windows) {
16271627 return os.windows.ReadFile(self.handle, buffer, null, io.default_mode);
16281628 }
16291629
......@@ -1638,7 +1638,7 @@ pub const Stream = struct {
16381638 /// file system thread instead of non-blocking. It needs to be reworked to properly
16391639 /// use non-blocking I/O.
16401640 pub fn write(self: Stream, buffer: []const u8) WriteError!usize {
1641 if (std.Target.current.os.tag == .windows) {
1641 if (builtin.os.tag == .windows) {
16421642 return os.windows.WriteFile(self.handle, buffer, null, io.default_mode);
16431643 }
16441644
lib/std/net/test.zig+12-12
......@@ -1,5 +1,5 @@
11const std = @import("../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const net = std.net;
44const mem = std.mem;
55const testing = std.testing;
......@@ -35,7 +35,7 @@ test "parse and render IPv6 addresses" {
3535 var newIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable;
3636 try std.testing.expect(std.mem.eql(u8, printed[i], newIp[1 .. newIp.len - 3]));
3737
38 if (std.builtin.os.tag == .linux) {
38 if (builtin.os.tag == .linux) {
3939 var addr_via_resolve = net.Address.resolveIp6(ip, 0) catch unreachable;
4040 var newResolvedIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr_via_resolve}) catch unreachable;
4141 try std.testing.expect(std.mem.eql(u8, printed[i], newResolvedIp[1 .. newResolvedIp.len - 3]));
......@@ -49,7 +49,7 @@ test "parse and render IPv6 addresses" {
4949 try testing.expectError(error.Incomplete, net.Address.parseIp6("FF01:", 0));
5050 try testing.expectError(error.InvalidIpv4Mapping, net.Address.parseIp6("::123.123.123.123", 0));
5151 // TODO Make this test pass on other operating systems.
52 if (std.builtin.os.tag == .linux) {
52 if (builtin.os.tag == .linux) {
5353 try testing.expectError(error.Incomplete, net.Address.resolveIp6("ff01::fb%", 0));
5454 try testing.expectError(error.Overflow, net.Address.resolveIp6("ff01::fb%wlp3s0s0s0s0s0s0s0s0", 0));
5555 try testing.expectError(error.Overflow, net.Address.resolveIp6("ff01::fb%12345678901234", 0));
......@@ -57,7 +57,7 @@ test "parse and render IPv6 addresses" {
5757}
5858
5959test "invalid but parseable IPv6 scope ids" {
60 if (std.builtin.os.tag != .linux) {
60 if (builtin.os.tag != .linux) {
6161 // Currently, resolveIp6 with alphanumerical scope IDs only works on Linux.
6262 // TODO Make this test pass on other operating systems.
6363 return error.SkipZigTest;
......@@ -106,11 +106,11 @@ test "parse and render UNIX addresses" {
106106test "resolve DNS" {
107107 if (builtin.os.tag == .wasi) return error.SkipZigTest;
108108
109 if (std.builtin.os.tag == .windows) {
109 if (builtin.os.tag == .windows) {
110110 _ = try std.os.windows.WSAStartup(2, 2);
111111 }
112112 defer {
113 if (std.builtin.os.tag == .windows) {
113 if (builtin.os.tag == .windows) {
114114 std.os.windows.WSACleanup() catch unreachable;
115115 }
116116 }
......@@ -143,11 +143,11 @@ test "listen on a port, send bytes, receive bytes" {
143143 if (builtin.single_threaded) return error.SkipZigTest;
144144 if (builtin.os.tag == .wasi) return error.SkipZigTest;
145145
146 if (std.builtin.os.tag == .windows) {
146 if (builtin.os.tag == .windows) {
147147 _ = try std.os.windows.WSAStartup(2, 2);
148148 }
149149 defer {
150 if (std.builtin.os.tag == .windows) {
150 if (builtin.os.tag == .windows) {
151151 std.os.windows.WSACleanup() catch unreachable;
152152 }
153153 }
......@@ -185,7 +185,7 @@ test "listen on a port, send bytes, receive bytes" {
185185test "listen on a port, send bytes, receive bytes" {
186186 if (!std.io.is_async) return error.SkipZigTest;
187187
188 if (std.builtin.os.tag != .linux and !std.builtin.os.tag.isDarwin()) {
188 if (builtin.os.tag != .linux and !builtin.os.tag.isDarwin()) {
189189 // TODO build abstractions for other operating systems
190190 return error.SkipZigTest;
191191 }
......@@ -207,7 +207,7 @@ test "listen on a port, send bytes, receive bytes" {
207207test "listen on ipv4 try connect on ipv6 then ipv4" {
208208 if (!std.io.is_async) return error.SkipZigTest;
209209
210 if (std.builtin.os.tag != .linux and !std.builtin.os.tag.isDarwin()) {
210 if (builtin.os.tag != .linux and !builtin.os.tag.isDarwin()) {
211211 // TODO build abstractions for other operating systems
212212 return error.SkipZigTest;
213213 }
......@@ -267,11 +267,11 @@ test "listen on a unix socket, send bytes, receive bytes" {
267267 if (builtin.single_threaded) return error.SkipZigTest;
268268 if (!net.has_unix_sockets) return error.SkipZigTest;
269269
270 if (std.builtin.os.tag == .windows) {
270 if (builtin.os.tag == .windows) {
271271 _ = try std.os.windows.WSAStartup(2, 2);
272272 }
273273 defer {
274 if (std.builtin.os.tag == .windows) {
274 if (builtin.os.tag == .windows) {
275275 std.os.windows.WSACleanup() catch unreachable;
276276 }
277277 }
lib/std/once.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const testing = std.testing;
44
55pub fn once(comptime f: fn () void) Once(f) {
lib/std/os.zig+26-26
......@@ -240,7 +240,7 @@ pub fn close(fd: fd_t) void {
240240 _ = wasi.fd_close(fd);
241241 return;
242242 }
243 if (comptime std.Target.current.isDarwin()) {
243 if (comptime builtin.target.isDarwin()) {
244244 // This avoids the EINTR problem.
245245 switch (darwin.getErrno(darwin.@"close$NOCANCEL"(fd))) {
246246 .BADF => unreachable, // Always a race condition.
......@@ -487,7 +487,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
487487 }
488488
489489 // Prevents EINVAL.
490 const max_count = switch (std.Target.current.os.tag) {
490 const max_count = switch (builtin.os.tag) {
491491 .linux => 0x7ffff000,
492492 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
493493 else => math.maxInt(isize),
......@@ -525,7 +525,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
525525/// * Windows
526526/// On these systems, the read races with concurrent writes to the same file descriptor.
527527pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize {
528 if (std.Target.current.os.tag == .windows) {
528 if (builtin.os.tag == .windows) {
529529 // TODO improve this to use ReadFileScatter
530530 if (iov.len == 0) return @as(usize, 0);
531531 const first = iov[0];
......@@ -616,7 +616,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
616616 }
617617
618618 // Prevent EINVAL.
619 const max_count = switch (std.Target.current.os.tag) {
619 const max_count = switch (builtin.os.tag) {
620620 .linux => 0x7ffff000,
621621 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
622622 else => math.maxInt(isize),
......@@ -662,7 +662,7 @@ pub const TruncateError = error{
662662} || UnexpectedError;
663663
664664pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
665 if (std.Target.current.os.tag == .windows) {
665 if (builtin.os.tag == .windows) {
666666 var io_status_block: windows.IO_STATUS_BLOCK = undefined;
667667 var eof_info = windows.FILE_END_OF_FILE_INFORMATION{
668668 .EndOfFile = @bitCast(windows.LARGE_INTEGER, length),
......@@ -683,7 +683,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
683683 else => return windows.unexpectedStatus(rc),
684684 }
685685 }
686 if (std.Target.current.os.tag == .wasi and !builtin.link_libc) {
686 if (builtin.os.tag == .wasi and !builtin.link_libc) {
687687 switch (wasi.fd_filestat_set_size(fd, length)) {
688688 .SUCCESS => return,
689689 .INTR => unreachable,
......@@ -733,7 +733,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void {
733733/// * Windows
734734/// On these systems, the read races with concurrent writes to the same file descriptor.
735735pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
736 const have_pread_but_not_preadv = switch (std.Target.current.os.tag) {
736 const have_pread_but_not_preadv = switch (builtin.os.tag) {
737737 .windows, .macos, .ios, .watchos, .tvos, .haiku => true,
738738 else => false,
739739 };
......@@ -868,7 +868,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
868868 }
869869 }
870870
871 const max_count = switch (std.Target.current.os.tag) {
871 const max_count = switch (builtin.os.tag) {
872872 .linux => 0x7ffff000,
873873 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
874874 else => math.maxInt(isize),
......@@ -916,7 +916,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
916916///
917917/// If `iov.len` is larger than `IOV_MAX`, a partial write will occur.
918918pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {
919 if (std.Target.current.os.tag == .windows) {
919 if (builtin.os.tag == .windows) {
920920 // TODO improve this to use WriteFileScatter
921921 if (iov.len == 0) return @as(usize, 0);
922922 const first = iov[0];
......@@ -991,7 +991,7 @@ pub const PWriteError = WriteError || error{Unseekable};
991991/// The limit on Darwin is `0x7fffffff`, trying to write more than that returns EINVAL.
992992/// The corresponding POSIX limit is `math.maxInt(isize)`.
993993pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
994 if (std.Target.current.os.tag == .windows) {
994 if (builtin.os.tag == .windows) {
995995 return windows.WriteFile(fd, bytes, offset, std.io.default_mode);
996996 }
997997 if (builtin.os.tag == .wasi and !builtin.link_libc) {
......@@ -1024,7 +1024,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
10241024 }
10251025
10261026 // Prevent EINVAL.
1027 const max_count = switch (std.Target.current.os.tag) {
1027 const max_count = switch (builtin.os.tag) {
10281028 .linux => 0x7ffff000,
10291029 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
10301030 else => math.maxInt(isize),
......@@ -1083,7 +1083,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
10831083///
10841084/// If `iov.len` is larger than `IOV_MAX`, a partial write will occur.
10851085pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usize {
1086 const have_pwrite_but_not_pwritev = switch (std.Target.current.os.tag) {
1086 const have_pwrite_but_not_pwritev = switch (builtin.os.tag) {
10871087 .windows, .macos, .ios, .watchos, .tvos, .haiku => true,
10881088 else => false,
10891089 };
......@@ -1199,7 +1199,7 @@ pub const OpenError = error{
11991199/// Open and possibly create a file. Keeps trying if it gets interrupted.
12001200/// See also `openZ`.
12011201pub fn open(file_path: []const u8, flags: u32, perm: mode_t) OpenError!fd_t {
1202 if (std.Target.current.os.tag == .windows) {
1202 if (builtin.os.tag == .windows) {
12031203 const file_path_w = try windows.sliceToPrefixedFileW(file_path);
12041204 return openW(file_path_w.span(), flags, perm);
12051205 }
......@@ -1212,7 +1212,7 @@ pub const openC = @compileError("deprecated: renamed to openZ");
12121212/// Open and possibly create a file. Keeps trying if it gets interrupted.
12131213/// See also `open`.
12141214pub fn openZ(file_path: [*:0]const u8, flags: u32, perm: mode_t) OpenError!fd_t {
1215 if (std.Target.current.os.tag == .windows) {
1215 if (builtin.os.tag == .windows) {
12161216 const file_path_w = try windows.cStrToPrefixedFileW(file_path);
12171217 return openW(file_path_w.span(), flags, perm);
12181218 }
......@@ -2900,7 +2900,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
29002900 return rc;
29012901 }
29022902
2903 const have_sock_flags = comptime !std.Target.current.isDarwin();
2903 const have_sock_flags = comptime !builtin.target.isDarwin();
29042904 const filtered_sock_type = if (!have_sock_flags)
29052905 socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC)
29062906 else
......@@ -3199,7 +3199,7 @@ pub fn accept(
31993199 /// description of the `O.CLOEXEC` flag in `open` for reasons why this may be useful.
32003200 flags: u32,
32013201) AcceptError!socket_t {
3202 const have_accept4 = comptime !(std.Target.current.isDarwin() or builtin.os.tag == .windows);
3202 const have_accept4 = comptime !(builtin.target.isDarwin() or builtin.os.tag == .windows);
32033203 assert(0 == (flags & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC))); // Unsupported flag(s)
32043204
32053205 const accepted_sock = while (true) {
......@@ -4807,7 +4807,7 @@ pub const ClockGetTimeError = error{UnsupportedClock} || UnexpectedError;
48074807/// TODO: change this to return the timespec as a return value
48084808/// TODO: look into making clk_id an enum
48094809pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void {
4810 if (std.Target.current.os.tag == .wasi and !builtin.link_libc) {
4810 if (builtin.os.tag == .wasi and !builtin.link_libc) {
48114811 var ts: timestamp_t = undefined;
48124812 switch (system.clock_time_get(@bitCast(u32, clk_id), 1, &ts)) {
48134813 .SUCCESS => {
......@@ -4821,7 +4821,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void {
48214821 }
48224822 return;
48234823 }
4824 if (std.Target.current.os.tag == .windows) {
4824 if (builtin.os.tag == .windows) {
48254825 if (clk_id == CLOCK.REALTIME) {
48264826 var ft: windows.FILETIME = undefined;
48274827 windows.kernel32.GetSystemTimeAsFileTime(&ft);
......@@ -4848,7 +4848,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void {
48484848}
48494849
48504850pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void {
4851 if (std.Target.current.os.tag == .wasi and !builtin.link_libc) {
4851 if (builtin.os.tag == .wasi and !builtin.link_libc) {
48524852 var ts: timestamp_t = undefined;
48534853 switch (system.clock_res_get(@bitCast(u32, clk_id), &ts)) {
48544854 .SUCCESS => res.* = .{
......@@ -5416,19 +5416,19 @@ pub fn sendfile(
54165416
54175417 // Prevents EOVERFLOW.
54185418 const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1);
5419 const max_count = switch (std.Target.current.os.tag) {
5419 const max_count = switch (builtin.os.tag) {
54205420 .linux => 0x7ffff000,
54215421 .macos, .ios, .watchos, .tvos => math.maxInt(i32),
54225422 else => math.maxInt(size_t),
54235423 };
54245424
5425 switch (std.Target.current.os.tag) {
5425 switch (builtin.os.tag) {
54265426 .linux => sf: {
54275427 // sendfile() first appeared in Linux 2.2, glibc 2.1.
54285428 const call_sf = comptime if (builtin.link_libc)
54295429 std.c.versionCheck(.{ .major = 2, .minor = 1 }).ok
54305430 else
5431 std.Target.current.os.version_range.linux.range.max.order(.{ .major = 2, .minor = 2 }) != .lt;
5431 builtin.os.version_range.linux.range.max.order(.{ .major = 2, .minor = 2 }) != .lt;
54325432 if (!call_sf) break :sf;
54335433
54345434 if (headers.len != 0) {
......@@ -5719,13 +5719,13 @@ var has_copy_file_range_syscall = std.atomic.Atomic(bool).init(true);
57195719///
57205720/// Maximum offsets on Linux are `math.maxInt(i64)`.
57215721pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize {
5722 const call_cfr = comptime if (std.Target.current.os.tag == .wasi)
5722 const call_cfr = comptime if (builtin.os.tag == .wasi)
57235723 // WASI-libc doesn't have copy_file_range.
57245724 false
57255725 else if (builtin.link_libc)
57265726 std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }).ok
57275727 else
5728 std.Target.current.os.isAtLeast(.linux, .{ .major = 4, .minor = 5 }) orelse true;
5728 builtin.os.isAtLeast(.linux, .{ .major = 4, .minor = 5 }) orelse true;
57295729
57305730 if (call_cfr and has_copy_file_range_syscall.load(.Monotonic)) {
57315731 var off_in_copy = @bitCast(i64, off_in);
......@@ -6179,7 +6179,7 @@ pub fn syncfs(fd: fd_t) SyncError!void {
61796179
61806180/// Write all pending file contents and metadata modifications for the specified file descriptor to the underlying filesystem.
61816181pub fn fsync(fd: fd_t) SyncError!void {
6182 if (std.Target.current.os.tag == .windows) {
6182 if (builtin.os.tag == .windows) {
61836183 if (windows.kernel32.FlushFileBuffers(fd) != 0)
61846184 return;
61856185 switch (windows.kernel32.GetLastError()) {
......@@ -6203,7 +6203,7 @@ pub fn fsync(fd: fd_t) SyncError!void {
62036203
62046204/// Write all pending file contents for the specified file descriptor to the underlying filesystem, but not necessarily the metadata.
62056205pub fn fdatasync(fd: fd_t) SyncError!void {
6206 if (std.Target.current.os.tag == .windows) {
6206 if (builtin.os.tag == .windows) {
62076207 return fsync(fd) catch |err| switch (err) {
62086208 SyncError.AccessDenied => return, // fdatasync doesn't promise that the access time was synced
62096209 else => return err,
lib/std/os/linux.zig+9-8
......@@ -6,12 +6,13 @@
66//! provide `rename` when only the `renameat` syscall exists.
77//! * Does not support POSIX thread cancellation.
88const std = @import("../std.zig");
9const builtin = @import("builtin");
910const assert = std.debug.assert;
1011const maxInt = std.math.maxInt;
1112const elf = std.elf;
1213const vdso = @import("linux/vdso.zig");
1314const dl = @import("../dynamic_library.zig");
14const native_arch = std.Target.current.cpu.arch;
15const native_arch = builtin.cpu.arch;
1516const native_endian = native_arch.endian();
1617const is_mips = native_arch.isMIPS();
1718const is_ppc = native_arch.isPPC();
......@@ -21,7 +22,7 @@ const iovec = std.os.iovec;
2122const iovec_const = std.os.iovec_const;
2223
2324test {
24 if (std.Target.current.os.tag == .linux) {
25 if (builtin.os.tag == .linux) {
2526 _ = @import("linux/test.zig");
2627 }
2728}
......@@ -150,10 +151,10 @@ pub fn getauxval(index: usize) usize {
150151// Some architectures (and some syscalls) require 64bit parameters to be passed
151152// in a even-aligned register pair.
152153const require_aligned_register_pair =
153 std.Target.current.cpu.arch.isPPC() or
154 std.Target.current.cpu.arch.isMIPS() or
155 std.Target.current.cpu.arch.isARM() or
156 std.Target.current.cpu.arch.isThumb();
154 builtin.cpu.arch.isPPC() or
155 builtin.cpu.arch.isMIPS() or
156 builtin.cpu.arch.isARM() or
157 builtin.cpu.arch.isThumb();
157158
158159// Split a 64bit value into a {LSB,MSB} pair.
159160// The LE/BE variants specify the endianness to assume.
......@@ -1579,7 +1580,7 @@ pub fn process_vm_writev(pid: pid_t, local: [*]const iovec, local_count: usize,
15791580}
15801581
15811582pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize {
1582 if (comptime std.Target.current.cpu.arch.isMIPS()) {
1583 if (comptime builtin.cpu.arch.isMIPS()) {
15831584 // MIPS requires a 7 argument syscall
15841585
15851586 const offset_halves = splitValue64(offset);
......@@ -1595,7 +1596,7 @@ pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize {
15951596 length_halves[1],
15961597 advice,
15971598 );
1598 } else if (comptime std.Target.current.cpu.arch.isARM()) {
1599 } else if (comptime builtin.cpu.arch.isARM()) {
15991600 // ARM reorders the arguments
16001601
16011602 const offset_halves = splitValue64(offset);
lib/std/os/linux/bpf/kern.zig+2-1
......@@ -1,6 +1,7 @@
11const std = @import("../../../std.zig");
2const builtin = @import("builtin");
23
3const in_bpf_program = switch (std.builtin.cpu.arch) {
4const in_bpf_program = switch (builtin.cpu.arch) {
45 .bpfel, .bpfeb => true,
56 else => false,
67};
lib/std/os/linux/io_uring.zig+1-1
......@@ -1,6 +1,6 @@
11const std = @import("../../std.zig");
2const builtin = @import("builtin");
23const assert = std.debug.assert;
3const builtin = std.builtin;
44const mem = std.mem;
55const net = std.net;
66const os = std.os;
lib/std/os/linux/start_pie.zig+1-1
......@@ -1,6 +1,6 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const elf = std.elf;
3const builtin = std.builtin;
44const assert = std.debug.assert;
55
66const R_AMD64_RELATIVE = 8;
lib/std/os/linux/test.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("../../std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const linux = std.os.linux;
44const mem = std.mem;
55const elf = std.elf;
lib/std/os/linux/tls.zig+1-1
......@@ -4,7 +4,7 @@ const mem = std.mem;
44const elf = std.elf;
55const math = std.math;
66const assert = std.debug.assert;
7const native_arch = std.Target.current.cpu.arch;
7const native_arch = @import("builtin").cpu.arch;
88
99// This file implements the two TLS variants [1] used by ELF-based systems.
1010//
lib/std/os/windows/user32.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("../../std.zig");
2const builtin = @import("builtin");
23const assert = std.debug.assert;
34
45const windows = std.os.windows;
......@@ -29,7 +30,7 @@ const HBRUSH = windows.HBRUSH;
2930
3031fn selectSymbol(comptime function_static: anytype, function_dynamic: @TypeOf(function_static), comptime os: std.Target.Os.WindowsVersion) @TypeOf(function_static) {
3132 comptime {
32 const sym_ok = std.Target.current.os.isAtLeast(.windows, os);
33 const sym_ok = builtin.os.isAtLeast(.windows, os);
3334 if (sym_ok == true) return function_static;
3435 if (sym_ok == null) return function_dynamic;
3536 if (sym_ok == false) @compileError("Target OS range does not support function, at least " ++ @tagName(os) ++ " is required");
lib/std/pdb.zig-1
......@@ -1,4 +1,3 @@
1const builtin = std.builtin;
21const std = @import("std.zig");
32const io = std.io;
43const math = std.math;
lib/std/process.zig+3-3
......@@ -1,5 +1,5 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const os = std.os;
44const fs = std.fs;
55const BufMap = std.BufMap;
......@@ -863,9 +863,9 @@ pub fn execve(
863863 if (env_map) |m| {
864864 const envp_buf = try child_process.createNullDelimitedEnvMap(arena, m);
865865 break :m envp_buf.ptr;
866 } else if (std.builtin.link_libc) {
866 } else if (builtin.link_libc) {
867867 break :m std.c.environ;
868 } else if (std.builtin.output_mode == .Exe) {
868 } else if (builtin.output_mode == .Exe) {
869869 // Then we have Zig start code and this works.
870870 // TODO type-safety for null-termination of `os.environ`.
871871 break :m @ptrCast([*:null]?[*:0]u8, os.environ.ptr);
lib/std/rand.zig-1
......@@ -7,7 +7,6 @@
77//! TODO(tiehuis): Benchmark these against other reference implementations.
88
99const std = @import("std.zig");
10const builtin = std.builtin;
1110const assert = std.debug.assert;
1211const expect = std.testing.expect;
1312const expectEqual = std.testing.expectEqual;
lib/std/rand/ziggurat.zig+11-10
......@@ -1,14 +1,15 @@
1// Implements ZIGNOR [1].
2//
3// [1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to Generate Normal Random Samples*]
4// (https://www.doornik.com/research/ziggurat.pdf). Nuffield College, Oxford.
5//
6// rust/rand used as a reference;
7//
8// NOTE: This seems interesting but reference code is a bit hard to grok:
9// https://sbarral.github.io/etf.
1//! Implements ZIGNOR [1].
2//!
3//! [1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to Generate Normal Random Samples*]
4//! (https://www.doornik.com/research/ziggurat.pdf). Nuffield College, Oxford.
5//!
6//! rust/rand used as a reference;
7//!
8//! NOTE: This seems interesting but reference code is a bit hard to grok:
9//! https://sbarral.github.io/etf.
1010
1111const std = @import("../std.zig");
12const builtin = @import("builtin");
1213const math = std.math;
1314const Random = std.rand.Random;
1415
......@@ -126,7 +127,7 @@ fn norm_zero_case(random: *Random, u: f64) f64 {
126127 }
127128}
128129
129const please_windows_dont_oom = std.Target.current.os.tag == .windows;
130const please_windows_dont_oom = builtin.os.tag == .windows;
130131
131132test "normal dist sanity" {
132133 if (please_windows_dont_oom) return error.SkipZigTest;
lib/std/sort.zig-1
......@@ -3,7 +3,6 @@ const assert = std.debug.assert;
33const testing = std.testing;
44const mem = std.mem;
55const math = std.math;
6const builtin = std.builtin;
76
87pub fn binarySearch(
98 comptime T: type,
lib/std/special/compiler_rt.zig+2-2
......@@ -1,9 +1,9 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const is_test = builtin.is_test;
4const os_tag = std.Target.current.os.tag;
4const os_tag = builtin.os.tag;
55const arch = builtin.stage2_arch;
6const abi = std.Target.current.abi;
6const abi = builtin.abi;
77
88const is_gnu = abi.isGnu();
99const is_mingw = os_tag == .windows and is_gnu;
lib/std/special/compiler_rt/atomics.zig+5-5
......@@ -1,8 +1,8 @@
11const std = @import("std");
2const builtin = std.builtin;
3const arch = std.Target.current.cpu.arch;
2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
44
5const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
66
77// This parameter is true iff the target architecture supports the bare minimum
88// to implement the atomic load/store intrinsics.
......@@ -16,7 +16,7 @@ const supports_atomic_ops = switch (arch) {
1616 // operations (unless we're targeting Linux, the kernel provides a way to
1717 // perform CAS operations).
1818 // XXX: The Linux code path is not implemented yet.
19 !std.Target.arm.featureSetHas(std.Target.current.cpu.features, .has_v6m),
19 !std.Target.arm.featureSetHas(builtin.cpu.features, .has_v6m),
2020 else => true,
2121};
2222
......@@ -257,7 +257,7 @@ comptime {
257257 }
258258}
259259
260fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T {
260fn fetchFn(comptime T: type, comptime op: std.builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T {
261261 return struct {
262262 pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T {
263263 _ = model;
lib/std/special/compiler_rt/clear_cache.zig+4-3
......@@ -1,6 +1,7 @@
11const std = @import("std");
2const arch = std.builtin.cpu.arch;
3const os = std.builtin.os.tag;
2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;
4const os = builtin.os.tag;
45
56// Ported from llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28
67
......@@ -156,7 +157,7 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void {
156157 }
157158}
158159
159const linkage = if (std.builtin.is_test) std.builtin.GlobalLinkage.Internal else std.builtin.GlobalLinkage.Weak;
160const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.Internal else std.builtin.GlobalLinkage.Weak;
160161
161162fn exportIt() void {
162163 @export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage });
lib/std/special/compiler_rt/count0bits.zig+8-8
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33
44// clz - count leading zeroes
55// - clzXi2_generic for little endian
......@@ -118,18 +118,18 @@ fn __clzsi2_arm32() callconv(.Naked) void {
118118}
119119
120120pub const __clzsi2 = impl: {
121 switch (std.Target.current.cpu.arch) {
121 switch (builtin.cpu.arch) {
122122 .arm, .armeb, .thumb, .thumbeb => {
123123 const use_thumb1 =
124 (std.Target.current.cpu.arch.isThumb() or
125 std.Target.arm.featureSetHas(std.Target.current.cpu.features, .noarm)) and
126 !std.Target.arm.featureSetHas(std.Target.current.cpu.features, .thumb2);
124 (builtin.cpu.arch.isThumb() or
125 std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
126 !std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
127127
128128 if (use_thumb1) {
129129 break :impl __clzsi2_thumb1;
130130 }
131131 // From here on we're either targeting Thumb2 or ARM.
132 else if (!std.Target.current.cpu.arch.isThumb()) {
132 else if (!builtin.cpu.arch.isThumb()) {
133133 break :impl __clzsi2_arm32;
134134 }
135135 // Use the generic implementation otherwise.
......@@ -140,14 +140,14 @@ pub const __clzsi2 = impl: {
140140};
141141
142142pub const __clzdi2 = impl: {
143 switch (std.Target.current.cpu.arch) {
143 switch (builtin.cpu.arch) {
144144 // TODO architecture optimised versions
145145 else => break :impl clzXi2_generic(i64),
146146 }
147147};
148148
149149pub const __clzti2 = impl: {
150 switch (std.Target.current.cpu.arch) {
150 switch (builtin.cpu.arch) {
151151 // TODO architecture optimised versions
152152 else => break :impl clzXi2_generic(i128),
153153 }
lib/std/special/compiler_rt/emutls.zig+2-1
......@@ -5,6 +5,7 @@
55//
66
77const std = @import("std");
8const builtin = @import("builtin");
89
910const abort = std.os.abort;
1011const assert = std.debug.assert;
......@@ -15,7 +16,7 @@ const expect = std.testing.expect;
1516const gcc_word = usize;
1617
1718comptime {
18 assert(std.builtin.link_libc);
19 assert(builtin.link_libc);
1920}
2021
2122/// public entrypoint for generated code using EmulatedTLS
lib/std/special/compiler_rt/muldi3.zig+3-2
......@@ -1,6 +1,7 @@
11const std = @import("std");
2const is_test = std.builtin.is_test;
3const native_endian = std.Target.current.cpu.arch.endian();
2const builtin = @import("builtin");
3const is_test = builtin.is_test;
4const native_endian = builtin.cpu.arch.endian();
45
56// Ported from
67// https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/compiler-rt/lib/builtins/muldi3.c
lib/std/special/compiler_rt/multi3.zig+3-2
......@@ -1,7 +1,8 @@
11const compiler_rt = @import("../compiler_rt.zig");
22const std = @import("std");
3const is_test = std.builtin.is_test;
4const native_endian = std.Target.current.cpu.arch.endian();
3const builtin = @import("builtin");
4const is_test = builtin.is_test;
5const native_endian = builtin.cpu.arch.endian();
56
67// Ported from git@github.com:llvm-project/llvm-project-20170507.git
78// ae684fad6d34858c014c94da69c15e7774a633c3
lib/std/special/compiler_rt/shift.zig+1-1
......@@ -1,6 +1,6 @@
11const std = @import("std");
22const Log2Int = std.math.Log2Int;
3const native_endian = std.Target.current.cpu.arch.endian();
3const native_endian = @import("builtin").cpu.arch.endian();
44
55fn Dwords(comptime T: type, comptime signed_half: bool) type {
66 return extern union {
lib/std/special/compiler_rt/stack_probe.zig+1-1
......@@ -1,4 +1,4 @@
1const native_arch = @import("std").Target.current.cpu.arch;
1const native_arch = @import("builtin").cpu.arch;
22
33// Zig's own stack-probe routine (available only on x86 and x86_64)
44pub fn zig_probe_stack() callconv(.Naked) void {
lib/std/special/compiler_rt/udivmod.zig+1-1
......@@ -1,6 +1,6 @@
11const builtin = @import("builtin");
22const is_test = builtin.is_test;
3const native_endian = @import("std").Target.current.cpu.arch.endian();
3const native_endian = builtin.cpu.arch.endian();
44
55const low = switch (native_endian) {
66 .Big => 1,
lib/std/special/ssp.zig+15-16
......@@ -1,19 +1,18 @@
1//
2// Small Zig reimplementation of gcc's libssp.
3//
4// This library implements most of the builtins required by the stack smashing
5// protection as implemented by gcc&clang.
6const std = @import("std");
7const builtin = std.builtin;
1//!
2//! Small Zig reimplementation of gcc's libssp.
3//!
4//! This library implements most of the builtins required by the stack smashing
5//! protection as implemented by gcc&clang.
6//! Missing exports:
7//! - __gets_chk
8//! - __mempcpy_chk
9//! - __snprintf_chk
10//! - __sprintf_chk
11//! - __stpcpy_chk
12//! - __vsnprintf_chk
13//! - __vsprintf_chk
814
9// Missing exports:
10// - __gets_chk
11// - __mempcpy_chk
12// - __snprintf_chk
13// - __sprintf_chk
14// - __stpcpy_chk
15// - __vsnprintf_chk
16// - __vsprintf_chk
15const std = @import("std");
1716
1817extern fn strncpy(dest: [*:0]u8, src: [*:0]const u8, n: usize) callconv(.C) [*:0]u8;
1918extern fn memset(dest: ?[*]u8, c: u8, n: usize) callconv(.C) ?[*]u8;
......@@ -21,7 +20,7 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call
2120extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8;
2221
2322// Avoid dragging in the runtime safety mechanisms into this .o file.
24pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
23pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
2524 _ = msg;
2625 _ = error_return_trace;
2726 @setCold(true);
lib/std/std.zig+1-1
......@@ -95,7 +95,7 @@ comptime {
9595}
9696
9797test {
98 if (builtin.os.tag == .windows) {
98 if (@import("builtin").os.tag == .windows) {
9999 // We only test the Windows-relevant stuff to save memory because the CI
100100 // server is hitting OOM. TODO revert this after stage2 arrives.
101101 _ = ChildProcess;
lib/std/target.zig+3-3
......@@ -1,6 +1,5 @@
11const std = @import("std.zig");
22const mem = std.mem;
3const builtin = std.builtin;
43const Version = std.builtin.Version;
54
65/// TODO Nearly all the functions in this namespace would be
......@@ -1017,7 +1016,7 @@ pub const Target = struct {
10171016 };
10181017 }
10191018
1020 pub fn endian(arch: Arch) builtin.Endian {
1019 pub fn endian(arch: Arch) std.builtin.Endian {
10211020 return switch (arch) {
10221021 .avr,
10231022 .arm,
......@@ -1302,7 +1301,8 @@ pub const Target = struct {
13021301 }
13031302 };
13041303
1305 pub const current = builtin.target;
1304 /// TODO delete this deprecated declaration after 0.9.0 is released
1305 pub const current = @compileError("instead of std.Target.current, use @import(\"builtin\").target");
13061306
13071307 pub const stack_align = 16;
13081308
lib/std/testing.zig+3-2
......@@ -1,4 +1,5 @@
11const std = @import("std.zig");
2const builtin = @import("builtin");
23
34const math = std.math;
45const print = std.debug.print;
......@@ -322,7 +323,7 @@ pub const TmpDir = struct {
322323};
323324
324325fn getCwdOrWasiPreopen() std.fs.Dir {
325 if (std.builtin.os.tag == .wasi and !std.builtin.link_libc) {
326 if (builtin.os.tag == .wasi and !builtin.link_libc) {
326327 var preopens = std.fs.wasi.PreopenList.init(allocator);
327328 defer preopens.deinit();
328329 preopens.populate() catch
......@@ -464,7 +465,7 @@ test {
464465
465466/// Given a type, reference all the declarations inside, so that the semantic analyzer sees them.
466467pub fn refAllDecls(comptime T: type) void {
467 if (!std.builtin.is_test) return;
468 if (!builtin.is_test) return;
468469 inline for (std.meta.declarations(T)) |decl| {
469470 _ = decl;
470471 }
lib/std/time.zig+5-5
......@@ -1,10 +1,10 @@
11const std = @import("std.zig");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const assert = std.debug.assert;
44const testing = std.testing;
55const os = std.os;
66const math = std.math;
7const is_windows = std.Target.current.os.tag == .windows;
7const is_windows = builtin.os.tag == .windows;
88
99pub const epoch = @import("time/epoch.zig");
1010
......@@ -173,7 +173,7 @@ pub const Timer = struct {
173173 .resolution = @divFloor(ns_per_s, freq),
174174 .start_time = os.windows.QueryPerformanceCounter(),
175175 };
176 } else if (comptime std.Target.current.isDarwin()) {
176 } else if (comptime builtin.target.isDarwin()) {
177177 var freq: os.darwin.mach_timebase_info_data = undefined;
178178 os.darwin.mach_timebase_info(&freq);
179179
......@@ -225,7 +225,7 @@ pub const Timer = struct {
225225 if (is_windows) {
226226 return os.windows.QueryPerformanceCounter();
227227 }
228 if (comptime std.Target.current.isDarwin()) {
228 if (comptime builtin.target.isDarwin()) {
229229 return os.darwin.mach_absolute_time();
230230 }
231231 var ts: os.timespec = undefined;
......@@ -237,7 +237,7 @@ pub const Timer = struct {
237237 if (is_windows) {
238238 return safeMulDiv(duration, ns_per_s, self.frequency);
239239 }
240 if (comptime std.Target.current.isDarwin()) {
240 if (comptime builtin.target.isDarwin()) {
241241 return safeMulDiv(duration, self.frequency.numer, self.frequency.denom);
242242 }
243243 return duration;
lib/std/unicode.zig-1
......@@ -1,5 +1,4 @@
11const std = @import("./std.zig");
2const builtin = std.builtin;
32const assert = std.debug.assert;
43const testing = std.testing;
54const mem = std.mem;
lib/std/unicode/throughput_test.zig-1
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = std.builtin;
32const time = std.time;
43const unicode = std.unicode;
54
lib/std/x/net/tcp.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("../../std.zig");
2const builtin = @import("builtin");
23
34const io = std.io;
45const os = std.os;
......@@ -7,7 +8,7 @@ const ip = std.x.net.ip;
78const fmt = std.fmt;
89const mem = std.mem;
910const testing = std.testing;
10const native_os = std.Target.current.os;
11const native_os = builtin.os;
1112
1213const IPv4 = std.x.os.IPv4;
1314const IPv6 = std.x.os.IPv6;
lib/std/x/os/io.zig+2-1
......@@ -1,9 +1,10 @@
11const std = @import("../../std.zig");
2const builtin = @import("builtin");
23
34const os = std.os;
45const mem = std.mem;
56const testing = std.testing;
6const native_os = std.Target.current.os;
7const native_os = builtin.os;
78const linux = std.os.linux;
89
910/// POSIX `iovec`, or Windows `WSABUF`. The difference between the two are the ordering
lib/std/x/os/net.zig+2-1
......@@ -1,11 +1,12 @@
11const std = @import("../../std.zig");
2const builtin = @import("builtin");
23
34const os = std.os;
45const fmt = std.fmt;
56const mem = std.mem;
67const math = std.math;
78const testing = std.testing;
8const native_os = std.Target.current.os;
9const native_os = builtin.os;
910const have_ifnamesize = @hasDecl(os.system, "IFNAMESIZE");
1011
1112/// Resolves a network interface name into a scope/zone ID. It returns
lib/std/x/os/socket.zig+3-2
......@@ -1,4 +1,5 @@
11const std = @import("../../std.zig");
2const builtin = @import("builtin");
23const net = @import("net.zig");
34
45const os = std.os;
......@@ -6,8 +7,8 @@ const fmt = std.fmt;
67const mem = std.mem;
78const time = std.time;
89const meta = std.meta;
9const native_os = std.Target.current.os;
10const native_endian = std.Target.current.cpu.arch.endian();
10const native_os = builtin.os;
11const native_endian = builtin.cpu.arch.endian();
1112
1213const Buffer = std.x.os.Buffer;
1314
lib/std/zig/cross_target.zig+13-12
......@@ -1,4 +1,5 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const assert = std.debug.assert;
34const Target = std.Target;
45const mem = std.mem;
......@@ -329,7 +330,7 @@ pub const CrossTarget = struct {
329330 // This works when doing `zig build` because Zig generates a build executable using
330331 // native CPU model & features. However this will not be accurate otherwise, and
331332 // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`.
332 return Target.current.cpu;
333 return builtin.cpu;
333334 },
334335 .baseline => {
335336 var adjusted_baseline = Target.Cpu.baseline(self.getCpuArch());
......@@ -340,7 +341,7 @@ pub const CrossTarget = struct {
340341 // This works when doing `zig build` because Zig generates a build executable using
341342 // native CPU model & features. However this will not be accurate otherwise, and
342343 // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`.
343 return Target.current.cpu;
344 return builtin.cpu;
344345 } else {
345346 var adjusted_baseline = Target.Cpu.baseline(self.getCpuArch());
346347 self.updateCpuFeatures(&adjusted_baseline.features);
......@@ -355,7 +356,7 @@ pub const CrossTarget = struct {
355356 }
356357
357358 pub fn getCpuArch(self: CrossTarget) Target.Cpu.Arch {
358 return self.cpu_arch orelse Target.current.cpu.arch;
359 return self.cpu_arch orelse builtin.cpu.arch;
359360 }
360361
361362 pub fn getCpuModel(self: CrossTarget) *const Target.Cpu.Model {
......@@ -371,10 +372,10 @@ pub const CrossTarget = struct {
371372
372373 /// TODO deprecated, use `std.zig.system.NativeTargetInfo.detect`.
373374 pub fn getOs(self: CrossTarget) Target.Os {
374 // `Target.current.os` works when doing `zig build` because Zig generates a build executable using
375 // `builtin.os` works when doing `zig build` because Zig generates a build executable using
375376 // native OS version range. However this will not be accurate otherwise, and
376377 // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`.
377 var adjusted_os = if (self.os_tag) |os_tag| os_tag.defaultVersionRange() else Target.current.os;
378 var adjusted_os = if (self.os_tag) |os_tag| os_tag.defaultVersionRange() else builtin.os;
378379
379380 if (self.os_version_min) |min| switch (min) {
380381 .none => {},
......@@ -403,7 +404,7 @@ pub const CrossTarget = struct {
403404 }
404405
405406 pub fn getOsTag(self: CrossTarget) Target.Os.Tag {
406 return self.os_tag orelse Target.current.os.tag;
407 return self.os_tag orelse builtin.os.tag;
407408 }
408409
409410 /// TODO deprecated, use `std.zig.system.NativeTargetInfo.detect`.
......@@ -430,7 +431,7 @@ pub const CrossTarget = struct {
430431 // This works when doing `zig build` because Zig generates a build executable using
431432 // native CPU model & features. However this will not be accurate otherwise, and
432433 // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`.
433 return Target.current.abi;
434 return builtin.abi;
434435 }
435436
436437 return Target.Abi.default(self.getCpuArch(), self.getOs());
......@@ -607,12 +608,12 @@ pub const CrossTarget = struct {
607608 pub fn getExternalExecutor(self: CrossTarget) Executor {
608609 const cpu_arch = self.getCpuArch();
609610 const os_tag = self.getOsTag();
610 const os_match = os_tag == Target.current.os.tag;
611 const os_match = os_tag == builtin.os.tag;
611612
612613 // If the OS and CPU arch match, the binary can be considered native.
613614 // TODO additionally match the CPU features. This `getExternalExecutor` function should
614615 // be moved to std.Target and match any chosen target against the native target.
615 if (os_match and cpu_arch == Target.current.cpu.arch) {
616 if (os_match and cpu_arch == builtin.cpu.arch) {
616617 // However, we also need to verify that the dynamic linker path is valid.
617618 if (self.os_tag == null) {
618619 return .native;
......@@ -664,7 +665,7 @@ pub const CrossTarget = struct {
664665 // TODO loosen this check once upstream adds QEMU-based emulation
665666 // layer for non-host architectures:
666667 // https://github.com/darlinghq/darling/issues/863
667 if (cpu_arch != Target.current.cpu.arch) {
668 if (cpu_arch != builtin.cpu.arch) {
668669 return .unavailable;
669670 }
670671 return Executor{ .darling = "darling" };
......@@ -789,7 +790,7 @@ pub const CrossTarget = struct {
789790};
790791
791792test "CrossTarget.parse" {
792 if (Target.current.isGnuLibC()) {
793 if (builtin.target.isGnuLibC()) {
793794 var cross_target = try CrossTarget.parse(.{});
794795 cross_target.setGnuLibCVersion(2, 1, 1);
795796
......@@ -800,7 +801,7 @@ test "CrossTarget.parse" {
800801 const triple = std.fmt.bufPrint(
801802 buf[0..],
802803 "native-native-{s}.2.1.1",
803 .{@tagName(std.Target.current.abi)},
804 .{@tagName(builtin.abi)},
804805 ) catch unreachable;
805806
806807 try std.testing.expectEqualSlices(u8, triple, text);
lib/std/zig/system.zig+14-13
......@@ -1,4 +1,5 @@
11const std = @import("../std.zig");
2const builtin = @import("builtin");
23const elf = std.elf;
34const mem = std.mem;
45const fs = std.fs;
......@@ -8,7 +9,7 @@ const assert = std.debug.assert;
89const process = std.process;
910const Target = std.Target;
1011const CrossTarget = std.zig.CrossTarget;
11const native_endian = std.Target.current.cpu.arch.endian();
12const native_endian = builtin.cpu.arch.endian();
1213const linux = @import("system/linux.zig");
1314pub const windows = @import("system/windows.zig");
1415pub const darwin = @import("system/darwin.zig");
......@@ -88,7 +89,7 @@ pub const NativePaths = struct {
8889 return self;
8990 }
9091
91 if (comptime Target.current.isDarwin()) {
92 if (comptime builtin.target.isDarwin()) {
9293 try self.addIncludeDir("/usr/include");
9394 try self.addIncludeDir("/usr/local/include");
9495
......@@ -239,7 +240,7 @@ pub const NativeTargetInfo = struct {
239240 pub fn detect(allocator: *Allocator, cross_target: CrossTarget) DetectError!NativeTargetInfo {
240241 var os = cross_target.getOsTag().defaultVersionRange();
241242 if (cross_target.os_tag == null) {
242 switch (Target.current.os.tag) {
243 switch (builtin.target.os.tag) {
243244 .linux => {
244245 const uts = std.os.uname();
245246 const release = mem.spanZ(&uts.release);
......@@ -273,7 +274,7 @@ pub const NativeTargetInfo = struct {
273274 },
274275 .macos => try darwin.macos.detect(&os),
275276 .freebsd, .netbsd, .dragonfly => {
276 const key = switch (Target.current.os.tag) {
277 const key = switch (builtin.target.os.tag) {
277278 .freebsd => "kern.osreldate",
278279 .netbsd, .dragonfly => "kern.osrevision",
279280 else => unreachable,
......@@ -289,7 +290,7 @@ pub const NativeTargetInfo = struct {
289290 error.Unexpected => return error.OSVersionDetectionFail,
290291 };
291292
292 switch (Target.current.os.tag) {
293 switch (builtin.target.os.tag) {
293294 .freebsd => {
294295 // https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions.html
295296 // Major * 100,000 has been convention since FreeBSD 2.2 (1997)
......@@ -445,8 +446,8 @@ pub const NativeTargetInfo = struct {
445446 os: Target.Os,
446447 cross_target: CrossTarget,
447448 ) DetectError!NativeTargetInfo {
448 const native_target_has_ld = comptime Target.current.hasDynamicLinker();
449 const is_linux = Target.current.os.tag == .linux;
449 const native_target_has_ld = comptime builtin.target.hasDynamicLinker();
450 const is_linux = builtin.target.os.tag == .linux;
450451 const have_all_info = cross_target.dynamic_linker.get() != null and
451452 cross_target.abi != null and (!is_linux or cross_target.abi.?.isGnu());
452453 const os_is_non_native = cross_target.os_tag != null;
......@@ -463,7 +464,7 @@ pub const NativeTargetInfo = struct {
463464 // compiler for target riscv64-linux-musl and provide a tarball for users to download.
464465 // A user could then run that zig compiler on riscv64-linux-gnu. This use case is well-defined
465466 // and supported by Zig. But that means that we must detect the system ABI here rather than
466 // relying on `Target.current`.
467 // relying on `builtin.target`.
467468 const all_abis = comptime blk: {
468469 assert(@enumToInt(Target.Abi.none) == 0);
469470 const fields = std.meta.fields(Target.Abi)[1..];
......@@ -524,7 +525,7 @@ pub const NativeTargetInfo = struct {
524525
525526 // Look for glibc version.
526527 var os_adjusted = os;
527 if (Target.current.os.tag == .linux and found_ld_info.abi.isGnu() and
528 if (builtin.target.os.tag == .linux and found_ld_info.abi.isGnu() and
528529 cross_target.glibc_version == null)
529530 {
530531 for (lib_paths) |lib_path| {
......@@ -740,7 +741,7 @@ pub const NativeTargetInfo = struct {
740741 }
741742 },
742743 // We only need this for detecting glibc version.
743 elf.PT_DYNAMIC => if (Target.current.os.tag == .linux and result.target.isGnuLibC() and
744 elf.PT_DYNAMIC => if (builtin.target.os.tag == .linux and result.target.isGnuLibC() and
744745 cross_target.glibc_version == null)
745746 {
746747 var dyn_off = elfInt(is_64, need_bswap, ph32.p_offset, ph64.p_offset);
......@@ -787,7 +788,7 @@ pub const NativeTargetInfo = struct {
787788 }
788789 }
789790
790 if (Target.current.os.tag == .linux and result.target.isGnuLibC() and cross_target.glibc_version == null) {
791 if (builtin.target.os.tag == .linux and result.target.isGnuLibC() and cross_target.glibc_version == null) {
791792 if (rpath_offset) |rpoff| {
792793 const shstrndx = elfInt(is_64, need_bswap, hdr32.e_shstrndx, hdr64.e_shstrndx);
793794
......@@ -979,14 +980,14 @@ pub const NativeTargetInfo = struct {
979980 // Here we switch on a comptime value rather than `cpu_arch`. This is valid because `cpu_arch`,
980981 // although it is a runtime value, is guaranteed to be one of the architectures in the set
981982 // of the respective switch prong.
982 switch (std.Target.current.cpu.arch) {
983 switch (builtin.cpu.arch) {
983984 .x86_64, .i386 => {
984985 return @import("system/x86.zig").detectNativeCpuAndFeatures(cpu_arch, os, cross_target);
985986 },
986987 else => {},
987988 }
988989
989 switch (std.Target.current.os.tag) {
990 switch (builtin.os.tag) {
990991 .linux => return linux.detectNativeCpuAndFeatures(),
991992 .macos => return darwin.macos.detectNativeCpuAndFeatures(),
992993 else => {},
lib/std/zig/system/darwin/macos.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const assert = std.debug.assert;
34const mem = std.mem;
45const testing = std.testing;
......@@ -414,7 +415,7 @@ pub fn detectNativeCpuAndFeatures() ?Target.Cpu {
414415 error.Unexpected => unreachable, // EFAULT: stack should be safe, EISDIR/ENOTDIR: constant, known good value
415416 };
416417
417 const current_arch = Target.current.cpu.arch;
418 const current_arch = builtin.cpu.arch;
418419 switch (current_arch) {
419420 .aarch64, .aarch64_be, .aarch64_32 => {
420421 const model = switch (cpu_family) {
lib/std/zig/system/linux.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const mem = std.mem;
34const io = std.io;
45const fs = std.fs;
......@@ -450,7 +451,7 @@ pub fn detectNativeCpuAndFeatures() ?Target.Cpu {
450451 };
451452 defer f.close();
452453
453 const current_arch = std.Target.current.cpu.arch;
454 const current_arch = builtin.cpu.arch;
454455 switch (current_arch) {
455456 .arm, .armeb, .thumb, .thumbeb, .aarch64, .aarch64_be, .aarch64_32 => {
456457 return ArmCpuinfoParser.parse(current_arch, f.reader()) catch null;
src/Air.zig+2-1
......@@ -4,6 +4,7 @@
44//! gets its own `Air` instance.
55
66const std = @import("std");
7const builtin = @import("builtin");
78const Value = @import("value.zig").Value;
89const Type = @import("type.zig").Type;
910const Module = @import("Module.zig");
......@@ -484,7 +485,7 @@ pub const Inst = struct {
484485 // bigger than expected. Note that in Debug builds, Zig is allowed
485486 // to insert a secret field for safety checks.
486487 comptime {
487 if (std.builtin.mode != .Debug) {
488 if (builtin.mode != .Debug) {
488489 assert(@sizeOf(Data) == 8);
489490 }
490491 }
src/Cache.zig+7-6
......@@ -4,6 +4,7 @@ hash: HashHelper = .{},
44
55const Cache = @This();
66const std = @import("std");
7const builtin = @import("builtin");
78const crypto = std.crypto;
89const fs = std.fs;
910const assert = std.debug.assert;
......@@ -713,7 +714,7 @@ pub const Manifest = struct {
713714/// uses the file contents. Windows supports symlinks but only with elevated privileges, so
714715/// it is treated as not supporting symlinks.
715716pub fn readSmallFile(dir: fs.Dir, sub_path: []const u8, buffer: []u8) ![]u8 {
716 if (std.Target.current.os.tag == .windows) {
717 if (builtin.os.tag == .windows) {
717718 return dir.readFile(sub_path, buffer);
718719 } else {
719720 return dir.readLink(sub_path, buffer);
......@@ -726,7 +727,7 @@ pub fn readSmallFile(dir: fs.Dir, sub_path: []const u8, buffer: []u8) ![]u8 {
726727/// `data` must be a valid UTF-8 encoded file path and 255 bytes or fewer.
727728pub fn writeSmallFile(dir: fs.Dir, sub_path: []const u8, data: []const u8) !void {
728729 assert(data.len <= 255);
729 if (std.Target.current.os.tag == .windows) {
730 if (builtin.os.tag == .windows) {
730731 return dir.writeFile(sub_path, data);
731732 } else {
732733 return dir.symLink(data, sub_path, .{});
......@@ -778,7 +779,7 @@ fn isProblematicTimestamp(fs_clock: i128) bool {
778779}
779780
780781test "cache file and then recall it" {
781 if (std.Target.current.os.tag == .wasi) {
782 if (builtin.os.tag == .wasi) {
782783 // https://github.com/ziglang/zig/issues/5437
783784 return error.SkipZigTest;
784785 }
......@@ -856,7 +857,7 @@ test "give nonproblematic timestamp" {
856857}
857858
858859test "check that changing a file makes cache fail" {
859 if (std.Target.current.os.tag == .wasi) {
860 if (builtin.os.tag == .wasi) {
860861 // https://github.com/ziglang/zig/issues/5437
861862 return error.SkipZigTest;
862863 }
......@@ -932,7 +933,7 @@ test "check that changing a file makes cache fail" {
932933}
933934
934935test "no file inputs" {
935 if (std.Target.current.os.tag == .wasi) {
936 if (builtin.os.tag == .wasi) {
936937 // https://github.com/ziglang/zig/issues/5437
937938 return error.SkipZigTest;
938939 }
......@@ -977,7 +978,7 @@ test "no file inputs" {
977978}
978979
979980test "Manifest with files added after initial hash work" {
980 if (std.Target.current.os.tag == .wasi) {
981 if (builtin.os.tag == .wasi) {
981982 // https://github.com/ziglang/zig/issues/5437
982983 return error.SkipZigTest;
983984 }
src/Compilation.zig+3-3
......@@ -937,8 +937,8 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
937937 };
938938
939939 const darwin_can_use_system_sdk = blk: {
940 if (comptime !std.Target.current.isDarwin()) break :blk false;
941 break :blk std.builtin.os.tag == .macos and options.target.isDarwin();
940 if (comptime !builtin.target.isDarwin()) break :blk false;
941 break :blk builtin.os.tag == .macos and options.target.isDarwin();
942942 };
943943
944944 const sysroot = blk: {
......@@ -3582,7 +3582,7 @@ fn detectLibCIncludeDirs(
35823582 // native abi, fall back to using the system libc installation.
35833583 // On windows, instead of the native (mingw) abi, we want to check
35843584 // for the MSVC abi as a fallback.
3585 const use_system_abi = if (std.Target.current.os.tag == .windows)
3585 const use_system_abi = if (builtin.target.os.tag == .windows)
35863586 target.abi == .msvc
35873587 else
35883588 is_native_abi;
src/ThreadPool.zig+3-2
......@@ -4,6 +4,7 @@
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
66const std = @import("std");
7const builtin = @import("builtin");
78const ThreadPool = @This();
89
910lock: std.Thread.Mutex = .{},
......@@ -57,7 +58,7 @@ pub fn init(self: *ThreadPool, allocator: *std.mem.Allocator) !void {
5758 .allocator = allocator,
5859 .workers = &[_]Worker{},
5960 };
60 if (std.builtin.single_threaded)
61 if (builtin.single_threaded)
6162 return;
6263
6364 const worker_count = std.math.max(1, std.Thread.getCpuCount() catch 1);
......@@ -100,7 +101,7 @@ pub fn deinit(self: *ThreadPool) void {
100101}
101102
102103pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void {
103 if (std.builtin.single_threaded) {
104 if (builtin.single_threaded) {
104105 @call(.{}, func, args);
105106 return;
106107 }
src/Zir.zig+2-1
......@@ -11,6 +11,7 @@
1111//! inline assembly is not an exception.
1212
1313const std = @import("std");
14const builtin = @import("builtin");
1415const mem = std.mem;
1516const Allocator = std.mem.Allocator;
1617const assert = std.debug.assert;
......@@ -2215,7 +2216,7 @@ pub const Inst = struct {
22152216 // bigger than expected. Note that in Debug builds, Zig is allowed
22162217 // to insert a secret field for safety checks.
22172218 comptime {
2218 if (std.builtin.mode != .Debug) {
2219 if (builtin.mode != .Debug) {
22192220 assert(@sizeOf(Data) == 8);
22202221 }
22212222 }
src/codegen.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const mem = std.mem;
34const math = std.math;
45const assert = std.debug.assert;
......@@ -522,7 +523,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
522523 code: *std.ArrayList(u8),
523524 debug_output: DebugInfoOutput,
524525 ) GenerateSymbolError!FnResult {
525 if (build_options.skip_non_native and std.Target.current.cpu.arch != arch) {
526 if (build_options.skip_non_native and builtin.cpu.arch != arch) {
526527 @panic("Attempted to compile for architecture that was disabled by build configuration");
527528 }
528529
src/codegen/c.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const assert = std.debug.assert;
34const mem = std.mem;
45const log = std.log.scoped(.c);
......@@ -600,7 +601,7 @@ pub const DeclGen = struct {
600601 );
601602 },
602603 .ErrorSet => {
603 comptime std.debug.assert(Type.initTag(.anyerror).abiSize(std.Target.current) == 2);
604 comptime std.debug.assert(Type.initTag(.anyerror).abiSize(builtin.target) == 2);
604605 try w.writeAll("uint16_t");
605606 },
606607 .ErrorUnion => {
src/introspect.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const mem = std.mem;
34const fs = std.fs;
45const Compilation = @import("Compilation.zig");
......@@ -71,7 +72,7 @@ pub fn resolveGlobalCacheDir(allocator: *mem.Allocator) ![]u8 {
7172
7273 const appname = "zig";
7374
74 if (std.Target.current.os.tag != .windows) {
75 if (builtin.os.tag != .windows) {
7576 if (std.os.getenv("XDG_CACHE_HOME")) |cache_root| {
7677 return fs.path.join(allocator, &[_][]const u8{ cache_root, appname });
7778 } else if (std.os.getenv("HOME")) |home| {
src/libc_installation.zig+4-4
......@@ -6,9 +6,9 @@ const Allocator = std.mem.Allocator;
66const Batch = std.event.Batch;
77const build_options = @import("build_options");
88
9const is_darwin = Target.current.isDarwin();
10const is_windows = Target.current.os.tag == .windows;
11const is_haiku = Target.current.os.tag == .haiku;
9const is_darwin = builtin.target.isDarwin();
10const is_windows = builtin.target.os.tag == .windows;
11const is_haiku = builtin.target.os.tag == .haiku;
1212
1313const log = std.log.scoped(.libc_installation);
1414
......@@ -219,7 +219,7 @@ pub const LibCInstallation = struct {
219219 var batch = Batch(FindError!void, 2, .auto_async).init();
220220 errdefer batch.wait() catch {};
221221 batch.add(&async self.findNativeIncludeDirPosix(args));
222 switch (Target.current.os.tag) {
222 switch (builtin.target.os.tag) {
223223 .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try std.mem.dupeZ(args.allocator, u8, "/usr/lib"),
224224 .solaris => self.crt_dir = try std.mem.dupeZ(args.allocator, u8, "/usr/lib/64"),
225225 .linux => batch.add(&async self.findNativeCrtDirPosix(args)),
src/link.zig+2-2
......@@ -292,7 +292,7 @@ pub const File = struct {
292292 // make executable, so we don't have to close it.
293293 return;
294294 }
295 if (comptime std.Target.current.isDarwin() and std.Target.current.cpu.arch == .aarch64) {
295 if (comptime builtin.target.isDarwin() and builtin.target.cpu.arch == .aarch64) {
296296 if (base.options.target.cpu.arch != .aarch64) return; // If we're not targeting aarch64, nothing to do.
297297 // XNU starting with Big Sur running on arm64 is caching inodes of running binaries.
298298 // Any change to the binary will effectively invalidate the kernel's cache
......@@ -711,7 +711,7 @@ pub fn determineMode(options: Options) fs.File.Mode {
711711 // with 0o755 permissions, but it works appropriately if the system is configured
712712 // more leniently. As another data point, C's fopen seems to open files with the
713713 // 666 mode.
714 const executable_mode = if (std.Target.current.os.tag == .windows) 0 else 0o777;
714 const executable_mode = if (builtin.target.os.tag == .windows) 0 else 0o777;
715715 switch (options.effectiveOutputMode()) {
716716 .Lib => return switch (options.link_mode) {
717717 .Dynamic => executable_mode,
src/link/Elf.zig+5-5
......@@ -755,7 +755,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
755755 const module = self.base.options.module orelse return error.LinkingWithoutZigSourceUnimplemented;
756756
757757 const target_endian = self.base.options.target.cpu.arch.endian();
758 const foreign_endian = target_endian != std.Target.current.cpu.arch.endian();
758 const foreign_endian = target_endian != builtin.cpu.arch.endian();
759759 const ptr_width_bytes: u8 = self.ptrWidthBytes();
760760 const init_len_size: usize = switch (self.ptr_width) {
761761 .p32 => 4,
......@@ -2827,7 +2827,7 @@ pub fn deleteExport(self: *Elf, exp: Export) void {
28272827}
28282828
28292829fn writeProgHeader(self: *Elf, index: usize) !void {
2830 const foreign_endian = self.base.options.target.cpu.arch.endian() != std.Target.current.cpu.arch.endian();
2830 const foreign_endian = self.base.options.target.cpu.arch.endian() != builtin.cpu.arch.endian();
28312831 const offset = self.program_headers.items[index].p_offset;
28322832 switch (self.ptr_width) {
28332833 .p32 => {
......@@ -2848,7 +2848,7 @@ fn writeProgHeader(self: *Elf, index: usize) !void {
28482848}
28492849
28502850fn writeSectHeader(self: *Elf, index: usize) !void {
2851 const foreign_endian = self.base.options.target.cpu.arch.endian() != std.Target.current.cpu.arch.endian();
2851 const foreign_endian = self.base.options.target.cpu.arch.endian() != builtin.cpu.arch.endian();
28522852 switch (self.ptr_width) {
28532853 .p32 => {
28542854 var shdr: [1]elf.Elf32_Shdr = undefined;
......@@ -2946,7 +2946,7 @@ fn writeSymbol(self: *Elf, index: usize) !void {
29462946 syms_sect.sh_size = needed_size; // anticipating adding the global symbols later
29472947 self.shdr_table_dirty = true; // TODO look into only writing one section
29482948 }
2949 const foreign_endian = self.base.options.target.cpu.arch.endian() != std.Target.current.cpu.arch.endian();
2949 const foreign_endian = self.base.options.target.cpu.arch.endian() != builtin.cpu.arch.endian();
29502950 switch (self.ptr_width) {
29512951 .p32 => {
29522952 var sym = [1]elf.Elf32_Sym{
......@@ -2982,7 +2982,7 @@ fn writeAllGlobalSymbols(self: *Elf) !void {
29822982 .p32 => @sizeOf(elf.Elf32_Sym),
29832983 .p64 => @sizeOf(elf.Elf64_Sym),
29842984 };
2985 const foreign_endian = self.base.options.target.cpu.arch.endian() != std.Target.current.cpu.arch.endian();
2985 const foreign_endian = self.base.options.target.cpu.arch.endian() != builtin.cpu.arch.endian();
29862986 const global_syms_off = syms_sect.sh_offset + self.local_symbols.items.len * sym_size;
29872987 switch (self.ptr_width) {
29882988 .p32 => {
src/link/MachO.zig+1-1
......@@ -967,7 +967,7 @@ fn resolveSearchDir(
967967
968968 if (fs.path.isAbsolute(dir)) {
969969 if (syslibroot) |root| {
970 const common_dir = if (std.Target.current.os.tag == .windows) blk: {
970 const common_dir = if (builtin.os.tag == .windows) blk: {
971971 // We need to check for disk designator and strip it out from dir path so
972972 // that we can concat dir with syslibroot.
973973 // TODO we should backport this mechanism to 'MachO.Dylib.parseDependentLibs()'
src/link/MachO/fat.zig+2-2
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const log = std.log.scoped(.archive);
44const macho = std.macho;
55const mem = std.mem;
......@@ -23,7 +23,7 @@ fn readFatStruct(reader: anytype, comptime T: type) !T {
2323 // Fat structures (fat_header & fat_arch) are always written and read to/from
2424 // disk in big endian order.
2525 var res = try reader.readStruct(T);
26 if (native_endian != builtin.Endian.Big) {
26 if (native_endian != std.builtin.Endian.Big) {
2727 mem.bswapAllFields(T, &res);
2828 }
2929 return res;
src/main.zig+10-9
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const assert = std.debug.assert;
34const io = std.io;
45const fs = std.fs;
......@@ -34,7 +35,7 @@ pub fn fatal(comptime format: []const u8, args: anytype) noreturn {
3435/// be byte-indexed with a u32 integer.
3536pub const max_src_size = std.math.maxInt(u32);
3637
37pub const debug_extensions_enabled = std.builtin.mode == .Debug;
38pub const debug_extensions_enabled = builtin.mode == .Debug;
3839
3940pub const Color = enum {
4041 auto,
......@@ -90,7 +91,7 @@ const debug_usage = normal_usage ++
9091
9192const usage = if (debug_extensions_enabled) debug_usage else normal_usage;
9293
93pub const log_level: std.log.Level = switch (std.builtin.mode) {
94pub const log_level: std.log.Level = switch (builtin.mode) {
9495 .Debug => .debug,
9596 .ReleaseSafe, .ReleaseFast => .info,
9697 .ReleaseSmall => .crit,
......@@ -142,7 +143,7 @@ pub fn main() anyerror!void {
142143
143144 var gpa_need_deinit = false;
144145 const gpa = gpa: {
145 if (!std.builtin.link_libc) {
146 if (!builtin.link_libc) {
146147 gpa_need_deinit = true;
147148 break :gpa &general_purpose_allocator.allocator;
148149 }
......@@ -1688,13 +1689,13 @@ fn buildOutputType(
16881689 }
16891690 }
16901691
1691 if (comptime std.Target.current.isDarwin()) {
1692 if (comptime builtin.target.isDarwin()) {
16921693 // If we want to link against frameworks, we need system headers.
16931694 if (framework_dirs.items.len > 0 or frameworks.items.len > 0)
16941695 want_native_include_dirs = true;
16951696 }
16961697
1697 const is_darwin_on_darwin = (comptime std.Target.current.isDarwin()) and cross_target.isDarwin();
1698 const is_darwin_on_darwin = (comptime builtin.target.isDarwin()) and cross_target.isDarwin();
16981699
16991700 if (sysroot == null and (cross_target.isNativeOs() or is_darwin_on_darwin) and
17001701 (system_libs.items.len != 0 or want_native_include_dirs))
......@@ -1706,7 +1707,7 @@ fn buildOutputType(
17061707 warn("{s}", .{warning});
17071708 }
17081709
1709 const has_sysroot = if (comptime std.Target.current.isDarwin()) outer: {
1710 const has_sysroot = if (comptime builtin.target.isDarwin()) outer: {
17101711 const should_get_sdk_path = if (cross_target.isNativeOs() and target_info.target.os.tag == .macos) inner: {
17111712 const min = target_info.target.os.getVersionRange().semver.min;
17121713 const at_least_mojave = min.major >= 11 or (min.major >= 10 and min.minor >= 14);
......@@ -2355,7 +2356,7 @@ fn runOrTest(
23552356 defer argv.deinit();
23562357
23572358 if (test_exec_args.len == 0) {
2358 if (!std.Target.current.canExecBinariesOf(target)) {
2359 if (!builtin.target.canExecBinariesOf(target)) {
23592360 switch (arg_mode) {
23602361 .zig_test => {
23612362 warn("created {s} but skipping execution because it is non-native", .{exe_path});
......@@ -3915,7 +3916,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
39153916 const posix = std.os;
39163917
39173918 var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried.
3918 if (comptime std.Target.current.isDarwin()) {
3919 if (comptime builtin.target.isDarwin()) {
39193920 // On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`.
39203921 // According to the man pages for setrlimit():
39213922 // setrlimit() now returns with errno set to EINVAL in places that historically succeeded.
......@@ -3959,7 +3960,7 @@ fn detectNativeTargetInfo(gpa: *Allocator, cross_target: std.zig.CrossTarget) !s
39593960/// check for resource leaks can be accurate. In release builds, this
39603961/// calls exit(0), and does not return.
39613962pub fn cleanExit() void {
3962 if (std.builtin.mode == .Debug) {
3963 if (builtin.mode == .Debug) {
39633964 return;
39643965 } else {
39653966 process.exit(0);
src/tracy.zig+3-2
......@@ -1,6 +1,7 @@
1pub const std = @import("std");
1const std = @import("std");
2const builtin = @import("builtin");
23
3pub const enable = if (std.builtin.is_test) false else @import("build_options").enable_tracy;
4pub const enable = if (builtin.is_test) false else @import("build_options").enable_tracy;
45
56extern fn ___tracy_emit_zone_begin_callstack(
67 srcloc: *const ___tracy_source_location_data,
test/assemble_and_link.zig+2-1
......@@ -1,8 +1,9 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const tests = @import("tests.zig");
34
45pub fn addCases(cases: *tests.CompareOutputContext) void {
5 if (std.Target.current.os.tag == .linux and std.Target.current.cpu.arch == .x86_64) {
6 if (builtin.os.tag == .linux and builtin.cpu.arch == .x86_64) {
67 cases.addAsm("hello world linux x86_64",
78 \\.text
89 \\.globl _start
test/behavior/asm.zig+2-1
......@@ -1,7 +1,8 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const expect = std.testing.expect;
34
4const is_x86_64_linux = std.Target.current.cpu.arch == .x86_64 and std.Target.current.os.tag == .linux;
5const is_x86_64_linux = builtin.cpu.arch == .x86_64 and builtin.os.tag == .linux;
56
67comptime {
78 if (is_x86_64_linux) {
test/behavior/atomics.zig+1-1
......@@ -1,7 +1,7 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const expect = std.testing.expect;
34const expectEqual = std.testing.expectEqual;
4const builtin = @import("builtin");
55
66test "cmpxchg" {
77 try testCmpxchg();
test/behavior/namespace_depends_on_compile_var.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const expect = std.testing.expect;
34
45test "namespace depends on compile var" {
......@@ -8,7 +9,7 @@ test "namespace depends on compile var" {
89 try expect(!some_namespace.a_bool);
910 }
1011}
11const some_namespace = switch (std.builtin.os.tag) {
12const some_namespace = switch (builtin.os.tag) {
1213 .linux => @import("namespace_depends_on_compile_var/a.zig"),
1314 else => @import("namespace_depends_on_compile_var/b.zig"),
1415};
test/behavior/sizeof_and_typeof.zig-1
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = std.builtin;
32const expect = std.testing.expect;
43const expectEqual = std.testing.expectEqual;
54
test/behavior/sizeof_and_typeof_stage1.zig-1
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = std.builtin;
32const expect = std.testing.expect;
43const expectEqual = std.testing.expectEqual;
54
test/behavior/vector.zig+1-1
......@@ -674,7 +674,7 @@ test "saturating subtraction" {
674674
675675test "saturating multiplication" {
676676 // TODO: once #9660 has been solved, remove this line
677 if (std.builtin.target.cpu.arch == .wasm32) return error.SkipZigTest;
677 if (builtin.target.cpu.arch == .wasm32) return error.SkipZigTest;
678678
679679 const S = struct {
680680 fn doTheTest() !void {
test/cli.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const testing = std.testing;
34const process = std.process;
45const fs = std.fs;
......@@ -97,7 +98,7 @@ fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void {
9798}
9899
99100fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
100 if (std.Target.current.os.tag != .linux or std.Target.current.cpu.arch != .x86_64) return;
101 if (builtin.os.tag != .linux or builtin.cpu.arch != .x86_64) return;
101102
102103 const example_zig_path = try fs.path.join(a, &[_][]const u8{ dir_path, "example.zig" });
103104 const example_s_path = try fs.path.join(a, &[_][]const u8{ dir_path, "example.s" });
test/compare_output.zig+4-2
......@@ -28,7 +28,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
2828
2929 cases.addC("number literals",
3030 \\const std = @import("std");
31 \\const is_windows = std.Target.current.os.tag == .windows;
31 \\const builtin = @import("builtin");
32 \\const is_windows = builtin.os.tag == .windows;
3233 \\const c = @cImport({
3334 \\ if (is_windows) {
3435 \\ // See https://github.com/ziglang/zig/issues/515
......@@ -207,7 +208,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
207208
208209 cases.addC("casting between float and integer types",
209210 \\const std = @import("std");
210 \\const is_windows = std.Target.current.os.tag == .windows;
211 \\const builtin = @import("builtin");
212 \\const is_windows = builtin.os.tag == .windows;
211213 \\const c = @cImport({
212214 \\ if (is_windows) {
213215 \\ // See https://github.com/ziglang/zig/issues/515
test/compile_errors.zig+4-2
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const TestContext = @import("../src/test.zig").TestContext;
34
45pub fn addCases(ctx: *TestContext) !void {
......@@ -2898,7 +2899,7 @@ pub fn addCases(ctx: *TestContext) !void {
28982899 "tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}'",
28992900 });
29002901
2901 if (std.Target.current.os.tag == .linux) {
2902 if (builtin.os.tag == .linux) {
29022903 ctx.testErrStage1("implicit dependency on libc",
29032904 \\extern "c" fn exit(u8) void;
29042905 \\export fn entry() void {
......@@ -8834,9 +8835,10 @@ pub fn addCases(ctx: *TestContext) !void {
88348835
88358836 ctx.objErrStage1("Issue #9165: windows tcp server compilation error",
88368837 \\const std = @import("std");
8838 \\const builtin = @import("builtin");
88378839 \\pub const io_mode = .evented;
88388840 \\pub fn main() !void {
8839 \\ if (std.builtin.os.tag == .windows) {
8841 \\ if (builtin.os.tag == .windows) {
88408842 \\ _ = try (std.net.StreamServer.init(.{})).accept();
88418843 \\ } else {
88428844 \\ @compileError("Unsupported OS");
test/src/compare_output.zig+1-2
......@@ -1,14 +1,13 @@
11// This is the implementation of the test harness.
22// For the actual test cases, see test/compare_output.zig.
33const std = @import("std");
4const builtin = std.builtin;
54const build = std.build;
65const ArrayList = std.ArrayList;
76const fmt = std.fmt;
87const mem = std.mem;
98const fs = std.fs;
109const warn = std.debug.warn;
11const Mode = builtin.Mode;
10const Mode = std.builtin.Mode;
1211
1312pub const CompareOutputContext = struct {
1413 b: *build.Builder,
test/standalone.zig+5-4
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const tests = @import("tests.zig");
34
45pub fn addCases(cases: *tests.StandaloneContext) void {
......@@ -29,19 +30,19 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
2930 cases.addBuildFile("test/standalone/issue_7030/build.zig", .{});
3031 cases.addBuildFile("test/standalone/install_raw_hex/build.zig", .{});
3132 cases.addBuildFile("test/standalone/issue_9812/build.zig", .{});
32 if (std.Target.current.os.tag != .wasi) {
33 if (builtin.os.tag != .wasi) {
3334 cases.addBuildFile("test/standalone/load_dynamic_library/build.zig", .{});
3435 }
35 if (std.Target.current.cpu.arch == .x86_64) { // TODO add C ABI support for other architectures
36 if (builtin.cpu.arch == .x86_64) { // TODO add C ABI support for other architectures
3637 cases.addBuildFile("test/stage1/c_abi/build.zig", .{});
3738 }
3839 cases.addBuildFile("test/standalone/c_compiler/build.zig", .{ .build_modes = true, .cross_targets = true });
3940
40 if (std.Target.current.os.tag == .windows) {
41 if (builtin.os.tag == .windows) {
4142 cases.addC("test/standalone/issue_9402/main.zig");
4243 }
4344 // Try to build and run a PIE executable.
44 if (std.Target.current.os.tag == .linux) {
45 if (builtin.os.tag == .linux) {
4546 cases.addBuildFile("test/standalone/pie/build.zig", .{});
4647 }
4748 // Try to build and run an Objective-C executable.
test/standalone/c_compiler/build.zig+3-2
......@@ -1,12 +1,13 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const Builder = std.build.Builder;
34const CrossTarget = std.zig.CrossTarget;
45
56fn isRunnableTarget(t: CrossTarget) bool {
67 if (t.isNative()) return true;
78
8 return (t.getOsTag() == std.Target.current.os.tag and
9 t.getCpuArch() == std.Target.current.cpu.arch);
9 return (t.getOsTag() == builtin.os.tag and
10 t.getCpuArch() == builtin.cpu.arch);
1011}
1112
1213pub fn build(b: *Builder) void {
test/standalone/install_raw_hex/build.zig+107-113
......@@ -28,14 +28,14 @@ pub fn build(b: *Builder) void {
2828
2929 const expected_hex = &[_][]const u8{
3030 ":020000021000EC",
31 ":1000D400D001010001000000D20101000100000074",
32 ":1000E40028020100010000002402010001000000B8",
33 ":1000F4003A02010001000000E202010001000000D8",
34 ":100104000C03010001000000A50202000000000031",
31 ":1000D400A401010001000000A601010001000000CC",
32 ":1000E400FC01010001000000F80101000100000012",
33 ":1000F4000E02010001000000B60201000100000030",
34 ":10010400E00201000100000079020200000000008A",
3535 ":1001140000000000000000000000000000000000DB",
3636 ":1001240000000000000000000000000000000000CB",
3737 ":1001340000000000000000000000000000000000BB",
38 ":10014400AF02020098020100090000004D02010004",
38 ":10014400830202006C020100090000002102010088",
3939 ":100154000900000001000000000000000000000091",
4040 ":1001640000080002008001010004000010000000EB",
4141 ":100174000000000000000000000000001F0000005C",
......@@ -44,55 +44,52 @@ pub fn build(b: *Builder) void {
4444 ":1001A40000000000000000001F000000000000002C",
4545 ":1001B400000000000000000000000000000000003B",
4646 ":1001C400000000000000000000000000000000002B",
47 ":1001D400000000000000000000000000000000001B",
48 ":1001E400000000000000000000000000000000000B",
49 ":1001F4000000000000000000000000008702010071",
50 ":1002040010000000200201002C0000006B0201001D",
51 ":100214001B000000570201001300000072656D61AD",
52 ":10022400696E646572206469766973696F6E2062B1",
53 ":1002340079207A65726F206F72206E6567617469C8",
54 ":1002440076652076616C756500636F727465782DD0",
55 ":100254006D3400696E646578206F7574206F662054",
56 ":10026400626F756E647300696E746567657220638E",
57 ":10027400617374207472756E63617465642062695D",
58 ":100284007473006469766973696F6E206279207A89",
59 ":1002940065726F00636F727465785F6D340000007F",
60 ":1002A40081B00091FFE700BEFDE7D0B502AF90B08A",
61 ":1002B4000391029007A800F029F803990020069002",
62 ":1002C40048680490FFE704990698019088420FD289",
63 ":1002D400FFE7019903980068405C07F8310C17F8B0",
64 ":1002E400311C07A800F021F8019801300690EAE7D4",
65 ":1002F400029807A9B1E80C50A0E80C5091E81C50F2",
66 ":1003040080E81C5010B0D0BDFFE7FEE7D0B502AFC7",
67 ":1003140040F2DC11C0F20101B1E80C50A0E80C502D",
68 ":1003240091E81C5080E81C50D0BD80B56F4688B061",
69 ":1003340006906FF35F2127F80A1C37F80A0C049023",
70 ":10034400012038B9FFE740F20020C0F2010000218B",
71 ":10035400FFF7A6FF0498C0F3431027F8020C37F800",
72 ":100364000A0C0390002038B9FFE7039800F01F003F",
73 ":100374000290012038B914E040F20820C0F20100D4",
74 ":100384000021FFF78DFF029800F01F0007F8030C0F",
75 ":100394000698009037F8020C0146019109280ED303",
76 ":1003A40006E040F21020C0F201000021FFF778FFC0",
77 ":1003B40040F21820C0F201000021FFF771FF0099FC",
78 ":1003C400019A51F8220017F803CC012303FA0CF325",
79 ":1003D400184341F8220008B080BD81B000F03F000E",
80 ":1003E4008DF802009DF802000F3000F03F00022853",
81 ":1003F40004D3FFE700208DF8030003E001208DF80B",
82 ":100404000300FFE79DF8030001B070470A000000F5",
83 ":1004140012000000020071001200000066000000DB",
84 ":1004240003007D0C06000000000000000001110123",
85 ":10043400250E1305030E10171B0EB44219110112D9",
86 ":0604440006000002340076",
47 ":1001D4005B02010010000000F40101002C0000008B",
48 ":1001E4003F0201001B0000002B020100130000006D",
49 ":1001F40072656D61696E646572206469766973699C",
50 ":100204006F6E206279207A65726F206F72206E653E",
51 ":100214006761746976652076616C756500636F72D9",
52 ":100224007465782D6D3400696E646578206F75741B",
53 ":10023400206F6620626F756E647300696E74656703",
54 ":1002440065722063617374207472756E6361746582",
55 ":10025400642062697473006469766973696F6E20DF",
56 ":100264006279207A65726F00636F727465785F6D6E",
57 ":100274003400000081B00091FFE700BEFDE7D0B577",
58 ":1002840002AF90B00391029007A800F029F80399F7",
59 ":100294000020069048680490FFE7049906980190AE",
60 ":1002A40088420FD2FFE7019903980068405C07F881",
61 ":1002B400310C17F8311C07A800F021F8019801301F",
62 ":1002C4000690EAE7029807A9B1E80C50A0E80C50A0",
63 ":1002D40091E81C5080E81C5010B0D0BDFFE7FEE749",
64 ":1002E400D0B502AF40F2B011C0F20101B1E80C5038",
65 ":1002F400A0E80C5091E81C5080E81C50D0BD80B59B",
66 ":100304006F4688B006906FF35F2127F80A1C37F810",
67 ":100314000A0C0490012038B9FFE740F2D410C0F26F",
68 ":1003240001000021FFF7A6FF0498C0F3431027F84B",
69 ":10033400020C37F80A0C0390002038B9FFE7039841",
70 ":1003440000F01F000290012038B914E040F2DC10E4",
71 ":10035400C0F201000021FFF78DFF029800F01F009A",
72 ":1003640007F8030C0698009037F8020C0146019137",
73 ":1003740009280ED306E040F2E410C0F20100002187",
74 ":10038400FFF778FF40F2EC10C0F201000021FFF704",
75 ":1003940071FF0099019A51F8220017F803CC012348",
76 ":1003A40003FA0CF3184341F8220008B080BD81B071",
77 ":1003B40000F03F008DF802009DF802000F3000F0BD",
78 ":1003C4003F00022804D3FFE700208DF8030003E078",
79 ":1003D40001208DF80300FFE79DF8030001B070478A",
80 ":1003E4000A00000012000000020071001200000068",
81 ":1003F4006600000003007D0C060000000000000001",
82 ":1004040000011101250E1305030E10171B0EB44233",
83 ":0A0414001911011206000002340065",
8784 ":020000021000EC",
88 ":1000D400D001010001000000D20101000100000074",
89 ":1000E40028020100010000002402010001000000B8",
90 ":1000F4003A02010001000000E202010001000000D8",
91 ":100104000C03010001000000A50202000000000031",
85 ":1000D400A401010001000000A601010001000000CC",
86 ":1000E400FC01010001000000F80101000100000012",
87 ":1000F4000E02010001000000B60201000100000030",
88 ":10010400E00201000100000079020200000000008A",
9289 ":1001140000000000000000000000000000000000DB",
9390 ":1001240000000000000000000000000000000000CB",
9491 ":1001340000000000000000000000000000000000BB",
95 ":10014400AF02020098020100090000004D02010004",
92 ":10014400830202006C020100090000002102010088",
9693 ":100154000900000001000000000000000000000091",
9794 ":1001640000080002008001010004000010000000EB",
9895 ":100174000000000000000000000000001F0000005C",
......@@ -101,70 +98,67 @@ pub fn build(b: *Builder) void {
10198 ":1001A40000000000000000001F000000000000002C",
10299 ":1001B400000000000000000000000000000000003B",
103100 ":1001C400000000000000000000000000000000002B",
104 ":1001D400000000000000000000000000000000001B",
105 ":1001E400000000000000000000000000000000000B",
106 ":1001F4000000000000000000000000008702010071",
107 ":1002040010000000200201002C0000006B0201001D",
108 ":100214001B000000570201001300000072656D61AD",
109 ":10022400696E646572206469766973696F6E2062B1",
110 ":1002340079207A65726F206F72206E6567617469C8",
111 ":1002440076652076616C756500636F727465782DD0",
112 ":100254006D3400696E646578206F7574206F662054",
113 ":10026400626F756E647300696E746567657220638E",
114 ":10027400617374207472756E63617465642062695D",
115 ":100284007473006469766973696F6E206279207A89",
116 ":1002940065726F00636F727465785F6D340000007F",
117 ":1002A40081B00091FFE700BEFDE7D0B502AF90B08A",
118 ":1002B4000391029007A800F029F803990020069002",
119 ":1002C40048680490FFE704990698019088420FD289",
120 ":1002D400FFE7019903980068405C07F8310C17F8B0",
121 ":1002E400311C07A800F021F8019801300690EAE7D4",
122 ":1002F400029807A9B1E80C50A0E80C5091E81C50F2",
123 ":1003040080E81C5010B0D0BDFFE7FEE7D0B502AFC7",
124 ":1003140040F2DC11C0F20101B1E80C50A0E80C502D",
125 ":1003240091E81C5080E81C50D0BD80B56F4688B061",
126 ":1003340006906FF35F2127F80A1C37F80A0C049023",
127 ":10034400012038B9FFE740F20020C0F2010000218B",
128 ":10035400FFF7A6FF0498C0F3431027F8020C37F800",
129 ":100364000A0C0390002038B9FFE7039800F01F003F",
130 ":100374000290012038B914E040F20820C0F20100D4",
131 ":100384000021FFF78DFF029800F01F0007F8030C0F",
132 ":100394000698009037F8020C0146019109280ED303",
133 ":1003A40006E040F21020C0F201000021FFF778FFC0",
134 ":1003B40040F21820C0F201000021FFF771FF0099FC",
135 ":1003C400019A51F8220017F803CC012303FA0CF325",
136 ":1003D400184341F8220008B080BD81B000F03F000E",
137 ":1003E4008DF802009DF802000F3000F03F00022853",
138 ":1003F40004D3FFE700208DF8030003E001208DF80B",
139 ":100404000300FFE79DF8030001B070470A000000F5",
140 ":1004140012000000020071001200000066000000DB",
141 ":1004240003007D0C06000000000000000001110123",
142 ":10043400250E1305030E10171B0EB44219110112D9",
143 ":0604440006000002340076",
101 ":1001D4005B02010010000000F40101002C0000008B",
102 ":1001E4003F0201001B0000002B020100130000006D",
103 ":1001F40072656D61696E646572206469766973699C",
104 ":100204006F6E206279207A65726F206F72206E653E",
105 ":100214006761746976652076616C756500636F72D9",
106 ":100224007465782D6D3400696E646578206F75741B",
107 ":10023400206F6620626F756E647300696E74656703",
108 ":1002440065722063617374207472756E6361746582",
109 ":10025400642062697473006469766973696F6E20DF",
110 ":100264006279207A65726F00636F727465785F6D6E",
111 ":100274003400000081B00091FFE700BEFDE7D0B577",
112 ":1002840002AF90B00391029007A800F029F80399F7",
113 ":100294000020069048680490FFE7049906980190AE",
114 ":1002A40088420FD2FFE7019903980068405C07F881",
115 ":1002B400310C17F8311C07A800F021F8019801301F",
116 ":1002C4000690EAE7029807A9B1E80C50A0E80C50A0",
117 ":1002D40091E81C5080E81C5010B0D0BDFFE7FEE749",
118 ":1002E400D0B502AF40F2B011C0F20101B1E80C5038",
119 ":1002F400A0E80C5091E81C5080E81C50D0BD80B59B",
120 ":100304006F4688B006906FF35F2127F80A1C37F810",
121 ":100314000A0C0490012038B9FFE740F2D410C0F26F",
122 ":1003240001000021FFF7A6FF0498C0F3431027F84B",
123 ":10033400020C37F80A0C0390002038B9FFE7039841",
124 ":1003440000F01F000290012038B914E040F2DC10E4",
125 ":10035400C0F201000021FFF78DFF029800F01F009A",
126 ":1003640007F8030C0698009037F8020C0146019137",
127 ":1003740009280ED306E040F2E410C0F20100002187",
128 ":10038400FFF778FF40F2EC10C0F201000021FFF704",
129 ":1003940071FF0099019A51F8220017F803CC012348",
130 ":1003A40003FA0CF3184341F8220008B080BD81B071",
131 ":1003B40000F03F008DF802009DF802000F3000F0BD",
132 ":1003C4003F00022804D3FFE700208DF8030003E078",
133 ":1003D40001208DF80300FFE79DF8030001B070478A",
134 ":1003E4000A00000012000000020071001200000068",
135 ":1003F4006600000003007D0C060000000000000001",
136 ":1004040000011101250E1305030E10171B0EB44233",
137 ":0A0414001911011206000002340065",
144138 ":020000022000DC",
145 ":1002A40081B00091FFE700BEFDE7D0B502AF90B08A",
146 ":1002B4000391029007A800F029F803990020069002",
147 ":1002C40048680490FFE704990698019088420FD289",
148 ":1002D400FFE7019903980068405C07F8310C17F8B0",
149 ":1002E400311C07A800F021F8019801300690EAE7D4",
150 ":1002F400029807A9B1E80C50A0E80C5091E81C50F2",
151 ":1003040080E81C5010B0D0BDFFE7FEE7D0B502AFC7",
152 ":1003140040F2DC11C0F20101B1E80C50A0E80C502D",
153 ":1003240091E81C5080E81C50D0BD80B56F4688B061",
154 ":1003340006906FF35F2127F80A1C37F80A0C049023",
155 ":10034400012038B9FFE740F20020C0F2010000218B",
156 ":10035400FFF7A6FF0498C0F3431027F8020C37F800",
157 ":100364000A0C0390002038B9FFE7039800F01F003F",
158 ":100374000290012038B914E040F20820C0F20100D4",
159 ":100384000021FFF78DFF029800F01F0007F8030C0F",
160 ":100394000698009037F8020C0146019109280ED303",
161 ":1003A40006E040F21020C0F201000021FFF778FFC0",
162 ":1003B40040F21820C0F201000021FFF771FF0099FC",
163 ":1003C400019A51F8220017F803CC012303FA0CF325",
164 ":1003D400184341F8220008B080BD81B000F03F000E",
165 ":1003E4008DF802009DF802000F3000F03F00022853",
166 ":1003F40004D3FFE700208DF8030003E001208DF80B",
167 ":0C0404000300FFE79DF8030001B0704703",
139 ":1002780081B00091FFE700BEFDE7D0B502AF90B0B6",
140 ":100288000391029007A800F029F80399002006902E",
141 ":1002980048680490FFE704990698019088420FD2B5",
142 ":1002A800FFE7019903980068405C07F8310C17F8DC",
143 ":1002B800311C07A800F021F8019801300690EAE700",
144 ":1002C800029807A9B1E80C50A0E80C5091E81C501E",
145 ":1002D80080E81C5010B0D0BDFFE7FEE7D0B502AFF4",
146 ":1002E80040F2B011C0F20101B1E80C50A0E80C5086",
147 ":1002F80091E81C5080E81C50D0BD80B56F4688B08E",
148 ":1003080006906FF35F2127F80A1C37F80A0C04904F",
149 ":10031800012038B9FFE740F2D410C0F201000021F3",
150 ":10032800FFF7A6FF0498C0F3431027F8020C37F82C",
151 ":100338000A0C0390002038B9FFE7039800F01F006B",
152 ":100348000290012038B914E040F2DC10C0F201003C",
153 ":100358000021FFF78DFF029800F01F0007F8030C3B",
154 ":100368000698009037F8020C0146019109280ED32F",
155 ":1003780006E040F2E410C0F201000021FFF778FF28",
156 ":1003880040F2EC10C0F201000021FFF771FF009964",
157 ":10039800019A51F8220017F803CC012303FA0CF351",
158 ":1003A800184341F8220008B080BD81B000F03F003A",
159 ":1003B8008DF802009DF802000F3000F03F0002287F",
160 ":1003C80004D3FFE700208DF8030003E001208DF837",
161 ":0C03D8000300FFE79DF8030001B0704730",
168162 ":00000001FF",
169163 };
170164
test/tests.zig+7-7
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const builtin = std.builtin;
2const builtin = @import("builtin");
33const debug = std.debug;
44const warn = debug.warn;
55const build = std.build;
......@@ -9,7 +9,7 @@ const fs = std.fs;
99const mem = std.mem;
1010const fmt = std.fmt;
1111const ArrayList = std.ArrayList;
12const Mode = builtin.Mode;
12const Mode = std.builtin.Mode;
1313const LibExeObjStep = build.LibExeObjStep;
1414
1515// Cases
......@@ -29,7 +29,7 @@ pub const CompareOutputContext = @import("src/compare_output.zig").CompareOutput
2929
3030const TestTarget = struct {
3131 target: CrossTarget = @as(CrossTarget, .{}),
32 mode: builtin.Mode = .Debug,
32 mode: std.builtin.Mode = .Debug,
3333 link_libc: bool = false,
3434 single_threaded: bool = false,
3535 disable_native: bool = false,
......@@ -532,8 +532,8 @@ pub fn addPkgTests(
532532 continue;
533533
534534 if (test_target.disable_native and
535 test_target.target.getOsTag() == std.Target.current.os.tag and
536 test_target.target.getCpuArch() == std.Target.current.cpu.arch)
535 test_target.target.getOsTag() == builtin.os.tag and
536 test_target.target.getCpuArch() == builtin.cpu.arch)
537537 {
538538 continue;
539539 }
......@@ -785,7 +785,7 @@ pub const StackTracesContext = struct {
785785 if (line.len == 0) continue;
786786
787787 // offset search past `[drive]:` on windows
788 var pos: usize = if (std.Target.current.os.tag == .windows) 2 else 0;
788 var pos: usize = if (builtin.os.tag == .windows) 2 else 0;
789789 // locate delims/anchor
790790 const delims = [_][]const u8{ ":", ":", ":", " in ", "(", ")" };
791791 var marks = [_]usize{0} ** delims.len;
......@@ -1055,7 +1055,7 @@ pub const GenHContext = struct {
10551055 pub fn addCase(self: *GenHContext, case: *const TestCase) void {
10561056 const b = self.b;
10571057
1058 const mode = builtin.Mode.Debug;
1058 const mode = std.builtin.Mode.Debug;
10591059 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {s} ({s})", .{ case.name, @tagName(mode) }) catch unreachable;
10601060 if (self.test_filter) |filter| {
10611061 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
test/translate_c.zig+7-6
......@@ -1,9 +1,10 @@
1const tests = @import("tests.zig");
21const std = @import("std");
2const builtin = @import("builtin");
3const tests = @import("tests.zig");
34const CrossTarget = std.zig.CrossTarget;
45
56pub fn addCases(cases: *tests.TranslateCContext) void {
6 const default_enum_type = if (std.Target.current.abi == .msvc) "c_int" else "c_uint";
7 const default_enum_type = if (builtin.abi == .msvc) "c_int" else "c_uint";
78
89 cases.add("field access is grouped if necessary",
910 \\unsigned long foo(unsigned long x) {
......@@ -1153,7 +1154,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
11531154 \\pub export fn foo() void {}
11541155 });
11551156
1156 if (std.Target.current.os.tag != .windows) {
1157 if (builtin.os.tag != .windows) {
11571158 // Windows treats this as an enum with type c_int
11581159 cases.add("big negative enum init values when C ABI supports long long enums",
11591160 \\enum EnumWithInits {
......@@ -1558,7 +1559,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
15581559 \\}
15591560 });
15601561
1561 if (std.Target.current.os.tag != .windows) {
1562 if (builtin.os.tag != .windows) {
15621563 // sysv_abi not currently supported on windows
15631564 cases.add("Macro qualified functions",
15641565 \\void __attribute__((sysv_abi)) foo(void);
......@@ -2160,7 +2161,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
21602161 \\}
21612162 });
21622163
2163 if (std.Target.current.os.tag != .windows) {
2164 if (builtin.os.tag != .windows) {
21642165 // When clang uses the <arch>-windows-none triple it behaves as MSVC and
21652166 // interprets the inner `struct Bar` as an anonymous structure
21662167 cases.add("type referenced struct",
......@@ -3398,7 +3399,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
33983399 \\pub const FOO = @import("std").zig.c_translation.cast(c_int, @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8000, .hexadecimal));
33993400 });
34003401
3401 if (std.Target.current.abi == .msvc) {
3402 if (builtin.abi == .msvc) {
34023403 cases.add("nameless struct fields",
34033404 \\typedef struct NAMED
34043405 \\{
tools/update_cpu_features.zig+2-1
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23const fs = std.fs;
34const mem = std.mem;
45const json = std.json;
......@@ -803,7 +804,7 @@ pub fn main() anyerror!void {
803804 const root_progress = try progress.start("", llvm_targets.len);
804805 defer root_progress.end();
805806
806 if (std.builtin.single_threaded) {
807 if (builtin.single_threaded) {
807808 for (llvm_targets) |llvm_target| {
808809 try processOneTarget(Job{
809810 .llvm_tblgen_exe = llvm_tblgen_exe,