| author | |
| committer | |
| log | 6115cf22404467fd13d0290fc022d51d372d139a |
| tree | 26c0bab951c81e89b5f0edcc5dc9f4b8e64df7db |
| parent | 78902db68bbd400f6d84b65280c31d417105f2a8 |
closes #9388
closes #9321147 files changed, 624 insertions(+), 596 deletions(-)
doc/docgen.zig+2-2| ... | ... | @@ -1334,7 +1334,7 @@ fn genHtml( |
| 1334 | 1334 | if (mem.startsWith(u8, triple, "wasm32") or |
| 1335 | 1335 | mem.startsWith(u8, triple, "riscv64-linux") or |
| 1336 | 1336 | (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)) | |
| 1338 | 1338 | { |
| 1339 | 1339 | // skip execution |
| 1340 | 1340 | break :code_block; |
| ... | ... | @@ -1602,7 +1602,7 @@ fn genHtml( |
| 1602 | 1602 | Code.Id.Lib => { |
| 1603 | 1603 | const bin_basename = try std.zig.binNameAlloc(allocator, .{ |
| 1604 | 1604 | .root_name = code.name, |
| 1605 | .target = std.Target.current, | |
| 1605 | .target = builtin.target, | |
| 1606 | 1606 | .output_mode = .Lib, |
| 1607 | 1607 | }); |
| 1608 | 1608 |
doc/langref.html.in+7-4| ... | ... | @@ -2681,6 +2681,7 @@ test "pointer child type" { |
| 2681 | 2681 | </p> |
| 2682 | 2682 | {#code_begin|test|variable_alignment#} |
| 2683 | 2683 | const std = @import("std"); |
| 2684 | const builtin = @import("builtin"); | |
| 2684 | 2685 | const expect = std.testing.expect; |
| 2685 | 2686 | |
| 2686 | 2687 | test "variable alignment" { |
| ... | ... | @@ -2688,7 +2689,7 @@ test "variable alignment" { |
| 2688 | 2689 | const align_of_i32 = @alignOf(@TypeOf(x)); |
| 2689 | 2690 | try expect(@TypeOf(&x) == *i32); |
| 2690 | 2691 | 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) { | |
| 2692 | 2693 | try expect(@typeInfo(*i32).Pointer.alignment == 4); |
| 2693 | 2694 | } |
| 2694 | 2695 | } |
| ... | ... | @@ -3878,6 +3879,7 @@ test "separate scopes" { |
| 3878 | 3879 | {#header_open|switch#} |
| 3879 | 3880 | {#code_begin|test|switch#} |
| 3880 | 3881 | const std = @import("std"); |
| 3882 | const builtin = @import("builtin"); | |
| 3881 | 3883 | const expect = std.testing.expect; |
| 3882 | 3884 | |
| 3883 | 3885 | test "switch simple" { |
| ... | ... | @@ -3922,7 +3924,7 @@ test "switch simple" { |
| 3922 | 3924 | } |
| 3923 | 3925 | |
| 3924 | 3926 | // Switch expressions can be used outside a function: |
| 3925 | const os_msg = switch (std.Target.current.os.tag) { | |
| 3927 | const os_msg = switch (builtin.target.os.tag) { | |
| 3926 | 3928 | .linux => "we found a linux user", |
| 3927 | 3929 | else => "not a linux user", |
| 3928 | 3930 | }; |
| ... | ... | @@ -3930,7 +3932,7 @@ const os_msg = switch (std.Target.current.os.tag) { |
| 3930 | 3932 | // Inside a function, switch statements implicitly are compile-time |
| 3931 | 3933 | // evaluated if the target expression is compile-time known. |
| 3932 | 3934 | test "switch inside function" { |
| 3933 | switch (std.Target.current.os.tag) { | |
| 3935 | switch (builtin.target.os.tag) { | |
| 3934 | 3936 | .fuchsia => { |
| 3935 | 3937 | // On an OS other than fuchsia, block is not even analyzed, |
| 3936 | 3938 | // so this compile error is not triggered. |
| ... | ... | @@ -5690,6 +5692,7 @@ test "cast *[1][*]const u8 to [*]const ?[*]const u8" { |
| 5690 | 5692 | </p> |
| 5691 | 5693 | {#code_begin|test|test_integer_widening#} |
| 5692 | 5694 | const std = @import("std"); |
| 5695 | const builtin = @import("builtin"); | |
| 5693 | 5696 | const expect = std.testing.expect; |
| 5694 | 5697 | const mem = std.mem; |
| 5695 | 5698 | |
| ... | ... | @@ -5712,7 +5715,7 @@ test "implicit unsigned integer to signed integer" { |
| 5712 | 5715 | test "float widening" { |
| 5713 | 5716 | // Note: there is an open issue preventing this from working on aarch64: |
| 5714 | 5717 | // 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; | |
| 5716 | 5719 | |
| 5717 | 5720 | var a: f16 = 12.34; |
| 5718 | 5721 | var b: f32 = a; |
lib/std/Progress.zig+4-3| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | //! * `initial_delay_ms` |
| 8 | 8 | |
| 9 | 9 | const std = @import("std"); |
| 10 | const builtin = @import("builtin"); | |
| 10 | 11 | const windows = std.os.windows; |
| 11 | 12 | const testing = std.testing; |
| 12 | 13 | const assert = std.debug.assert; |
| ... | ... | @@ -144,10 +145,10 @@ pub fn start(self: *Progress, name: []const u8, estimated_total_items: usize) !* |
| 144 | 145 | if (stderr.supportsAnsiEscapeCodes()) { |
| 145 | 146 | self.terminal = stderr; |
| 146 | 147 | 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()) { | |
| 148 | 149 | self.is_windows_terminal = true; |
| 149 | 150 | self.terminal = stderr; |
| 150 | } else if (std.builtin.os.tag != .windows) { | |
| 151 | } else if (builtin.os.tag != .windows) { | |
| 151 | 152 | // we are in a "dumb" terminal like in acme or writing to a file |
| 152 | 153 | self.terminal = stderr; |
| 153 | 154 | } |
| ... | ... | @@ -200,7 +201,7 @@ fn refreshWithHeldLock(self: *Progress) void { |
| 200 | 201 | if (self.supports_ansi_escape_codes) { |
| 201 | 202 | end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{d}D", .{self.columns_written}) catch unreachable).len; |
| 202 | 203 | 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: { | |
| 204 | 205 | std.debug.assert(self.is_windows_terminal); |
| 205 | 206 | |
| 206 | 207 | var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; |
lib/std/Thread/AutoResetEvent.zig+1-1| ... | ... | @@ -26,7 +26,7 @@ |
| 26 | 26 | state: usize = UNSET, |
| 27 | 27 | |
| 28 | 28 | const std = @import("../std.zig"); |
| 29 | const builtin = std.builtin; | |
| 29 | const builtin = @import("builtin"); | |
| 30 | 30 | const testing = std.testing; |
| 31 | 31 | const assert = std.debug.assert; |
| 32 | 32 | const StaticResetEvent = std.Thread.StaticResetEvent; |
lib/std/Thread/Condition.zig+5-4| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | impl: Impl = .{}, |
| 6 | 6 | |
| 7 | 7 | const std = @import("../std.zig"); |
| 8 | const builtin = @import("builtin"); | |
| 8 | 9 | const Condition = @This(); |
| 9 | 10 | const windows = std.os.windows; |
| 10 | 11 | const linux = std.os.linux; |
| ... | ... | @@ -23,9 +24,9 @@ pub fn broadcast(cond: *Condition) void { |
| 23 | 24 | cond.impl.broadcast(); |
| 24 | 25 | } |
| 25 | 26 | |
| 26 | const Impl = if (std.builtin.single_threaded) | |
| 27 | const Impl = if (builtin.single_threaded) | |
| 27 | 28 | SingleThreadedCondition |
| 28 | else if (std.Target.current.os.tag == .windows) | |
| 29 | else if (builtin.os.tag == .windows) | |
| 29 | 30 | WindowsCondition |
| 30 | 31 | else if (std.Thread.use_pthreads) |
| 31 | 32 | PthreadCondition |
| ... | ... | @@ -101,7 +102,7 @@ pub const AtomicCondition = struct { |
| 101 | 102 | |
| 102 | 103 | fn wait(cond: *@This()) void { |
| 103 | 104 | while (@atomicLoad(i32, &cond.futex, .Acquire) == 0) { |
| 104 | switch (std.Target.current.os.tag) { | |
| 105 | switch (builtin.os.tag) { | |
| 105 | 106 | .linux => { |
| 106 | 107 | switch (linux.getErrno(linux.futex_wait( |
| 107 | 108 | &cond.futex, |
| ... | ... | @@ -123,7 +124,7 @@ pub const AtomicCondition = struct { |
| 123 | 124 | fn notify(cond: *@This()) void { |
| 124 | 125 | @atomicStore(i32, &cond.futex, 1, .Release); |
| 125 | 126 | |
| 126 | switch (std.Target.current.os.tag) { | |
| 127 | switch (builtin.os.tag) { | |
| 127 | 128 | .linux => { |
| 128 | 129 | switch (linux.getErrno(linux.futex_wake( |
| 129 | 130 | &cond.futex, |
lib/std/Thread/Futex.zig+4-3| ... | ... | @@ -4,10 +4,11 @@ |
| 4 | 4 | //! Using Futex, other Thread synchronization primitives can be built which efficiently wait for cross-thread events or signals. |
| 5 | 5 | |
| 6 | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | |
| 7 | 8 | const Futex = @This(); |
| 8 | 9 | |
| 9 | const target = std.Target.current; | |
| 10 | const single_threaded = std.builtin.single_threaded; | |
| 10 | const target = builtin.target; | |
| 11 | const single_threaded = builtin.single_threaded; | |
| 11 | 12 | |
| 12 | 13 | const assert = std.debug.assert; |
| 13 | 14 | const testing = std.testing; |
| ... | ... | @@ -70,7 +71,7 @@ else if (target.os.tag == .linux) |
| 70 | 71 | LinuxFutex |
| 71 | 72 | else if (target.isDarwin()) |
| 72 | 73 | DarwinFutex |
| 73 | else if (std.builtin.link_libc) | |
| 74 | else if (builtin.link_libc) | |
| 74 | 75 | PosixFutex |
| 75 | 76 | else |
| 76 | 77 | UnsupportedFutex; |
lib/std/Thread/Mutex.zig+3-3| ... | ... | @@ -24,7 +24,7 @@ impl: Impl = .{}, |
| 24 | 24 | |
| 25 | 25 | const Mutex = @This(); |
| 26 | 26 | const std = @import("../std.zig"); |
| 27 | const builtin = std.builtin; | |
| 27 | const builtin = @import("builtin"); | |
| 28 | 28 | const os = std.os; |
| 29 | 29 | const assert = std.debug.assert; |
| 30 | 30 | const windows = os.windows; |
| ... | ... | @@ -160,7 +160,7 @@ pub const AtomicMutex = struct { |
| 160 | 160 | .unlocked => return, |
| 161 | 161 | else => {}, |
| 162 | 162 | } |
| 163 | switch (std.Target.current.os.tag) { | |
| 163 | switch (builtin.os.tag) { | |
| 164 | 164 | .linux => { |
| 165 | 165 | switch (linux.getErrno(linux.futex_wait( |
| 166 | 166 | @ptrCast(*const i32, &m.state), |
| ... | ... | @@ -182,7 +182,7 @@ pub const AtomicMutex = struct { |
| 182 | 182 | fn unlockSlow(m: *AtomicMutex) void { |
| 183 | 183 | @setCold(true); |
| 184 | 184 | |
| 185 | switch (std.Target.current.os.tag) { | |
| 185 | switch (builtin.os.tag) { | |
| 186 | 186 | .linux => { |
| 187 | 187 | switch (linux.getErrno(linux.futex_wake( |
| 188 | 188 | @ptrCast(*const i32, &m.state), |
lib/std/Thread/ResetEvent.zig+2-2| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | |
| 9 | 9 | const ResetEvent = @This(); |
| 10 | 10 | const std = @import("../std.zig"); |
| 11 | const builtin = std.builtin; | |
| 11 | const builtin = @import("builtin"); | |
| 12 | 12 | const testing = std.testing; |
| 13 | 13 | const assert = std.debug.assert; |
| 14 | 14 | const c = std.c; |
| ... | ... | @@ -19,7 +19,7 @@ impl: Impl, |
| 19 | 19 | |
| 20 | 20 | pub const Impl = if (builtin.single_threaded) |
| 21 | 21 | std.Thread.StaticResetEvent.DebugEvent |
| 22 | else if (std.Target.current.isDarwin()) | |
| 22 | else if (builtin.target.isDarwin()) | |
| 23 | 23 | DarwinEvent |
| 24 | 24 | else if (std.Thread.use_pthreads) |
| 25 | 25 | PosixEvent |
lib/std/Thread/StaticResetEvent.zig+4-3| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | //! the logic needs stronger API guarantees. |
| 9 | 9 | |
| 10 | 10 | const std = @import("../std.zig"); |
| 11 | const builtin = @import("builtin"); | |
| 11 | 12 | const StaticResetEvent = @This(); |
| 12 | 13 | const assert = std.debug.assert; |
| 13 | 14 | const os = std.os; |
| ... | ... | @@ -18,7 +19,7 @@ const testing = std.testing; |
| 18 | 19 | |
| 19 | 20 | impl: Impl = .{}, |
| 20 | 21 | |
| 21 | pub const Impl = if (std.builtin.single_threaded) | |
| 22 | pub const Impl = if (builtin.single_threaded) | |
| 22 | 23 | DebugEvent |
| 23 | 24 | else |
| 24 | 25 | AtomicEvent; |
| ... | ... | @@ -162,7 +163,7 @@ pub const AtomicEvent = struct { |
| 162 | 163 | @atomicStore(u32, &ev.waiters, 0, .Monotonic); |
| 163 | 164 | } |
| 164 | 165 | |
| 165 | pub const Futex = switch (std.Target.current.os.tag) { | |
| 166 | pub const Futex = switch (builtin.os.tag) { | |
| 166 | 167 | .windows => WindowsFutex, |
| 167 | 168 | .linux => LinuxFutex, |
| 168 | 169 | else => SpinFutex, |
| ... | ... | @@ -322,7 +323,7 @@ test "basic usage" { |
| 322 | 323 | try testing.expectEqual(TimedWaitResult.event_set, event.timedWait(1)); |
| 323 | 324 | |
| 324 | 325 | // test cross-thread signaling |
| 325 | if (std.builtin.single_threaded) | |
| 326 | if (builtin.single_threaded) | |
| 326 | 327 | return; |
| 327 | 328 | |
| 328 | 329 | const Context = struct { |
lib/std/array_hash_map.zig-1| ... | ... | @@ -9,7 +9,6 @@ const trait = meta.trait; |
| 9 | 9 | const autoHash = std.hash.autoHash; |
| 10 | 10 | const Wyhash = std.hash.Wyhash; |
| 11 | 11 | const Allocator = mem.Allocator; |
| 12 | const builtin = std.builtin; | |
| 13 | 12 | const hash_map = @This(); |
| 14 | 13 | |
| 15 | 14 | /// An ArrayHashMap with default hash and equal functions. |
lib/std/atomic.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const target = std.Target.current; | |
| 2 | const target = @import("builtin").target; | |
| 3 | 3 | |
| 4 | 4 | pub const Ordering = std.builtin.AtomicOrder; |
| 5 | 5 |
lib/std/atomic/Atomic.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | 2 | |
| 3 | 3 | const testing = std.testing; |
| 4 | const target = std.Target.current; | |
| 4 | const target = @import("builtin").target; | |
| 5 | 5 | const Ordering = std.atomic.Ordering; |
| 6 | 6 | |
| 7 | 7 | pub fn Atomic(comptime T: type) type { |
lib/std/atomic/queue.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | 4 | const expect = std.testing.expect; |
| 5 | 5 |
lib/std/atomic/stack.zig+2-2| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("../std.zig"); | |
| 2 | const builtin = @import("builtin"); | |
| 1 | 3 | const assert = std.debug.assert; |
| 2 | const builtin = std.builtin; | |
| 3 | 4 | const expect = std.testing.expect; |
| 4 | 5 | |
| 5 | 6 | /// Many reader, many writer, non-allocating, thread-safe |
| ... | ... | @@ -67,7 +68,6 @@ pub fn Stack(comptime T: type) type { |
| 67 | 68 | }; |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | const std = @import("../std.zig"); | |
| 71 | 71 | const Context = struct { |
| 72 | 72 | allocator: *std.mem.Allocator, |
| 73 | 73 | stack: *Stack(i32), |
lib/std/build.zig+21-21| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const io = std.io; |
| 4 | 4 | const fs = std.fs; |
| 5 | 5 | const mem = std.mem; |
| ... | ... | @@ -62,7 +62,7 @@ pub const Builder = struct { |
| 62 | 62 | build_root: []const u8, |
| 63 | 63 | cache_root: []const u8, |
| 64 | 64 | global_cache_root: []const u8, |
| 65 | release_mode: ?builtin.Mode, | |
| 65 | release_mode: ?std.builtin.Mode, | |
| 66 | 66 | is_release: bool, |
| 67 | 67 | override_lib_dir: ?[]const u8, |
| 68 | 68 | vcpkg_root: VcpkgRoot, |
| ... | ... | @@ -633,18 +633,18 @@ pub const Builder = struct { |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /// 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 { | |
| 637 | 637 | if (self.release_mode != null) { |
| 638 | 638 | @panic("setPreferredReleaseMode must be called before standardReleaseOptions and may not be called twice"); |
| 639 | 639 | } |
| 640 | 640 | const description = self.fmt("Create a release build ({s})", .{@tagName(mode)}); |
| 641 | 641 | 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; | |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /// If you call this without first calling `setPreferredReleaseMode` then it gives the build user |
| 646 | 646 | /// the choice of what kind of release. |
| 647 | pub fn standardReleaseOptions(self: *Builder) builtin.Mode { | |
| 647 | pub fn standardReleaseOptions(self: *Builder) std.builtin.Mode { | |
| 648 | 648 | if (self.release_mode) |mode| return mode; |
| 649 | 649 | |
| 650 | 650 | const release_safe = self.option(bool, "release-safe", "Optimizations on and safety on") orelse false; |
| ... | ... | @@ -652,17 +652,17 @@ pub const Builder = struct { |
| 652 | 652 | const release_small = self.option(bool, "release-small", "Size optimizations on and safety off") orelse false; |
| 653 | 653 | |
| 654 | 654 | const mode = if (release_safe and !release_fast and !release_small) |
| 655 | builtin.Mode.ReleaseSafe | |
| 655 | std.builtin.Mode.ReleaseSafe | |
| 656 | 656 | else if (release_fast and !release_safe and !release_small) |
| 657 | builtin.Mode.ReleaseFast | |
| 657 | std.builtin.Mode.ReleaseFast | |
| 658 | 658 | else if (release_small and !release_fast and !release_safe) |
| 659 | builtin.Mode.ReleaseSmall | |
| 659 | std.builtin.Mode.ReleaseSmall | |
| 660 | 660 | else if (!release_fast and !release_safe and !release_small) |
| 661 | builtin.Mode.Debug | |
| 661 | std.builtin.Mode.Debug | |
| 662 | 662 | else x: { |
| 663 | 663 | warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)\n\n", .{}); |
| 664 | 664 | self.markInvalidUserInput(); |
| 665 | break :x builtin.Mode.Debug; | |
| 665 | break :x std.builtin.Mode.Debug; | |
| 666 | 666 | }; |
| 667 | 667 | self.is_release = mode != .Debug; |
| 668 | 668 | self.release_mode = mode; |
| ... | ... | @@ -1290,7 +1290,7 @@ test "builder.findProgram compiles" { |
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | /// Deprecated. Use `std.builtin.Version`. |
| 1293 | pub const Version = builtin.Version; | |
| 1293 | pub const Version = std.builtin.Version; | |
| 1294 | 1294 | |
| 1295 | 1295 | /// Deprecated. Use `std.zig.CrossTarget`. |
| 1296 | 1296 | pub const Target = std.zig.CrossTarget; |
| ... | ... | @@ -1417,8 +1417,8 @@ pub const LibExeObjStep = struct { |
| 1417 | 1417 | version_script: ?[]const u8 = null, |
| 1418 | 1418 | out_filename: []const u8, |
| 1419 | 1419 | linkage: ?Linkage = null, |
| 1420 | version: ?Version, | |
| 1421 | build_mode: builtin.Mode, | |
| 1420 | version: ?std.builtin.Version, | |
| 1421 | build_mode: std.builtin.Mode, | |
| 1422 | 1422 | kind: Kind, |
| 1423 | 1423 | major_only_filename: ?[]const u8, |
| 1424 | 1424 | name_only_filename: ?[]const u8, |
| ... | ... | @@ -1447,8 +1447,8 @@ pub const LibExeObjStep = struct { |
| 1447 | 1447 | filter: ?[]const u8, |
| 1448 | 1448 | single_threaded: bool, |
| 1449 | 1449 | 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, | |
| 1452 | 1452 | |
| 1453 | 1453 | root_src: ?FileSource, |
| 1454 | 1454 | out_h_filename: []const u8, |
| ... | ... | @@ -1550,7 +1550,7 @@ pub const LibExeObjStep = struct { |
| 1550 | 1550 | }; |
| 1551 | 1551 | |
| 1552 | 1552 | const SharedLibKind = union(enum) { |
| 1553 | versioned: Version, | |
| 1553 | versioned: std.builtin.Version, | |
| 1554 | 1554 | unversioned: void, |
| 1555 | 1555 | }; |
| 1556 | 1556 | |
| ... | ... | @@ -1585,7 +1585,7 @@ pub const LibExeObjStep = struct { |
| 1585 | 1585 | root_src_raw: ?FileSource, |
| 1586 | 1586 | kind: Kind, |
| 1587 | 1587 | linkage: ?Linkage, |
| 1588 | ver: ?Version, | |
| 1588 | ver: ?std.builtin.Version, | |
| 1589 | 1589 | ) *LibExeObjStep { |
| 1590 | 1590 | const name = builder.dupe(name_raw); |
| 1591 | 1591 | const root_src: ?FileSource = if (root_src_raw) |rsrc| rsrc.dupe(builder) else null; |
| ... | ... | @@ -1599,7 +1599,7 @@ pub const LibExeObjStep = struct { |
| 1599 | 1599 | .builder = builder, |
| 1600 | 1600 | .verbose_link = false, |
| 1601 | 1601 | .verbose_cc = false, |
| 1602 | .build_mode = builtin.Mode.Debug, | |
| 1602 | .build_mode = std.builtin.Mode.Debug, | |
| 1603 | 1603 | .linkage = linkage, |
| 1604 | 1604 | .kind = kind, |
| 1605 | 1605 | .root_src = root_src, |
| ... | ... | @@ -1988,7 +1988,7 @@ pub const LibExeObjStep = struct { |
| 1988 | 1988 | self.verbose_cc = value; |
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | pub fn setBuildMode(self: *LibExeObjStep, mode: builtin.Mode) void { | |
| 1991 | pub fn setBuildMode(self: *LibExeObjStep, mode: std.builtin.Mode) void { | |
| 1992 | 1992 | self.build_mode = mode; |
| 1993 | 1993 | } |
| 1994 | 1994 | |
| ... | ... | @@ -2553,7 +2553,7 @@ pub const LibExeObjStep = struct { |
| 2553 | 2553 | |
| 2554 | 2554 | const resolved_include_path = self.builder.pathFromRoot(include_path); |
| 2555 | 2555 | |
| 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: { | |
| 2557 | 2557 | // We need to check for disk designator and strip it out from dir path so |
| 2558 | 2558 | // that zig/clang can concat resolved_include_path with sysroot. |
| 2559 | 2559 | const disk_designator = fs.path.diskDesignatorWindows(resolved_include_path); |
| ... | ... | @@ -3237,7 +3237,7 @@ test "LibExeObjStep.addPackage" { |
| 3237 | 3237 | test { |
| 3238 | 3238 | // The only purpose of this test is to get all these untested functions |
| 3239 | 3239 | // 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) { | |
| 3241 | 3241 | std.testing.refAllDecls(@This()); |
| 3242 | 3242 | std.testing.refAllDecls(Builder); |
| 3243 | 3243 |
lib/std/build/OptionsStep.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const build = std.build; |
| 3 | 4 | const fs = std.fs; |
| 4 | 5 | const Step = build.Step; |
| ... | ... | @@ -219,7 +220,7 @@ const OptionFileSourceArg = struct { |
| 219 | 220 | }; |
| 220 | 221 | |
| 221 | 222 | test "OptionsStep" { |
| 222 | if (std.builtin.os.tag == .wasi) return error.SkipZigTest; | |
| 223 | if (builtin.os.tag == .wasi) return error.SkipZigTest; | |
| 223 | 224 | |
| 224 | 225 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 225 | 226 | defer arena.deinit(); |
lib/std/build/RunStep.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const build = std.build; |
| 4 | 4 | const Step = build.Step; |
| 5 | 5 | const Builder = build.Builder; |
lib/std/builtin.zig+23-22| ... | ... | @@ -1,26 +1,27 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | |
| 3 | // These are all deprecated. | |
| 4 | pub const zig_version = builtin.zig_version; | |
| 5 | pub const zig_is_stage2 = builtin.zig_is_stage2; | |
| 6 | pub const output_mode = builtin.output_mode; | |
| 7 | pub const link_mode = builtin.link_mode; | |
| 8 | pub const is_test = builtin.is_test; | |
| 9 | pub const single_threaded = builtin.single_threaded; | |
| 10 | pub const abi = builtin.abi; | |
| 11 | pub const cpu = builtin.cpu; | |
| 12 | pub const os = builtin.os; | |
| 13 | pub const target = builtin.target; | |
| 14 | pub const object_format = builtin.object_format; | |
| 15 | pub const mode = builtin.mode; | |
| 16 | pub const link_libc = builtin.link_libc; | |
| 17 | pub const link_libcpp = builtin.link_libcpp; | |
| 18 | pub const have_error_return_tracing = builtin.have_error_return_tracing; | |
| 19 | pub const valgrind_support = builtin.valgrind_support; | |
| 20 | pub const position_independent_code = builtin.position_independent_code; | |
| 21 | pub const position_independent_executable = builtin.position_independent_executable; | |
| 22 | pub const strip_debug_info = builtin.strip_debug_info; | |
| 23 | pub const code_model = builtin.code_model; | |
| 3 | // TODO delete these after releasing 0.9.0 | |
| 4 | ||
| 5 | pub const zig_version = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 6 | pub const zig_is_stage2 = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 7 | pub const output_mode = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 8 | pub const link_mode = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 9 | pub const is_test = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 10 | pub const single_threaded = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 11 | pub const abi = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 12 | pub const cpu = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 13 | pub const os = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 14 | pub const target = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 15 | pub const object_format = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 16 | pub const mode = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 17 | pub const link_libc = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 18 | pub const link_libcpp = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 19 | pub const have_error_return_tracing = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 20 | pub const valgrind_support = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 21 | pub const position_independent_code = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 22 | pub const position_independent_executable = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 23 | pub const strip_debug_info = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 24 | pub const code_model = @compileError("get this from @import(\"builtin\") instead of std.builtin"); | |
| 24 | 25 | |
| 25 | 26 | /// `explicit_subsystem` is missing when the subsystem is automatically detected, |
| 26 | 27 | /// 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 |
| 694 | 695 | @breakpoint(); |
| 695 | 696 | } |
| 696 | 697 | } |
| 697 | switch (os.tag) { | |
| 698 | switch (builtin.os.tag) { | |
| 698 | 699 | .freestanding => { |
| 699 | 700 | while (true) { |
| 700 | 701 | @breakpoint(); |
lib/std/c.zig+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const c = @This(); |
| 4 | 4 | const page_size = std.mem.page_size; |
| 5 | 5 | const iovec = std.os.iovec; |
| ... | ... | @@ -20,7 +20,7 @@ pub const Tokenizer = tokenizer.Tokenizer; |
| 20 | 20 | /// If linking gnu libc (glibc), the `ok` value will be true if the target |
| 21 | 21 | /// version is greater than or equal to `glibc_version`. |
| 22 | 22 | /// If linking a libc other than these, returns `false`. |
| 23 | pub fn versionCheck(glibc_version: builtin.Version) type { | |
| 23 | pub fn versionCheck(glibc_version: std.builtin.Version) type { | |
| 24 | 24 | return struct { |
| 25 | 25 | pub const ok = blk: { |
| 26 | 26 | if (!builtin.link_libc) break :blk false; |
lib/std/c/darwin.zig+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const assert = std.debug.assert; | |
| 3 | 2 | const builtin = @import("builtin"); |
| 3 | const assert = std.debug.assert; | |
| 4 | 4 | const macho = std.macho; |
| 5 | 5 | const native_arch = builtin.target.cpu.arch; |
| 6 | 6 | const maxInt = std.math.maxInt; |
| ... | ... | @@ -72,7 +72,7 @@ const mach_hdr = if (@sizeOf(usize) == 8) mach_header_64 else mach_header; |
| 72 | 72 | var dummy_execute_header: mach_hdr = undefined; |
| 73 | 73 | pub extern var _mh_execute_header: mach_hdr; |
| 74 | 74 | comptime { |
| 75 | if (std.Target.current.isDarwin()) { | |
| 75 | if (builtin.target.isDarwin()) { | |
| 76 | 76 | @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .Weak }); |
| 77 | 77 | } |
| 78 | 78 | } |
lib/std/child_process.zig+4-4| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const cstr = std.cstr; |
| 3 | 4 | const unicode = std.unicode; |
| 4 | 5 | const io = std.io; |
| ... | ... | @@ -12,8 +13,7 @@ const mem = std.mem; |
| 12 | 13 | const math = std.math; |
| 13 | 14 | const debug = std.debug; |
| 14 | 15 | const BufMap = std.BufMap; |
| 15 | const builtin = std.builtin; | |
| 16 | const Os = builtin.Os; | |
| 16 | const Os = std.builtin.Os; | |
| 17 | 17 | const TailQueue = std.TailQueue; |
| 18 | 18 | const maxInt = std.math.maxInt; |
| 19 | 19 | const assert = std.debug.assert; |
| ... | ... | @@ -561,9 +561,9 @@ pub const ChildProcess = struct { |
| 561 | 561 | if (self.env_map) |env_map| { |
| 562 | 562 | const envp_buf = try createNullDelimitedEnvMap(arena, env_map); |
| 563 | 563 | break :m envp_buf.ptr; |
| 564 | } else if (std.builtin.link_libc) { | |
| 564 | } else if (builtin.link_libc) { | |
| 565 | 565 | break :m std.c.environ; |
| 566 | } else if (std.builtin.output_mode == .Exe) { | |
| 566 | } else if (builtin.output_mode == .Exe) { | |
| 567 | 567 | // Then we have Zig start code and this works. |
| 568 | 568 | // TODO type-safety for null-termination of `os.environ`. |
| 569 | 569 | break :m @ptrCast([*:null]?[*:0]u8, os.environ.ptr); |
lib/std/coff.zig-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | const builtin = std.builtin; | |
| 2 | 1 | const std = @import("std.zig"); |
| 3 | 2 | const io = std.io; |
| 4 | 3 | const mem = std.mem; |
lib/std/crypto.zig+1-1| ... | ... | @@ -163,7 +163,7 @@ const std = @import("std.zig"); |
| 163 | 163 | pub const errors = @import("crypto/errors.zig"); |
| 164 | 164 | |
| 165 | 165 | test "crypto" { |
| 166 | const please_windows_dont_oom = std.Target.current.os.tag == .windows; | |
| 166 | const please_windows_dont_oom = @import("builtin").os.tag == .windows; | |
| 167 | 167 | if (please_windows_dont_oom) return error.SkipZigTest; |
| 168 | 168 | |
| 169 | 169 | inline for (std.meta.declarations(@This())) |decl| { |
lib/std/crypto/aes.zig+7-7| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const testing = std.testing; |
| 3 | const builtin = std.builtin; | |
| 4 | 4 | |
| 5 | const has_aesni = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes); | |
| 6 | const has_avx = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx); | |
| 7 | const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes); | |
| 8 | const impl = if (std.Target.current.cpu.arch == .x86_64 and has_aesni and has_avx) impl: { | |
| 5 | const has_aesni = std.Target.x86.featureSetHas(builtin.cpu.features, .aes); | |
| 6 | const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx); | |
| 7 | const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes); | |
| 8 | const impl = if (builtin.cpu.arch == .x86_64 and has_aesni and has_avx) impl: { | |
| 9 | 9 | 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) | |
| 11 | 11 | impl: { |
| 12 | 12 | break :impl @import("aes/armcrypto.zig"); |
| 13 | 13 | } else impl: { |
| ... | ... | @@ -41,7 +41,7 @@ test "ctr" { |
| 41 | 41 | |
| 42 | 42 | var out: [exp_out.len]u8 = undefined; |
| 43 | 43 | 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); | |
| 45 | 45 | try testing.expectEqualSlices(u8, exp_out[0..], out[0..]); |
| 46 | 46 | } |
| 47 | 47 |
lib/std/crypto/aes/aesni.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const debug = std.debug; |
| 4 | 5 | const Vector = std.meta.Vector; |
| ... | ... | @@ -97,7 +98,7 @@ pub const Block = struct { |
| 97 | 98 | const cpu = std.Target.x86.cpu; |
| 98 | 99 | |
| 99 | 100 | /// 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) { | |
| 101 | 102 | &cpu.westmere => 6, |
| 102 | 103 | &cpu.sandybridge, &cpu.ivybridge => 8, |
| 103 | 104 | &cpu.haswell, &cpu.broadwell => 7, |
lib/std/crypto/aes_gcm.zig+2-3| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const assert = std.debug.assert; |
| 3 | const builtin = std.builtin; | |
| 4 | 3 | const crypto = std.crypto; |
| 5 | 4 | const debug = std.debug; |
| 6 | 5 | const Ghash = std.crypto.onetimeauth.Ghash; |
| ... | ... | @@ -40,7 +39,7 @@ fn AesGcm(comptime Aes: anytype) type { |
| 40 | 39 | mac.pad(); |
| 41 | 40 | |
| 42 | 41 | 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); | |
| 44 | 43 | mac.update(c[0..m.len][0..]); |
| 45 | 44 | mac.pad(); |
| 46 | 45 | |
| ... | ... | @@ -94,7 +93,7 @@ fn AesGcm(comptime Aes: anytype) type { |
| 94 | 93 | } |
| 95 | 94 | |
| 96 | 95 | 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); | |
| 98 | 97 | } |
| 99 | 98 | }; |
| 100 | 99 | } |
lib/std/crypto/aes_ocb.zig+4-3| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const crypto = std.crypto; |
| 3 | 4 | const aes = crypto.core.aes; |
| 4 | 5 | const assert = std.debug.assert; |
| ... | ... | @@ -100,9 +101,9 @@ fn AesOcb(comptime Aes: anytype) type { |
| 100 | 101 | return offset; |
| 101 | 102 | } |
| 102 | 103 | |
| 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; | |
| 106 | 107 | |
| 107 | 108 | /// c: ciphertext: output buffer should be of size m.len |
| 108 | 109 | /// tag: authentication tag: output MAC |
lib/std/crypto/benchmark.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | // zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig |
| 2 | 2 | |
| 3 | 3 | const std = @import("../std.zig"); |
| 4 | const builtin = std.builtin; | |
| 4 | const builtin = @import("builtin"); | |
| 5 | 5 | const mem = std.mem; |
| 6 | 6 | const time = std.time; |
| 7 | 7 | const Timer = time.Timer; |
lib/std/crypto/blake3.zig+2-1| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | // Source: https://github.com/BLAKE3-team/BLAKE3 |
| 3 | 3 | |
| 4 | 4 | const std = @import("../std.zig"); |
| 5 | const builtin = @import("builtin"); | |
| 5 | 6 | const fmt = std.fmt; |
| 6 | 7 | const math = std.math; |
| 7 | 8 | const mem = std.mem; |
| ... | ... | @@ -200,7 +201,7 @@ const CompressGeneric = struct { |
| 200 | 201 | } |
| 201 | 202 | }; |
| 202 | 203 | |
| 203 | const compress = if (std.Target.current.cpu.arch == .x86_64) CompressVectorized.compress else CompressGeneric.compress; | |
| 204 | const compress = if (builtin.cpu.arch == .x86_64) CompressVectorized.compress else CompressGeneric.compress; | |
| 204 | 205 | |
| 205 | 206 | fn first8Words(words: [16]u32) [8]u32 { |
| 206 | 207 | return @ptrCast(*const [8]u32, &words).*; |
lib/std/crypto/chacha20.zig+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | // Based on public domain Supercop by Daniel J. Bernstein |
| 2 | 2 | |
| 3 | 3 | const std = @import("../std.zig"); |
| 4 | const builtin = @import("builtin"); | |
| 4 | 5 | const math = std.math; |
| 5 | 6 | const mem = std.mem; |
| 6 | 7 | const assert = std.debug.assert; |
| ... | ... | @@ -359,7 +360,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type { |
| 359 | 360 | } |
| 360 | 361 | |
| 361 | 362 | fn 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); | |
| 363 | 364 | } |
| 364 | 365 | |
| 365 | 366 | fn keyToWords(key: [32]u8) [8]u32 { |
lib/std/crypto/ghash.zig+8-7| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | // Adapted from BearSSL's ctmul64 implementation originally written by Thomas Pornin <pornin@bolet.org> |
| 3 | 3 | |
| 4 | 4 | const std = @import("../std.zig"); |
| 5 | const builtin = @import("builtin"); | |
| 5 | 6 | const assert = std.debug.assert; |
| 6 | 7 | const math = std.math; |
| 7 | 8 | const mem = std.mem; |
| ... | ... | @@ -45,7 +46,7 @@ pub const Ghash = struct { |
| 45 | 46 | const h2 = h0 ^ h1; |
| 46 | 47 | const h2r = h0r ^ h1r; |
| 47 | 48 | |
| 48 | if (std.builtin.mode == .ReleaseSmall) { | |
| 49 | if (builtin.mode == .ReleaseSmall) { | |
| 49 | 50 | return Ghash{ |
| 50 | 51 | .h0 = h0, |
| 51 | 52 | .h1 = h1, |
| ... | ... | @@ -132,12 +133,12 @@ pub const Ghash = struct { |
| 132 | 133 | return z0 | z1 | z2 | z3; |
| 133 | 134 | } |
| 134 | 135 | |
| 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: { | |
| 139 | 140 | 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: { | |
| 141 | 142 | break :impl clmul_pmull; |
| 142 | 143 | } else impl: { |
| 143 | 144 | break :impl clmul_soft; |
| ... | ... | @@ -151,7 +152,7 @@ pub const Ghash = struct { |
| 151 | 152 | var i: usize = 0; |
| 152 | 153 | |
| 153 | 154 | // 2-blocks aggregated reduction |
| 154 | if (std.builtin.mode != .ReleaseSmall) { | |
| 155 | if (builtin.mode != .ReleaseSmall) { | |
| 155 | 156 | while (i + 32 <= msg.len) : (i += 32) { |
| 156 | 157 | // B0 * H^2 unreduced |
| 157 | 158 | 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 | |
| 9 | 9 | |
| 10 | 10 | const std = @import("../std.zig"); |
| 11 | const builtin = @import("builtin"); | |
| 11 | 12 | const mem = std.mem; |
| 12 | 13 | const math = std.math; |
| 13 | 14 | const debug = std.debug; |
| ... | ... | @@ -152,9 +153,9 @@ pub const State = struct { |
| 152 | 153 | self.endianSwap(); |
| 153 | 154 | } |
| 154 | 155 | |
| 155 | pub const permute = if (std.Target.current.cpu.arch == .x86_64) impl: { | |
| 156 | pub const permute = if (builtin.cpu.arch == .x86_64) impl: { | |
| 156 | 157 | break :impl permute_vectorized; |
| 157 | } else if (std.builtin.mode == .ReleaseSmall) impl: { | |
| 158 | } else if (builtin.mode == .ReleaseSmall) impl: { | |
| 158 | 159 | break :impl permute_small; |
| 159 | 160 | } else impl: { |
| 160 | 161 | break :impl permute_unrolled; |
lib/std/crypto/modes.zig+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | // Based on Go stdlib implementation |
| 2 | 2 | |
| 3 | 3 | const std = @import("../std.zig"); |
| 4 | const builtin = std.builtin; | |
| 5 | 4 | const mem = std.mem; |
| 6 | 5 | const debug = std.debug; |
| 7 | 6 | |
| ... | ... | @@ -11,7 +10,7 @@ const debug = std.debug; |
| 11 | 10 | /// |
| 12 | 11 | /// Important: the counter mode doesn't provide authenticated encryption: the ciphertext can be trivially modified without this being detected. |
| 13 | 12 | /// As a result, applications should generally never use it directly, but only in a construction that includes a MAC. |
| 14 | pub fn ctr(comptime BlockCipher: anytype, block_cipher: BlockCipher, dst: []u8, src: []const u8, iv: [BlockCipher.block_length]u8, endian: builtin.Endian) void { | |
| 13 | pub fn ctr(comptime BlockCipher: anytype, block_cipher: BlockCipher, dst: []u8, src: []const u8, iv: [BlockCipher.block_length]u8, endian: std.builtin.Endian) void { | |
| 15 | 14 | debug.assert(dst.len >= src.len); |
| 16 | 15 | const block_length = BlockCipher.block_length; |
| 17 | 16 | var counter: [BlockCipher.block_length]u8 = undefined; |
lib/std/crypto/pcurves/common.zig+3-4| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const crypto = std.crypto; |
| 4 | 3 | const debug = std.debug; |
| 5 | 4 | const mem = std.mem; |
| ... | ... | @@ -51,7 +50,7 @@ pub fn Field(comptime params: FieldParams) type { |
| 51 | 50 | }; |
| 52 | 51 | |
| 53 | 52 | /// 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 { | |
| 55 | 54 | var s = if (endian == .Little) s_ else orderSwap(s_); |
| 56 | 55 | const field_order_s = comptime fos: { |
| 57 | 56 | var fos: [encoded_length]u8 = undefined; |
| ... | ... | @@ -71,7 +70,7 @@ pub fn Field(comptime params: FieldParams) type { |
| 71 | 70 | } |
| 72 | 71 | |
| 73 | 72 | /// 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 { | |
| 75 | 74 | var s = if (endian == .Little) s_ else orderSwap(s_); |
| 76 | 75 | try rejectNonCanonical(s, .Little); |
| 77 | 76 | var limbs_z: NonMontgomeryDomainFieldElement = undefined; |
| ... | ... | @@ -82,7 +81,7 @@ pub fn Field(comptime params: FieldParams) type { |
| 82 | 81 | } |
| 83 | 82 | |
| 84 | 83 | /// 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 { | |
| 86 | 85 | var limbs_z: NonMontgomeryDomainFieldElement = undefined; |
| 87 | 86 | fiat.fromMontgomery(&limbs_z, fe.limbs); |
| 88 | 87 | var s: [encoded_length]u8 = undefined; |
lib/std/crypto/pcurves/p256.zig+4-5| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const crypto = std.crypto; |
| 4 | 3 | const mem = std.mem; |
| 5 | 4 | const meta = std.meta; |
| ... | ... | @@ -59,7 +58,7 @@ pub const P256 = struct { |
| 59 | 58 | } |
| 60 | 59 | |
| 61 | 60 | /// 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 { | |
| 63 | 62 | const x = try Fe.fromBytes(xs, endian); |
| 64 | 63 | const y = try Fe.fromBytes(ys, endian); |
| 65 | 64 | return fromAffineCoordinates(.{ .x = x, .y = y }); |
| ... | ... | @@ -396,7 +395,7 @@ pub const P256 = struct { |
| 396 | 395 | |
| 397 | 396 | /// Multiply an elliptic curve point by a scalar. |
| 398 | 397 | /// 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 { | |
| 400 | 399 | const s = if (endian == .Little) s_ else Fe.orderSwap(s_); |
| 401 | 400 | if (p.is_base) { |
| 402 | 401 | return pcMul16(&basePointPc, s, false); |
| ... | ... | @@ -408,7 +407,7 @@ pub const P256 = struct { |
| 408 | 407 | |
| 409 | 408 | /// Multiply an elliptic curve point by a *PUBLIC* scalar *IN VARIABLE TIME* |
| 410 | 409 | /// 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 { | |
| 412 | 411 | const s = if (endian == .Little) s_ else Fe.orderSwap(s_); |
| 413 | 412 | if (p.is_base) { |
| 414 | 413 | return pcMul16(&basePointPc, s, true); |
| ... | ... | @@ -420,7 +419,7 @@ pub const P256 = struct { |
| 420 | 419 | |
| 421 | 420 | /// Double-base multiplication of public parameters - Compute (p1*s1)+(p2*s2) *IN VARIABLE TIME* |
| 422 | 421 | /// 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 { | |
| 424 | 423 | const s1 = if (endian == .Little) s1_ else Fe.orderSwap(s1_); |
| 425 | 424 | const s2 = if (endian == .Little) s2_ else Fe.orderSwap(s2_); |
| 426 | 425 | try p1.rejectIdentity(); |
lib/std/crypto/pcurves/p256/p256_64.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | // if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 |
| 19 | 19 | |
| 20 | 20 | const std = @import("std"); |
| 21 | const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels | |
| 21 | const mode = @import("builtin").mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels | |
| 22 | 22 | |
| 23 | 23 | // The type MontgomeryDomainFieldElement is a field element in the Montgomery domain. |
| 24 | 24 | // Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] |
lib/std/crypto/pcurves/p256/p256_scalar_64.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | // if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 |
| 19 | 19 | |
| 20 | 20 | const std = @import("std"); |
| 21 | const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels | |
| 21 | const mode = @import("builtin").mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels | |
| 22 | 22 | |
| 23 | 23 | // The type MontgomeryDomainFieldElement is a field element in the Montgomery domain. |
| 24 | 24 | // Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] |
lib/std/crypto/pcurves/p256/scalar.zig+14-15| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const common = @import("../common.zig"); |
| 4 | 3 | const crypto = std.crypto; |
| 5 | 4 | const debug = std.debug; |
| ... | ... | @@ -26,47 +25,47 @@ const Fe = Field(.{ |
| 26 | 25 | }); |
| 27 | 26 | |
| 28 | 27 | /// Reject a scalar whose encoding is not canonical. |
| 29 | pub fn rejectNonCanonical(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!void { | |
| 28 | pub fn rejectNonCanonical(s: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!void { | |
| 30 | 29 | return Fe.rejectNonCanonical(s, endian); |
| 31 | 30 | } |
| 32 | 31 | |
| 33 | 32 | /// Reduce a 48-bytes scalar to the field size. |
| 34 | pub fn reduce48(s: [48]u8, endian: builtin.Endian) CompressedScalar { | |
| 33 | pub fn reduce48(s: [48]u8, endian: std.builtin.Endian) CompressedScalar { | |
| 35 | 34 | return Scalar.fromBytes48(s, endian).toBytes(endian); |
| 36 | 35 | } |
| 37 | 36 | |
| 38 | 37 | /// Reduce a 64-bytes scalar to the field size. |
| 39 | pub fn reduce64(s: [64]u8, endian: builtin.Endian) CompressedScalar { | |
| 38 | pub fn reduce64(s: [64]u8, endian: std.builtin.Endian) CompressedScalar { | |
| 40 | 39 | return ScalarDouble.fromBytes64(s, endian).toBytes(endian); |
| 41 | 40 | } |
| 42 | 41 | |
| 43 | 42 | /// Return a*b (mod L) |
| 44 | pub fn mul(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 43 | pub fn mul(a: CompressedScalar, b: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 45 | 44 | return (try Scalar.fromBytes(a, endian)).mul(try Scalar.fromBytes(b, endian)).toBytes(endian); |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | 47 | /// Return a*b+c (mod L) |
| 49 | pub fn mulAdd(a: CompressedScalar, b: CompressedScalar, c: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 48 | pub fn mulAdd(a: CompressedScalar, b: CompressedScalar, c: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 50 | 49 | return (try Scalar.fromBytes(a, endian)).mul(try Scalar.fromBytes(b, endian)).add(try Scalar.fromBytes(c, endian)).toBytes(endian); |
| 51 | 50 | } |
| 52 | 51 | |
| 53 | 52 | /// Return a+b (mod L) |
| 54 | pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 53 | pub fn add(a: CompressedScalar, b: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 55 | 54 | return (try Scalar.fromBytes(a, endian)).add(try Scalar.fromBytes(b, endian)).toBytes(endian); |
| 56 | 55 | } |
| 57 | 56 | |
| 58 | 57 | /// Return -s (mod L) |
| 59 | pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 58 | pub fn neg(s: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 60 | 59 | return (try Scalar.fromBytes(s, endian)).neg().toBytes(endian); |
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | /// Return (a-b) (mod L) |
| 64 | pub fn sub(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 63 | pub fn sub(a: CompressedScalar, b: CompressedScalar, endian: std.builtin.Endian) NonCanonicalError!CompressedScalar { | |
| 65 | 64 | return (try Scalar.fromBytes(a, endian)).sub(try Scalar.fromBytes(b.endian)).toBytes(endian); |
| 66 | 65 | } |
| 67 | 66 | |
| 68 | 67 | /// Return a random scalar |
| 69 | pub fn random(endian: builtin.Endian) CompressedScalar { | |
| 68 | pub fn random(endian: std.builtin.Endian) CompressedScalar { | |
| 70 | 69 | return Scalar.random().toBytes(endian); |
| 71 | 70 | } |
| 72 | 71 | |
| ... | ... | @@ -81,24 +80,24 @@ pub const Scalar = struct { |
| 81 | 80 | pub const one = Scalar{ .fe = Fe.one }; |
| 82 | 81 | |
| 83 | 82 | /// 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 { | |
| 85 | 84 | return Scalar{ .fe = try Fe.fromBytes(s, endian) }; |
| 86 | 85 | } |
| 87 | 86 | |
| 88 | 87 | /// 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 { | |
| 90 | 89 | const t = ScalarDouble.fromBytes(384, s, endian); |
| 91 | 90 | return t.reduce(384); |
| 92 | 91 | } |
| 93 | 92 | |
| 94 | 93 | /// 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 { | |
| 96 | 95 | const t = ScalarDouble.fromBytes(512, s, endian); |
| 97 | 96 | return t.reduce(512); |
| 98 | 97 | } |
| 99 | 98 | |
| 100 | 99 | /// 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 { | |
| 102 | 101 | return n.fe.toBytes(endian); |
| 103 | 102 | } |
| 104 | 103 | |
| ... | ... | @@ -180,7 +179,7 @@ const ScalarDouble = struct { |
| 180 | 179 | x2: Fe, |
| 181 | 180 | x3: Fe, |
| 182 | 181 | |
| 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 { | |
| 184 | 183 | debug.assert(bits > 0 and bits <= 512 and bits >= Fe.saturated_bits and bits <= Fe.saturated_bits * 3); |
| 185 | 184 | |
| 186 | 185 | var s = s_; |
lib/std/crypto/salsa20.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const crypto = std.crypto; |
| 3 | 4 | const debug = std.debug; |
| 4 | 5 | const math = std.math; |
| ... | ... | @@ -304,7 +305,7 @@ const Salsa20NonVecImpl = struct { |
| 304 | 305 | } |
| 305 | 306 | }; |
| 306 | 307 | |
| 307 | const Salsa20Impl = if (std.Target.current.cpu.arch == .x86_64) Salsa20VecImpl else Salsa20NonVecImpl; | |
| 308 | const Salsa20Impl = if (builtin.cpu.arch == .x86_64) Salsa20VecImpl else Salsa20NonVecImpl; | |
| 308 | 309 | |
| 309 | 310 | fn keyToWords(key: [32]u8) [8]u32 { |
| 310 | 311 | var k: [8]u32 = undefined; |
lib/std/crypto/tlcsprng.zig+5-4| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | //! directly to standard library users. |
| 5 | 5 | |
| 6 | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | |
| 7 | 8 | const root = @import("root"); |
| 8 | 9 | const mem = std.mem; |
| 9 | 10 | const os = std.os; |
| ... | ... | @@ -12,7 +13,7 @@ const os = std.os; |
| 12 | 13 | /// point to thread-local variables. |
| 13 | 14 | pub var interface = std.rand.Random{ .fillFn = tlsCsprngFill }; |
| 14 | 15 | |
| 15 | const os_has_fork = switch (std.Target.current.os.tag) { | |
| 16 | const os_has_fork = switch (builtin.os.tag) { | |
| 16 | 17 | .dragonfly, |
| 17 | 18 | .freebsd, |
| 18 | 19 | .ios, |
| ... | ... | @@ -29,10 +30,10 @@ const os_has_fork = switch (std.Target.current.os.tag) { |
| 29 | 30 | |
| 30 | 31 | else => false, |
| 31 | 32 | }; |
| 32 | const os_has_arc4random = std.builtin.link_libc and @hasDecl(std.c, "arc4random_buf"); | |
| 33 | const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf"); | |
| 33 | 34 | const want_fork_safety = os_has_fork and !os_has_arc4random and |
| 34 | 35 | (std.meta.globalOption("crypto_fork_safety", bool) orelse true); |
| 35 | const maybe_have_wipe_on_fork = std.Target.current.os.isAtLeast(.linux, .{ | |
| 36 | const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{ | |
| 36 | 37 | .major = 4, |
| 37 | 38 | .minor = 14, |
| 38 | 39 | }) orelse true; |
| ... | ... | @@ -55,7 +56,7 @@ var install_atfork_handler = std.once(struct { |
| 55 | 56 | threadlocal var wipe_mem: []align(mem.page_size) u8 = &[_]u8{}; |
| 56 | 57 | |
| 57 | 58 | fn 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")) { | |
| 59 | 60 | // arc4random is already a thread-local CSPRNG. |
| 60 | 61 | return std.c.arc4random_buf(buffer.ptr, buffer.len); |
| 61 | 62 | } |
lib/std/cstr.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const debug = std.debug; |
| 4 | 4 | const mem = std.mem; |
| 5 | 5 | const testing = std.testing; |
lib/std/debug.zig+11-11| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const math = std.math; |
| 4 | 4 | const mem = std.mem; |
| 5 | 5 | const io = std.io; |
| ... | ... | @@ -16,8 +16,8 @@ const root = @import("root"); |
| 16 | 16 | const maxInt = std.math.maxInt; |
| 17 | 17 | const File = std.fs.File; |
| 18 | 18 | const windows = std.os.windows; |
| 19 | const native_arch = std.Target.current.cpu.arch; | |
| 20 | const native_os = std.Target.current.os.tag; | |
| 19 | const native_arch = builtin.cpu.arch; | |
| 20 | const native_os = builtin.os.tag; | |
| 21 | 21 | const native_endian = native_arch.endian(); |
| 22 | 22 | |
| 23 | 23 | pub const runtime_safety = switch (builtin.mode) { |
| ... | ... | @@ -150,7 +150,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { |
| 150 | 150 | /// capture that many stack frames exactly, and then look for the first address, |
| 151 | 151 | /// chopping off the irrelevant frames and shifting so that the returned addresses pointer |
| 152 | 152 | /// equals the passed in addresses pointer. |
| 153 | pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace) void { | |
| 153 | pub fn captureStackTrace(first_address: ?usize, stack_trace: *std.builtin.StackTrace) void { | |
| 154 | 154 | if (native_os == .windows) { |
| 155 | 155 | const addrs = stack_trace.instruction_addresses; |
| 156 | 156 | const u32_addrs_len = @intCast(u32, addrs.len); |
| ... | ... | @@ -194,7 +194,7 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace |
| 194 | 194 | |
| 195 | 195 | /// Tries to print a stack trace to stderr, unbuffered, and ignores any error returned. |
| 196 | 196 | /// TODO multithreaded awareness |
| 197 | pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void { | |
| 197 | pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void { | |
| 198 | 198 | nosuspend { |
| 199 | 199 | const stderr = io.getStdErr().writer(); |
| 200 | 200 | if (builtin.strip_debug_info) { |
| ... | ... | @@ -235,7 +235,7 @@ pub fn panic(comptime format: []const u8, args: anytype) noreturn { |
| 235 | 235 | /// `panicExtra` is useful when you want to print out an `@errorReturnTrace` |
| 236 | 236 | /// and also print out some values. |
| 237 | 237 | pub fn panicExtra( |
| 238 | trace: ?*builtin.StackTrace, | |
| 238 | trace: ?*std.builtin.StackTrace, | |
| 239 | 239 | comptime format: []const u8, |
| 240 | 240 | args: anytype, |
| 241 | 241 | ) noreturn { |
| ... | ... | @@ -253,7 +253,7 @@ pub fn panicExtra( |
| 253 | 253 | break :blk &buf; |
| 254 | 254 | }, |
| 255 | 255 | }; |
| 256 | builtin.panic(msg, trace); | |
| 256 | std.builtin.panic(msg, trace); | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /// Non-zero whenever the program triggered a panic. |
| ... | ... | @@ -269,7 +269,7 @@ threadlocal var panic_stage: usize = 0; |
| 269 | 269 | |
| 270 | 270 | // `panicImpl` could be useful in implementing a custom panic handler which |
| 271 | 271 | // calls the default handler (on supported platforms) |
| 272 | pub fn panicImpl(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn { | |
| 272 | pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn { | |
| 273 | 273 | @setCold(true); |
| 274 | 274 | |
| 275 | 275 | if (enable_segfault_handler) { |
| ... | ... | @@ -339,7 +339,7 @@ const DIM = "\x1b[2m"; |
| 339 | 339 | const RESET = "\x1b[0m"; |
| 340 | 340 | |
| 341 | 341 | pub fn writeStackTrace( |
| 342 | stack_trace: builtin.StackTrace, | |
| 342 | stack_trace: std.builtin.StackTrace, | |
| 343 | 343 | out_stream: anytype, |
| 344 | 344 | allocator: *mem.Allocator, |
| 345 | 345 | debug_info: *DebugInfo, |
| ... | ... | @@ -764,7 +764,7 @@ pub fn readElfDebugInfo(allocator: *mem.Allocator, elf_file: File) !ModuleDebugI |
| 764 | 764 | if (!mem.eql(u8, hdr.e_ident[0..4], "\x7fELF")) return error.InvalidElfMagic; |
| 765 | 765 | if (hdr.e_ident[elf.EI_VERSION] != 1) return error.InvalidElfVersion; |
| 766 | 766 | |
| 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]) { | |
| 768 | 768 | elf.ELFDATA2LSB => .Little, |
| 769 | 769 | elf.ELFDATA2MSB => .Big, |
| 770 | 770 | else => return error.InvalidElfEndian, |
| ... | ... | @@ -1002,7 +1002,7 @@ pub const DebugInfo = struct { |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo { |
| 1005 | if (comptime std.Target.current.isDarwin()) { | |
| 1005 | if (comptime builtin.target.isDarwin()) { | |
| 1006 | 1006 | return self.lookupModuleDyld(address); |
| 1007 | 1007 | } else if (native_os == .windows) { |
| 1008 | 1008 | return self.lookupModuleWin32(address); |
lib/std/dwarf.zig+7-8| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const debug = std.debug; |
| 4 | 3 | const fs = std.fs; |
| 5 | 4 | const io = std.io; |
| ... | ... | @@ -454,7 +453,7 @@ const LineNumberProgram = struct { |
| 454 | 453 | } |
| 455 | 454 | }; |
| 456 | 455 | |
| 457 | fn readUnitLength(in_stream: anytype, endian: builtin.Endian, is_64: *bool) !u64 { | |
| 456 | fn readUnitLength(in_stream: anytype, endian: std.builtin.Endian, is_64: *bool) !u64 { | |
| 458 | 457 | const first_32_bits = try in_stream.readInt(u32, endian); |
| 459 | 458 | is_64.* = (first_32_bits == 0xffffffff); |
| 460 | 459 | if (is_64.*) { |
| ... | ... | @@ -475,7 +474,7 @@ fn readAllocBytes(allocator: *mem.Allocator, in_stream: anytype, size: usize) ![ |
| 475 | 474 | } |
| 476 | 475 | |
| 477 | 476 | // TODO the nosuspends here are workarounds |
| 478 | fn readAddress(in_stream: anytype, endian: builtin.Endian, is_64: bool) !u64 { | |
| 477 | fn readAddress(in_stream: anytype, endian: std.builtin.Endian, is_64: bool) !u64 { | |
| 479 | 478 | return nosuspend if (is_64) |
| 480 | 479 | try in_stream.readInt(u64, endian) |
| 481 | 480 | else |
| ... | ... | @@ -488,12 +487,12 @@ fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: anytype, size: u |
| 488 | 487 | } |
| 489 | 488 | |
| 490 | 489 | // TODO the nosuspends here are workarounds |
| 491 | fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: usize) !FormValue { | |
| 490 | fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: std.builtin.Endian, size: usize) !FormValue { | |
| 492 | 491 | const block_len = try nosuspend in_stream.readVarInt(usize, endian, size); |
| 493 | 492 | return parseFormValueBlockLen(allocator, in_stream, block_len); |
| 494 | 493 | } |
| 495 | 494 | |
| 496 | fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue { | |
| 495 | fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: std.builtin.Endian, comptime size: i32) !FormValue { | |
| 497 | 496 | _ = allocator; |
| 498 | 497 | // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here. |
| 499 | 498 | // `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: |
| 521 | 520 | } |
| 522 | 521 | |
| 523 | 522 | // TODO the nosuspends here are workarounds |
| 524 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue { | |
| 523 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: std.builtin.Endian, size: i32) !FormValue { | |
| 525 | 524 | _ = allocator; |
| 526 | 525 | return FormValue{ |
| 527 | 526 | .Ref = switch (size) { |
| ... | ... | @@ -536,7 +535,7 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: buil |
| 536 | 535 | } |
| 537 | 536 | |
| 538 | 537 | // TODO the nosuspends here are workarounds |
| 539 | fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue { | |
| 538 | fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: std.builtin.Endian, is_64: bool) anyerror!FormValue { | |
| 540 | 539 | return switch (form_id) { |
| 541 | 540 | FORM.addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) }, |
| 542 | 541 | FORM.block1 => parseFormValueBlock(allocator, in_stream, endian, 1), |
| ... | ... | @@ -593,7 +592,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con |
| 593 | 592 | } |
| 594 | 593 | |
| 595 | 594 | pub const DwarfInfo = struct { |
| 596 | endian: builtin.Endian, | |
| 595 | endian: std.builtin.Endian, | |
| 597 | 596 | // No memory is owned by the DwarfInfo |
| 598 | 597 | debug_info: []const u8, |
| 599 | 598 | debug_abbrev: []const u8, |
lib/std/dynamic_library.zig+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | const builtin = std.builtin; | |
| 2 | ||
| 3 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 4 | 3 | const mem = std.mem; |
| 5 | 4 | const os = std.os; |
| 6 | 5 | const assert = std.debug.assert; |
lib/std/event/channel.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | 4 | const testing = std.testing; |
| 5 | 5 | const Loop = std.event.Loop; |
lib/std/event/future.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | const testing = std.testing; |
| 4 | const builtin = std.builtin; | |
| 5 | 5 | const Lock = std.event.Lock; |
| 6 | 6 | |
| 7 | 7 | /// This is a value that starts out unavailable, until resolve() is called |
lib/std/event/group.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const Lock = std.event.Lock; |
| 4 | 4 | const testing = std.testing; |
| 5 | 5 | const Allocator = std.mem.Allocator; |
lib/std/event/lock.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | 4 | const testing = std.testing; |
| 5 | 5 | const mem = std.mem; |
lib/std/event/loop.zig+4-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const root = @import("root"); |
| 4 | 4 | const assert = std.debug.assert; |
| 5 | 5 | const testing = std.testing; |
| ... | ... | @@ -9,7 +9,7 @@ const windows = os.windows; |
| 9 | 9 | const maxInt = std.math.maxInt; |
| 10 | 10 | const Thread = std.Thread; |
| 11 | 11 | |
| 12 | const is_windows = std.Target.current.os.tag == .windows; | |
| 12 | const is_windows = builtin.os.tag == .windows; | |
| 13 | 13 | |
| 14 | 14 | pub const Loop = struct { |
| 15 | 15 | next_tick_queue: std.atomic.Queue(anyframe), |
| ... | ... | @@ -191,7 +191,7 @@ pub const Loop = struct { |
| 191 | 191 | self.fs_thread.join(); |
| 192 | 192 | }; |
| 193 | 193 | |
| 194 | if (!std.builtin.single_threaded) | |
| 194 | if (!builtin.single_threaded) | |
| 195 | 195 | try self.delay_queue.init(); |
| 196 | 196 | } |
| 197 | 197 | |
| ... | ... | @@ -825,7 +825,7 @@ pub const Loop = struct { |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | pub fn sleep(self: *Loop, nanoseconds: u64) void { |
| 828 | if (std.builtin.single_threaded) | |
| 828 | if (builtin.single_threaded) | |
| 829 | 829 | @compileError("TODO: integrate timers with epoll/kevent/iocp for single-threaded"); |
| 830 | 830 | |
| 831 | 831 | suspend { |
lib/std/event/rwlock.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | 4 | const testing = std.testing; |
| 5 | 5 | const mem = std.mem; |
lib/std/event/wait_group.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const Loop = std.event.Loop; |
| 4 | 4 | |
| 5 | 5 | /// A WaitGroup keeps track and waits for a group of async tasks to finish. |
lib/std/fs.zig+5-5| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | const root = @import("root"); | |
| 2 | const builtin = std.builtin; | |
| 3 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 3 | const root = @import("root"); | |
| 4 | 4 | const os = std.os; |
| 5 | 5 | const mem = std.mem; |
| 6 | 6 | const base64 = std.base64; |
| ... | ... | @@ -9,7 +9,7 @@ const Allocator = std.mem.Allocator; |
| 9 | 9 | const assert = std.debug.assert; |
| 10 | 10 | const math = std.math; |
| 11 | 11 | |
| 12 | const is_darwin = std.Target.current.os.tag.isDarwin(); | |
| 12 | const is_darwin = builtin.os.tag.isDarwin(); | |
| 13 | 13 | |
| 14 | 14 | pub const path = @import("fs/path.zig"); |
| 15 | 15 | pub const File = @import("fs/file.zig").File; |
| ... | ... | @@ -2607,7 +2607,7 @@ const CopyFileError = error{SystemResources} || os.CopyFileRangeError || os.Send |
| 2607 | 2607 | // The copy starts at offset 0, the initial offsets are preserved. |
| 2608 | 2608 | // No metadata is transferred over. |
| 2609 | 2609 | fn 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()) { | |
| 2611 | 2611 | const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA); |
| 2612 | 2612 | switch (os.errno(rc)) { |
| 2613 | 2613 | .SUCCESS => return, |
| ... | ... | @@ -2620,7 +2620,7 @@ fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void { |
| 2620 | 2620 | } |
| 2621 | 2621 | } |
| 2622 | 2622 | |
| 2623 | if (std.Target.current.os.tag == .linux) { | |
| 2623 | if (builtin.os.tag == .linux) { | |
| 2624 | 2624 | // Try copy_file_range first as that works at the FS level and is the |
| 2625 | 2625 | // most efficient method (if available). |
| 2626 | 2626 | var offset: u64 = 0; |
lib/std/fs/file.zig+3-3| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const os = std.os; |
| 4 | 4 | const io = std.io; |
| 5 | 5 | const mem = std.mem; |
| 6 | 6 | const math = std.math; |
| 7 | 7 | const assert = std.debug.assert; |
| 8 | 8 | const windows = os.windows; |
| 9 | const Os = builtin.Os; | |
| 9 | const Os = std.builtin.Os; | |
| 10 | 10 | const maxInt = std.math.maxInt; |
| 11 | const is_windows = std.Target.current.os.tag == .windows; | |
| 11 | const is_windows = builtin.os.tag == .windows; | |
| 12 | 12 | |
| 13 | 13 | pub const File = struct { |
| 14 | 14 | /// The OS-specific file descriptor or file handle. |
lib/std/fs/get_app_data_dir.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const unicode = std.unicode; |
| 4 | 4 | const mem = std.mem; |
| 5 | 5 | const fs = std.fs; |
lib/std/fs/test.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const testing = std.testing; |
| 3 | const builtin = std.builtin; | |
| 4 | 4 | const fs = std.fs; |
| 5 | 5 | const mem = std.mem; |
| 6 | 6 | const wasi = std.os.wasi; |
lib/std/fs/wasi.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const os = std.os; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const math = std.math; |
| ... | ... | @@ -165,7 +166,7 @@ pub const PreopenList = struct { |
| 165 | 166 | }; |
| 166 | 167 | |
| 167 | 168 | test "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; | |
| 169 | 170 | |
| 170 | 171 | var preopens = PreopenList.init(std.testing.allocator); |
| 171 | 172 | defer preopens.deinit(); |
lib/std/fs/watch.zig+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const event = std.event; |
| 4 | 4 | const assert = std.debug.assert; |
| 5 | 5 | const testing = std.testing; |
| ... | ... | @@ -250,7 +250,7 @@ pub fn Watch(comptime V: type) type { |
| 250 | 250 | }; |
| 251 | 251 | |
| 252 | 252 | // @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; | |
| 254 | 254 | const fd = try os.open(realpath, flags, 0); |
| 255 | 255 | gop.value_ptr.putter_frame = async self.kqPutEvents(fd, gop.key_ptr.*, gop.value_ptr.*); |
| 256 | 256 | return null; |
lib/std/hash/auto_hash.zig+1-2| ... | ... | @@ -2,7 +2,6 @@ const std = @import("std"); |
| 2 | 2 | const assert = std.debug.assert; |
| 3 | 3 | const mem = std.mem; |
| 4 | 4 | const meta = std.meta; |
| 5 | const builtin = std.builtin; | |
| 6 | 5 | |
| 7 | 6 | /// Describes how pointer types should be hashed. |
| 8 | 7 | pub const HashStrategy = enum { |
| ... | ... | @@ -233,7 +232,7 @@ fn testHashDeepRecursive(key: anytype) u64 { |
| 233 | 232 | |
| 234 | 233 | test "typeContainsSlice" { |
| 235 | 234 | comptime { |
| 236 | try testing.expect(!typeContainsSlice(meta.Tag(builtin.TypeInfo))); | |
| 235 | try testing.expect(!typeContainsSlice(meta.Tag(std.builtin.TypeInfo))); | |
| 237 | 236 | |
| 238 | 237 | try testing.expect(typeContainsSlice([]const u8)); |
| 239 | 238 | try testing.expect(!typeContainsSlice(u8)); |
lib/std/hash/benchmark.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | // zig run -O ReleaseFast --zig-lib-dir ../.. benchmark.zig |
| 2 | 2 | |
| 3 | const builtin = std.builtin; | |
| 4 | 3 | const std = @import("std"); |
| 4 | const builtin = @import("builtin"); | |
| 5 | 5 | const time = std.time; |
| 6 | 6 | const Timer = time.Timer; |
| 7 | 7 | const hash = std.hash; |
lib/std/hash/cityhash.zig-1| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | |
| 4 | 3 | inline fn offsetPtr(ptr: [*]const u8, offset: usize) [*]const u8 { |
| 5 | 4 | // ptr + offset doesn't work at comptime so we need this instead. |
lib/std/hash/crc.zig+2-1| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | // still moderately fast just slow relative to the slicing approach. |
| 7 | 7 | |
| 8 | 8 | const std = @import("../std.zig"); |
| 9 | const builtin = @import("builtin"); | |
| 9 | 10 | const debug = std.debug; |
| 10 | 11 | const testing = std.testing; |
| 11 | 12 | |
| ... | ... | @@ -97,7 +98,7 @@ pub fn Crc32WithPoly(comptime poly: Polynomial) type { |
| 97 | 98 | }; |
| 98 | 99 | } |
| 99 | 100 | |
| 100 | const please_windows_dont_oom = std.Target.current.os.tag == .windows; | |
| 101 | const please_windows_dont_oom = builtin.os.tag == .windows; | |
| 101 | 102 | |
| 102 | 103 | test "crc32 ieee" { |
| 103 | 104 | if (please_windows_dont_oom) return error.SkipZigTest; |
lib/std/heap.zig+10-10| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const root = @import("root"); |
| 3 | 4 | const debug = std.debug; |
| 4 | 5 | const assert = debug.assert; |
| 5 | 6 | const testing = std.testing; |
| 6 | 7 | const mem = std.mem; |
| 7 | 8 | const os = std.os; |
| 8 | const builtin = std.builtin; | |
| 9 | 9 | const c = std.c; |
| 10 | 10 | const maxInt = std.math.maxInt; |
| 11 | 11 | |
| ... | ... | @@ -209,9 +209,9 @@ fn rawCResize( |
| 209 | 209 | |
| 210 | 210 | /// This allocator makes a syscall directly for every allocation and free. |
| 211 | 211 | /// Thread-safe and lock-free. |
| 212 | pub const page_allocator = if (std.Target.current.isWasm()) | |
| 212 | pub const page_allocator = if (builtin.target.isWasm()) | |
| 213 | 213 | &wasm_page_allocator_state |
| 214 | else if (std.Target.current.os.tag == .freestanding) | |
| 214 | else if (builtin.target.os.tag == .freestanding) | |
| 215 | 215 | root.os.heap.page_allocator |
| 216 | 216 | else |
| 217 | 217 | &page_allocator_state; |
| ... | ... | @@ -402,7 +402,7 @@ const PageAllocator = struct { |
| 402 | 402 | |
| 403 | 403 | const WasmPageAllocator = struct { |
| 404 | 404 | comptime { |
| 405 | if (!std.Target.current.isWasm()) { | |
| 405 | if (!builtin.target.isWasm()) { | |
| 406 | 406 | @compileError("WasmPageAllocator is only available for wasm32 arch"); |
| 407 | 407 | } |
| 408 | 408 | } |
| ... | ... | @@ -608,11 +608,11 @@ pub const HeapAllocator = switch (builtin.os.tag) { |
| 608 | 608 | const self = @fieldParentPtr(HeapAllocator, "allocator", allocator); |
| 609 | 609 | |
| 610 | 610 | 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); | |
| 612 | 612 | const heap_handle = optional_heap_handle orelse blk: { |
| 613 | 613 | const options = if (builtin.single_threaded) os.windows.HEAP_NO_SERIALIZE else 0; |
| 614 | 614 | 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; | |
| 616 | 616 | os.windows.HeapDestroy(hh); |
| 617 | 617 | break :blk other_hh.?; // can't be null because of the cmpxchg |
| 618 | 618 | }; |
| ... | ... | @@ -792,7 +792,7 @@ pub const ThreadSafeFixedBufferAllocator = blk: { |
| 792 | 792 | _ = len_align; |
| 793 | 793 | _ = ra; |
| 794 | 794 | 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); | |
| 796 | 796 | while (true) { |
| 797 | 797 | const adjust_off = mem.alignPointerOffset(self.buffer.ptr + end_index, ptr_align) orelse |
| 798 | 798 | return error.OutOfMemory; |
| ... | ... | @@ -801,7 +801,7 @@ pub const ThreadSafeFixedBufferAllocator = blk: { |
| 801 | 801 | if (new_end_index > self.buffer.len) { |
| 802 | 802 | return error.OutOfMemory; |
| 803 | 803 | } |
| 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]; | |
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | |
| ... | ... | @@ -884,7 +884,7 @@ test "raw_c_allocator" { |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | test "WasmPageAllocator internals" { |
| 887 | if (comptime std.Target.current.isWasm()) { | |
| 887 | if (comptime builtin.target.isWasm()) { | |
| 888 | 888 | const conventional_memsize = WasmPageAllocator.conventional.totalPages() * mem.page_size; |
| 889 | 889 | const initial = try page_allocator.alloc(u8, mem.page_size); |
| 890 | 890 | 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" { |
| 924 | 924 | const allocator = page_allocator; |
| 925 | 925 | try testAllocator(allocator); |
| 926 | 926 | try testAllocatorAligned(allocator); |
| 927 | if (!std.Target.current.isWasm()) { | |
| 927 | if (!builtin.target.isWasm()) { | |
| 928 | 928 | try testAllocatorLargeAlignment(allocator); |
| 929 | 929 | try testAllocatorAlignedShrink(allocator); |
| 930 | 930 | } |
lib/std/heap/general_purpose_allocator.zig+8-7| ... | ... | @@ -93,6 +93,7 @@ |
| 93 | 93 | //! in a `std.HashMap` using the backing allocator. |
| 94 | 94 | |
| 95 | 95 | const std = @import("std"); |
| 96 | const builtin = @import("builtin"); | |
| 96 | 97 | const log = std.log.scoped(.gpa); |
| 97 | 98 | const math = std.math; |
| 98 | 99 | const assert = std.debug.assert; |
| ... | ... | @@ -104,7 +105,7 @@ const StackTrace = std.builtin.StackTrace; |
| 104 | 105 | /// Integer type for pointing to slots in a small allocation |
| 105 | 106 | const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1); |
| 106 | 107 | |
| 107 | const sys_can_stack_trace = switch (std.Target.current.cpu.arch) { | |
| 108 | const sys_can_stack_trace = switch (builtin.cpu.arch) { | |
| 108 | 109 | // Observed to go into an infinite loop. |
| 109 | 110 | // TODO: Make this work. |
| 110 | 111 | .mips, |
| ... | ... | @@ -115,13 +116,13 @@ const sys_can_stack_trace = switch (std.Target.current.cpu.arch) { |
| 115 | 116 | // "Non-Emscripten WebAssembly hasn't implemented __builtin_return_address". |
| 116 | 117 | .wasm32, |
| 117 | 118 | .wasm64, |
| 118 | => std.Target.current.os.tag == .emscripten, | |
| 119 | => builtin.os.tag == .emscripten, | |
| 119 | 120 | |
| 120 | 121 | else => true, |
| 121 | 122 | }; |
| 122 | const default_test_stack_trace_frames: usize = if (std.builtin.is_test) 8 else 4; | |
| 123 | const default_test_stack_trace_frames: usize = if (builtin.is_test) 8 else 4; | |
| 123 | 124 | const default_sys_stack_trace_frames: usize = if (sys_can_stack_trace) default_test_stack_trace_frames else 0; |
| 124 | const default_stack_trace_frames: usize = switch (std.builtin.mode) { | |
| 125 | const default_stack_trace_frames: usize = switch (builtin.mode) { | |
| 125 | 126 | .Debug => default_sys_stack_trace_frames, |
| 126 | 127 | else => 0, |
| 127 | 128 | }; |
| ... | ... | @@ -141,7 +142,7 @@ pub const Config = struct { |
| 141 | 142 | safety: bool = std.debug.runtime_safety, |
| 142 | 143 | |
| 143 | 144 | /// 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, | |
| 145 | 146 | |
| 146 | 147 | /// What type of mutex you'd like to use, for thread safety. |
| 147 | 148 | /// 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" { |
| 988 | 989 | var slice = try allocator.alignedAlloc(u8, 16, alloc_size); |
| 989 | 990 | defer allocator.free(slice); |
| 990 | 991 | |
| 991 | const big_alignment: usize = switch (std.Target.current.os.tag) { | |
| 992 | const big_alignment: usize = switch (builtin.os.tag) { | |
| 992 | 993 | .windows => page_size * 32, // Windows aligns to 64K. |
| 993 | 994 | else => page_size * 2, |
| 994 | 995 | }; |
| ... | ... | @@ -1058,7 +1059,7 @@ test "realloc large object to larger alignment" { |
| 1058 | 1059 | var slice = try allocator.alignedAlloc(u8, 16, page_size * 2 + 50); |
| 1059 | 1060 | defer allocator.free(slice); |
| 1060 | 1061 | |
| 1061 | const big_alignment: usize = switch (std.Target.current.os.tag) { | |
| 1062 | const big_alignment: usize = switch (builtin.os.tag) { | |
| 1062 | 1063 | .windows => page_size * 32, // Windows aligns to 64K. |
| 1063 | 1064 | else => page_size * 2, |
| 1064 | 1065 | }; |
lib/std/io.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const root = @import("root"); |
| 4 | 4 | const c = std.c; |
| 5 | 5 |
lib/std/io/bit_reader.zig+2-3| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const io = std.io; |
| 4 | 3 | const assert = std.debug.assert; |
| 5 | 4 | const testing = std.testing; |
| ... | ... | @@ -8,7 +7,7 @@ const meta = std.meta; |
| 8 | 7 | const math = std.math; |
| 9 | 8 | |
| 10 | 9 | /// Creates a stream which allows for reading bit fields from another stream |
| 11 | pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type { | |
| 10 | pub fn BitReader(endian: std.builtin.Endian, comptime ReaderType: type) type { | |
| 12 | 11 | return struct { |
| 13 | 12 | forward_reader: ReaderType, |
| 14 | 13 | bit_buffer: u7, |
| ... | ... | @@ -162,7 +161,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type { |
| 162 | 161 | } |
| 163 | 162 | |
| 164 | 163 | pub fn bitReader( |
| 165 | comptime endian: builtin.Endian, | |
| 164 | comptime endian: std.builtin.Endian, | |
| 166 | 165 | underlying_stream: anytype, |
| 167 | 166 | ) BitReader(endian, @TypeOf(underlying_stream)) { |
| 168 | 167 | return BitReader(endian, @TypeOf(underlying_stream)).init(underlying_stream); |
lib/std/io/bit_writer.zig+2-3| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const io = std.io; |
| 4 | 3 | const testing = std.testing; |
| 5 | 4 | const assert = std.debug.assert; |
| ... | ... | @@ -8,7 +7,7 @@ const meta = std.meta; |
| 8 | 7 | const math = std.math; |
| 9 | 8 | |
| 10 | 9 | /// Creates a stream which allows for writing bit fields to another stream |
| 11 | pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type { | |
| 10 | pub fn BitWriter(endian: std.builtin.Endian, comptime WriterType: type) type { | |
| 12 | 11 | return struct { |
| 13 | 12 | forward_writer: WriterType, |
| 14 | 13 | bit_buffer: u8, |
| ... | ... | @@ -138,7 +137,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type { |
| 138 | 137 | } |
| 139 | 138 | |
| 140 | 139 | pub fn bitWriter( |
| 141 | comptime endian: builtin.Endian, | |
| 140 | comptime endian: std.builtin.Endian, | |
| 142 | 141 | underlying_stream: anytype, |
| 143 | 142 | ) BitWriter(endian, @TypeOf(underlying_stream)) { |
| 144 | 143 | return BitWriter(endian, @TypeOf(underlying_stream)).init(underlying_stream); |
lib/std/io/c_writer.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const io = std.io; |
| 4 | 4 | const testing = std.testing; |
| 5 | 5 | const os = std.os; |
lib/std/io/reader.zig+4-5| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const math = std.math; |
| 4 | 3 | const assert = std.debug.assert; |
| 5 | 4 | const mem = std.mem; |
| ... | ... | @@ -265,12 +264,12 @@ pub fn Reader( |
| 265 | 264 | return mem.readIntBig(T, &bytes); |
| 266 | 265 | } |
| 267 | 266 | |
| 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 { | |
| 269 | 268 | const bytes = try self.readBytesNoEof((@typeInfo(T).Int.bits + 7) / 8); |
| 270 | 269 | return mem.readInt(T, &bytes, endian); |
| 271 | 270 | } |
| 272 | 271 | |
| 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 { | |
| 274 | 273 | assert(size <= @sizeOf(ReturnType)); |
| 275 | 274 | var bytes_buf: [@sizeOf(ReturnType)]u8 = undefined; |
| 276 | 275 | const bytes = bytes_buf[0..size]; |
| ... | ... | @@ -310,7 +309,7 @@ pub fn Reader( |
| 310 | 309 | |
| 311 | 310 | pub fn readStruct(self: Self, comptime T: type) !T { |
| 312 | 311 | // 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); | |
| 314 | 313 | var res: [1]T = undefined; |
| 315 | 314 | try self.readNoEof(mem.sliceAsBytes(res[0..])); |
| 316 | 315 | return res[0]; |
| ... | ... | @@ -319,7 +318,7 @@ pub fn Reader( |
| 319 | 318 | /// Reads an integer with the same size as the given enum's tag type. If the integer matches |
| 320 | 319 | /// an enum tag, casts the integer to the enum tag and returns it. Otherwise, returns an error. |
| 321 | 320 | /// 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 { | |
| 323 | 322 | const E = error{ |
| 324 | 323 | /// An integer was read, but it did not match any of the tags in the supplied enum. |
| 325 | 324 | InvalidValue, |
lib/std/io/stream_source.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const io = std.io; |
| 3 | 4 | |
| 4 | 5 | /// Provides `io.Reader`, `io.Writer`, and `io.SeekableStream` for in-memory buffers as |
| ... | ... | @@ -6,7 +7,7 @@ const io = std.io; |
| 6 | 7 | /// For memory sources, if the supplied byte buffer is const, then `io.Writer` is not available. |
| 7 | 8 | /// The error set of the stream functions is the error set of the corresponding file functions. |
| 8 | 9 | pub const StreamSource = union(enum) { |
| 9 | const has_file = (std.builtin.os.tag != .freestanding); | |
| 10 | const has_file = (builtin.os.tag != .freestanding); | |
| 10 | 11 | |
| 11 | 12 | /// The stream access is redirected to this buffer. |
| 12 | 13 | buffer: io.FixedBufferStream([]u8), |
lib/std/io/writer.zig+2-3| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | 2 | const assert = std.debug.assert; |
| 3 | const builtin = std.builtin; | |
| 4 | 3 | const mem = std.mem; |
| 5 | 4 | |
| 6 | 5 | pub fn Writer( |
| ... | ... | @@ -77,7 +76,7 @@ pub fn Writer( |
| 77 | 76 | } |
| 78 | 77 | |
| 79 | 78 | /// 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 { | |
| 81 | 80 | var bytes: [(@typeInfo(T).Int.bits + 7) / 8]u8 = undefined; |
| 82 | 81 | mem.writeInt(T, &bytes, value, endian); |
| 83 | 82 | return self.writeAll(&bytes); |
| ... | ... | @@ -85,7 +84,7 @@ pub fn Writer( |
| 85 | 84 | |
| 86 | 85 | pub fn writeStruct(self: Self, value: anytype) Error!void { |
| 87 | 86 | // 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); | |
| 89 | 88 | return self.writeAll(mem.asBytes(&value)); |
| 90 | 89 | } |
| 91 | 90 | }; |
lib/std/log.zig+2-2| ... | ... | @@ -69,7 +69,7 @@ |
| 69 | 69 | //! ``` |
| 70 | 70 | |
| 71 | 71 | const std = @import("std.zig"); |
| 72 | const builtin = std.builtin; | |
| 72 | const builtin = @import("builtin"); | |
| 73 | 73 | const root = @import("root"); |
| 74 | 74 | |
| 75 | 75 | pub const Level = enum { |
| ... | ... | @@ -170,7 +170,7 @@ pub fn defaultLog( |
| 170 | 170 | comptime format: []const u8, |
| 171 | 171 | args: anytype, |
| 172 | 172 | ) void { |
| 173 | if (std.Target.current.os.tag == .freestanding) { | |
| 173 | if (builtin.os.tag == .freestanding) { | |
| 174 | 174 | // On freestanding one must provide a log function; we do not have |
| 175 | 175 | // any I/O configured. |
| 176 | 176 | return; |
lib/std/mem.zig+4-3| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const debug = std.debug; |
| 3 | 4 | const assert = debug.assert; |
| 4 | 5 | const math = std.math; |
| ... | ... | @@ -7,13 +8,13 @@ const meta = std.meta; |
| 7 | 8 | const trait = meta.trait; |
| 8 | 9 | const testing = std.testing; |
| 9 | 10 | const Endian = std.builtin.Endian; |
| 10 | const native_endian = std.Target.current.cpu.arch.endian(); | |
| 11 | const native_endian = builtin.cpu.arch.endian(); | |
| 11 | 12 | |
| 12 | 13 | /// Compile time known minimum page size. |
| 13 | 14 | /// https://github.com/ziglang/zig/issues/4082 |
| 14 | pub const page_size = switch (std.Target.current.cpu.arch) { | |
| 15 | pub const page_size = switch (builtin.cpu.arch) { | |
| 15 | 16 | .wasm32, .wasm64 => 64 * 1024, |
| 16 | .aarch64 => switch (std.Target.current.os.tag) { | |
| 17 | .aarch64 => switch (builtin.os.tag) { | |
| 17 | 18 | .macos, .ios, .watchos, .tvos => 16 * 1024, |
| 18 | 19 | else => 4 * 1024, |
| 19 | 20 | }, |
lib/std/meta.zig+2-3| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const debug = std.debug; |
| 4 | 3 | const mem = std.mem; |
| 5 | 4 | const math = std.math; |
| ... | ... | @@ -9,7 +8,7 @@ const root = @import("root"); |
| 9 | 8 | pub const trait = @import("meta/trait.zig"); |
| 10 | 9 | pub const TrailerFlags = @import("meta/trailer_flags.zig").TrailerFlags; |
| 11 | 10 | |
| 12 | const TypeInfo = builtin.TypeInfo; | |
| 11 | const TypeInfo = std.builtin.TypeInfo; | |
| 13 | 12 | |
| 14 | 13 | pub fn tagName(v: anytype) []const u8 { |
| 15 | 14 | const T = @TypeOf(v); |
| ... | ... | @@ -858,7 +857,7 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De |
| 858 | 857 | |
| 859 | 858 | pub const IntType = @compileError("replaced by std.meta.Int"); |
| 860 | 859 | |
| 861 | pub fn Int(comptime signedness: builtin.Signedness, comptime bit_count: u16) type { | |
| 860 | pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type { | |
| 862 | 861 | return @Type(TypeInfo{ |
| 863 | 862 | .Int = .{ |
| 864 | 863 | .signedness = signedness, |
lib/std/meta/trait.zig+3-4| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const mem = std.mem; |
| 4 | 3 | const debug = std.debug; |
| 5 | 4 | const testing = std.testing; |
| ... | ... | @@ -98,7 +97,7 @@ test "std.meta.trait.hasField" { |
| 98 | 97 | try testing.expect(!hasField("value")(u8)); |
| 99 | 98 | } |
| 100 | 99 | |
| 101 | pub fn is(comptime id: builtin.TypeId) TraitFn { | |
| 100 | pub fn is(comptime id: std.builtin.TypeId) TraitFn { | |
| 102 | 101 | const Closure = struct { |
| 103 | 102 | pub fn trait(comptime T: type) bool { |
| 104 | 103 | return id == @typeInfo(T); |
| ... | ... | @@ -115,7 +114,7 @@ test "std.meta.trait.is" { |
| 115 | 114 | try testing.expect(!is(.Optional)(anyerror)); |
| 116 | 115 | } |
| 117 | 116 | |
| 118 | pub fn isPtrTo(comptime id: builtin.TypeId) TraitFn { | |
| 117 | pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn { | |
| 119 | 118 | const Closure = struct { |
| 120 | 119 | pub fn trait(comptime T: type) bool { |
| 121 | 120 | if (!comptime isSingleItemPtr(T)) return false; |
| ... | ... | @@ -131,7 +130,7 @@ test "std.meta.trait.isPtrTo" { |
| 131 | 130 | try testing.expect(!isPtrTo(.Struct)(**struct {})); |
| 132 | 131 | } |
| 133 | 132 | |
| 134 | pub fn isSliceOf(comptime id: builtin.TypeId) TraitFn { | |
| 133 | pub fn isSliceOf(comptime id: std.builtin.TypeId) TraitFn { | |
| 135 | 134 | const Closure = struct { |
| 136 | 135 | pub fn trait(comptime T: type) bool { |
| 137 | 136 | if (!comptime isSlice(T)) return false; |
lib/std/net.zig+3-3| ... | ... | @@ -12,7 +12,7 @@ const native_endian = builtin.target.cpu.arch.endian(); |
| 12 | 12 | // first release to support them. |
| 13 | 13 | pub const has_unix_sockets = @hasDecl(os.sockaddr, "un") and |
| 14 | 14 | (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); | |
| 16 | 16 | |
| 17 | 17 | pub const Address = extern union { |
| 18 | 18 | any: os.sockaddr, |
| ... | ... | @@ -1623,7 +1623,7 @@ pub const Stream = struct { |
| 1623 | 1623 | } |
| 1624 | 1624 | |
| 1625 | 1625 | pub fn read(self: Stream, buffer: []u8) ReadError!usize { |
| 1626 | if (std.Target.current.os.tag == .windows) { | |
| 1626 | if (builtin.os.tag == .windows) { | |
| 1627 | 1627 | return os.windows.ReadFile(self.handle, buffer, null, io.default_mode); |
| 1628 | 1628 | } |
| 1629 | 1629 | |
| ... | ... | @@ -1638,7 +1638,7 @@ pub const Stream = struct { |
| 1638 | 1638 | /// file system thread instead of non-blocking. It needs to be reworked to properly |
| 1639 | 1639 | /// use non-blocking I/O. |
| 1640 | 1640 | pub fn write(self: Stream, buffer: []const u8) WriteError!usize { |
| 1641 | if (std.Target.current.os.tag == .windows) { | |
| 1641 | if (builtin.os.tag == .windows) { | |
| 1642 | 1642 | return os.windows.WriteFile(self.handle, buffer, null, io.default_mode); |
| 1643 | 1643 | } |
| 1644 | 1644 |
lib/std/net/test.zig+12-12| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const net = std.net; |
| 4 | 4 | const mem = std.mem; |
| 5 | 5 | const testing = std.testing; |
| ... | ... | @@ -35,7 +35,7 @@ test "parse and render IPv6 addresses" { |
| 35 | 35 | var newIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable; |
| 36 | 36 | try std.testing.expect(std.mem.eql(u8, printed[i], newIp[1 .. newIp.len - 3])); |
| 37 | 37 | |
| 38 | if (std.builtin.os.tag == .linux) { | |
| 38 | if (builtin.os.tag == .linux) { | |
| 39 | 39 | var addr_via_resolve = net.Address.resolveIp6(ip, 0) catch unreachable; |
| 40 | 40 | var newResolvedIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr_via_resolve}) catch unreachable; |
| 41 | 41 | 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" { |
| 49 | 49 | try testing.expectError(error.Incomplete, net.Address.parseIp6("FF01:", 0)); |
| 50 | 50 | try testing.expectError(error.InvalidIpv4Mapping, net.Address.parseIp6("::123.123.123.123", 0)); |
| 51 | 51 | // TODO Make this test pass on other operating systems. |
| 52 | if (std.builtin.os.tag == .linux) { | |
| 52 | if (builtin.os.tag == .linux) { | |
| 53 | 53 | try testing.expectError(error.Incomplete, net.Address.resolveIp6("ff01::fb%", 0)); |
| 54 | 54 | try testing.expectError(error.Overflow, net.Address.resolveIp6("ff01::fb%wlp3s0s0s0s0s0s0s0s0", 0)); |
| 55 | 55 | try testing.expectError(error.Overflow, net.Address.resolveIp6("ff01::fb%12345678901234", 0)); |
| ... | ... | @@ -57,7 +57,7 @@ test "parse and render IPv6 addresses" { |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | test "invalid but parseable IPv6 scope ids" { |
| 60 | if (std.builtin.os.tag != .linux) { | |
| 60 | if (builtin.os.tag != .linux) { | |
| 61 | 61 | // Currently, resolveIp6 with alphanumerical scope IDs only works on Linux. |
| 62 | 62 | // TODO Make this test pass on other operating systems. |
| 63 | 63 | return error.SkipZigTest; |
| ... | ... | @@ -106,11 +106,11 @@ test "parse and render UNIX addresses" { |
| 106 | 106 | test "resolve DNS" { |
| 107 | 107 | if (builtin.os.tag == .wasi) return error.SkipZigTest; |
| 108 | 108 | |
| 109 | if (std.builtin.os.tag == .windows) { | |
| 109 | if (builtin.os.tag == .windows) { | |
| 110 | 110 | _ = try std.os.windows.WSAStartup(2, 2); |
| 111 | 111 | } |
| 112 | 112 | defer { |
| 113 | if (std.builtin.os.tag == .windows) { | |
| 113 | if (builtin.os.tag == .windows) { | |
| 114 | 114 | std.os.windows.WSACleanup() catch unreachable; |
| 115 | 115 | } |
| 116 | 116 | } |
| ... | ... | @@ -143,11 +143,11 @@ test "listen on a port, send bytes, receive bytes" { |
| 143 | 143 | if (builtin.single_threaded) return error.SkipZigTest; |
| 144 | 144 | if (builtin.os.tag == .wasi) return error.SkipZigTest; |
| 145 | 145 | |
| 146 | if (std.builtin.os.tag == .windows) { | |
| 146 | if (builtin.os.tag == .windows) { | |
| 147 | 147 | _ = try std.os.windows.WSAStartup(2, 2); |
| 148 | 148 | } |
| 149 | 149 | defer { |
| 150 | if (std.builtin.os.tag == .windows) { | |
| 150 | if (builtin.os.tag == .windows) { | |
| 151 | 151 | std.os.windows.WSACleanup() catch unreachable; |
| 152 | 152 | } |
| 153 | 153 | } |
| ... | ... | @@ -185,7 +185,7 @@ test "listen on a port, send bytes, receive bytes" { |
| 185 | 185 | test "listen on a port, send bytes, receive bytes" { |
| 186 | 186 | if (!std.io.is_async) return error.SkipZigTest; |
| 187 | 187 | |
| 188 | if (std.builtin.os.tag != .linux and !std.builtin.os.tag.isDarwin()) { | |
| 188 | if (builtin.os.tag != .linux and !builtin.os.tag.isDarwin()) { | |
| 189 | 189 | // TODO build abstractions for other operating systems |
| 190 | 190 | return error.SkipZigTest; |
| 191 | 191 | } |
| ... | ... | @@ -207,7 +207,7 @@ test "listen on a port, send bytes, receive bytes" { |
| 207 | 207 | test "listen on ipv4 try connect on ipv6 then ipv4" { |
| 208 | 208 | if (!std.io.is_async) return error.SkipZigTest; |
| 209 | 209 | |
| 210 | if (std.builtin.os.tag != .linux and !std.builtin.os.tag.isDarwin()) { | |
| 210 | if (builtin.os.tag != .linux and !builtin.os.tag.isDarwin()) { | |
| 211 | 211 | // TODO build abstractions for other operating systems |
| 212 | 212 | return error.SkipZigTest; |
| 213 | 213 | } |
| ... | ... | @@ -267,11 +267,11 @@ test "listen on a unix socket, send bytes, receive bytes" { |
| 267 | 267 | if (builtin.single_threaded) return error.SkipZigTest; |
| 268 | 268 | if (!net.has_unix_sockets) return error.SkipZigTest; |
| 269 | 269 | |
| 270 | if (std.builtin.os.tag == .windows) { | |
| 270 | if (builtin.os.tag == .windows) { | |
| 271 | 271 | _ = try std.os.windows.WSAStartup(2, 2); |
| 272 | 272 | } |
| 273 | 273 | defer { |
| 274 | if (std.builtin.os.tag == .windows) { | |
| 274 | if (builtin.os.tag == .windows) { | |
| 275 | 275 | std.os.windows.WSACleanup() catch unreachable; |
| 276 | 276 | } |
| 277 | 277 | } |
lib/std/once.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const testing = std.testing; |
| 4 | 4 | |
| 5 | 5 | pub 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 { |
| 240 | 240 | _ = wasi.fd_close(fd); |
| 241 | 241 | return; |
| 242 | 242 | } |
| 243 | if (comptime std.Target.current.isDarwin()) { | |
| 243 | if (comptime builtin.target.isDarwin()) { | |
| 244 | 244 | // This avoids the EINTR problem. |
| 245 | 245 | switch (darwin.getErrno(darwin.@"close$NOCANCEL"(fd))) { |
| 246 | 246 | .BADF => unreachable, // Always a race condition. |
| ... | ... | @@ -487,7 +487,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | // Prevents EINVAL. |
| 490 | const max_count = switch (std.Target.current.os.tag) { | |
| 490 | const max_count = switch (builtin.os.tag) { | |
| 491 | 491 | .linux => 0x7ffff000, |
| 492 | 492 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 493 | 493 | else => math.maxInt(isize), |
| ... | ... | @@ -525,7 +525,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 525 | 525 | /// * Windows |
| 526 | 526 | /// On these systems, the read races with concurrent writes to the same file descriptor. |
| 527 | 527 | pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { |
| 528 | if (std.Target.current.os.tag == .windows) { | |
| 528 | if (builtin.os.tag == .windows) { | |
| 529 | 529 | // TODO improve this to use ReadFileScatter |
| 530 | 530 | if (iov.len == 0) return @as(usize, 0); |
| 531 | 531 | const first = iov[0]; |
| ... | ... | @@ -616,7 +616,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | // Prevent EINVAL. |
| 619 | const max_count = switch (std.Target.current.os.tag) { | |
| 619 | const max_count = switch (builtin.os.tag) { | |
| 620 | 620 | .linux => 0x7ffff000, |
| 621 | 621 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 622 | 622 | else => math.maxInt(isize), |
| ... | ... | @@ -662,7 +662,7 @@ pub const TruncateError = error{ |
| 662 | 662 | } || UnexpectedError; |
| 663 | 663 | |
| 664 | 664 | pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 665 | if (std.Target.current.os.tag == .windows) { | |
| 665 | if (builtin.os.tag == .windows) { | |
| 666 | 666 | var io_status_block: windows.IO_STATUS_BLOCK = undefined; |
| 667 | 667 | var eof_info = windows.FILE_END_OF_FILE_INFORMATION{ |
| 668 | 668 | .EndOfFile = @bitCast(windows.LARGE_INTEGER, length), |
| ... | ... | @@ -683,7 +683,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 683 | 683 | else => return windows.unexpectedStatus(rc), |
| 684 | 684 | } |
| 685 | 685 | } |
| 686 | if (std.Target.current.os.tag == .wasi and !builtin.link_libc) { | |
| 686 | if (builtin.os.tag == .wasi and !builtin.link_libc) { | |
| 687 | 687 | switch (wasi.fd_filestat_set_size(fd, length)) { |
| 688 | 688 | .SUCCESS => return, |
| 689 | 689 | .INTR => unreachable, |
| ... | ... | @@ -733,7 +733,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 733 | 733 | /// * Windows |
| 734 | 734 | /// On these systems, the read races with concurrent writes to the same file descriptor. |
| 735 | 735 | pub 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) { | |
| 737 | 737 | .windows, .macos, .ios, .watchos, .tvos, .haiku => true, |
| 738 | 738 | else => false, |
| 739 | 739 | }; |
| ... | ... | @@ -868,7 +868,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | const max_count = switch (std.Target.current.os.tag) { | |
| 871 | const max_count = switch (builtin.os.tag) { | |
| 872 | 872 | .linux => 0x7ffff000, |
| 873 | 873 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 874 | 874 | else => math.maxInt(isize), |
| ... | ... | @@ -916,7 +916,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 916 | 916 | /// |
| 917 | 917 | /// If `iov.len` is larger than `IOV_MAX`, a partial write will occur. |
| 918 | 918 | pub 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) { | |
| 920 | 920 | // TODO improve this to use WriteFileScatter |
| 921 | 921 | if (iov.len == 0) return @as(usize, 0); |
| 922 | 922 | const first = iov[0]; |
| ... | ... | @@ -991,7 +991,7 @@ pub const PWriteError = WriteError || error{Unseekable}; |
| 991 | 991 | /// The limit on Darwin is `0x7fffffff`, trying to write more than that returns EINVAL. |
| 992 | 992 | /// The corresponding POSIX limit is `math.maxInt(isize)`. |
| 993 | 993 | pub 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) { | |
| 995 | 995 | return windows.WriteFile(fd, bytes, offset, std.io.default_mode); |
| 996 | 996 | } |
| 997 | 997 | 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 { |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | // Prevent EINVAL. |
| 1027 | const max_count = switch (std.Target.current.os.tag) { | |
| 1027 | const max_count = switch (builtin.os.tag) { | |
| 1028 | 1028 | .linux => 0x7ffff000, |
| 1029 | 1029 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 1030 | 1030 | else => math.maxInt(isize), |
| ... | ... | @@ -1083,7 +1083,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 1083 | 1083 | /// |
| 1084 | 1084 | /// If `iov.len` is larger than `IOV_MAX`, a partial write will occur. |
| 1085 | 1085 | pub 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) { | |
| 1087 | 1087 | .windows, .macos, .ios, .watchos, .tvos, .haiku => true, |
| 1088 | 1088 | else => false, |
| 1089 | 1089 | }; |
| ... | ... | @@ -1199,7 +1199,7 @@ pub const OpenError = error{ |
| 1199 | 1199 | /// Open and possibly create a file. Keeps trying if it gets interrupted. |
| 1200 | 1200 | /// See also `openZ`. |
| 1201 | 1201 | pub 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) { | |
| 1203 | 1203 | const file_path_w = try windows.sliceToPrefixedFileW(file_path); |
| 1204 | 1204 | return openW(file_path_w.span(), flags, perm); |
| 1205 | 1205 | } |
| ... | ... | @@ -1212,7 +1212,7 @@ pub const openC = @compileError("deprecated: renamed to openZ"); |
| 1212 | 1212 | /// Open and possibly create a file. Keeps trying if it gets interrupted. |
| 1213 | 1213 | /// See also `open`. |
| 1214 | 1214 | pub 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) { | |
| 1216 | 1216 | const file_path_w = try windows.cStrToPrefixedFileW(file_path); |
| 1217 | 1217 | return openW(file_path_w.span(), flags, perm); |
| 1218 | 1218 | } |
| ... | ... | @@ -2900,7 +2900,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t |
| 2900 | 2900 | return rc; |
| 2901 | 2901 | } |
| 2902 | 2902 | |
| 2903 | const have_sock_flags = comptime !std.Target.current.isDarwin(); | |
| 2903 | const have_sock_flags = comptime !builtin.target.isDarwin(); | |
| 2904 | 2904 | const filtered_sock_type = if (!have_sock_flags) |
| 2905 | 2905 | socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC) |
| 2906 | 2906 | else |
| ... | ... | @@ -3199,7 +3199,7 @@ pub fn accept( |
| 3199 | 3199 | /// description of the `O.CLOEXEC` flag in `open` for reasons why this may be useful. |
| 3200 | 3200 | flags: u32, |
| 3201 | 3201 | ) 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); | |
| 3203 | 3203 | assert(0 == (flags & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC))); // Unsupported flag(s) |
| 3204 | 3204 | |
| 3205 | 3205 | const accepted_sock = while (true) { |
| ... | ... | @@ -4807,7 +4807,7 @@ pub const ClockGetTimeError = error{UnsupportedClock} || UnexpectedError; |
| 4807 | 4807 | /// TODO: change this to return the timespec as a return value |
| 4808 | 4808 | /// TODO: look into making clk_id an enum |
| 4809 | 4809 | pub 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) { | |
| 4811 | 4811 | var ts: timestamp_t = undefined; |
| 4812 | 4812 | switch (system.clock_time_get(@bitCast(u32, clk_id), 1, &ts)) { |
| 4813 | 4813 | .SUCCESS => { |
| ... | ... | @@ -4821,7 +4821,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 4821 | 4821 | } |
| 4822 | 4822 | return; |
| 4823 | 4823 | } |
| 4824 | if (std.Target.current.os.tag == .windows) { | |
| 4824 | if (builtin.os.tag == .windows) { | |
| 4825 | 4825 | if (clk_id == CLOCK.REALTIME) { |
| 4826 | 4826 | var ft: windows.FILETIME = undefined; |
| 4827 | 4827 | windows.kernel32.GetSystemTimeAsFileTime(&ft); |
| ... | ... | @@ -4848,7 +4848,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void { |
| 4848 | 4848 | } |
| 4849 | 4849 | |
| 4850 | 4850 | pub 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) { | |
| 4852 | 4852 | var ts: timestamp_t = undefined; |
| 4853 | 4853 | switch (system.clock_res_get(@bitCast(u32, clk_id), &ts)) { |
| 4854 | 4854 | .SUCCESS => res.* = .{ |
| ... | ... | @@ -5416,19 +5416,19 @@ pub fn sendfile( |
| 5416 | 5416 | |
| 5417 | 5417 | // Prevents EOVERFLOW. |
| 5418 | 5418 | 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) { | |
| 5420 | 5420 | .linux => 0x7ffff000, |
| 5421 | 5421 | .macos, .ios, .watchos, .tvos => math.maxInt(i32), |
| 5422 | 5422 | else => math.maxInt(size_t), |
| 5423 | 5423 | }; |
| 5424 | 5424 | |
| 5425 | switch (std.Target.current.os.tag) { | |
| 5425 | switch (builtin.os.tag) { | |
| 5426 | 5426 | .linux => sf: { |
| 5427 | 5427 | // sendfile() first appeared in Linux 2.2, glibc 2.1. |
| 5428 | 5428 | const call_sf = comptime if (builtin.link_libc) |
| 5429 | 5429 | std.c.versionCheck(.{ .major = 2, .minor = 1 }).ok |
| 5430 | 5430 | 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; | |
| 5432 | 5432 | if (!call_sf) break :sf; |
| 5433 | 5433 | |
| 5434 | 5434 | if (headers.len != 0) { |
| ... | ... | @@ -5719,13 +5719,13 @@ var has_copy_file_range_syscall = std.atomic.Atomic(bool).init(true); |
| 5719 | 5719 | /// |
| 5720 | 5720 | /// Maximum offsets on Linux are `math.maxInt(i64)`. |
| 5721 | 5721 | pub 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) | |
| 5723 | 5723 | // WASI-libc doesn't have copy_file_range. |
| 5724 | 5724 | false |
| 5725 | 5725 | else if (builtin.link_libc) |
| 5726 | 5726 | std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }).ok |
| 5727 | 5727 | 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; | |
| 5729 | 5729 | |
| 5730 | 5730 | if (call_cfr and has_copy_file_range_syscall.load(.Monotonic)) { |
| 5731 | 5731 | var off_in_copy = @bitCast(i64, off_in); |
| ... | ... | @@ -6179,7 +6179,7 @@ pub fn syncfs(fd: fd_t) SyncError!void { |
| 6179 | 6179 | |
| 6180 | 6180 | /// Write all pending file contents and metadata modifications for the specified file descriptor to the underlying filesystem. |
| 6181 | 6181 | pub fn fsync(fd: fd_t) SyncError!void { |
| 6182 | if (std.Target.current.os.tag == .windows) { | |
| 6182 | if (builtin.os.tag == .windows) { | |
| 6183 | 6183 | if (windows.kernel32.FlushFileBuffers(fd) != 0) |
| 6184 | 6184 | return; |
| 6185 | 6185 | switch (windows.kernel32.GetLastError()) { |
| ... | ... | @@ -6203,7 +6203,7 @@ pub fn fsync(fd: fd_t) SyncError!void { |
| 6203 | 6203 | |
| 6204 | 6204 | /// Write all pending file contents for the specified file descriptor to the underlying filesystem, but not necessarily the metadata. |
| 6205 | 6205 | pub fn fdatasync(fd: fd_t) SyncError!void { |
| 6206 | if (std.Target.current.os.tag == .windows) { | |
| 6206 | if (builtin.os.tag == .windows) { | |
| 6207 | 6207 | return fsync(fd) catch |err| switch (err) { |
| 6208 | 6208 | SyncError.AccessDenied => return, // fdatasync doesn't promise that the access time was synced |
| 6209 | 6209 | else => return err, |
lib/std/os/linux.zig+9-8| ... | ... | @@ -6,12 +6,13 @@ |
| 6 | 6 | //! provide `rename` when only the `renameat` syscall exists. |
| 7 | 7 | //! * Does not support POSIX thread cancellation. |
| 8 | 8 | const std = @import("../std.zig"); |
| 9 | const builtin = @import("builtin"); | |
| 9 | 10 | const assert = std.debug.assert; |
| 10 | 11 | const maxInt = std.math.maxInt; |
| 11 | 12 | const elf = std.elf; |
| 12 | 13 | const vdso = @import("linux/vdso.zig"); |
| 13 | 14 | const dl = @import("../dynamic_library.zig"); |
| 14 | const native_arch = std.Target.current.cpu.arch; | |
| 15 | const native_arch = builtin.cpu.arch; | |
| 15 | 16 | const native_endian = native_arch.endian(); |
| 16 | 17 | const is_mips = native_arch.isMIPS(); |
| 17 | 18 | const is_ppc = native_arch.isPPC(); |
| ... | ... | @@ -21,7 +22,7 @@ const iovec = std.os.iovec; |
| 21 | 22 | const iovec_const = std.os.iovec_const; |
| 22 | 23 | |
| 23 | 24 | test { |
| 24 | if (std.Target.current.os.tag == .linux) { | |
| 25 | if (builtin.os.tag == .linux) { | |
| 25 | 26 | _ = @import("linux/test.zig"); |
| 26 | 27 | } |
| 27 | 28 | } |
| ... | ... | @@ -150,10 +151,10 @@ pub fn getauxval(index: usize) usize { |
| 150 | 151 | // Some architectures (and some syscalls) require 64bit parameters to be passed |
| 151 | 152 | // in a even-aligned register pair. |
| 152 | 153 | const 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(); | |
| 157 | 158 | |
| 158 | 159 | // Split a 64bit value into a {LSB,MSB} pair. |
| 159 | 160 | // 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, |
| 1579 | 1580 | } |
| 1580 | 1581 | |
| 1581 | 1582 | pub 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()) { | |
| 1583 | 1584 | // MIPS requires a 7 argument syscall |
| 1584 | 1585 | |
| 1585 | 1586 | const offset_halves = splitValue64(offset); |
| ... | ... | @@ -1595,7 +1596,7 @@ pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize { |
| 1595 | 1596 | length_halves[1], |
| 1596 | 1597 | advice, |
| 1597 | 1598 | ); |
| 1598 | } else if (comptime std.Target.current.cpu.arch.isARM()) { | |
| 1599 | } else if (comptime builtin.cpu.arch.isARM()) { | |
| 1599 | 1600 | // ARM reorders the arguments |
| 1600 | 1601 | |
| 1601 | 1602 | const offset_halves = splitValue64(offset); |
lib/std/os/linux/bpf/kern.zig+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("../../../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | const in_bpf_program = switch (std.builtin.cpu.arch) { | |
| 4 | const in_bpf_program = switch (builtin.cpu.arch) { | |
| 4 | 5 | .bpfel, .bpfeb => true, |
| 5 | 6 | else => false, |
| 6 | 7 | }; |
lib/std/os/linux/io_uring.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | const builtin = std.builtin; | |
| 4 | 4 | const mem = std.mem; |
| 5 | 5 | const net = std.net; |
| 6 | 6 | const os = std.os; |
lib/std/os/linux/start_pie.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const elf = std.elf; |
| 3 | const builtin = std.builtin; | |
| 4 | 4 | const assert = std.debug.assert; |
| 5 | 5 | |
| 6 | 6 | const R_AMD64_RELATIVE = 8; |
lib/std/os/linux/test.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const linux = std.os.linux; |
| 4 | 4 | const mem = std.mem; |
| 5 | 5 | const elf = std.elf; |
lib/std/os/linux/tls.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const mem = std.mem; |
| 4 | 4 | const elf = std.elf; |
| 5 | 5 | const math = std.math; |
| 6 | 6 | const assert = std.debug.assert; |
| 7 | const native_arch = std.Target.current.cpu.arch; | |
| 7 | const native_arch = @import("builtin").cpu.arch; | |
| 8 | 8 | |
| 9 | 9 | // This file implements the two TLS variants [1] used by ELF-based systems. |
| 10 | 10 | // |
lib/std/os/windows/user32.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | |
| 4 | 5 | const windows = std.os.windows; |
| ... | ... | @@ -29,7 +30,7 @@ const HBRUSH = windows.HBRUSH; |
| 29 | 30 | |
| 30 | 31 | fn selectSymbol(comptime function_static: anytype, function_dynamic: @TypeOf(function_static), comptime os: std.Target.Os.WindowsVersion) @TypeOf(function_static) { |
| 31 | 32 | comptime { |
| 32 | const sym_ok = std.Target.current.os.isAtLeast(.windows, os); | |
| 33 | const sym_ok = builtin.os.isAtLeast(.windows, os); | |
| 33 | 34 | if (sym_ok == true) return function_static; |
| 34 | 35 | if (sym_ok == null) return function_dynamic; |
| 35 | 36 | 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 @@ |
| 1 | const builtin = std.builtin; | |
| 2 | 1 | const std = @import("std.zig"); |
| 3 | 2 | const io = std.io; |
| 4 | 3 | const math = std.math; |
lib/std/process.zig+3-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const os = std.os; |
| 4 | 4 | const fs = std.fs; |
| 5 | 5 | const BufMap = std.BufMap; |
| ... | ... | @@ -863,9 +863,9 @@ pub fn execve( |
| 863 | 863 | if (env_map) |m| { |
| 864 | 864 | const envp_buf = try child_process.createNullDelimitedEnvMap(arena, m); |
| 865 | 865 | break :m envp_buf.ptr; |
| 866 | } else if (std.builtin.link_libc) { | |
| 866 | } else if (builtin.link_libc) { | |
| 867 | 867 | break :m std.c.environ; |
| 868 | } else if (std.builtin.output_mode == .Exe) { | |
| 868 | } else if (builtin.output_mode == .Exe) { | |
| 869 | 869 | // Then we have Zig start code and this works. |
| 870 | 870 | // TODO type-safety for null-termination of `os.environ`. |
| 871 | 871 | break :m @ptrCast([*:null]?[*:0]u8, os.environ.ptr); |
lib/std/rand.zig-1| ... | ... | @@ -7,7 +7,6 @@ |
| 7 | 7 | //! TODO(tiehuis): Benchmark these against other reference implementations. |
| 8 | 8 | |
| 9 | 9 | const std = @import("std.zig"); |
| 10 | const builtin = std.builtin; | |
| 11 | 10 | const assert = std.debug.assert; |
| 12 | 11 | const expect = std.testing.expect; |
| 13 | 12 | const 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. | |
| 10 | 10 | |
| 11 | 11 | const std = @import("../std.zig"); |
| 12 | const builtin = @import("builtin"); | |
| 12 | 13 | const math = std.math; |
| 13 | 14 | const Random = std.rand.Random; |
| 14 | 15 | |
| ... | ... | @@ -126,7 +127,7 @@ fn norm_zero_case(random: *Random, u: f64) f64 { |
| 126 | 127 | } |
| 127 | 128 | } |
| 128 | 129 | |
| 129 | const please_windows_dont_oom = std.Target.current.os.tag == .windows; | |
| 130 | const please_windows_dont_oom = builtin.os.tag == .windows; | |
| 130 | 131 | |
| 131 | 132 | test "normal dist sanity" { |
| 132 | 133 | if (please_windows_dont_oom) return error.SkipZigTest; |
lib/std/sort.zig-1| ... | ... | @@ -3,7 +3,6 @@ const assert = std.debug.assert; |
| 3 | 3 | const testing = std.testing; |
| 4 | 4 | const mem = std.mem; |
| 5 | 5 | const math = std.math; |
| 6 | const builtin = std.builtin; | |
| 7 | 6 | |
| 8 | 7 | pub fn binarySearch( |
| 9 | 8 | comptime T: type, |
lib/std/special/compiler_rt.zig+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | const is_test = builtin.is_test; |
| 4 | const os_tag = std.Target.current.os.tag; | |
| 4 | const os_tag = builtin.os.tag; | |
| 5 | 5 | const arch = builtin.stage2_arch; |
| 6 | const abi = std.Target.current.abi; | |
| 6 | const abi = builtin.abi; | |
| 7 | 7 | |
| 8 | 8 | const is_gnu = abi.isGnu(); |
| 9 | 9 | const is_mingw = os_tag == .windows and is_gnu; |
lib/std/special/compiler_rt/atomics.zig+5-5| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 3 | const arch = std.Target.current.cpu.arch; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | const arch = builtin.cpu.arch; | |
| 4 | 4 | |
| 5 | const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | |
| 6 | 6 | |
| 7 | 7 | // This parameter is true iff the target architecture supports the bare minimum |
| 8 | 8 | // to implement the atomic load/store intrinsics. |
| ... | ... | @@ -16,7 +16,7 @@ const supports_atomic_ops = switch (arch) { |
| 16 | 16 | // operations (unless we're targeting Linux, the kernel provides a way to |
| 17 | 17 | // perform CAS operations). |
| 18 | 18 | // 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), | |
| 20 | 20 | else => true, |
| 21 | 21 | }; |
| 22 | 22 | |
| ... | ... | @@ -257,7 +257,7 @@ comptime { |
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T { | |
| 260 | fn fetchFn(comptime T: type, comptime op: std.builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T { | |
| 261 | 261 | return struct { |
| 262 | 262 | pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T { |
| 263 | 263 | _ = model; |
lib/std/special/compiler_rt/clear_cache.zig+4-3| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const arch = std.builtin.cpu.arch; | |
| 3 | const os = std.builtin.os.tag; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | const arch = builtin.cpu.arch; | |
| 4 | const os = builtin.os.tag; | |
| 4 | 5 | |
| 5 | 6 | // Ported from llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28 |
| 6 | 7 | |
| ... | ... | @@ -156,7 +157,7 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void { |
| 156 | 157 | } |
| 157 | 158 | } |
| 158 | 159 | |
| 159 | const linkage = if (std.builtin.is_test) std.builtin.GlobalLinkage.Internal else std.builtin.GlobalLinkage.Weak; | |
| 160 | const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.Internal else std.builtin.GlobalLinkage.Weak; | |
| 160 | 161 | |
| 161 | 162 | fn exportIt() void { |
| 162 | 163 | @export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage }); |
lib/std/special/compiler_rt/count0bits.zig+8-8| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | |
| 4 | 4 | // clz - count leading zeroes |
| 5 | 5 | // - clzXi2_generic for little endian |
| ... | ... | @@ -118,18 +118,18 @@ fn __clzsi2_arm32() callconv(.Naked) void { |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | pub const __clzsi2 = impl: { |
| 121 | switch (std.Target.current.cpu.arch) { | |
| 121 | switch (builtin.cpu.arch) { | |
| 122 | 122 | .arm, .armeb, .thumb, .thumbeb => { |
| 123 | 123 | 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); | |
| 127 | 127 | |
| 128 | 128 | if (use_thumb1) { |
| 129 | 129 | break :impl __clzsi2_thumb1; |
| 130 | 130 | } |
| 131 | 131 | // 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()) { | |
| 133 | 133 | break :impl __clzsi2_arm32; |
| 134 | 134 | } |
| 135 | 135 | // Use the generic implementation otherwise. |
| ... | ... | @@ -140,14 +140,14 @@ pub const __clzsi2 = impl: { |
| 140 | 140 | }; |
| 141 | 141 | |
| 142 | 142 | pub const __clzdi2 = impl: { |
| 143 | switch (std.Target.current.cpu.arch) { | |
| 143 | switch (builtin.cpu.arch) { | |
| 144 | 144 | // TODO architecture optimised versions |
| 145 | 145 | else => break :impl clzXi2_generic(i64), |
| 146 | 146 | } |
| 147 | 147 | }; |
| 148 | 148 | |
| 149 | 149 | pub const __clzti2 = impl: { |
| 150 | switch (std.Target.current.cpu.arch) { | |
| 150 | switch (builtin.cpu.arch) { | |
| 151 | 151 | // TODO architecture optimised versions |
| 152 | 152 | else => break :impl clzXi2_generic(i128), |
| 153 | 153 | } |
lib/std/special/compiler_rt/emutls.zig+2-1| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | // |
| 6 | 6 | |
| 7 | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | |
| 8 | 9 | |
| 9 | 10 | const abort = std.os.abort; |
| 10 | 11 | const assert = std.debug.assert; |
| ... | ... | @@ -15,7 +16,7 @@ const expect = std.testing.expect; |
| 15 | 16 | const gcc_word = usize; |
| 16 | 17 | |
| 17 | 18 | comptime { |
| 18 | assert(std.builtin.link_libc); | |
| 19 | assert(builtin.link_libc); | |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | 22 | /// public entrypoint for generated code using EmulatedTLS |
lib/std/special/compiler_rt/muldi3.zig+3-2| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const is_test = std.builtin.is_test; | |
| 3 | const native_endian = std.Target.current.cpu.arch.endian(); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | const is_test = builtin.is_test; | |
| 4 | const native_endian = builtin.cpu.arch.endian(); | |
| 4 | 5 | |
| 5 | 6 | // Ported from |
| 6 | 7 | // 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 @@ |
| 1 | 1 | const compiler_rt = @import("../compiler_rt.zig"); |
| 2 | 2 | const std = @import("std"); |
| 3 | const is_test = std.builtin.is_test; | |
| 4 | const native_endian = std.Target.current.cpu.arch.endian(); | |
| 3 | const builtin = @import("builtin"); | |
| 4 | const is_test = builtin.is_test; | |
| 5 | const native_endian = builtin.cpu.arch.endian(); | |
| 5 | 6 | |
| 6 | 7 | // Ported from git@github.com:llvm-project/llvm-project-20170507.git |
| 7 | 8 | // ae684fad6d34858c014c94da69c15e7774a633c3 |
lib/std/special/compiler_rt/shift.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const Log2Int = std.math.Log2Int; |
| 3 | const native_endian = std.Target.current.cpu.arch.endian(); | |
| 3 | const native_endian = @import("builtin").cpu.arch.endian(); | |
| 4 | 4 | |
| 5 | 5 | fn Dwords(comptime T: type, comptime signed_half: bool) type { |
| 6 | 6 | return extern union { |
lib/std/special/compiler_rt/stack_probe.zig+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | const native_arch = @import("std").Target.current.cpu.arch; | |
| 1 | const native_arch = @import("builtin").cpu.arch; | |
| 2 | 2 | |
| 3 | 3 | // Zig's own stack-probe routine (available only on x86 and x86_64) |
| 4 | 4 | pub fn zig_probe_stack() callconv(.Naked) void { |
lib/std/special/compiler_rt/udivmod.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | const is_test = builtin.is_test; |
| 3 | const native_endian = @import("std").Target.current.cpu.arch.endian(); | |
| 3 | const native_endian = builtin.cpu.arch.endian(); | |
| 4 | 4 | |
| 5 | 5 | const low = switch (native_endian) { |
| 6 | 6 | .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. | |
| 6 | const std = @import("std"); | |
| 7 | const 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 | |
| 8 | 14 | |
| 9 | // Missing exports: | |
| 10 | // - __gets_chk | |
| 11 | // - __mempcpy_chk | |
| 12 | // - __snprintf_chk | |
| 13 | // - __sprintf_chk | |
| 14 | // - __stpcpy_chk | |
| 15 | // - __vsnprintf_chk | |
| 16 | // - __vsprintf_chk | |
| 15 | const std = @import("std"); | |
| 17 | 16 | |
| 18 | 17 | extern fn strncpy(dest: [*:0]u8, src: [*:0]const u8, n: usize) callconv(.C) [*:0]u8; |
| 19 | 18 | extern 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 |
| 21 | 20 | extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8; |
| 22 | 21 | |
| 23 | 22 | // Avoid dragging in the runtime safety mechanisms into this .o file. |
| 24 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { | |
| 23 | pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { | |
| 25 | 24 | _ = msg; |
| 26 | 25 | _ = error_return_trace; |
| 27 | 26 | @setCold(true); |
lib/std/std.zig+1-1| ... | ... | @@ -95,7 +95,7 @@ comptime { |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | test { |
| 98 | if (builtin.os.tag == .windows) { | |
| 98 | if (@import("builtin").os.tag == .windows) { | |
| 99 | 99 | // We only test the Windows-relevant stuff to save memory because the CI |
| 100 | 100 | // server is hitting OOM. TODO revert this after stage2 arrives. |
| 101 | 101 | _ = ChildProcess; |
lib/std/target.zig+3-3| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | 2 | const mem = std.mem; |
| 3 | const builtin = std.builtin; | |
| 4 | 3 | const Version = std.builtin.Version; |
| 5 | 4 | |
| 6 | 5 | /// TODO Nearly all the functions in this namespace would be |
| ... | ... | @@ -1017,7 +1016,7 @@ pub const Target = struct { |
| 1017 | 1016 | }; |
| 1018 | 1017 | } |
| 1019 | 1018 | |
| 1020 | pub fn endian(arch: Arch) builtin.Endian { | |
| 1019 | pub fn endian(arch: Arch) std.builtin.Endian { | |
| 1021 | 1020 | return switch (arch) { |
| 1022 | 1021 | .avr, |
| 1023 | 1022 | .arm, |
| ... | ... | @@ -1302,7 +1301,8 @@ pub const Target = struct { |
| 1302 | 1301 | } |
| 1303 | 1302 | }; |
| 1304 | 1303 | |
| 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"); | |
| 1306 | 1306 | |
| 1307 | 1307 | pub const stack_align = 16; |
| 1308 | 1308 |
lib/std/testing.zig+3-2| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const math = std.math; |
| 4 | 5 | const print = std.debug.print; |
| ... | ... | @@ -322,7 +323,7 @@ pub const TmpDir = struct { |
| 322 | 323 | }; |
| 323 | 324 | |
| 324 | 325 | fn 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) { | |
| 326 | 327 | var preopens = std.fs.wasi.PreopenList.init(allocator); |
| 327 | 328 | defer preopens.deinit(); |
| 328 | 329 | preopens.populate() catch |
| ... | ... | @@ -464,7 +465,7 @@ test { |
| 464 | 465 | |
| 465 | 466 | /// Given a type, reference all the declarations inside, so that the semantic analyzer sees them. |
| 466 | 467 | pub fn refAllDecls(comptime T: type) void { |
| 467 | if (!std.builtin.is_test) return; | |
| 468 | if (!builtin.is_test) return; | |
| 468 | 469 | inline for (std.meta.declarations(T)) |decl| { |
| 469 | 470 | _ = decl; |
| 470 | 471 | } |
lib/std/time.zig+5-5| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | const std = @import("std.zig"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | 4 | const testing = std.testing; |
| 5 | 5 | const os = std.os; |
| 6 | 6 | const math = std.math; |
| 7 | const is_windows = std.Target.current.os.tag == .windows; | |
| 7 | const is_windows = builtin.os.tag == .windows; | |
| 8 | 8 | |
| 9 | 9 | pub const epoch = @import("time/epoch.zig"); |
| 10 | 10 | |
| ... | ... | @@ -173,7 +173,7 @@ pub const Timer = struct { |
| 173 | 173 | .resolution = @divFloor(ns_per_s, freq), |
| 174 | 174 | .start_time = os.windows.QueryPerformanceCounter(), |
| 175 | 175 | }; |
| 176 | } else if (comptime std.Target.current.isDarwin()) { | |
| 176 | } else if (comptime builtin.target.isDarwin()) { | |
| 177 | 177 | var freq: os.darwin.mach_timebase_info_data = undefined; |
| 178 | 178 | os.darwin.mach_timebase_info(&freq); |
| 179 | 179 | |
| ... | ... | @@ -225,7 +225,7 @@ pub const Timer = struct { |
| 225 | 225 | if (is_windows) { |
| 226 | 226 | return os.windows.QueryPerformanceCounter(); |
| 227 | 227 | } |
| 228 | if (comptime std.Target.current.isDarwin()) { | |
| 228 | if (comptime builtin.target.isDarwin()) { | |
| 229 | 229 | return os.darwin.mach_absolute_time(); |
| 230 | 230 | } |
| 231 | 231 | var ts: os.timespec = undefined; |
| ... | ... | @@ -237,7 +237,7 @@ pub const Timer = struct { |
| 237 | 237 | if (is_windows) { |
| 238 | 238 | return safeMulDiv(duration, ns_per_s, self.frequency); |
| 239 | 239 | } |
| 240 | if (comptime std.Target.current.isDarwin()) { | |
| 240 | if (comptime builtin.target.isDarwin()) { | |
| 241 | 241 | return safeMulDiv(duration, self.frequency.numer, self.frequency.denom); |
| 242 | 242 | } |
| 243 | 243 | return duration; |
lib/std/unicode.zig-1| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("./std.zig"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const assert = std.debug.assert; |
| 4 | 3 | const testing = std.testing; |
| 5 | 4 | const mem = std.mem; |
lib/std/unicode/throughput_test.zig-1| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const time = std.time; |
| 4 | 3 | const unicode = std.unicode; |
| 5 | 4 |
lib/std/x/net/tcp.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const io = std.io; |
| 4 | 5 | const os = std.os; |
| ... | ... | @@ -7,7 +8,7 @@ const ip = std.x.net.ip; |
| 7 | 8 | const fmt = std.fmt; |
| 8 | 9 | const mem = std.mem; |
| 9 | 10 | const testing = std.testing; |
| 10 | const native_os = std.Target.current.os; | |
| 11 | const native_os = builtin.os; | |
| 11 | 12 | |
| 12 | 13 | const IPv4 = std.x.os.IPv4; |
| 13 | 14 | const IPv6 = std.x.os.IPv6; |
lib/std/x/os/io.zig+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const os = std.os; |
| 4 | 5 | const mem = std.mem; |
| 5 | 6 | const testing = std.testing; |
| 6 | const native_os = std.Target.current.os; | |
| 7 | const native_os = builtin.os; | |
| 7 | 8 | const linux = std.os.linux; |
| 8 | 9 | |
| 9 | 10 | /// 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 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const os = std.os; |
| 4 | 5 | const fmt = std.fmt; |
| 5 | 6 | const mem = std.mem; |
| 6 | 7 | const math = std.math; |
| 7 | 8 | const testing = std.testing; |
| 8 | const native_os = std.Target.current.os; | |
| 9 | const native_os = builtin.os; | |
| 9 | 10 | const have_ifnamesize = @hasDecl(os.system, "IFNAMESIZE"); |
| 10 | 11 | |
| 11 | 12 | /// Resolves a network interface name into a scope/zone ID. It returns |
lib/std/x/os/socket.zig+3-2| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("../../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const net = @import("net.zig"); |
| 3 | 4 | |
| 4 | 5 | const os = std.os; |
| ... | ... | @@ -6,8 +7,8 @@ const fmt = std.fmt; |
| 6 | 7 | const mem = std.mem; |
| 7 | 8 | const time = std.time; |
| 8 | 9 | const meta = std.meta; |
| 9 | const native_os = std.Target.current.os; | |
| 10 | const native_endian = std.Target.current.cpu.arch.endian(); | |
| 10 | const native_os = builtin.os; | |
| 11 | const native_endian = builtin.cpu.arch.endian(); | |
| 11 | 12 | |
| 12 | 13 | const Buffer = std.x.os.Buffer; |
| 13 | 14 |
lib/std/zig/cross_target.zig+13-12| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | const Target = std.Target; |
| 4 | 5 | const mem = std.mem; |
| ... | ... | @@ -329,7 +330,7 @@ pub const CrossTarget = struct { |
| 329 | 330 | // This works when doing `zig build` because Zig generates a build executable using |
| 330 | 331 | // native CPU model & features. However this will not be accurate otherwise, and |
| 331 | 332 | // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`. |
| 332 | return Target.current.cpu; | |
| 333 | return builtin.cpu; | |
| 333 | 334 | }, |
| 334 | 335 | .baseline => { |
| 335 | 336 | var adjusted_baseline = Target.Cpu.baseline(self.getCpuArch()); |
| ... | ... | @@ -340,7 +341,7 @@ pub const CrossTarget = struct { |
| 340 | 341 | // This works when doing `zig build` because Zig generates a build executable using |
| 341 | 342 | // native CPU model & features. However this will not be accurate otherwise, and |
| 342 | 343 | // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`. |
| 343 | return Target.current.cpu; | |
| 344 | return builtin.cpu; | |
| 344 | 345 | } else { |
| 345 | 346 | var adjusted_baseline = Target.Cpu.baseline(self.getCpuArch()); |
| 346 | 347 | self.updateCpuFeatures(&adjusted_baseline.features); |
| ... | ... | @@ -355,7 +356,7 @@ pub const CrossTarget = struct { |
| 355 | 356 | } |
| 356 | 357 | |
| 357 | 358 | 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; | |
| 359 | 360 | } |
| 360 | 361 | |
| 361 | 362 | pub fn getCpuModel(self: CrossTarget) *const Target.Cpu.Model { |
| ... | ... | @@ -371,10 +372,10 @@ pub const CrossTarget = struct { |
| 371 | 372 | |
| 372 | 373 | /// TODO deprecated, use `std.zig.system.NativeTargetInfo.detect`. |
| 373 | 374 | 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 | |
| 375 | 376 | // native OS version range. However this will not be accurate otherwise, and |
| 376 | 377 | // 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; | |
| 378 | 379 | |
| 379 | 380 | if (self.os_version_min) |min| switch (min) { |
| 380 | 381 | .none => {}, |
| ... | ... | @@ -403,7 +404,7 @@ pub const CrossTarget = struct { |
| 403 | 404 | } |
| 404 | 405 | |
| 405 | 406 | 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; | |
| 407 | 408 | } |
| 408 | 409 | |
| 409 | 410 | /// TODO deprecated, use `std.zig.system.NativeTargetInfo.detect`. |
| ... | ... | @@ -430,7 +431,7 @@ pub const CrossTarget = struct { |
| 430 | 431 | // This works when doing `zig build` because Zig generates a build executable using |
| 431 | 432 | // native CPU model & features. However this will not be accurate otherwise, and |
| 432 | 433 | // will need to be integrated with `std.zig.system.NativeTargetInfo.detect`. |
| 433 | return Target.current.abi; | |
| 434 | return builtin.abi; | |
| 434 | 435 | } |
| 435 | 436 | |
| 436 | 437 | return Target.Abi.default(self.getCpuArch(), self.getOs()); |
| ... | ... | @@ -607,12 +608,12 @@ pub const CrossTarget = struct { |
| 607 | 608 | pub fn getExternalExecutor(self: CrossTarget) Executor { |
| 608 | 609 | const cpu_arch = self.getCpuArch(); |
| 609 | 610 | const os_tag = self.getOsTag(); |
| 610 | const os_match = os_tag == Target.current.os.tag; | |
| 611 | const os_match = os_tag == builtin.os.tag; | |
| 611 | 612 | |
| 612 | 613 | // If the OS and CPU arch match, the binary can be considered native. |
| 613 | 614 | // TODO additionally match the CPU features. This `getExternalExecutor` function should |
| 614 | 615 | // 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) { | |
| 616 | 617 | // However, we also need to verify that the dynamic linker path is valid. |
| 617 | 618 | if (self.os_tag == null) { |
| 618 | 619 | return .native; |
| ... | ... | @@ -664,7 +665,7 @@ pub const CrossTarget = struct { |
| 664 | 665 | // TODO loosen this check once upstream adds QEMU-based emulation |
| 665 | 666 | // layer for non-host architectures: |
| 666 | 667 | // https://github.com/darlinghq/darling/issues/863 |
| 667 | if (cpu_arch != Target.current.cpu.arch) { | |
| 668 | if (cpu_arch != builtin.cpu.arch) { | |
| 668 | 669 | return .unavailable; |
| 669 | 670 | } |
| 670 | 671 | return Executor{ .darling = "darling" }; |
| ... | ... | @@ -789,7 +790,7 @@ pub const CrossTarget = struct { |
| 789 | 790 | }; |
| 790 | 791 | |
| 791 | 792 | test "CrossTarget.parse" { |
| 792 | if (Target.current.isGnuLibC()) { | |
| 793 | if (builtin.target.isGnuLibC()) { | |
| 793 | 794 | var cross_target = try CrossTarget.parse(.{}); |
| 794 | 795 | cross_target.setGnuLibCVersion(2, 1, 1); |
| 795 | 796 | |
| ... | ... | @@ -800,7 +801,7 @@ test "CrossTarget.parse" { |
| 800 | 801 | const triple = std.fmt.bufPrint( |
| 801 | 802 | buf[0..], |
| 802 | 803 | "native-native-{s}.2.1.1", |
| 803 | .{@tagName(std.Target.current.abi)}, | |
| 804 | .{@tagName(builtin.abi)}, | |
| 804 | 805 | ) catch unreachable; |
| 805 | 806 | |
| 806 | 807 | try std.testing.expectEqualSlices(u8, triple, text); |
lib/std/zig/system.zig+14-13| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("../std.zig"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const elf = std.elf; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const fs = std.fs; |
| ... | ... | @@ -8,7 +9,7 @@ const assert = std.debug.assert; |
| 8 | 9 | const process = std.process; |
| 9 | 10 | const Target = std.Target; |
| 10 | 11 | const CrossTarget = std.zig.CrossTarget; |
| 11 | const native_endian = std.Target.current.cpu.arch.endian(); | |
| 12 | const native_endian = builtin.cpu.arch.endian(); | |
| 12 | 13 | const linux = @import("system/linux.zig"); |
| 13 | 14 | pub const windows = @import("system/windows.zig"); |
| 14 | 15 | pub const darwin = @import("system/darwin.zig"); |
| ... | ... | @@ -88,7 +89,7 @@ pub const NativePaths = struct { |
| 88 | 89 | return self; |
| 89 | 90 | } |
| 90 | 91 | |
| 91 | if (comptime Target.current.isDarwin()) { | |
| 92 | if (comptime builtin.target.isDarwin()) { | |
| 92 | 93 | try self.addIncludeDir("/usr/include"); |
| 93 | 94 | try self.addIncludeDir("/usr/local/include"); |
| 94 | 95 | |
| ... | ... | @@ -239,7 +240,7 @@ pub const NativeTargetInfo = struct { |
| 239 | 240 | pub fn detect(allocator: *Allocator, cross_target: CrossTarget) DetectError!NativeTargetInfo { |
| 240 | 241 | var os = cross_target.getOsTag().defaultVersionRange(); |
| 241 | 242 | if (cross_target.os_tag == null) { |
| 242 | switch (Target.current.os.tag) { | |
| 243 | switch (builtin.target.os.tag) { | |
| 243 | 244 | .linux => { |
| 244 | 245 | const uts = std.os.uname(); |
| 245 | 246 | const release = mem.spanZ(&uts.release); |
| ... | ... | @@ -273,7 +274,7 @@ pub const NativeTargetInfo = struct { |
| 273 | 274 | }, |
| 274 | 275 | .macos => try darwin.macos.detect(&os), |
| 275 | 276 | .freebsd, .netbsd, .dragonfly => { |
| 276 | const key = switch (Target.current.os.tag) { | |
| 277 | const key = switch (builtin.target.os.tag) { | |
| 277 | 278 | .freebsd => "kern.osreldate", |
| 278 | 279 | .netbsd, .dragonfly => "kern.osrevision", |
| 279 | 280 | else => unreachable, |
| ... | ... | @@ -289,7 +290,7 @@ pub const NativeTargetInfo = struct { |
| 289 | 290 | error.Unexpected => return error.OSVersionDetectionFail, |
| 290 | 291 | }; |
| 291 | 292 | |
| 292 | switch (Target.current.os.tag) { | |
| 293 | switch (builtin.target.os.tag) { | |
| 293 | 294 | .freebsd => { |
| 294 | 295 | // https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions.html |
| 295 | 296 | // Major * 100,000 has been convention since FreeBSD 2.2 (1997) |
| ... | ... | @@ -445,8 +446,8 @@ pub const NativeTargetInfo = struct { |
| 445 | 446 | os: Target.Os, |
| 446 | 447 | cross_target: CrossTarget, |
| 447 | 448 | ) 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; | |
| 450 | 451 | const have_all_info = cross_target.dynamic_linker.get() != null and |
| 451 | 452 | cross_target.abi != null and (!is_linux or cross_target.abi.?.isGnu()); |
| 452 | 453 | const os_is_non_native = cross_target.os_tag != null; |
| ... | ... | @@ -463,7 +464,7 @@ pub const NativeTargetInfo = struct { |
| 463 | 464 | // compiler for target riscv64-linux-musl and provide a tarball for users to download. |
| 464 | 465 | // A user could then run that zig compiler on riscv64-linux-gnu. This use case is well-defined |
| 465 | 466 | // 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`. | |
| 467 | 468 | const all_abis = comptime blk: { |
| 468 | 469 | assert(@enumToInt(Target.Abi.none) == 0); |
| 469 | 470 | const fields = std.meta.fields(Target.Abi)[1..]; |
| ... | ... | @@ -524,7 +525,7 @@ pub const NativeTargetInfo = struct { |
| 524 | 525 | |
| 525 | 526 | // Look for glibc version. |
| 526 | 527 | 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 | |
| 528 | 529 | cross_target.glibc_version == null) |
| 529 | 530 | { |
| 530 | 531 | for (lib_paths) |lib_path| { |
| ... | ... | @@ -740,7 +741,7 @@ pub const NativeTargetInfo = struct { |
| 740 | 741 | } |
| 741 | 742 | }, |
| 742 | 743 | // 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 | |
| 744 | 745 | cross_target.glibc_version == null) |
| 745 | 746 | { |
| 746 | 747 | var dyn_off = elfInt(is_64, need_bswap, ph32.p_offset, ph64.p_offset); |
| ... | ... | @@ -787,7 +788,7 @@ pub const NativeTargetInfo = struct { |
| 787 | 788 | } |
| 788 | 789 | } |
| 789 | 790 | |
| 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) { | |
| 791 | 792 | if (rpath_offset) |rpoff| { |
| 792 | 793 | const shstrndx = elfInt(is_64, need_bswap, hdr32.e_shstrndx, hdr64.e_shstrndx); |
| 793 | 794 | |
| ... | ... | @@ -979,14 +980,14 @@ pub const NativeTargetInfo = struct { |
| 979 | 980 | // Here we switch on a comptime value rather than `cpu_arch`. This is valid because `cpu_arch`, |
| 980 | 981 | // although it is a runtime value, is guaranteed to be one of the architectures in the set |
| 981 | 982 | // of the respective switch prong. |
| 982 | switch (std.Target.current.cpu.arch) { | |
| 983 | switch (builtin.cpu.arch) { | |
| 983 | 984 | .x86_64, .i386 => { |
| 984 | 985 | return @import("system/x86.zig").detectNativeCpuAndFeatures(cpu_arch, os, cross_target); |
| 985 | 986 | }, |
| 986 | 987 | else => {}, |
| 987 | 988 | } |
| 988 | 989 | |
| 989 | switch (std.Target.current.os.tag) { | |
| 990 | switch (builtin.os.tag) { | |
| 990 | 991 | .linux => return linux.detectNativeCpuAndFeatures(), |
| 991 | 992 | .macos => return darwin.macos.detectNativeCpuAndFeatures(), |
| 992 | 993 | else => {}, |
lib/std/zig/system/darwin/macos.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const testing = std.testing; |
| ... | ... | @@ -414,7 +415,7 @@ pub fn detectNativeCpuAndFeatures() ?Target.Cpu { |
| 414 | 415 | error.Unexpected => unreachable, // EFAULT: stack should be safe, EISDIR/ENOTDIR: constant, known good value |
| 415 | 416 | }; |
| 416 | 417 | |
| 417 | const current_arch = Target.current.cpu.arch; | |
| 418 | const current_arch = builtin.cpu.arch; | |
| 418 | 419 | switch (current_arch) { |
| 419 | 420 | .aarch64, .aarch64_be, .aarch64_32 => { |
| 420 | 421 | const model = switch (cpu_family) { |
lib/std/zig/system/linux.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const io = std.io; |
| 4 | 5 | const fs = std.fs; |
| ... | ... | @@ -450,7 +451,7 @@ pub fn detectNativeCpuAndFeatures() ?Target.Cpu { |
| 450 | 451 | }; |
| 451 | 452 | defer f.close(); |
| 452 | 453 | |
| 453 | const current_arch = std.Target.current.cpu.arch; | |
| 454 | const current_arch = builtin.cpu.arch; | |
| 454 | 455 | switch (current_arch) { |
| 455 | 456 | .arm, .armeb, .thumb, .thumbeb, .aarch64, .aarch64_be, .aarch64_32 => { |
| 456 | 457 | return ArmCpuinfoParser.parse(current_arch, f.reader()) catch null; |
src/Air.zig+2-1| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | //! gets its own `Air` instance. |
| 5 | 5 | |
| 6 | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | |
| 7 | 8 | const Value = @import("value.zig").Value; |
| 8 | 9 | const Type = @import("type.zig").Type; |
| 9 | 10 | const Module = @import("Module.zig"); |
| ... | ... | @@ -484,7 +485,7 @@ pub const Inst = struct { |
| 484 | 485 | // bigger than expected. Note that in Debug builds, Zig is allowed |
| 485 | 486 | // to insert a secret field for safety checks. |
| 486 | 487 | comptime { |
| 487 | if (std.builtin.mode != .Debug) { | |
| 488 | if (builtin.mode != .Debug) { | |
| 488 | 489 | assert(@sizeOf(Data) == 8); |
| 489 | 490 | } |
| 490 | 491 | } |
src/Cache.zig+7-6| ... | ... | @@ -4,6 +4,7 @@ hash: HashHelper = .{}, |
| 4 | 4 | |
| 5 | 5 | const Cache = @This(); |
| 6 | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | |
| 7 | 8 | const crypto = std.crypto; |
| 8 | 9 | const fs = std.fs; |
| 9 | 10 | const assert = std.debug.assert; |
| ... | ... | @@ -713,7 +714,7 @@ pub const Manifest = struct { |
| 713 | 714 | /// uses the file contents. Windows supports symlinks but only with elevated privileges, so |
| 714 | 715 | /// it is treated as not supporting symlinks. |
| 715 | 716 | pub 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) { | |
| 717 | 718 | return dir.readFile(sub_path, buffer); |
| 718 | 719 | } else { |
| 719 | 720 | return dir.readLink(sub_path, buffer); |
| ... | ... | @@ -726,7 +727,7 @@ pub fn readSmallFile(dir: fs.Dir, sub_path: []const u8, buffer: []u8) ![]u8 { |
| 726 | 727 | /// `data` must be a valid UTF-8 encoded file path and 255 bytes or fewer. |
| 727 | 728 | pub fn writeSmallFile(dir: fs.Dir, sub_path: []const u8, data: []const u8) !void { |
| 728 | 729 | assert(data.len <= 255); |
| 729 | if (std.Target.current.os.tag == .windows) { | |
| 730 | if (builtin.os.tag == .windows) { | |
| 730 | 731 | return dir.writeFile(sub_path, data); |
| 731 | 732 | } else { |
| 732 | 733 | return dir.symLink(data, sub_path, .{}); |
| ... | ... | @@ -778,7 +779,7 @@ fn isProblematicTimestamp(fs_clock: i128) bool { |
| 778 | 779 | } |
| 779 | 780 | |
| 780 | 781 | test "cache file and then recall it" { |
| 781 | if (std.Target.current.os.tag == .wasi) { | |
| 782 | if (builtin.os.tag == .wasi) { | |
| 782 | 783 | // https://github.com/ziglang/zig/issues/5437 |
| 783 | 784 | return error.SkipZigTest; |
| 784 | 785 | } |
| ... | ... | @@ -856,7 +857,7 @@ test "give nonproblematic timestamp" { |
| 856 | 857 | } |
| 857 | 858 | |
| 858 | 859 | test "check that changing a file makes cache fail" { |
| 859 | if (std.Target.current.os.tag == .wasi) { | |
| 860 | if (builtin.os.tag == .wasi) { | |
| 860 | 861 | // https://github.com/ziglang/zig/issues/5437 |
| 861 | 862 | return error.SkipZigTest; |
| 862 | 863 | } |
| ... | ... | @@ -932,7 +933,7 @@ test "check that changing a file makes cache fail" { |
| 932 | 933 | } |
| 933 | 934 | |
| 934 | 935 | test "no file inputs" { |
| 935 | if (std.Target.current.os.tag == .wasi) { | |
| 936 | if (builtin.os.tag == .wasi) { | |
| 936 | 937 | // https://github.com/ziglang/zig/issues/5437 |
| 937 | 938 | return error.SkipZigTest; |
| 938 | 939 | } |
| ... | ... | @@ -977,7 +978,7 @@ test "no file inputs" { |
| 977 | 978 | } |
| 978 | 979 | |
| 979 | 980 | test "Manifest with files added after initial hash work" { |
| 980 | if (std.Target.current.os.tag == .wasi) { | |
| 981 | if (builtin.os.tag == .wasi) { | |
| 981 | 982 | // https://github.com/ziglang/zig/issues/5437 |
| 982 | 983 | return error.SkipZigTest; |
| 983 | 984 | } |
src/Compilation.zig+3-3| ... | ... | @@ -937,8 +937,8 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 937 | 937 | }; |
| 938 | 938 | |
| 939 | 939 | 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(); | |
| 942 | 942 | }; |
| 943 | 943 | |
| 944 | 944 | const sysroot = blk: { |
| ... | ... | @@ -3582,7 +3582,7 @@ fn detectLibCIncludeDirs( |
| 3582 | 3582 | // native abi, fall back to using the system libc installation. |
| 3583 | 3583 | // On windows, instead of the native (mingw) abi, we want to check |
| 3584 | 3584 | // 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) | |
| 3586 | 3586 | target.abi == .msvc |
| 3587 | 3587 | else |
| 3588 | 3588 | is_native_abi; |
src/ThreadPool.zig+3-2| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | 5 | // and substantial portions of the software. |
| 6 | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | |
| 7 | 8 | const ThreadPool = @This(); |
| 8 | 9 | |
| 9 | 10 | lock: std.Thread.Mutex = .{}, |
| ... | ... | @@ -57,7 +58,7 @@ pub fn init(self: *ThreadPool, allocator: *std.mem.Allocator) !void { |
| 57 | 58 | .allocator = allocator, |
| 58 | 59 | .workers = &[_]Worker{}, |
| 59 | 60 | }; |
| 60 | if (std.builtin.single_threaded) | |
| 61 | if (builtin.single_threaded) | |
| 61 | 62 | return; |
| 62 | 63 | |
| 63 | 64 | const worker_count = std.math.max(1, std.Thread.getCpuCount() catch 1); |
| ... | ... | @@ -100,7 +101,7 @@ pub fn deinit(self: *ThreadPool) void { |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | 103 | pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void { |
| 103 | if (std.builtin.single_threaded) { | |
| 104 | if (builtin.single_threaded) { | |
| 104 | 105 | @call(.{}, func, args); |
| 105 | 106 | return; |
| 106 | 107 | } |
src/Zir.zig+2-1| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | //! inline assembly is not an exception. |
| 12 | 12 | |
| 13 | 13 | const std = @import("std"); |
| 14 | const builtin = @import("builtin"); | |
| 14 | 15 | const mem = std.mem; |
| 15 | 16 | const Allocator = std.mem.Allocator; |
| 16 | 17 | const assert = std.debug.assert; |
| ... | ... | @@ -2215,7 +2216,7 @@ pub const Inst = struct { |
| 2215 | 2216 | // bigger than expected. Note that in Debug builds, Zig is allowed |
| 2216 | 2217 | // to insert a secret field for safety checks. |
| 2217 | 2218 | comptime { |
| 2218 | if (std.builtin.mode != .Debug) { | |
| 2219 | if (builtin.mode != .Debug) { | |
| 2219 | 2220 | assert(@sizeOf(Data) == 8); |
| 2220 | 2221 | } |
| 2221 | 2222 | } |
src/codegen.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const math = std.math; |
| 4 | 5 | const assert = std.debug.assert; |
| ... | ... | @@ -522,7 +523,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 522 | 523 | code: *std.ArrayList(u8), |
| 523 | 524 | debug_output: DebugInfoOutput, |
| 524 | 525 | ) 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) { | |
| 526 | 527 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 527 | 528 | } |
| 528 | 529 |
src/codegen/c.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const log = std.log.scoped(.c); |
| ... | ... | @@ -600,7 +601,7 @@ pub const DeclGen = struct { |
| 600 | 601 | ); |
| 601 | 602 | }, |
| 602 | 603 | .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); | |
| 604 | 605 | try w.writeAll("uint16_t"); |
| 605 | 606 | }, |
| 606 | 607 | .ErrorUnion => { |
src/introspect.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const fs = std.fs; |
| 4 | 5 | const Compilation = @import("Compilation.zig"); |
| ... | ... | @@ -71,7 +72,7 @@ pub fn resolveGlobalCacheDir(allocator: *mem.Allocator) ![]u8 { |
| 71 | 72 | |
| 72 | 73 | const appname = "zig"; |
| 73 | 74 | |
| 74 | if (std.Target.current.os.tag != .windows) { | |
| 75 | if (builtin.os.tag != .windows) { | |
| 75 | 76 | if (std.os.getenv("XDG_CACHE_HOME")) |cache_root| { |
| 76 | 77 | return fs.path.join(allocator, &[_][]const u8{ cache_root, appname }); |
| 77 | 78 | } else if (std.os.getenv("HOME")) |home| { |
src/libc_installation.zig+4-4| ... | ... | @@ -6,9 +6,9 @@ const Allocator = std.mem.Allocator; |
| 6 | 6 | const Batch = std.event.Batch; |
| 7 | 7 | const build_options = @import("build_options"); |
| 8 | 8 | |
| 9 | const is_darwin = Target.current.isDarwin(); | |
| 10 | const is_windows = Target.current.os.tag == .windows; | |
| 11 | const is_haiku = Target.current.os.tag == .haiku; | |
| 9 | const is_darwin = builtin.target.isDarwin(); | |
| 10 | const is_windows = builtin.target.os.tag == .windows; | |
| 11 | const is_haiku = builtin.target.os.tag == .haiku; | |
| 12 | 12 | |
| 13 | 13 | const log = std.log.scoped(.libc_installation); |
| 14 | 14 | |
| ... | ... | @@ -219,7 +219,7 @@ pub const LibCInstallation = struct { |
| 219 | 219 | var batch = Batch(FindError!void, 2, .auto_async).init(); |
| 220 | 220 | errdefer batch.wait() catch {}; |
| 221 | 221 | batch.add(&async self.findNativeIncludeDirPosix(args)); |
| 222 | switch (Target.current.os.tag) { | |
| 222 | switch (builtin.target.os.tag) { | |
| 223 | 223 | .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try std.mem.dupeZ(args.allocator, u8, "/usr/lib"), |
| 224 | 224 | .solaris => self.crt_dir = try std.mem.dupeZ(args.allocator, u8, "/usr/lib/64"), |
| 225 | 225 | .linux => batch.add(&async self.findNativeCrtDirPosix(args)), |
src/link.zig+2-2| ... | ... | @@ -292,7 +292,7 @@ pub const File = struct { |
| 292 | 292 | // make executable, so we don't have to close it. |
| 293 | 293 | return; |
| 294 | 294 | } |
| 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) { | |
| 296 | 296 | if (base.options.target.cpu.arch != .aarch64) return; // If we're not targeting aarch64, nothing to do. |
| 297 | 297 | // XNU starting with Big Sur running on arm64 is caching inodes of running binaries. |
| 298 | 298 | // Any change to the binary will effectively invalidate the kernel's cache |
| ... | ... | @@ -711,7 +711,7 @@ pub fn determineMode(options: Options) fs.File.Mode { |
| 711 | 711 | // with 0o755 permissions, but it works appropriately if the system is configured |
| 712 | 712 | // more leniently. As another data point, C's fopen seems to open files with the |
| 713 | 713 | // 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; | |
| 715 | 715 | switch (options.effectiveOutputMode()) { |
| 716 | 716 | .Lib => return switch (options.link_mode) { |
| 717 | 717 | .Dynamic => executable_mode, |
src/link/Elf.zig+5-5| ... | ... | @@ -755,7 +755,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void { |
| 755 | 755 | const module = self.base.options.module orelse return error.LinkingWithoutZigSourceUnimplemented; |
| 756 | 756 | |
| 757 | 757 | 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(); | |
| 759 | 759 | const ptr_width_bytes: u8 = self.ptrWidthBytes(); |
| 760 | 760 | const init_len_size: usize = switch (self.ptr_width) { |
| 761 | 761 | .p32 => 4, |
| ... | ... | @@ -2827,7 +2827,7 @@ pub fn deleteExport(self: *Elf, exp: Export) void { |
| 2827 | 2827 | } |
| 2828 | 2828 | |
| 2829 | 2829 | fn 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(); | |
| 2831 | 2831 | const offset = self.program_headers.items[index].p_offset; |
| 2832 | 2832 | switch (self.ptr_width) { |
| 2833 | 2833 | .p32 => { |
| ... | ... | @@ -2848,7 +2848,7 @@ fn writeProgHeader(self: *Elf, index: usize) !void { |
| 2848 | 2848 | } |
| 2849 | 2849 | |
| 2850 | 2850 | fn 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(); | |
| 2852 | 2852 | switch (self.ptr_width) { |
| 2853 | 2853 | .p32 => { |
| 2854 | 2854 | var shdr: [1]elf.Elf32_Shdr = undefined; |
| ... | ... | @@ -2946,7 +2946,7 @@ fn writeSymbol(self: *Elf, index: usize) !void { |
| 2946 | 2946 | syms_sect.sh_size = needed_size; // anticipating adding the global symbols later |
| 2947 | 2947 | self.shdr_table_dirty = true; // TODO look into only writing one section |
| 2948 | 2948 | } |
| 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(); | |
| 2950 | 2950 | switch (self.ptr_width) { |
| 2951 | 2951 | .p32 => { |
| 2952 | 2952 | var sym = [1]elf.Elf32_Sym{ |
| ... | ... | @@ -2982,7 +2982,7 @@ fn writeAllGlobalSymbols(self: *Elf) !void { |
| 2982 | 2982 | .p32 => @sizeOf(elf.Elf32_Sym), |
| 2983 | 2983 | .p64 => @sizeOf(elf.Elf64_Sym), |
| 2984 | 2984 | }; |
| 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(); | |
| 2986 | 2986 | const global_syms_off = syms_sect.sh_offset + self.local_symbols.items.len * sym_size; |
| 2987 | 2987 | switch (self.ptr_width) { |
| 2988 | 2988 | .p32 => { |
src/link/MachO.zig+1-1| ... | ... | @@ -967,7 +967,7 @@ fn resolveSearchDir( |
| 967 | 967 | |
| 968 | 968 | if (fs.path.isAbsolute(dir)) { |
| 969 | 969 | 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: { | |
| 971 | 971 | // We need to check for disk designator and strip it out from dir path so |
| 972 | 972 | // that we can concat dir with syslibroot. |
| 973 | 973 | // TODO we should backport this mechanism to 'MachO.Dylib.parseDependentLibs()' |
src/link/MachO/fat.zig+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const log = std.log.scoped(.archive); |
| 4 | 4 | const macho = std.macho; |
| 5 | 5 | const mem = std.mem; |
| ... | ... | @@ -23,7 +23,7 @@ fn readFatStruct(reader: anytype, comptime T: type) !T { |
| 23 | 23 | // Fat structures (fat_header & fat_arch) are always written and read to/from |
| 24 | 24 | // disk in big endian order. |
| 25 | 25 | var res = try reader.readStruct(T); |
| 26 | if (native_endian != builtin.Endian.Big) { | |
| 26 | if (native_endian != std.builtin.Endian.Big) { | |
| 27 | 27 | mem.bswapAllFields(T, &res); |
| 28 | 28 | } |
| 29 | 29 | return res; |
src/main.zig+10-9| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | const io = std.io; |
| 4 | 5 | const fs = std.fs; |
| ... | ... | @@ -34,7 +35,7 @@ pub fn fatal(comptime format: []const u8, args: anytype) noreturn { |
| 34 | 35 | /// be byte-indexed with a u32 integer. |
| 35 | 36 | pub const max_src_size = std.math.maxInt(u32); |
| 36 | 37 | |
| 37 | pub const debug_extensions_enabled = std.builtin.mode == .Debug; | |
| 38 | pub const debug_extensions_enabled = builtin.mode == .Debug; | |
| 38 | 39 | |
| 39 | 40 | pub const Color = enum { |
| 40 | 41 | auto, |
| ... | ... | @@ -90,7 +91,7 @@ const debug_usage = normal_usage ++ |
| 90 | 91 | |
| 91 | 92 | const usage = if (debug_extensions_enabled) debug_usage else normal_usage; |
| 92 | 93 | |
| 93 | pub const log_level: std.log.Level = switch (std.builtin.mode) { | |
| 94 | pub const log_level: std.log.Level = switch (builtin.mode) { | |
| 94 | 95 | .Debug => .debug, |
| 95 | 96 | .ReleaseSafe, .ReleaseFast => .info, |
| 96 | 97 | .ReleaseSmall => .crit, |
| ... | ... | @@ -142,7 +143,7 @@ pub fn main() anyerror!void { |
| 142 | 143 | |
| 143 | 144 | var gpa_need_deinit = false; |
| 144 | 145 | const gpa = gpa: { |
| 145 | if (!std.builtin.link_libc) { | |
| 146 | if (!builtin.link_libc) { | |
| 146 | 147 | gpa_need_deinit = true; |
| 147 | 148 | break :gpa &general_purpose_allocator.allocator; |
| 148 | 149 | } |
| ... | ... | @@ -1688,13 +1689,13 @@ fn buildOutputType( |
| 1688 | 1689 | } |
| 1689 | 1690 | } |
| 1690 | 1691 | |
| 1691 | if (comptime std.Target.current.isDarwin()) { | |
| 1692 | if (comptime builtin.target.isDarwin()) { | |
| 1692 | 1693 | // If we want to link against frameworks, we need system headers. |
| 1693 | 1694 | if (framework_dirs.items.len > 0 or frameworks.items.len > 0) |
| 1694 | 1695 | want_native_include_dirs = true; |
| 1695 | 1696 | } |
| 1696 | 1697 | |
| 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(); | |
| 1698 | 1699 | |
| 1699 | 1700 | if (sysroot == null and (cross_target.isNativeOs() or is_darwin_on_darwin) and |
| 1700 | 1701 | (system_libs.items.len != 0 or want_native_include_dirs)) |
| ... | ... | @@ -1706,7 +1707,7 @@ fn buildOutputType( |
| 1706 | 1707 | warn("{s}", .{warning}); |
| 1707 | 1708 | } |
| 1708 | 1709 | |
| 1709 | const has_sysroot = if (comptime std.Target.current.isDarwin()) outer: { | |
| 1710 | const has_sysroot = if (comptime builtin.target.isDarwin()) outer: { | |
| 1710 | 1711 | const should_get_sdk_path = if (cross_target.isNativeOs() and target_info.target.os.tag == .macos) inner: { |
| 1711 | 1712 | const min = target_info.target.os.getVersionRange().semver.min; |
| 1712 | 1713 | const at_least_mojave = min.major >= 11 or (min.major >= 10 and min.minor >= 14); |
| ... | ... | @@ -2355,7 +2356,7 @@ fn runOrTest( |
| 2355 | 2356 | defer argv.deinit(); |
| 2356 | 2357 | |
| 2357 | 2358 | if (test_exec_args.len == 0) { |
| 2358 | if (!std.Target.current.canExecBinariesOf(target)) { | |
| 2359 | if (!builtin.target.canExecBinariesOf(target)) { | |
| 2359 | 2360 | switch (arg_mode) { |
| 2360 | 2361 | .zig_test => { |
| 2361 | 2362 | warn("created {s} but skipping execution because it is non-native", .{exe_path}); |
| ... | ... | @@ -3915,7 +3916,7 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void { |
| 3915 | 3916 | const posix = std.os; |
| 3916 | 3917 | |
| 3917 | 3918 | var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried. |
| 3918 | if (comptime std.Target.current.isDarwin()) { | |
| 3919 | if (comptime builtin.target.isDarwin()) { | |
| 3919 | 3920 | // On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`. |
| 3920 | 3921 | // According to the man pages for setrlimit(): |
| 3921 | 3922 | // 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 |
| 3959 | 3960 | /// check for resource leaks can be accurate. In release builds, this |
| 3960 | 3961 | /// calls exit(0), and does not return. |
| 3961 | 3962 | pub fn cleanExit() void { |
| 3962 | if (std.builtin.mode == .Debug) { | |
| 3963 | if (builtin.mode == .Debug) { | |
| 3963 | 3964 | return; |
| 3964 | 3965 | } else { |
| 3965 | 3966 | process.exit(0); |
src/tracy.zig+3-2| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | pub const std = @import("std"); | |
| 1 | const std = @import("std"); | |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | pub const enable = if (std.builtin.is_test) false else @import("build_options").enable_tracy; | |
| 4 | pub const enable = if (builtin.is_test) false else @import("build_options").enable_tracy; | |
| 4 | 5 | |
| 5 | 6 | extern fn ___tracy_emit_zone_begin_callstack( |
| 6 | 7 | srcloc: *const ___tracy_source_location_data, |
test/assemble_and_link.zig+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const tests = @import("tests.zig"); |
| 3 | 4 | |
| 4 | 5 | pub 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) { | |
| 6 | 7 | cases.addAsm("hello world linux x86_64", |
| 7 | 8 | \\.text |
| 8 | 9 | \\.globl _start |
test/behavior/asm.zig+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | |
| 4 | const is_x86_64_linux = std.Target.current.cpu.arch == .x86_64 and std.Target.current.os.tag == .linux; | |
| 5 | const is_x86_64_linux = builtin.cpu.arch == .x86_64 and builtin.os.tag == .linux; | |
| 5 | 6 | |
| 6 | 7 | comptime { |
| 7 | 8 | if (is_x86_64_linux) { |
test/behavior/atomics.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | const expectEqual = std.testing.expectEqual; |
| 4 | const builtin = @import("builtin"); | |
| 5 | 5 | |
| 6 | 6 | test "cmpxchg" { |
| 7 | 7 | try testCmpxchg(); |
test/behavior/namespace_depends_on_compile_var.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | |
| 4 | 5 | test "namespace depends on compile var" { |
| ... | ... | @@ -8,7 +9,7 @@ test "namespace depends on compile var" { |
| 8 | 9 | try expect(!some_namespace.a_bool); |
| 9 | 10 | } |
| 10 | 11 | } |
| 11 | const some_namespace = switch (std.builtin.os.tag) { | |
| 12 | const some_namespace = switch (builtin.os.tag) { | |
| 12 | 13 | .linux => @import("namespace_depends_on_compile_var/a.zig"), |
| 13 | 14 | else => @import("namespace_depends_on_compile_var/b.zig"), |
| 14 | 15 | }; |
test/behavior/sizeof_and_typeof.zig-1| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const expect = std.testing.expect; |
| 4 | 3 | const expectEqual = std.testing.expectEqual; |
| 5 | 4 |
test/behavior/sizeof_and_typeof_stage1.zig-1| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 3 | 2 | const expect = std.testing.expect; |
| 4 | 3 | const expectEqual = std.testing.expectEqual; |
| 5 | 4 |
test/behavior/vector.zig+1-1| ... | ... | @@ -674,7 +674,7 @@ test "saturating subtraction" { |
| 674 | 674 | |
| 675 | 675 | test "saturating multiplication" { |
| 676 | 676 | // 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; | |
| 678 | 678 | |
| 679 | 679 | const S = struct { |
| 680 | 680 | fn doTheTest() !void { |
test/cli.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const testing = std.testing; |
| 3 | 4 | const process = std.process; |
| 4 | 5 | const fs = std.fs; |
| ... | ... | @@ -97,7 +98,7 @@ fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void { |
| 97 | 98 | } |
| 98 | 99 | |
| 99 | 100 | fn 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; | |
| 101 | 102 | |
| 102 | 103 | const example_zig_path = try fs.path.join(a, &[_][]const u8{ dir_path, "example.zig" }); |
| 103 | 104 | 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 { |
| 28 | 28 | |
| 29 | 29 | cases.addC("number literals", |
| 30 | 30 | \\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; | |
| 32 | 33 | \\const c = @cImport({ |
| 33 | 34 | \\ if (is_windows) { |
| 34 | 35 | \\ // See https://github.com/ziglang/zig/issues/515 |
| ... | ... | @@ -207,7 +208,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 207 | 208 | |
| 208 | 209 | cases.addC("casting between float and integer types", |
| 209 | 210 | \\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; | |
| 211 | 213 | \\const c = @cImport({ |
| 212 | 214 | \\ if (is_windows) { |
| 213 | 215 | \\ // See https://github.com/ziglang/zig/issues/515 |
test/compile_errors.zig+4-2| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const TestContext = @import("../src/test.zig").TestContext; |
| 3 | 4 | |
| 4 | 5 | pub fn addCases(ctx: *TestContext) !void { |
| ... | ... | @@ -2898,7 +2899,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 2898 | 2899 | "tmp.zig:2:18: error: invalid operands to binary expression: 'error{A}' and 'error{B}'", |
| 2899 | 2900 | }); |
| 2900 | 2901 | |
| 2901 | if (std.Target.current.os.tag == .linux) { | |
| 2902 | if (builtin.os.tag == .linux) { | |
| 2902 | 2903 | ctx.testErrStage1("implicit dependency on libc", |
| 2903 | 2904 | \\extern "c" fn exit(u8) void; |
| 2904 | 2905 | \\export fn entry() void { |
| ... | ... | @@ -8834,9 +8835,10 @@ pub fn addCases(ctx: *TestContext) !void { |
| 8834 | 8835 | |
| 8835 | 8836 | ctx.objErrStage1("Issue #9165: windows tcp server compilation error", |
| 8836 | 8837 | \\const std = @import("std"); |
| 8838 | \\const builtin = @import("builtin"); | |
| 8837 | 8839 | \\pub const io_mode = .evented; |
| 8838 | 8840 | \\pub fn main() !void { |
| 8839 | \\ if (std.builtin.os.tag == .windows) { | |
| 8841 | \\ if (builtin.os.tag == .windows) { | |
| 8840 | 8842 | \\ _ = try (std.net.StreamServer.init(.{})).accept(); |
| 8841 | 8843 | \\ } else { |
| 8842 | 8844 | \\ @compileError("Unsupported OS"); |
test/src/compare_output.zig+1-2| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | 1 | // This is the implementation of the test harness. |
| 2 | 2 | // For the actual test cases, see test/compare_output.zig. |
| 3 | 3 | const std = @import("std"); |
| 4 | const builtin = std.builtin; | |
| 5 | 4 | const build = std.build; |
| 6 | 5 | const ArrayList = std.ArrayList; |
| 7 | 6 | const fmt = std.fmt; |
| 8 | 7 | const mem = std.mem; |
| 9 | 8 | const fs = std.fs; |
| 10 | 9 | const warn = std.debug.warn; |
| 11 | const Mode = builtin.Mode; | |
| 10 | const Mode = std.builtin.Mode; | |
| 12 | 11 | |
| 13 | 12 | pub const CompareOutputContext = struct { |
| 14 | 13 | b: *build.Builder, |
test/standalone.zig+5-4| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const tests = @import("tests.zig"); |
| 3 | 4 | |
| 4 | 5 | pub fn addCases(cases: *tests.StandaloneContext) void { |
| ... | ... | @@ -29,19 +30,19 @@ pub fn addCases(cases: *tests.StandaloneContext) void { |
| 29 | 30 | cases.addBuildFile("test/standalone/issue_7030/build.zig", .{}); |
| 30 | 31 | cases.addBuildFile("test/standalone/install_raw_hex/build.zig", .{}); |
| 31 | 32 | cases.addBuildFile("test/standalone/issue_9812/build.zig", .{}); |
| 32 | if (std.Target.current.os.tag != .wasi) { | |
| 33 | if (builtin.os.tag != .wasi) { | |
| 33 | 34 | cases.addBuildFile("test/standalone/load_dynamic_library/build.zig", .{}); |
| 34 | 35 | } |
| 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 | |
| 36 | 37 | cases.addBuildFile("test/stage1/c_abi/build.zig", .{}); |
| 37 | 38 | } |
| 38 | 39 | cases.addBuildFile("test/standalone/c_compiler/build.zig", .{ .build_modes = true, .cross_targets = true }); |
| 39 | 40 | |
| 40 | if (std.Target.current.os.tag == .windows) { | |
| 41 | if (builtin.os.tag == .windows) { | |
| 41 | 42 | cases.addC("test/standalone/issue_9402/main.zig"); |
| 42 | 43 | } |
| 43 | 44 | // Try to build and run a PIE executable. |
| 44 | if (std.Target.current.os.tag == .linux) { | |
| 45 | if (builtin.os.tag == .linux) { | |
| 45 | 46 | cases.addBuildFile("test/standalone/pie/build.zig", .{}); |
| 46 | 47 | } |
| 47 | 48 | // Try to build and run an Objective-C executable. |
test/standalone/c_compiler/build.zig+3-2| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const Builder = std.build.Builder; |
| 3 | 4 | const CrossTarget = std.zig.CrossTarget; |
| 4 | 5 | |
| 5 | 6 | fn isRunnableTarget(t: CrossTarget) bool { |
| 6 | 7 | if (t.isNative()) return true; |
| 7 | 8 | |
| 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); | |
| 10 | 11 | } |
| 11 | 12 | |
| 12 | 13 | pub fn build(b: *Builder) void { |
test/standalone/install_raw_hex/build.zig+107-113| ... | ... | @@ -28,14 +28,14 @@ pub fn build(b: *Builder) void { |
| 28 | 28 | |
| 29 | 29 | const expected_hex = &[_][]const u8{ |
| 30 | 30 | ":020000021000EC", |
| 31 | ":1000D400D001010001000000D20101000100000074", | |
| 32 | ":1000E40028020100010000002402010001000000B8", | |
| 33 | ":1000F4003A02010001000000E202010001000000D8", | |
| 34 | ":100104000C03010001000000A50202000000000031", | |
| 31 | ":1000D400A401010001000000A601010001000000CC", | |
| 32 | ":1000E400FC01010001000000F80101000100000012", | |
| 33 | ":1000F4000E02010001000000B60201000100000030", | |
| 34 | ":10010400E00201000100000079020200000000008A", | |
| 35 | 35 | ":1001140000000000000000000000000000000000DB", |
| 36 | 36 | ":1001240000000000000000000000000000000000CB", |
| 37 | 37 | ":1001340000000000000000000000000000000000BB", |
| 38 | ":10014400AF02020098020100090000004D02010004", | |
| 38 | ":10014400830202006C020100090000002102010088", | |
| 39 | 39 | ":100154000900000001000000000000000000000091", |
| 40 | 40 | ":1001640000080002008001010004000010000000EB", |
| 41 | 41 | ":100174000000000000000000000000001F0000005C", |
| ... | ... | @@ -44,55 +44,52 @@ pub fn build(b: *Builder) void { |
| 44 | 44 | ":1001A40000000000000000001F000000000000002C", |
| 45 | 45 | ":1001B400000000000000000000000000000000003B", |
| 46 | 46 | ":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", | |
| 87 | 84 | ":020000021000EC", |
| 88 | ":1000D400D001010001000000D20101000100000074", | |
| 89 | ":1000E40028020100010000002402010001000000B8", | |
| 90 | ":1000F4003A02010001000000E202010001000000D8", | |
| 91 | ":100104000C03010001000000A50202000000000031", | |
| 85 | ":1000D400A401010001000000A601010001000000CC", | |
| 86 | ":1000E400FC01010001000000F80101000100000012", | |
| 87 | ":1000F4000E02010001000000B60201000100000030", | |
| 88 | ":10010400E00201000100000079020200000000008A", | |
| 92 | 89 | ":1001140000000000000000000000000000000000DB", |
| 93 | 90 | ":1001240000000000000000000000000000000000CB", |
| 94 | 91 | ":1001340000000000000000000000000000000000BB", |
| 95 | ":10014400AF02020098020100090000004D02010004", | |
| 92 | ":10014400830202006C020100090000002102010088", | |
| 96 | 93 | ":100154000900000001000000000000000000000091", |
| 97 | 94 | ":1001640000080002008001010004000010000000EB", |
| 98 | 95 | ":100174000000000000000000000000001F0000005C", |
| ... | ... | @@ -101,70 +98,67 @@ pub fn build(b: *Builder) void { |
| 101 | 98 | ":1001A40000000000000000001F000000000000002C", |
| 102 | 99 | ":1001B400000000000000000000000000000000003B", |
| 103 | 100 | ":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", | |
| 144 | 138 | ":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", | |
| 168 | 162 | ":00000001FF", |
| 169 | 163 | }; |
| 170 | 164 |
test/tests.zig+7-7| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = std.builtin; | |
| 2 | const builtin = @import("builtin"); | |
| 3 | 3 | const debug = std.debug; |
| 4 | 4 | const warn = debug.warn; |
| 5 | 5 | const build = std.build; |
| ... | ... | @@ -9,7 +9,7 @@ const fs = std.fs; |
| 9 | 9 | const mem = std.mem; |
| 10 | 10 | const fmt = std.fmt; |
| 11 | 11 | const ArrayList = std.ArrayList; |
| 12 | const Mode = builtin.Mode; | |
| 12 | const Mode = std.builtin.Mode; | |
| 13 | 13 | const LibExeObjStep = build.LibExeObjStep; |
| 14 | 14 | |
| 15 | 15 | // Cases |
| ... | ... | @@ -29,7 +29,7 @@ pub const CompareOutputContext = @import("src/compare_output.zig").CompareOutput |
| 29 | 29 | |
| 30 | 30 | const TestTarget = struct { |
| 31 | 31 | target: CrossTarget = @as(CrossTarget, .{}), |
| 32 | mode: builtin.Mode = .Debug, | |
| 32 | mode: std.builtin.Mode = .Debug, | |
| 33 | 33 | link_libc: bool = false, |
| 34 | 34 | single_threaded: bool = false, |
| 35 | 35 | disable_native: bool = false, |
| ... | ... | @@ -532,8 +532,8 @@ pub fn addPkgTests( |
| 532 | 532 | continue; |
| 533 | 533 | |
| 534 | 534 | 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) | |
| 537 | 537 | { |
| 538 | 538 | continue; |
| 539 | 539 | } |
| ... | ... | @@ -785,7 +785,7 @@ pub const StackTracesContext = struct { |
| 785 | 785 | if (line.len == 0) continue; |
| 786 | 786 | |
| 787 | 787 | // 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; | |
| 789 | 789 | // locate delims/anchor |
| 790 | 790 | const delims = [_][]const u8{ ":", ":", ":", " in ", "(", ")" }; |
| 791 | 791 | var marks = [_]usize{0} ** delims.len; |
| ... | ... | @@ -1055,7 +1055,7 @@ pub const GenHContext = struct { |
| 1055 | 1055 | pub fn addCase(self: *GenHContext, case: *const TestCase) void { |
| 1056 | 1056 | const b = self.b; |
| 1057 | 1057 | |
| 1058 | const mode = builtin.Mode.Debug; | |
| 1058 | const mode = std.builtin.Mode.Debug; | |
| 1059 | 1059 | const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {s} ({s})", .{ case.name, @tagName(mode) }) catch unreachable; |
| 1060 | 1060 | if (self.test_filter) |filter| { |
| 1061 | 1061 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
test/translate_c.zig+7-6| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | const tests = @import("tests.zig"); | |
| 2 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 3 | const tests = @import("tests.zig"); | |
| 3 | 4 | const CrossTarget = std.zig.CrossTarget; |
| 4 | 5 | |
| 5 | 6 | pub 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"; | |
| 7 | 8 | |
| 8 | 9 | cases.add("field access is grouped if necessary", |
| 9 | 10 | \\unsigned long foo(unsigned long x) { |
| ... | ... | @@ -1153,7 +1154,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1153 | 1154 | \\pub export fn foo() void {} |
| 1154 | 1155 | }); |
| 1155 | 1156 | |
| 1156 | if (std.Target.current.os.tag != .windows) { | |
| 1157 | if (builtin.os.tag != .windows) { | |
| 1157 | 1158 | // Windows treats this as an enum with type c_int |
| 1158 | 1159 | cases.add("big negative enum init values when C ABI supports long long enums", |
| 1159 | 1160 | \\enum EnumWithInits { |
| ... | ... | @@ -1558,7 +1559,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1558 | 1559 | \\} |
| 1559 | 1560 | }); |
| 1560 | 1561 | |
| 1561 | if (std.Target.current.os.tag != .windows) { | |
| 1562 | if (builtin.os.tag != .windows) { | |
| 1562 | 1563 | // sysv_abi not currently supported on windows |
| 1563 | 1564 | cases.add("Macro qualified functions", |
| 1564 | 1565 | \\void __attribute__((sysv_abi)) foo(void); |
| ... | ... | @@ -2160,7 +2161,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2160 | 2161 | \\} |
| 2161 | 2162 | }); |
| 2162 | 2163 | |
| 2163 | if (std.Target.current.os.tag != .windows) { | |
| 2164 | if (builtin.os.tag != .windows) { | |
| 2164 | 2165 | // When clang uses the <arch>-windows-none triple it behaves as MSVC and |
| 2165 | 2166 | // interprets the inner `struct Bar` as an anonymous structure |
| 2166 | 2167 | cases.add("type referenced struct", |
| ... | ... | @@ -3398,7 +3399,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3398 | 3399 | \\pub const FOO = @import("std").zig.c_translation.cast(c_int, @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8000, .hexadecimal)); |
| 3399 | 3400 | }); |
| 3400 | 3401 | |
| 3401 | if (std.Target.current.abi == .msvc) { | |
| 3402 | if (builtin.abi == .msvc) { | |
| 3402 | 3403 | cases.add("nameless struct fields", |
| 3403 | 3404 | \\typedef struct NAMED |
| 3404 | 3405 | \\{ |
tools/update_cpu_features.zig+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const fs = std.fs; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const json = std.json; |
| ... | ... | @@ -803,7 +804,7 @@ pub fn main() anyerror!void { |
| 803 | 804 | const root_progress = try progress.start("", llvm_targets.len); |
| 804 | 805 | defer root_progress.end(); |
| 805 | 806 | |
| 806 | if (std.builtin.single_threaded) { | |
| 807 | if (builtin.single_threaded) { | |
| 807 | 808 | for (llvm_targets) |llvm_target| { |
| 808 | 809 | try processOneTarget(Job{ |
| 809 | 810 | .llvm_tblgen_exe = llvm_tblgen_exe, |