| author | |
| committer | |
| log | 429cd2b5dd27bec15a4a3351114ce1bcd12d8d01 |
| tree | 6f0dda8c4a63d7944046bf9a580e20ba304de814 |
| parent | a4bb7c8bb17a4ac692401946df6b9f4cc3e5b1b2 |
86 files changed, 264 insertions(+), 269 deletions(-)
lib/std/Thread/AutoResetEvent.zig+1-1| ... | @@ -32,7 +32,7 @@ | ... | @@ -32,7 +32,7 @@ |
| 32 | state: usize = UNSET, | 32 | state: usize = UNSET, |
| 33 | 33 | ||
| 34 | const std = @import("../std.zig"); | 34 | const std = @import("../std.zig"); |
| 35 | const builtin = @import("builtin"); | 35 | const builtin = std.builtin; |
| 36 | const testing = std.testing; | 36 | const testing = std.testing; |
| 37 | const assert = std.debug.assert; | 37 | const assert = std.debug.assert; |
| 38 | const StaticResetEvent = std.Thread.StaticResetEvent; | 38 | const StaticResetEvent = std.Thread.StaticResetEvent; |
lib/std/array_hash_map.zig+1-1| ... | @@ -14,7 +14,7 @@ const trait = meta.trait; | ... | @@ -14,7 +14,7 @@ const trait = meta.trait; |
| 14 | const autoHash = std.hash.autoHash; | 14 | const autoHash = std.hash.autoHash; |
| 15 | const Wyhash = std.hash.Wyhash; | 15 | const Wyhash = std.hash.Wyhash; |
| 16 | const Allocator = mem.Allocator; | 16 | const Allocator = mem.Allocator; |
| 17 | const builtin = @import("builtin"); | 17 | const builtin = std.builtin; |
| 18 | const hash_map = @This(); | 18 | const hash_map = @This(); |
| 19 | 19 | ||
| 20 | pub fn AutoArrayHashMap(comptime K: type, comptime V: type) type { | 20 | pub fn AutoArrayHashMap(comptime K: type, comptime V: type) type { |
lib/std/atomic/queue.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const assert = std.debug.assert; | 8 | const assert = std.debug.assert; |
| 9 | const expect = std.testing.expect; | 9 | const expect = std.testing.expect; |
| 10 | 10 |
lib/std/atomic/stack.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const assert = std.debug.assert; | 6 | const assert = std.debug.assert; |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const expect = std.testing.expect; | 8 | const expect = std.testing.expect; |
| 9 | 9 | ||
| 10 | /// Many reader, many writer, non-allocating, thread-safe | 10 | /// Many reader, many writer, non-allocating, thread-safe |
lib/std/build.zig+2-2| ... | @@ -1409,7 +1409,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1409,7 +1409,7 @@ pub const LibExeObjStep = struct { |
| 1409 | 1409 | ||
| 1410 | red_zone: ?bool = null, | 1410 | red_zone: ?bool = null, |
| 1411 | 1411 | ||
| 1412 | subsystem: ?builtin.SubSystem = null, | 1412 | subsystem: ?std.Target.SubSystem = null, |
| 1413 | 1413 | ||
| 1414 | /// Overrides the default stack size | 1414 | /// Overrides the default stack size |
| 1415 | stack_size: ?u64 = null, | 1415 | stack_size: ?u64 = null, |
| ... | @@ -1961,7 +1961,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1961,7 +1961,7 @@ pub const LibExeObjStep = struct { |
| 1961 | }, | 1961 | }, |
| 1962 | std.builtin.Version => { | 1962 | std.builtin.Version => { |
| 1963 | out.print( | 1963 | out.print( |
| 1964 | \\pub const {}: @import("builtin").Version = .{{ | 1964 | \\pub const {}: @import("std").builtin.Version = .{{ |
| 1965 | \\ .major = {d}, | 1965 | \\ .major = {d}, |
| 1966 | \\ .minor = {d}, | 1966 | \\ .minor = {d}, |
| 1967 | \\ .patch = {d}, | 1967 | \\ .patch = {d}, |
lib/std/builtin.zig+28-27| ... | @@ -3,39 +3,40 @@ | ... | @@ -3,39 +3,40 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | pub usingnamespace @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | 7 | ||
| 8 | /// Deprecated: use `std.Target`. | 8 | // These are all deprecated. |
| 9 | pub const Target = std.Target; | 9 | pub const zig_version = builtin.zig_version; |
| 10 | 10 | pub const zig_is_stage2 = builtin.zig_is_stage2; | |
| 11 | /// Deprecated: use `std.Target.Os`. | 11 | pub const output_mode = builtin.output_mode; |
| 12 | pub const Os = std.Target.Os; | 12 | pub const link_mode = builtin.link_mode; |
| 13 | 13 | pub const is_test = builtin.is_test; | |
| 14 | /// Deprecated: use `std.Target.Cpu.Arch`. | 14 | pub const single_threaded = builtin.single_threaded; |
| 15 | pub const Arch = std.Target.Cpu.Arch; | 15 | pub const abi = builtin.abi; |
| 16 | 16 | pub const cpu = builtin.cpu; | |
| 17 | /// Deprecated: use `std.Target.Abi`. | 17 | pub const os = builtin.os; |
| 18 | pub const Abi = std.Target.Abi; | 18 | pub const target = builtin.target; |
| 19 | 19 | pub const object_format = builtin.object_format; | |
| 20 | /// Deprecated: use `std.Target.ObjectFormat`. | 20 | pub const mode = builtin.mode; |
| 21 | pub const ObjectFormat = std.Target.ObjectFormat; | 21 | pub const link_libc = builtin.link_libc; |
| 22 | 22 | pub const link_libcpp = builtin.link_libcpp; | |
| 23 | /// Deprecated: use `std.Target.SubSystem`. | 23 | pub const have_error_return_tracing = builtin.have_error_return_tracing; |
| 24 | pub const SubSystem = std.Target.SubSystem; | 24 | pub const valgrind_support = builtin.valgrind_support; |
| 25 | 25 | pub const position_independent_code = builtin.position_independent_code; | |
| 26 | /// Deprecated: use `std.Target.Cpu`. | 26 | pub const position_independent_executable = builtin.position_independent_executable; |
| 27 | pub const Cpu = std.Target.Cpu; | 27 | pub const strip_debug_info = builtin.strip_debug_info; |
| 28 | pub const code_model = builtin.code_model; | ||
| 28 | 29 | ||
| 29 | /// `explicit_subsystem` is missing when the subsystem is automatically detected, | 30 | /// `explicit_subsystem` is missing when the subsystem is automatically detected, |
| 30 | /// so Zig standard library has the subsystem detection logic here. This should generally be | 31 | /// so Zig standard library has the subsystem detection logic here. This should generally be |
| 31 | /// used rather than `explicit_subsystem`. | 32 | /// used rather than `explicit_subsystem`. |
| 32 | /// On non-Windows targets, this is `null`. | 33 | /// On non-Windows targets, this is `null`. |
| 33 | pub const subsystem: ?SubSystem = blk: { | 34 | pub const subsystem: ?std.Target.SubSystem = blk: { |
| 34 | if (@hasDecl(@This(), "explicit_subsystem")) break :blk explicit_subsystem; | 35 | if (@hasDecl(builtin, "explicit_subsystem")) break :blk explicit_subsystem; |
| 35 | switch (os.tag) { | 36 | switch (os.tag) { |
| 36 | .windows => { | 37 | .windows => { |
| 37 | if (is_test) { | 38 | if (is_test) { |
| 38 | break :blk SubSystem.Console; | 39 | break :blk std.Target.SubSystem.Console; |
| 39 | } | 40 | } |
| 40 | if (@hasDecl(root, "main") or | 41 | if (@hasDecl(root, "main") or |
| 41 | @hasDecl(root, "WinMain") or | 42 | @hasDecl(root, "WinMain") or |
| ... | @@ -43,9 +44,9 @@ pub const subsystem: ?SubSystem = blk: { | ... | @@ -43,9 +44,9 @@ pub const subsystem: ?SubSystem = blk: { |
| 43 | @hasDecl(root, "WinMainCRTStartup") or | 44 | @hasDecl(root, "WinMainCRTStartup") or |
| 44 | @hasDecl(root, "wWinMainCRTStartup")) | 45 | @hasDecl(root, "wWinMainCRTStartup")) |
| 45 | { | 46 | { |
| 46 | break :blk SubSystem.Windows; | 47 | break :blk std.Target.SubSystem.Windows; |
| 47 | } else { | 48 | } else { |
| 48 | break :blk SubSystem.Console; | 49 | break :blk std.Target.SubSystem.Console; |
| 49 | } | 50 | } |
| 50 | }, | 51 | }, |
| 51 | else => break :blk null, | 52 | else => break :blk null, |
lib/std/c/linux.zig+8-6| ... | @@ -3,12 +3,14 @@ | ... | @@ -3,12 +3,14 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | ||
| 7 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 8 | const maxInt = std.math.maxInt; | 7 | const maxInt = std.math.maxInt; |
| 8 | const abi = std.Target.current.abi; | ||
| 9 | const arch = std.Target.current.cpu.arch; | ||
| 10 | const os_tag = std.Target.current.os.tag; | ||
| 9 | usingnamespace std.c; | 11 | usingnamespace std.c; |
| 10 | 12 | ||
| 11 | pub const _errno = switch (builtin.abi) { | 13 | pub const _errno = switch (abi) { |
| 12 | .android => struct { | 14 | .android => struct { |
| 13 | extern "c" var __errno: c_int; | 15 | extern "c" var __errno: c_int; |
| 14 | fn getErrno() *c_int { | 16 | fn getErrno() *c_int { |
| ... | @@ -124,7 +126,7 @@ pub const pthread_mutex_t = extern struct { | ... | @@ -124,7 +126,7 @@ pub const pthread_mutex_t = extern struct { |
| 124 | pub const pthread_cond_t = extern struct { | 126 | pub const pthread_cond_t = extern struct { |
| 125 | size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T, | 127 | size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T, |
| 126 | }; | 128 | }; |
| 127 | pub const pthread_rwlock_t = switch (std.builtin.abi) { | 129 | pub const pthread_rwlock_t = switch (abi) { |
| 128 | .android => switch (@sizeOf(usize)) { | 130 | .android => switch (@sizeOf(usize)) { |
| 129 | 4 => extern struct { | 131 | 4 => extern struct { |
| 130 | lock: std.c.pthread_mutex_t = std.c.PTHREAD_MUTEX_INITIALIZER, | 132 | lock: std.c.pthread_mutex_t = std.c.PTHREAD_MUTEX_INITIALIZER, |
| ... | @@ -155,11 +157,11 @@ pub const sem_t = extern struct { | ... | @@ -155,11 +157,11 @@ pub const sem_t = extern struct { |
| 155 | }; | 157 | }; |
| 156 | 158 | ||
| 157 | const __SIZEOF_PTHREAD_COND_T = 48; | 159 | const __SIZEOF_PTHREAD_COND_T = 48; |
| 158 | const __SIZEOF_PTHREAD_MUTEX_T = if (builtin.os.tag == .fuchsia) 40 else switch (builtin.abi) { | 160 | const __SIZEOF_PTHREAD_MUTEX_T = if (os_tag == .fuchsia) 40 else switch (abi) { |
| 159 | .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24, | 161 | .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24, |
| 160 | .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (builtin.arch) { | 162 | .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (arch) { |
| 161 | .aarch64 => 48, | 163 | .aarch64 => 48, |
| 162 | .x86_64 => if (builtin.abi == .gnux32) 40 else 32, | 164 | .x86_64 => if (abi == .gnux32) 40 else 32, |
| 163 | .mips64, .powerpc64, .powerpc64le, .sparcv9 => 40, | 165 | .mips64, .powerpc64, .powerpc64le, .sparcv9 => 40, |
| 164 | else => if (@sizeOf(usize) == 8) 40 else 24, | 166 | else => if (@sizeOf(usize) == 8) 40 else 24, |
| 165 | }, | 167 | }, |
lib/std/child_process.zig+1-1| ... | @@ -15,7 +15,7 @@ const windows = os.windows; | ... | @@ -15,7 +15,7 @@ const windows = os.windows; |
| 15 | const mem = std.mem; | 15 | const mem = std.mem; |
| 16 | const debug = std.debug; | 16 | const debug = std.debug; |
| 17 | const BufMap = std.BufMap; | 17 | const BufMap = std.BufMap; |
| 18 | const builtin = @import("builtin"); | 18 | const builtin = std.builtin; |
| 19 | const Os = builtin.Os; | 19 | const Os = builtin.Os; |
| 20 | const TailQueue = std.TailQueue; | 20 | const TailQueue = std.TailQueue; |
| 21 | const maxInt = std.math.maxInt; | 21 | const maxInt = std.math.maxInt; |
lib/std/coff.zig+1-1| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = std.builtin; |
| 7 | const std = @import("std.zig"); | 7 | const std = @import("std.zig"); |
| 8 | const io = std.io; | 8 | const io = std.io; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
lib/std/cstr.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std.zig"); | 6 | const std = @import("std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const debug = std.debug; | 8 | const debug = std.debug; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
| 10 | const testing = std.testing; | 10 | const testing = std.testing; |
lib/std/debug.zig+25-22| ... | @@ -21,6 +21,9 @@ const root = @import("root"); | ... | @@ -21,6 +21,9 @@ const root = @import("root"); |
| 21 | const maxInt = std.math.maxInt; | 21 | const maxInt = std.math.maxInt; |
| 22 | const File = std.fs.File; | 22 | const File = std.fs.File; |
| 23 | const windows = std.os.windows; | 23 | const windows = std.os.windows; |
| 24 | const native_arch = std.Target.current.cpu.arch; | ||
| 25 | const native_os = std.Target.current.os.tag; | ||
| 26 | const native_endian = native_arch.endian(); | ||
| 24 | 27 | ||
| 25 | pub const runtime_safety = switch (builtin.mode) { | 28 | pub const runtime_safety = switch (builtin.mode) { |
| 26 | .Debug, .ReleaseSafe => true, | 29 | .Debug, .ReleaseSafe => true, |
| ... | @@ -90,7 +93,7 @@ pub fn detectTTYConfig() TTY.Config { | ... | @@ -90,7 +93,7 @@ pub fn detectTTYConfig() TTY.Config { |
| 90 | const stderr_file = io.getStdErr(); | 93 | const stderr_file = io.getStdErr(); |
| 91 | if (stderr_file.supportsAnsiEscapeCodes()) { | 94 | if (stderr_file.supportsAnsiEscapeCodes()) { |
| 92 | return .escape_codes; | 95 | return .escape_codes; |
| 93 | } else if (builtin.os.tag == .windows and stderr_file.isTty()) { | 96 | } else if (native_os == .windows and stderr_file.isTty()) { |
| 94 | return .windows_api; | 97 | return .windows_api; |
| 95 | } else { | 98 | } else { |
| 96 | return .no_color; | 99 | return .no_color; |
| ... | @@ -148,7 +151,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { | ... | @@ -148,7 +151,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { |
| 148 | /// chopping off the irrelevant frames and shifting so that the returned addresses pointer | 151 | /// chopping off the irrelevant frames and shifting so that the returned addresses pointer |
| 149 | /// equals the passed in addresses pointer. | 152 | /// equals the passed in addresses pointer. |
| 150 | pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace) void { | 153 | pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace) void { |
| 151 | if (builtin.os.tag == .windows) { | 154 | if (native_os == .windows) { |
| 152 | const addrs = stack_trace.instruction_addresses; | 155 | const addrs = stack_trace.instruction_addresses; |
| 153 | const u32_addrs_len = @intCast(u32, addrs.len); | 156 | const u32_addrs_len = @intCast(u32, addrs.len); |
| 154 | const first_addr = first_address orelse { | 157 | const first_addr = first_address orelse { |
| ... | @@ -226,7 +229,7 @@ pub fn assert(ok: bool) void { | ... | @@ -226,7 +229,7 @@ pub fn assert(ok: bool) void { |
| 226 | pub fn panic(comptime format: []const u8, args: anytype) noreturn { | 229 | pub fn panic(comptime format: []const u8, args: anytype) noreturn { |
| 227 | @setCold(true); | 230 | @setCold(true); |
| 228 | // TODO: remove conditional once wasi / LLVM defines __builtin_return_address | 231 | // TODO: remove conditional once wasi / LLVM defines __builtin_return_address |
| 229 | const first_trace_addr = if (builtin.os.tag == .wasi) null else @returnAddress(); | 232 | const first_trace_addr = if (native_os == .wasi) null else @returnAddress(); |
| 230 | panicExtra(null, first_trace_addr, format, args); | 233 | panicExtra(null, first_trace_addr, format, args); |
| 231 | } | 234 | } |
| 232 | 235 | ||
| ... | @@ -343,25 +346,25 @@ pub const StackIterator = struct { | ... | @@ -343,25 +346,25 @@ pub const StackIterator = struct { |
| 343 | } | 346 | } |
| 344 | 347 | ||
| 345 | // Offset of the saved BP wrt the frame pointer. | 348 | // Offset of the saved BP wrt the frame pointer. |
| 346 | const fp_offset = if (builtin.arch.isRISCV()) | 349 | const fp_offset = if (native_arch.isRISCV()) |
| 347 | // On RISC-V the frame pointer points to the top of the saved register | 350 | // On RISC-V the frame pointer points to the top of the saved register |
| 348 | // area, on pretty much every other architecture it points to the stack | 351 | // area, on pretty much every other architecture it points to the stack |
| 349 | // slot where the previous frame pointer is saved. | 352 | // slot where the previous frame pointer is saved. |
| 350 | 2 * @sizeOf(usize) | 353 | 2 * @sizeOf(usize) |
| 351 | else if (builtin.arch.isSPARC()) | 354 | else if (native_arch.isSPARC()) |
| 352 | // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS. | 355 | // On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS. |
| 353 | 14 * @sizeOf(usize) | 356 | 14 * @sizeOf(usize) |
| 354 | else | 357 | else |
| 355 | 0; | 358 | 0; |
| 356 | 359 | ||
| 357 | const fp_bias = if (builtin.arch.isSPARC()) | 360 | const fp_bias = if (native_arch.isSPARC()) |
| 358 | // On SPARC frame pointers are biased by a constant. | 361 | // On SPARC frame pointers are biased by a constant. |
| 359 | 2047 | 362 | 2047 |
| 360 | else | 363 | else |
| 361 | 0; | 364 | 0; |
| 362 | 365 | ||
| 363 | // Positive offset of the saved PC wrt the frame pointer. | 366 | // Positive offset of the saved PC wrt the frame pointer. |
| 364 | const pc_offset = if (builtin.arch == .powerpc64le) | 367 | const pc_offset = if (native_arch == .powerpc64le) |
| 365 | 2 * @sizeOf(usize) | 368 | 2 * @sizeOf(usize) |
| 366 | else | 369 | else |
| 367 | @sizeOf(usize); | 370 | @sizeOf(usize); |
| ... | @@ -380,7 +383,7 @@ pub const StackIterator = struct { | ... | @@ -380,7 +383,7 @@ pub const StackIterator = struct { |
| 380 | } | 383 | } |
| 381 | 384 | ||
| 382 | fn next_internal(self: *StackIterator) ?usize { | 385 | fn next_internal(self: *StackIterator) ?usize { |
| 383 | const fp = if (builtin.arch.isSPARC()) | 386 | const fp = if (native_arch.isSPARC()) |
| 384 | // On SPARC the offset is positive. (!) | 387 | // On SPARC the offset is positive. (!) |
| 385 | math.add(usize, self.fp, fp_offset) catch return null | 388 | math.add(usize, self.fp, fp_offset) catch return null |
| 386 | else | 389 | else |
| ... | @@ -416,7 +419,7 @@ pub fn writeCurrentStackTrace( | ... | @@ -416,7 +419,7 @@ pub fn writeCurrentStackTrace( |
| 416 | tty_config: TTY.Config, | 419 | tty_config: TTY.Config, |
| 417 | start_addr: ?usize, | 420 | start_addr: ?usize, |
| 418 | ) !void { | 421 | ) !void { |
| 419 | if (builtin.os.tag == .windows) { | 422 | if (native_os == .windows) { |
| 420 | return writeCurrentStackTraceWindows(out_stream, debug_info, tty_config, start_addr); | 423 | return writeCurrentStackTraceWindows(out_stream, debug_info, tty_config, start_addr); |
| 421 | } | 424 | } |
| 422 | var it = StackIterator.init(start_addr, null); | 425 | var it = StackIterator.init(start_addr, null); |
| ... | @@ -473,7 +476,7 @@ pub const TTY = struct { | ... | @@ -473,7 +476,7 @@ pub const TTY = struct { |
| 473 | .Dim => out_stream.writeAll(DIM) catch return, | 476 | .Dim => out_stream.writeAll(DIM) catch return, |
| 474 | .Reset => out_stream.writeAll(RESET) catch return, | 477 | .Reset => out_stream.writeAll(RESET) catch return, |
| 475 | }, | 478 | }, |
| 476 | .windows_api => if (builtin.os.tag == .windows) { | 479 | .windows_api => if (native_os == .windows) { |
| 477 | const stderr_file = io.getStdErr(); | 480 | const stderr_file = io.getStdErr(); |
| 478 | const S = struct { | 481 | const S = struct { |
| 479 | var attrs: windows.WORD = undefined; | 482 | var attrs: windows.WORD = undefined; |
| ... | @@ -675,7 +678,7 @@ pub fn openSelfDebugInfo(allocator: *mem.Allocator) anyerror!DebugInfo { | ... | @@ -675,7 +678,7 @@ pub fn openSelfDebugInfo(allocator: *mem.Allocator) anyerror!DebugInfo { |
| 675 | if (@hasDecl(root, "os") and @hasDecl(root.os, "debug") and @hasDecl(root.os.debug, "openSelfDebugInfo")) { | 678 | if (@hasDecl(root, "os") and @hasDecl(root.os, "debug") and @hasDecl(root.os.debug, "openSelfDebugInfo")) { |
| 676 | return root.os.debug.openSelfDebugInfo(allocator); | 679 | return root.os.debug.openSelfDebugInfo(allocator); |
| 677 | } | 680 | } |
| 678 | switch (builtin.os.tag) { | 681 | switch (native_os) { |
| 679 | .linux, | 682 | .linux, |
| 680 | .freebsd, | 683 | .freebsd, |
| 681 | .netbsd, | 684 | .netbsd, |
| ... | @@ -888,7 +891,7 @@ pub fn readElfDebugInfo(allocator: *mem.Allocator, elf_file: File) !ModuleDebugI | ... | @@ -888,7 +891,7 @@ pub fn readElfDebugInfo(allocator: *mem.Allocator, elf_file: File) !ModuleDebugI |
| 888 | elf.ELFDATA2MSB => .Big, | 891 | elf.ELFDATA2MSB => .Big, |
| 889 | else => return error.InvalidElfEndian, | 892 | else => return error.InvalidElfEndian, |
| 890 | }; | 893 | }; |
| 891 | assert(endian == std.builtin.endian); // this is our own debug info | 894 | assert(endian == native_endian); // this is our own debug info |
| 892 | 895 | ||
| 893 | const shoff = hdr.e_shoff; | 896 | const shoff = hdr.e_shoff; |
| 894 | const str_section_off = shoff + @as(u64, hdr.e_shentsize) * @as(u64, hdr.e_shstrndx); | 897 | const str_section_off = shoff + @as(u64, hdr.e_shentsize) * @as(u64, hdr.e_shstrndx); |
| ... | @@ -1123,9 +1126,9 @@ pub const DebugInfo = struct { | ... | @@ -1123,9 +1126,9 @@ pub const DebugInfo = struct { |
| 1123 | pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo { | 1126 | pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo { |
| 1124 | if (comptime std.Target.current.isDarwin()) { | 1127 | if (comptime std.Target.current.isDarwin()) { |
| 1125 | return self.lookupModuleDyld(address); | 1128 | return self.lookupModuleDyld(address); |
| 1126 | } else if (builtin.os.tag == .windows) { | 1129 | } else if (native_os == .windows) { |
| 1127 | return self.lookupModuleWin32(address); | 1130 | return self.lookupModuleWin32(address); |
| 1128 | } else if (builtin.os.tag == .haiku) { | 1131 | } else if (native_os == .haiku) { |
| 1129 | return self.lookupModuleHaiku(address); | 1132 | return self.lookupModuleHaiku(address); |
| 1130 | } else { | 1133 | } else { |
| 1131 | return self.lookupModuleDl(address); | 1134 | return self.lookupModuleDl(address); |
| ... | @@ -1353,7 +1356,7 @@ const SymbolInfo = struct { | ... | @@ -1353,7 +1356,7 @@ const SymbolInfo = struct { |
| 1353 | } | 1356 | } |
| 1354 | }; | 1357 | }; |
| 1355 | 1358 | ||
| 1356 | pub const ModuleDebugInfo = switch (builtin.os.tag) { | 1359 | pub const ModuleDebugInfo = switch (native_os) { |
| 1357 | .macos, .ios, .watchos, .tvos => struct { | 1360 | .macos, .ios, .watchos, .tvos => struct { |
| 1358 | base_address: usize, | 1361 | base_address: usize, |
| 1359 | mapped_memory: []const u8, | 1362 | mapped_memory: []const u8, |
| ... | @@ -1720,7 +1723,7 @@ fn getDebugInfoAllocator() *mem.Allocator { | ... | @@ -1720,7 +1723,7 @@ fn getDebugInfoAllocator() *mem.Allocator { |
| 1720 | } | 1723 | } |
| 1721 | 1724 | ||
| 1722 | /// Whether or not the current target can print useful debug information when a segfault occurs. | 1725 | /// Whether or not the current target can print useful debug information when a segfault occurs. |
| 1723 | pub const have_segfault_handling_support = switch (builtin.os.tag) { | 1726 | pub const have_segfault_handling_support = switch (native_os) { |
| 1724 | .linux, .netbsd => true, | 1727 | .linux, .netbsd => true, |
| 1725 | .windows => true, | 1728 | .windows => true, |
| 1726 | .freebsd, .openbsd => @hasDecl(os, "ucontext_t"), | 1729 | .freebsd, .openbsd => @hasDecl(os, "ucontext_t"), |
| ... | @@ -1744,7 +1747,7 @@ pub fn attachSegfaultHandler() void { | ... | @@ -1744,7 +1747,7 @@ pub fn attachSegfaultHandler() void { |
| 1744 | if (!have_segfault_handling_support) { | 1747 | if (!have_segfault_handling_support) { |
| 1745 | @compileError("segfault handler not supported for this target"); | 1748 | @compileError("segfault handler not supported for this target"); |
| 1746 | } | 1749 | } |
| 1747 | if (builtin.os.tag == .windows) { | 1750 | if (native_os == .windows) { |
| 1748 | windows_segfault_handle = windows.kernel32.AddVectoredExceptionHandler(0, handleSegfaultWindows); | 1751 | windows_segfault_handle = windows.kernel32.AddVectoredExceptionHandler(0, handleSegfaultWindows); |
| 1749 | return; | 1752 | return; |
| 1750 | } | 1753 | } |
| ... | @@ -1760,7 +1763,7 @@ pub fn attachSegfaultHandler() void { | ... | @@ -1760,7 +1763,7 @@ pub fn attachSegfaultHandler() void { |
| 1760 | } | 1763 | } |
| 1761 | 1764 | ||
| 1762 | fn resetSegfaultHandler() void { | 1765 | fn resetSegfaultHandler() void { |
| 1763 | if (builtin.os.tag == .windows) { | 1766 | if (native_os == .windows) { |
| 1764 | if (windows_segfault_handle) |handle| { | 1767 | if (windows_segfault_handle) |handle| { |
| 1765 | assert(windows.kernel32.RemoveVectoredExceptionHandler(handle) != 0); | 1768 | assert(windows.kernel32.RemoveVectoredExceptionHandler(handle) != 0); |
| 1766 | windows_segfault_handle = null; | 1769 | windows_segfault_handle = null; |
| ... | @@ -1783,7 +1786,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v | ... | @@ -1783,7 +1786,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v |
| 1783 | // and the resulting segfault will crash the process rather than continually dump stack traces. | 1786 | // and the resulting segfault will crash the process rather than continually dump stack traces. |
| 1784 | resetSegfaultHandler(); | 1787 | resetSegfaultHandler(); |
| 1785 | 1788 | ||
| 1786 | const addr = switch (builtin.os.tag) { | 1789 | const addr = switch (native_os) { |
| 1787 | .linux => @ptrToInt(info.fields.sigfault.addr), | 1790 | .linux => @ptrToInt(info.fields.sigfault.addr), |
| 1788 | .freebsd => @ptrToInt(info.addr), | 1791 | .freebsd => @ptrToInt(info.addr), |
| 1789 | .netbsd => @ptrToInt(info.info.reason.fault.addr), | 1792 | .netbsd => @ptrToInt(info.info.reason.fault.addr), |
| ... | @@ -1802,7 +1805,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v | ... | @@ -1802,7 +1805,7 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v |
| 1802 | } catch os.abort(); | 1805 | } catch os.abort(); |
| 1803 | } | 1806 | } |
| 1804 | 1807 | ||
| 1805 | switch (builtin.arch) { | 1808 | switch (native_arch) { |
| 1806 | .i386 => { | 1809 | .i386 => { |
| 1807 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); | 1810 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); |
| 1808 | const ip = @intCast(usize, ctx.mcontext.gregs[os.REG_EIP]); | 1811 | const ip = @intCast(usize, ctx.mcontext.gregs[os.REG_EIP]); |
| ... | @@ -1811,13 +1814,13 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v | ... | @@ -1811,13 +1814,13 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v |
| 1811 | }, | 1814 | }, |
| 1812 | .x86_64 => { | 1815 | .x86_64 => { |
| 1813 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); | 1816 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); |
| 1814 | const ip = switch (builtin.os.tag) { | 1817 | const ip = switch (native_os) { |
| 1815 | .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]), | 1818 | .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]), |
| 1816 | .freebsd => @intCast(usize, ctx.mcontext.rip), | 1819 | .freebsd => @intCast(usize, ctx.mcontext.rip), |
| 1817 | .openbsd => @intCast(usize, ctx.sc_rip), | 1820 | .openbsd => @intCast(usize, ctx.sc_rip), |
| 1818 | else => unreachable, | 1821 | else => unreachable, |
| 1819 | }; | 1822 | }; |
| 1820 | const bp = switch (builtin.os.tag) { | 1823 | const bp = switch (native_os) { |
| 1821 | .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]), | 1824 | .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]), |
| 1822 | .openbsd => @intCast(usize, ctx.sc_rbp), | 1825 | .openbsd => @intCast(usize, ctx.sc_rbp), |
| 1823 | .freebsd => @intCast(usize, ctx.mcontext.rbp), | 1826 | .freebsd => @intCast(usize, ctx.mcontext.rbp), |
lib/std/dwarf.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std.zig"); | 6 | const std = @import("std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const debug = std.debug; | 8 | const debug = std.debug; |
| 9 | const fs = std.fs; | 9 | const fs = std.fs; |
| 10 | const io = std.io; | 10 | const io = std.io; |
lib/std/dynamic_library.zig+1-1| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = std.builtin; |
| 7 | 7 | ||
| 8 | const std = @import("std.zig"); | 8 | const std = @import("std.zig"); |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
lib/std/event/channel.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const assert = std.debug.assert; | 8 | const assert = std.debug.assert; |
| 9 | const testing = std.testing; | 9 | const testing = std.testing; |
| 10 | const Loop = std.event.Loop; | 10 | const Loop = std.event.Loop; |
lib/std/event/future.zig+1-1| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const assert = std.debug.assert; | 7 | const assert = std.debug.assert; |
| 8 | const testing = std.testing; | 8 | const testing = std.testing; |
| 9 | const builtin = @import("builtin"); | 9 | const builtin = std.builtin; |
| 10 | const Lock = std.event.Lock; | 10 | const Lock = std.event.Lock; |
| 11 | 11 | ||
| 12 | /// This is a value that starts out unavailable, until resolve() is called | 12 | /// This is a value that starts out unavailable, until resolve() is called |
lib/std/event/group.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const Lock = std.event.Lock; | 8 | const Lock = std.event.Lock; |
| 9 | const testing = std.testing; | 9 | const testing = std.testing; |
| 10 | const Allocator = std.mem.Allocator; | 10 | const Allocator = std.mem.Allocator; |
lib/std/event/lock.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const assert = std.debug.assert; | 8 | const assert = std.debug.assert; |
| 9 | const testing = std.testing; | 9 | const testing = std.testing; |
| 10 | const mem = std.mem; | 10 | const mem = std.mem; |
lib/std/event/loop.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const root = @import("root"); | 8 | const root = @import("root"); |
| 9 | const assert = std.debug.assert; | 9 | const assert = std.debug.assert; |
| 10 | const testing = std.testing; | 10 | const testing = std.testing; |
lib/std/event/rwlock.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const assert = std.debug.assert; | 8 | const assert = std.debug.assert; |
| 9 | const testing = std.testing; | 9 | const testing = std.testing; |
| 10 | const mem = std.mem; | 10 | const mem = std.mem; |
lib/std/event/wait_group.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const Loop = std.event.Loop; | 8 | const Loop = std.event.Loop; |
| 9 | 9 | ||
| 10 | /// A WaitGroup keeps track and waits for a group of async tasks to finish. | 10 | /// A WaitGroup keeps track and waits for a group of async tasks to finish. |
lib/std/fmt.zig+1-1| ... | @@ -9,7 +9,7 @@ const assert = std.debug.assert; | ... | @@ -9,7 +9,7 @@ const assert = std.debug.assert; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
| 10 | const unicode = std.unicode; | 10 | const unicode = std.unicode; |
| 11 | const meta = std.meta; | 11 | const meta = std.meta; |
| 12 | const builtin = @import("builtin"); | 12 | const builtin = std.builtin; |
| 13 | const errol = @import("fmt/errol.zig"); | 13 | const errol = @import("fmt/errol.zig"); |
| 14 | const lossyCast = std.math.lossyCast; | 14 | const lossyCast = std.math.lossyCast; |
| 15 | const expectFmt = std.testing.expectFmt; | 15 | const expectFmt = std.testing.expectFmt; |
lib/std/fs.zig+1-1| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = std.builtin; |
| 7 | const std = @import("std.zig"); | 7 | const std = @import("std.zig"); |
| 8 | const os = std.os; | 8 | const os = std.os; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
lib/std/fs/file.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const os = std.os; | 8 | const os = std.os; |
| 9 | const io = std.io; | 9 | const io = std.io; |
| 10 | const mem = std.mem; | 10 | const mem = std.mem; |
lib/std/fs/get_app_data_dir.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const unicode = std.unicode; | 8 | const unicode = std.unicode; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
| 10 | const fs = std.fs; | 10 | const fs = std.fs; |
lib/std/fs/path.zig+1-1| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = std.builtin; |
| 7 | const std = @import("../std.zig"); | 7 | const std = @import("../std.zig"); |
| 8 | const debug = std.debug; | 8 | const debug = std.debug; |
| 9 | const assert = debug.assert; | 9 | const assert = debug.assert; |
lib/std/fs/wasi.zig+1-1| ... | @@ -167,7 +167,7 @@ pub const PreopenList = struct { | ... | @@ -167,7 +167,7 @@ pub const PreopenList = struct { |
| 167 | }; | 167 | }; |
| 168 | 168 | ||
| 169 | test "extracting WASI preopens" { | 169 | test "extracting WASI preopens" { |
| 170 | if (@import("builtin").os.tag != .wasi) return error.SkipZigTest; | 170 | if (std.builtin.os.tag != .wasi) return error.SkipZigTest; |
| 171 | 171 | ||
| 172 | var preopens = PreopenList.init(std.testing.allocator); | 172 | var preopens = PreopenList.init(std.testing.allocator); |
| 173 | defer preopens.deinit(); | 173 | defer preopens.deinit(); |
lib/std/fs/watch.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const event = std.event; | 8 | const event = std.event; |
| 9 | const assert = std.debug.assert; | 9 | const assert = std.debug.assert; |
| 10 | const testing = std.testing; | 10 | const testing = std.testing; |
lib/std/hash/auto_hash.zig+3-3| ... | @@ -4,10 +4,10 @@ | ... | @@ -4,10 +4,10 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | ||
| 8 | const assert = std.debug.assert; | 7 | const assert = std.debug.assert; |
| 9 | const mem = std.mem; | 8 | const mem = std.mem; |
| 10 | const meta = std.meta; | 9 | const meta = std.meta; |
| 10 | const builtin = std.builtin; | ||
| 11 | 11 | ||
| 12 | /// Describes how pointer types should be hashed. | 12 | /// Describes how pointer types should be hashed. |
| 13 | pub const HashStrategy = enum { | 13 | pub const HashStrategy = enum { |
| ... | @@ -239,7 +239,7 @@ fn testHashDeepRecursive(key: anytype) u64 { | ... | @@ -239,7 +239,7 @@ fn testHashDeepRecursive(key: anytype) u64 { |
| 239 | 239 | ||
| 240 | test "typeContainsSlice" { | 240 | test "typeContainsSlice" { |
| 241 | comptime { | 241 | comptime { |
| 242 | testing.expect(!typeContainsSlice(meta.Tag(std.builtin.TypeInfo))); | 242 | testing.expect(!typeContainsSlice(meta.Tag(builtin.TypeInfo))); |
| 243 | 243 | ||
| 244 | testing.expect(typeContainsSlice([]const u8)); | 244 | testing.expect(typeContainsSlice([]const u8)); |
| 245 | testing.expect(!typeContainsSlice(u8)); | 245 | testing.expect(!typeContainsSlice(u8)); |
| ... | @@ -400,7 +400,7 @@ test "testHash union" { | ... | @@ -400,7 +400,7 @@ test "testHash union" { |
| 400 | 400 | ||
| 401 | test "testHash vector" { | 401 | test "testHash vector" { |
| 402 | // Disabled because of #3317 | 402 | // Disabled because of #3317 |
| 403 | if (@import("builtin").arch == .mipsel or @import("builtin").arch == .mips) return error.SkipZigTest; | 403 | if (builtin.target.cpu.arch == .mipsel or builtin.target.cpu.arch == .mips) return error.SkipZigTest; |
| 404 | 404 | ||
| 405 | const a: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 4 }; | 405 | const a: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 4 }; |
| 406 | const b: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 5 }; | 406 | const b: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 5 }; |
lib/std/hash/benchmark.zig+1-1| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | // zig run benchmark.zig --release-fast --override-lib-dir .. | 6 | // zig run benchmark.zig --release-fast --override-lib-dir .. |
| 7 | 7 | ||
| 8 | const builtin = @import("builtin"); | 8 | const builtin = std.builtin; |
| 9 | const std = @import("std"); | 9 | const std = @import("std"); |
| 10 | const time = std.time; | 10 | const time = std.time; |
| 11 | const Timer = time.Timer; | 11 | const Timer = time.Timer; |
lib/std/hash/cityhash.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | 8 | ||
| 9 | fn offsetPtr(ptr: [*]const u8, offset: usize) callconv(.Inline) [*]const u8 { | 9 | fn offsetPtr(ptr: [*]const u8, offset: usize) callconv(.Inline) [*]const u8 { |
| 10 | // ptr + offset doesn't work at comptime so we need this instead. | 10 | // ptr + offset doesn't work at comptime so we need this instead. |
lib/std/hash/murmur.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const testing = std.testing; | 8 | const testing = std.testing; |
| 9 | 9 | ||
| 10 | const default_seed: u32 = 0xc70f6907; | 10 | const default_seed: u32 = 0xc70f6907; |
lib/std/hash_map.zig-1| ... | @@ -4,7 +4,6 @@ | ... | @@ -4,7 +4,6 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std.zig"); | 6 | const std = @import("std.zig"); |
| 7 | const builtin = @import("builtin"); | ||
| 8 | const assert = debug.assert; | 7 | const assert = debug.assert; |
| 9 | const autoHash = std.hash.autoHash; | 8 | const autoHash = std.hash.autoHash; |
| 10 | const debug = std.debug; | 9 | const debug = std.debug; |
lib/std/heap.zig+1-1| ... | @@ -10,7 +10,7 @@ const assert = debug.assert; | ... | @@ -10,7 +10,7 @@ const assert = debug.assert; |
| 10 | const testing = std.testing; | 10 | const testing = std.testing; |
| 11 | const mem = std.mem; | 11 | const mem = std.mem; |
| 12 | const os = std.os; | 12 | const os = std.os; |
| 13 | const builtin = @import("builtin"); | 13 | const builtin = std.builtin; |
| 14 | const c = std.c; | 14 | const c = std.c; |
| 15 | const maxInt = std.math.maxInt; | 15 | const maxInt = std.math.maxInt; |
| 16 | 16 |
lib/std/io.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std.zig"); | 6 | const std = @import("std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const root = @import("root"); | 8 | const root = @import("root"); |
| 9 | const c = std.c; | 9 | const c = std.c; |
| 10 | 10 |
lib/std/math/acosh.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/acoshf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/acoshf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/acosh.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/acosh.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../std.zig"); | 12 | const std = @import("../std.zig"); |
| 14 | const math = std.math; | 13 | const math = std.math; |
| 15 | const expect = std.testing.expect; | 14 | const expect = std.testing.expect; |
lib/std/math/ceil.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../std.zig"); | 12 | const std = @import("../std.zig"); |
| 14 | const math = std.math; | 13 | const math = std.math; |
| 15 | const expect = std.testing.expect; | 14 | const expect = std.testing.expect; |
lib/std/math/complex/atan.zig-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/catan.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/catan.c |
| 11 | 11 | ||
| 12 | const std = @import("../../std.zig"); | 12 | const std = @import("../../std.zig"); |
| 13 | const builtin = @import("builtin"); | ||
| 14 | const testing = std.testing; | 13 | const testing = std.testing; |
| 15 | const math = std.math; | 14 | const math = std.math; |
| 16 | const cmath = math.complex; | 15 | const cmath = math.complex; |
lib/std/math/complex/cosh.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/ccoshf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/ccoshf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/ccosh.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/ccosh.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../../std.zig"); | 12 | const std = @import("../../std.zig"); |
| 14 | const testing = std.testing; | 13 | const testing = std.testing; |
| 15 | const math = std.math; | 14 | const math = std.math; |
lib/std/math/complex/exp.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/cexpf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/cexpf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/cexp.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/cexp.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../../std.zig"); | 12 | const std = @import("../../std.zig"); |
| 14 | const testing = std.testing; | 13 | const testing = std.testing; |
| 15 | const math = std.math; | 14 | const math = std.math; |
lib/std/math/complex/sinh.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/csinhf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/csinhf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/csinh.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/csinh.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../../std.zig"); | 12 | const std = @import("../../std.zig"); |
| 14 | const testing = std.testing; | 13 | const testing = std.testing; |
| 15 | const math = std.math; | 14 | const math = std.math; |
lib/std/math/complex/tanh.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanhf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanhf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanh.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/complex/ctanh.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../../std.zig"); | 12 | const std = @import("../../std.zig"); |
| 14 | const testing = std.testing; | 13 | const testing = std.testing; |
| 15 | const math = std.math; | 14 | const math = std.math; |
lib/std/math/cos.zig-1| ... | @@ -8,7 +8,6 @@ | ... | @@ -8,7 +8,6 @@ |
| 8 | // | 8 | // |
| 9 | // https://golang.org/src/math/sin.go | 9 | // https://golang.org/src/math/sin.go |
| 10 | 10 | ||
| 11 | const builtin = @import("builtin"); | ||
| 12 | const std = @import("../std.zig"); | 11 | const std = @import("../std.zig"); |
| 13 | const math = std.math; | 12 | const math = std.math; |
| 14 | const expect = std.testing.expect; | 13 | const expect = std.testing.expect; |
lib/std/math/cosh.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/coshf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/coshf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/cosh.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/cosh.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../std.zig"); | 12 | const std = @import("../std.zig"); |
| 14 | const math = std.math; | 13 | const math = std.math; |
| 15 | const expo2 = @import("expo2.zig").expo2; | 14 | const expo2 = @import("expo2.zig").expo2; |
lib/std/math/expm1.zig-1| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | ||
| 12 | // TODO: Updated recently. | 12 | // TODO: Updated recently. |
| 13 | 13 | ||
| 14 | const builtin = @import("builtin"); | ||
| 15 | const std = @import("../std.zig"); | 14 | const std = @import("../std.zig"); |
| 16 | const math = std.math; | 15 | const math = std.math; |
| 17 | const expect = std.testing.expect; | 16 | const expect = std.testing.expect; |
lib/std/math/floor.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/floorf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/floorf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/floor.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/floor.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 14 | const std = @import("../std.zig"); | 13 | const std = @import("../std.zig"); |
| 15 | const math = std.math; | 14 | const math = std.math; |
lib/std/math/log1p.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log1pf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log1pf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log1p.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log1p.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../std.zig"); | 12 | const std = @import("../std.zig"); |
| 14 | const math = std.math; | 13 | const math = std.math; |
| 15 | const expect = std.testing.expect; | 14 | const expect = std.testing.expect; |
lib/std/math/pow.zig-1| ... | @@ -8,7 +8,6 @@ | ... | @@ -8,7 +8,6 @@ |
| 8 | // | 8 | // |
| 9 | // https://golang.org/src/math/pow.go | 9 | // https://golang.org/src/math/pow.go |
| 10 | 10 | ||
| 11 | const builtin = @import("builtin"); | ||
| 12 | const std = @import("../std.zig"); | 11 | const std = @import("../std.zig"); |
| 13 | const math = std.math; | 12 | const math = std.math; |
| 14 | const expect = std.testing.expect; | 13 | const expect = std.testing.expect; |
lib/std/math/powi.zig-1| ... | @@ -8,7 +8,6 @@ | ... | @@ -8,7 +8,6 @@ |
| 8 | // | 8 | // |
| 9 | // https://github.com/rust-lang/rust/blob/360432f1e8794de58cd94f34c9c17ad65871e5b5/src/libcore/num/mod.rs#L3423 | 9 | // https://github.com/rust-lang/rust/blob/360432f1e8794de58cd94f34c9c17ad65871e5b5/src/libcore/num/mod.rs#L3423 |
| 10 | 10 | ||
| 11 | const builtin = @import("builtin"); | ||
| 12 | const std = @import("../std.zig"); | 11 | const std = @import("../std.zig"); |
| 13 | const math = std.math; | 12 | const math = std.math; |
| 14 | const assert = std.debug.assert; | 13 | const assert = std.debug.assert; |
lib/std/math/round.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/roundf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/roundf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/round.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/round.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 14 | const std = @import("../std.zig"); | 13 | const std = @import("../std.zig"); |
| 15 | const math = std.math; | 14 | const math = std.math; |
lib/std/math/sin.zig-1| ... | @@ -8,7 +8,6 @@ | ... | @@ -8,7 +8,6 @@ |
| 8 | // | 8 | // |
| 9 | // https://golang.org/src/math/sin.go | 9 | // https://golang.org/src/math/sin.go |
| 10 | 10 | ||
| 11 | const builtin = @import("builtin"); | ||
| 12 | const std = @import("../std.zig"); | 11 | const std = @import("../std.zig"); |
| 13 | const math = std.math; | 12 | const math = std.math; |
| 14 | const expect = std.testing.expect; | 13 | const expect = std.testing.expect; |
lib/std/math/sinh.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/sinhf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/sinhf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/sinh.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/sinh.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../std.zig"); | 12 | const std = @import("../std.zig"); |
| 14 | const math = std.math; | 13 | const math = std.math; |
| 15 | const expect = std.testing.expect; | 14 | const expect = std.testing.expect; |
lib/std/math/sqrt.zig+1-2| ... | @@ -6,8 +6,7 @@ | ... | @@ -6,8 +6,7 @@ |
| 6 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 7 | const math = std.math; | 7 | const math = std.math; |
| 8 | const expect = std.testing.expect; | 8 | const expect = std.testing.expect; |
| 9 | const builtin = @import("builtin"); | 9 | const TypeId = std.builtin.TypeId; |
| 10 | const TypeId = builtin.TypeId; | ||
| 11 | const maxInt = std.math.maxInt; | 10 | const maxInt = std.math.maxInt; |
| 12 | 11 | ||
| 13 | /// Returns the square root of x. | 12 | /// Returns the square root of x. |
lib/std/math/tan.zig-1| ... | @@ -8,7 +8,6 @@ | ... | @@ -8,7 +8,6 @@ |
| 8 | // | 8 | // |
| 9 | // https://golang.org/src/math/tan.go | 9 | // https://golang.org/src/math/tan.go |
| 10 | 10 | ||
| 11 | const builtin = @import("builtin"); | ||
| 12 | const std = @import("../std.zig"); | 11 | const std = @import("../std.zig"); |
| 13 | const math = std.math; | 12 | const math = std.math; |
| 14 | const expect = std.testing.expect; | 13 | const expect = std.testing.expect; |
lib/std/math/tanh.zig-1| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/tanhf.c | 9 | // https://git.musl-libc.org/cgit/musl/tree/src/math/tanhf.c |
| 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/tanh.c | 10 | // https://git.musl-libc.org/cgit/musl/tree/src/math/tanh.c |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | ||
| 13 | const std = @import("../std.zig"); | 12 | const std = @import("../std.zig"); |
| 14 | const math = std.math; | 13 | const math = std.math; |
| 15 | const expect = std.testing.expect; | 14 | const expect = std.testing.expect; |
lib/std/mem.zig+46-45| ... | @@ -7,17 +7,18 @@ const std = @import("std.zig"); | ... | @@ -7,17 +7,18 @@ const std = @import("std.zig"); |
| 7 | const debug = std.debug; | 7 | const debug = std.debug; |
| 8 | const assert = debug.assert; | 8 | const assert = debug.assert; |
| 9 | const math = std.math; | 9 | const math = std.math; |
| 10 | const builtin = std.builtin; | ||
| 11 | const mem = @This(); | 10 | const mem = @This(); |
| 12 | const meta = std.meta; | 11 | const meta = std.meta; |
| 13 | const trait = meta.trait; | 12 | const trait = meta.trait; |
| 14 | const testing = std.testing; | 13 | const testing = std.testing; |
| 14 | const Endian = std.builtin.Endian; | ||
| 15 | const native_endian = std.Target.current.cpu.arch.endian(); | ||
| 15 | 16 | ||
| 16 | /// Compile time known minimum page size. | 17 | /// Compile time known minimum page size. |
| 17 | /// https://github.com/ziglang/zig/issues/4082 | 18 | /// https://github.com/ziglang/zig/issues/4082 |
| 18 | pub const page_size = switch (builtin.arch) { | 19 | pub const page_size = switch (std.Target.current.cpu.arch) { |
| 19 | .wasm32, .wasm64 => 64 * 1024, | 20 | .wasm32, .wasm64 => 64 * 1024, |
| 20 | .aarch64 => switch (builtin.os.tag) { | 21 | .aarch64 => switch (std.Target.current.os.tag) { |
| 21 | .macos, .ios, .watchos, .tvos => 16 * 1024, | 22 | .macos, .ios, .watchos, .tvos => 16 * 1024, |
| 22 | else => 4 * 1024, | 23 | else => 4 * 1024, |
| 23 | }, | 24 | }, |
| ... | @@ -1042,7 +1043,7 @@ test "mem.containsAtLeast" { | ... | @@ -1042,7 +1043,7 @@ test "mem.containsAtLeast" { |
| 1042 | /// Reads an integer from memory with size equal to bytes.len. | 1043 | /// Reads an integer from memory with size equal to bytes.len. |
| 1043 | /// T specifies the return type, which must be large enough to store | 1044 | /// T specifies the return type, which must be large enough to store |
| 1044 | /// the result. | 1045 | /// the result. |
| 1045 | pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: builtin.Endian) ReturnType { | 1046 | pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType { |
| 1046 | var result: ReturnType = 0; | 1047 | var result: ReturnType = 0; |
| 1047 | switch (endian) { | 1048 | switch (endian) { |
| 1048 | .Big => { | 1049 | .Big => { |
| ... | @@ -1077,12 +1078,12 @@ pub fn readIntForeign(comptime T: type, bytes: *const [@divExact(@typeInfo(T).In | ... | @@ -1077,12 +1078,12 @@ pub fn readIntForeign(comptime T: type, bytes: *const [@divExact(@typeInfo(T).In |
| 1077 | return @byteSwap(T, readIntNative(T, bytes)); | 1078 | return @byteSwap(T, readIntNative(T, bytes)); |
| 1078 | } | 1079 | } |
| 1079 | 1080 | ||
| 1080 | pub const readIntLittle = switch (builtin.endian) { | 1081 | pub const readIntLittle = switch (native_endian) { |
| 1081 | .Little => readIntNative, | 1082 | .Little => readIntNative, |
| 1082 | .Big => readIntForeign, | 1083 | .Big => readIntForeign, |
| 1083 | }; | 1084 | }; |
| 1084 | 1085 | ||
| 1085 | pub const readIntBig = switch (builtin.endian) { | 1086 | pub const readIntBig = switch (native_endian) { |
| 1086 | .Little => readIntForeign, | 1087 | .Little => readIntForeign, |
| 1087 | .Big => readIntNative, | 1088 | .Big => readIntNative, |
| 1088 | }; | 1089 | }; |
| ... | @@ -1106,12 +1107,12 @@ pub fn readIntSliceForeign(comptime T: type, bytes: []const u8) T { | ... | @@ -1106,12 +1107,12 @@ pub fn readIntSliceForeign(comptime T: type, bytes: []const u8) T { |
| 1106 | return @byteSwap(T, readIntSliceNative(T, bytes)); | 1107 | return @byteSwap(T, readIntSliceNative(T, bytes)); |
| 1107 | } | 1108 | } |
| 1108 | 1109 | ||
| 1109 | pub const readIntSliceLittle = switch (builtin.endian) { | 1110 | pub const readIntSliceLittle = switch (native_endian) { |
| 1110 | .Little => readIntSliceNative, | 1111 | .Little => readIntSliceNative, |
| 1111 | .Big => readIntSliceForeign, | 1112 | .Big => readIntSliceForeign, |
| 1112 | }; | 1113 | }; |
| 1113 | 1114 | ||
| 1114 | pub const readIntSliceBig = switch (builtin.endian) { | 1115 | pub const readIntSliceBig = switch (native_endian) { |
| 1115 | .Little => readIntSliceForeign, | 1116 | .Little => readIntSliceForeign, |
| 1116 | .Big => readIntSliceNative, | 1117 | .Big => readIntSliceNative, |
| 1117 | }; | 1118 | }; |
| ... | @@ -1119,8 +1120,8 @@ pub const readIntSliceBig = switch (builtin.endian) { | ... | @@ -1119,8 +1120,8 @@ pub const readIntSliceBig = switch (builtin.endian) { |
| 1119 | /// Reads an integer from memory with bit count specified by T. | 1120 | /// Reads an integer from memory with bit count specified by T. |
| 1120 | /// The bit count of T must be evenly divisible by 8. | 1121 | /// The bit count of T must be evenly divisible by 8. |
| 1121 | /// This function cannot fail and cannot cause undefined behavior. | 1122 | /// This function cannot fail and cannot cause undefined behavior. |
| 1122 | pub fn readInt(comptime T: type, bytes: *const [@divExact(@typeInfo(T).Int.bits, 8)]u8, endian: builtin.Endian) T { | 1123 | pub fn readInt(comptime T: type, bytes: *const [@divExact(@typeInfo(T).Int.bits, 8)]u8, endian: Endian) T { |
| 1123 | if (endian == builtin.endian) { | 1124 | if (endian == native_endian) { |
| 1124 | return readIntNative(T, bytes); | 1125 | return readIntNative(T, bytes); |
| 1125 | } else { | 1126 | } else { |
| 1126 | return readIntForeign(T, bytes); | 1127 | return readIntForeign(T, bytes); |
| ... | @@ -1130,7 +1131,7 @@ pub fn readInt(comptime T: type, bytes: *const [@divExact(@typeInfo(T).Int.bits, | ... | @@ -1130,7 +1131,7 @@ pub fn readInt(comptime T: type, bytes: *const [@divExact(@typeInfo(T).Int.bits, |
| 1130 | /// Asserts that bytes.len >= @typeInfo(T).Int.bits / 8. Reads the integer starting from index 0 | 1131 | /// Asserts that bytes.len >= @typeInfo(T).Int.bits / 8. Reads the integer starting from index 0 |
| 1131 | /// and ignores extra bytes. | 1132 | /// and ignores extra bytes. |
| 1132 | /// The bit count of T must be evenly divisible by 8. | 1133 | /// The bit count of T must be evenly divisible by 8. |
| 1133 | pub fn readIntSlice(comptime T: type, bytes: []const u8, endian: builtin.Endian) T { | 1134 | pub fn readIntSlice(comptime T: type, bytes: []const u8, endian: Endian) T { |
| 1134 | const n = @divExact(@typeInfo(T).Int.bits, 8); | 1135 | const n = @divExact(@typeInfo(T).Int.bits, 8); |
| 1135 | assert(bytes.len >= n); | 1136 | assert(bytes.len >= n); |
| 1136 | return readInt(T, bytes[0..n], endian); | 1137 | return readInt(T, bytes[0..n], endian); |
| ... | @@ -1188,12 +1189,12 @@ pub fn writeIntForeign(comptime T: type, buf: *[@divExact(@typeInfo(T).Int.bits, | ... | @@ -1188,12 +1189,12 @@ pub fn writeIntForeign(comptime T: type, buf: *[@divExact(@typeInfo(T).Int.bits, |
| 1188 | writeIntNative(T, buf, @byteSwap(T, value)); | 1189 | writeIntNative(T, buf, @byteSwap(T, value)); |
| 1189 | } | 1190 | } |
| 1190 | 1191 | ||
| 1191 | pub const writeIntLittle = switch (builtin.endian) { | 1192 | pub const writeIntLittle = switch (native_endian) { |
| 1192 | .Little => writeIntNative, | 1193 | .Little => writeIntNative, |
| 1193 | .Big => writeIntForeign, | 1194 | .Big => writeIntForeign, |
| 1194 | }; | 1195 | }; |
| 1195 | 1196 | ||
| 1196 | pub const writeIntBig = switch (builtin.endian) { | 1197 | pub const writeIntBig = switch (native_endian) { |
| 1197 | .Little => writeIntForeign, | 1198 | .Little => writeIntForeign, |
| 1198 | .Big => writeIntNative, | 1199 | .Big => writeIntNative, |
| 1199 | }; | 1200 | }; |
| ... | @@ -1201,8 +1202,8 @@ pub const writeIntBig = switch (builtin.endian) { | ... | @@ -1201,8 +1202,8 @@ pub const writeIntBig = switch (builtin.endian) { |
| 1201 | /// Writes an integer to memory, storing it in twos-complement. | 1202 | /// Writes an integer to memory, storing it in twos-complement. |
| 1202 | /// This function always succeeds, has defined behavior for all inputs, but | 1203 | /// This function always succeeds, has defined behavior for all inputs, but |
| 1203 | /// the integer bit width must be divisible by 8. | 1204 | /// the integer bit width must be divisible by 8. |
| 1204 | pub fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).Int.bits, 8)]u8, value: T, endian: builtin.Endian) void { | 1205 | pub fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).Int.bits, 8)]u8, value: T, endian: Endian) void { |
| 1205 | if (endian == builtin.endian) { | 1206 | if (endian == native_endian) { |
| 1206 | return writeIntNative(T, buffer, value); | 1207 | return writeIntNative(T, buffer, value); |
| 1207 | } else { | 1208 | } else { |
| 1208 | return writeIntForeign(T, buffer, value); | 1209 | return writeIntForeign(T, buffer, value); |
| ... | @@ -1252,12 +1253,12 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void { | ... | @@ -1252,12 +1253,12 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void { |
| 1252 | } | 1253 | } |
| 1253 | } | 1254 | } |
| 1254 | 1255 | ||
| 1255 | pub const writeIntSliceNative = switch (builtin.endian) { | 1256 | pub const writeIntSliceNative = switch (native_endian) { |
| 1256 | .Little => writeIntSliceLittle, | 1257 | .Little => writeIntSliceLittle, |
| 1257 | .Big => writeIntSliceBig, | 1258 | .Big => writeIntSliceBig, |
| 1258 | }; | 1259 | }; |
| 1259 | 1260 | ||
| 1260 | pub const writeIntSliceForeign = switch (builtin.endian) { | 1261 | pub const writeIntSliceForeign = switch (native_endian) { |
| 1261 | .Little => writeIntSliceBig, | 1262 | .Little => writeIntSliceBig, |
| 1262 | .Big => writeIntSliceLittle, | 1263 | .Big => writeIntSliceLittle, |
| 1263 | }; | 1264 | }; |
| ... | @@ -1268,7 +1269,7 @@ pub const writeIntSliceForeign = switch (builtin.endian) { | ... | @@ -1268,7 +1269,7 @@ pub const writeIntSliceForeign = switch (builtin.endian) { |
| 1268 | /// Any extra bytes in buffer not part of the integer are set to zero, with | 1269 | /// Any extra bytes in buffer not part of the integer are set to zero, with |
| 1269 | /// respect to endianness. To avoid the branch to check for extra buffer bytes, | 1270 | /// respect to endianness. To avoid the branch to check for extra buffer bytes, |
| 1270 | /// use writeInt instead. | 1271 | /// use writeInt instead. |
| 1271 | pub fn writeIntSlice(comptime T: type, buffer: []u8, value: T, endian: builtin.Endian) void { | 1272 | pub fn writeIntSlice(comptime T: type, buffer: []u8, value: T, endian: Endian) void { |
| 1272 | comptime assert(@typeInfo(T).Int.bits % 8 == 0); | 1273 | comptime assert(@typeInfo(T).Int.bits % 8 == 0); |
| 1273 | return switch (endian) { | 1274 | return switch (endian) { |
| 1274 | .Little => writeIntSliceLittle(T, buffer, value), | 1275 | .Little => writeIntSliceLittle(T, buffer, value), |
| ... | @@ -1678,10 +1679,10 @@ fn testReadIntImpl() void { | ... | @@ -1678,10 +1679,10 @@ fn testReadIntImpl() void { |
| 1678 | 0x56, | 1679 | 0x56, |
| 1679 | 0x78, | 1680 | 0x78, |
| 1680 | }; | 1681 | }; |
| 1681 | testing.expect(readInt(u32, &bytes, builtin.Endian.Big) == 0x12345678); | 1682 | testing.expect(readInt(u32, &bytes, Endian.Big) == 0x12345678); |
| 1682 | testing.expect(readIntBig(u32, &bytes) == 0x12345678); | 1683 | testing.expect(readIntBig(u32, &bytes) == 0x12345678); |
| 1683 | testing.expect(readIntBig(i32, &bytes) == 0x12345678); | 1684 | testing.expect(readIntBig(i32, &bytes) == 0x12345678); |
| 1684 | testing.expect(readInt(u32, &bytes, builtin.Endian.Little) == 0x78563412); | 1685 | testing.expect(readInt(u32, &bytes, Endian.Little) == 0x78563412); |
| 1685 | testing.expect(readIntLittle(u32, &bytes) == 0x78563412); | 1686 | testing.expect(readIntLittle(u32, &bytes) == 0x78563412); |
| 1686 | testing.expect(readIntLittle(i32, &bytes) == 0x78563412); | 1687 | testing.expect(readIntLittle(i32, &bytes) == 0x78563412); |
| 1687 | } | 1688 | } |
| ... | @@ -1692,7 +1693,7 @@ fn testReadIntImpl() void { | ... | @@ -1692,7 +1693,7 @@ fn testReadIntImpl() void { |
| 1692 | 0x12, | 1693 | 0x12, |
| 1693 | 0x34, | 1694 | 0x34, |
| 1694 | }; | 1695 | }; |
| 1695 | const answer = readInt(u32, &buf, builtin.Endian.Big); | 1696 | const answer = readInt(u32, &buf, Endian.Big); |
| 1696 | testing.expect(answer == 0x00001234); | 1697 | testing.expect(answer == 0x00001234); |
| 1697 | } | 1698 | } |
| 1698 | { | 1699 | { |
| ... | @@ -1702,7 +1703,7 @@ fn testReadIntImpl() void { | ... | @@ -1702,7 +1703,7 @@ fn testReadIntImpl() void { |
| 1702 | 0x00, | 1703 | 0x00, |
| 1703 | 0x00, | 1704 | 0x00, |
| 1704 | }; | 1705 | }; |
| 1705 | const answer = readInt(u32, &buf, builtin.Endian.Little); | 1706 | const answer = readInt(u32, &buf, Endian.Little); |
| 1706 | testing.expect(answer == 0x00003412); | 1707 | testing.expect(answer == 0x00003412); |
| 1707 | } | 1708 | } |
| 1708 | { | 1709 | { |
| ... | @@ -1724,19 +1725,19 @@ test "writeIntSlice" { | ... | @@ -1724,19 +1725,19 @@ test "writeIntSlice" { |
| 1724 | fn testWriteIntImpl() void { | 1725 | fn testWriteIntImpl() void { |
| 1725 | var bytes: [8]u8 = undefined; | 1726 | var bytes: [8]u8 = undefined; |
| 1726 | 1727 | ||
| 1727 | writeIntSlice(u0, bytes[0..], 0, builtin.Endian.Big); | 1728 | writeIntSlice(u0, bytes[0..], 0, Endian.Big); |
| 1728 | testing.expect(eql(u8, &bytes, &[_]u8{ | 1729 | testing.expect(eql(u8, &bytes, &[_]u8{ |
| 1729 | 0x00, 0x00, 0x00, 0x00, | 1730 | 0x00, 0x00, 0x00, 0x00, |
| 1730 | 0x00, 0x00, 0x00, 0x00, | 1731 | 0x00, 0x00, 0x00, 0x00, |
| 1731 | })); | 1732 | })); |
| 1732 | 1733 | ||
| 1733 | writeIntSlice(u0, bytes[0..], 0, builtin.Endian.Little); | 1734 | writeIntSlice(u0, bytes[0..], 0, Endian.Little); |
| 1734 | testing.expect(eql(u8, &bytes, &[_]u8{ | 1735 | testing.expect(eql(u8, &bytes, &[_]u8{ |
| 1735 | 0x00, 0x00, 0x00, 0x00, | 1736 | 0x00, 0x00, 0x00, 0x00, |
| 1736 | 0x00, 0x00, 0x00, 0x00, | 1737 | 0x00, 0x00, 0x00, 0x00, |
| 1737 | })); | 1738 | })); |
| 1738 | 1739 | ||
| 1739 | writeIntSlice(u64, bytes[0..], 0x12345678CAFEBABE, builtin.Endian.Big); | 1740 | writeIntSlice(u64, bytes[0..], 0x12345678CAFEBABE, Endian.Big); |
| 1740 | testing.expect(eql(u8, &bytes, &[_]u8{ | 1741 | testing.expect(eql(u8, &bytes, &[_]u8{ |
| 1741 | 0x12, | 1742 | 0x12, |
| 1742 | 0x34, | 1743 | 0x34, |
| ... | @@ -1748,7 +1749,7 @@ fn testWriteIntImpl() void { | ... | @@ -1748,7 +1749,7 @@ fn testWriteIntImpl() void { |
| 1748 | 0xBE, | 1749 | 0xBE, |
| 1749 | })); | 1750 | })); |
| 1750 | 1751 | ||
| 1751 | writeIntSlice(u64, bytes[0..], 0xBEBAFECA78563412, builtin.Endian.Little); | 1752 | writeIntSlice(u64, bytes[0..], 0xBEBAFECA78563412, Endian.Little); |
| 1752 | testing.expect(eql(u8, &bytes, &[_]u8{ | 1753 | testing.expect(eql(u8, &bytes, &[_]u8{ |
| 1753 | 0x12, | 1754 | 0x12, |
| 1754 | 0x34, | 1755 | 0x34, |
| ... | @@ -1760,7 +1761,7 @@ fn testWriteIntImpl() void { | ... | @@ -1760,7 +1761,7 @@ fn testWriteIntImpl() void { |
| 1760 | 0xBE, | 1761 | 0xBE, |
| 1761 | })); | 1762 | })); |
| 1762 | 1763 | ||
| 1763 | writeIntSlice(u32, bytes[0..], 0x12345678, builtin.Endian.Big); | 1764 | writeIntSlice(u32, bytes[0..], 0x12345678, Endian.Big); |
| 1764 | testing.expect(eql(u8, &bytes, &[_]u8{ | 1765 | testing.expect(eql(u8, &bytes, &[_]u8{ |
| 1765 | 0x00, | 1766 | 0x00, |
| 1766 | 0x00, | 1767 | 0x00, |
| ... | @@ -1772,7 +1773,7 @@ fn testWriteIntImpl() void { | ... | @@ -1772,7 +1773,7 @@ fn testWriteIntImpl() void { |
| 1772 | 0x78, | 1773 | 0x78, |
| 1773 | })); | 1774 | })); |
| 1774 | 1775 | ||
| 1775 | writeIntSlice(u32, bytes[0..], 0x78563412, builtin.Endian.Little); | 1776 | writeIntSlice(u32, bytes[0..], 0x78563412, Endian.Little); |
| 1776 | testing.expect(eql(u8, &bytes, &[_]u8{ | 1777 | testing.expect(eql(u8, &bytes, &[_]u8{ |
| 1777 | 0x12, | 1778 | 0x12, |
| 1778 | 0x34, | 1779 | 0x34, |
| ... | @@ -1784,7 +1785,7 @@ fn testWriteIntImpl() void { | ... | @@ -1784,7 +1785,7 @@ fn testWriteIntImpl() void { |
| 1784 | 0x00, | 1785 | 0x00, |
| 1785 | })); | 1786 | })); |
| 1786 | 1787 | ||
| 1787 | writeIntSlice(u16, bytes[0..], 0x1234, builtin.Endian.Big); | 1788 | writeIntSlice(u16, bytes[0..], 0x1234, Endian.Big); |
| 1788 | testing.expect(eql(u8, &bytes, &[_]u8{ | 1789 | testing.expect(eql(u8, &bytes, &[_]u8{ |
| 1789 | 0x00, | 1790 | 0x00, |
| 1790 | 0x00, | 1791 | 0x00, |
| ... | @@ -1796,7 +1797,7 @@ fn testWriteIntImpl() void { | ... | @@ -1796,7 +1797,7 @@ fn testWriteIntImpl() void { |
| 1796 | 0x34, | 1797 | 0x34, |
| 1797 | })); | 1798 | })); |
| 1798 | 1799 | ||
| 1799 | writeIntSlice(u16, bytes[0..], 0x1234, builtin.Endian.Little); | 1800 | writeIntSlice(u16, bytes[0..], 0x1234, Endian.Little); |
| 1800 | testing.expect(eql(u8, &bytes, &[_]u8{ | 1801 | testing.expect(eql(u8, &bytes, &[_]u8{ |
| 1801 | 0x34, | 1802 | 0x34, |
| 1802 | 0x12, | 1803 | 0x12, |
| ... | @@ -1949,7 +1950,7 @@ test "replaceOwned" { | ... | @@ -1949,7 +1950,7 @@ test "replaceOwned" { |
| 1949 | 1950 | ||
| 1950 | /// Converts a little-endian integer to host endianness. | 1951 | /// Converts a little-endian integer to host endianness. |
| 1951 | pub fn littleToNative(comptime T: type, x: T) T { | 1952 | pub fn littleToNative(comptime T: type, x: T) T { |
| 1952 | return switch (builtin.endian) { | 1953 | return switch (native_endian) { |
| 1953 | .Little => x, | 1954 | .Little => x, |
| 1954 | .Big => @byteSwap(T, x), | 1955 | .Big => @byteSwap(T, x), |
| 1955 | }; | 1956 | }; |
| ... | @@ -1957,14 +1958,14 @@ pub fn littleToNative(comptime T: type, x: T) T { | ... | @@ -1957,14 +1958,14 @@ pub fn littleToNative(comptime T: type, x: T) T { |
| 1957 | 1958 | ||
| 1958 | /// Converts a big-endian integer to host endianness. | 1959 | /// Converts a big-endian integer to host endianness. |
| 1959 | pub fn bigToNative(comptime T: type, x: T) T { | 1960 | pub fn bigToNative(comptime T: type, x: T) T { |
| 1960 | return switch (builtin.endian) { | 1961 | return switch (native_endian) { |
| 1961 | .Little => @byteSwap(T, x), | 1962 | .Little => @byteSwap(T, x), |
| 1962 | .Big => x, | 1963 | .Big => x, |
| 1963 | }; | 1964 | }; |
| 1964 | } | 1965 | } |
| 1965 | 1966 | ||
| 1966 | /// Converts an integer from specified endianness to host endianness. | 1967 | /// Converts an integer from specified endianness to host endianness. |
| 1967 | pub fn toNative(comptime T: type, x: T, endianness_of_x: builtin.Endian) T { | 1968 | pub fn toNative(comptime T: type, x: T, endianness_of_x: Endian) T { |
| 1968 | return switch (endianness_of_x) { | 1969 | return switch (endianness_of_x) { |
| 1969 | .Little => littleToNative(T, x), | 1970 | .Little => littleToNative(T, x), |
| 1970 | .Big => bigToNative(T, x), | 1971 | .Big => bigToNative(T, x), |
| ... | @@ -1972,7 +1973,7 @@ pub fn toNative(comptime T: type, x: T, endianness_of_x: builtin.Endian) T { | ... | @@ -1972,7 +1973,7 @@ pub fn toNative(comptime T: type, x: T, endianness_of_x: builtin.Endian) T { |
| 1972 | } | 1973 | } |
| 1973 | 1974 | ||
| 1974 | /// Converts an integer which has host endianness to the desired endianness. | 1975 | /// Converts an integer which has host endianness to the desired endianness. |
| 1975 | pub fn nativeTo(comptime T: type, x: T, desired_endianness: builtin.Endian) T { | 1976 | pub fn nativeTo(comptime T: type, x: T, desired_endianness: Endian) T { |
| 1976 | return switch (desired_endianness) { | 1977 | return switch (desired_endianness) { |
| 1977 | .Little => nativeToLittle(T, x), | 1978 | .Little => nativeToLittle(T, x), |
| 1978 | .Big => nativeToBig(T, x), | 1979 | .Big => nativeToBig(T, x), |
| ... | @@ -1981,7 +1982,7 @@ pub fn nativeTo(comptime T: type, x: T, desired_endianness: builtin.Endian) T { | ... | @@ -1981,7 +1982,7 @@ pub fn nativeTo(comptime T: type, x: T, desired_endianness: builtin.Endian) T { |
| 1981 | 1982 | ||
| 1982 | /// Converts an integer which has host endianness to little endian. | 1983 | /// Converts an integer which has host endianness to little endian. |
| 1983 | pub fn nativeToLittle(comptime T: type, x: T) T { | 1984 | pub fn nativeToLittle(comptime T: type, x: T) T { |
| 1984 | return switch (builtin.endian) { | 1985 | return switch (native_endian) { |
| 1985 | .Little => x, | 1986 | .Little => x, |
| 1986 | .Big => @byteSwap(T, x), | 1987 | .Big => @byteSwap(T, x), |
| 1987 | }; | 1988 | }; |
| ... | @@ -1989,13 +1990,13 @@ pub fn nativeToLittle(comptime T: type, x: T) T { | ... | @@ -1989,13 +1990,13 @@ pub fn nativeToLittle(comptime T: type, x: T) T { |
| 1989 | 1990 | ||
| 1990 | /// Converts an integer which has host endianness to big endian. | 1991 | /// Converts an integer which has host endianness to big endian. |
| 1991 | pub fn nativeToBig(comptime T: type, x: T) T { | 1992 | pub fn nativeToBig(comptime T: type, x: T) T { |
| 1992 | return switch (builtin.endian) { | 1993 | return switch (native_endian) { |
| 1993 | .Little => @byteSwap(T, x), | 1994 | .Little => @byteSwap(T, x), |
| 1994 | .Big => x, | 1995 | .Big => x, |
| 1995 | }; | 1996 | }; |
| 1996 | } | 1997 | } |
| 1997 | 1998 | ||
| 1998 | fn CopyPtrAttrs(comptime source: type, comptime size: builtin.TypeInfo.Pointer.Size, comptime child: type) type { | 1999 | fn CopyPtrAttrs(comptime source: type, comptime size: std.builtin.TypeInfo.Pointer.Size, comptime child: type) type { |
| 1999 | const info = @typeInfo(source).Pointer; | 2000 | const info = @typeInfo(source).Pointer; |
| 2000 | return @Type(.{ | 2001 | return @Type(.{ |
| 2001 | .Pointer = .{ | 2002 | .Pointer = .{ |
| ... | @@ -2027,7 +2028,7 @@ pub fn asBytes(ptr: anytype) AsBytesReturnType(@TypeOf(ptr)) { | ... | @@ -2027,7 +2028,7 @@ pub fn asBytes(ptr: anytype) AsBytesReturnType(@TypeOf(ptr)) { |
| 2027 | 2028 | ||
| 2028 | test "asBytes" { | 2029 | test "asBytes" { |
| 2029 | const deadbeef = @as(u32, 0xDEADBEEF); | 2030 | const deadbeef = @as(u32, 0xDEADBEEF); |
| 2030 | const deadbeef_bytes = switch (builtin.endian) { | 2031 | const deadbeef_bytes = switch (native_endian) { |
| 2031 | .Big => "\xDE\xAD\xBE\xEF", | 2032 | .Big => "\xDE\xAD\xBE\xEF", |
| 2032 | .Little => "\xEF\xBE\xAD\xDE", | 2033 | .Little => "\xEF\xBE\xAD\xDE", |
| 2033 | }; | 2034 | }; |
| ... | @@ -2080,13 +2081,13 @@ pub fn toBytes(value: anytype) [@sizeOf(@TypeOf(value))]u8 { | ... | @@ -2080,13 +2081,13 @@ pub fn toBytes(value: anytype) [@sizeOf(@TypeOf(value))]u8 { |
| 2080 | 2081 | ||
| 2081 | test "toBytes" { | 2082 | test "toBytes" { |
| 2082 | var my_bytes = toBytes(@as(u32, 0x12345678)); | 2083 | var my_bytes = toBytes(@as(u32, 0x12345678)); |
| 2083 | switch (builtin.endian) { | 2084 | switch (native_endian) { |
| 2084 | .Big => testing.expect(eql(u8, &my_bytes, "\x12\x34\x56\x78")), | 2085 | .Big => testing.expect(eql(u8, &my_bytes, "\x12\x34\x56\x78")), |
| 2085 | .Little => testing.expect(eql(u8, &my_bytes, "\x78\x56\x34\x12")), | 2086 | .Little => testing.expect(eql(u8, &my_bytes, "\x78\x56\x34\x12")), |
| 2086 | } | 2087 | } |
| 2087 | 2088 | ||
| 2088 | my_bytes[0] = '\x99'; | 2089 | my_bytes[0] = '\x99'; |
| 2089 | switch (builtin.endian) { | 2090 | switch (native_endian) { |
| 2090 | .Big => testing.expect(eql(u8, &my_bytes, "\x99\x34\x56\x78")), | 2091 | .Big => testing.expect(eql(u8, &my_bytes, "\x99\x34\x56\x78")), |
| 2091 | .Little => testing.expect(eql(u8, &my_bytes, "\x99\x56\x34\x12")), | 2092 | .Little => testing.expect(eql(u8, &my_bytes, "\x99\x56\x34\x12")), |
| 2092 | } | 2093 | } |
| ... | @@ -2113,14 +2114,14 @@ pub fn bytesAsValue(comptime T: type, bytes: anytype) BytesAsValueReturnType(T, | ... | @@ -2113,14 +2114,14 @@ pub fn bytesAsValue(comptime T: type, bytes: anytype) BytesAsValueReturnType(T, |
| 2113 | 2114 | ||
| 2114 | test "bytesAsValue" { | 2115 | test "bytesAsValue" { |
| 2115 | const deadbeef = @as(u32, 0xDEADBEEF); | 2116 | const deadbeef = @as(u32, 0xDEADBEEF); |
| 2116 | const deadbeef_bytes = switch (builtin.endian) { | 2117 | const deadbeef_bytes = switch (native_endian) { |
| 2117 | .Big => "\xDE\xAD\xBE\xEF", | 2118 | .Big => "\xDE\xAD\xBE\xEF", |
| 2118 | .Little => "\xEF\xBE\xAD\xDE", | 2119 | .Little => "\xEF\xBE\xAD\xDE", |
| 2119 | }; | 2120 | }; |
| 2120 | 2121 | ||
| 2121 | testing.expect(deadbeef == bytesAsValue(u32, deadbeef_bytes).*); | 2122 | testing.expect(deadbeef == bytesAsValue(u32, deadbeef_bytes).*); |
| 2122 | 2123 | ||
| 2123 | var codeface_bytes: [4]u8 = switch (builtin.endian) { | 2124 | var codeface_bytes: [4]u8 = switch (native_endian) { |
| 2124 | .Big => "\xC0\xDE\xFA\xCE", | 2125 | .Big => "\xC0\xDE\xFA\xCE", |
| 2125 | .Little => "\xCE\xFA\xDE\xC0", | 2126 | .Little => "\xCE\xFA\xDE\xC0", |
| 2126 | }.*; | 2127 | }.*; |
| ... | @@ -2168,7 +2169,7 @@ pub fn bytesToValue(comptime T: type, bytes: anytype) T { | ... | @@ -2168,7 +2169,7 @@ pub fn bytesToValue(comptime T: type, bytes: anytype) T { |
| 2168 | return bytesAsValue(T, bytes).*; | 2169 | return bytesAsValue(T, bytes).*; |
| 2169 | } | 2170 | } |
| 2170 | test "bytesToValue" { | 2171 | test "bytesToValue" { |
| 2171 | const deadbeef_bytes = switch (builtin.endian) { | 2172 | const deadbeef_bytes = switch (native_endian) { |
| 2172 | .Big => "\xDE\xAD\xBE\xEF", | 2173 | .Big => "\xDE\xAD\xBE\xEF", |
| 2173 | .Little => "\xEF\xBE\xAD\xDE", | 2174 | .Little => "\xEF\xBE\xAD\xDE", |
| 2174 | }; | 2175 | }; |
| ... | @@ -2297,7 +2298,7 @@ test "sliceAsBytes" { | ... | @@ -2297,7 +2298,7 @@ test "sliceAsBytes" { |
| 2297 | const bytes = [_]u16{ 0xDEAD, 0xBEEF }; | 2298 | const bytes = [_]u16{ 0xDEAD, 0xBEEF }; |
| 2298 | const slice = sliceAsBytes(bytes[0..]); | 2299 | const slice = sliceAsBytes(bytes[0..]); |
| 2299 | testing.expect(slice.len == 4); | 2300 | testing.expect(slice.len == 4); |
| 2300 | testing.expect(eql(u8, slice, switch (builtin.endian) { | 2301 | testing.expect(eql(u8, slice, switch (native_endian) { |
| 2301 | .Big => "\xDE\xAD\xBE\xEF", | 2302 | .Big => "\xDE\xAD\xBE\xEF", |
| 2302 | .Little => "\xAD\xDE\xEF\xBE", | 2303 | .Little => "\xAD\xDE\xEF\xBE", |
| 2303 | })); | 2304 | })); |
| ... | @@ -2319,7 +2320,7 @@ test "sliceAsBytes packed struct at runtime and comptime" { | ... | @@ -2319,7 +2320,7 @@ test "sliceAsBytes packed struct at runtime and comptime" { |
| 2319 | var foo: Foo = undefined; | 2320 | var foo: Foo = undefined; |
| 2320 | var slice = sliceAsBytes(@as(*[1]Foo, &foo)[0..1]); | 2321 | var slice = sliceAsBytes(@as(*[1]Foo, &foo)[0..1]); |
| 2321 | slice[0] = 0x13; | 2322 | slice[0] = 0x13; |
| 2322 | switch (builtin.endian) { | 2323 | switch (native_endian) { |
| 2323 | .Big => { | 2324 | .Big => { |
| 2324 | testing.expect(foo.a == 0x1); | 2325 | testing.expect(foo.a == 0x1); |
| 2325 | testing.expect(foo.b == 0x3); | 2326 | testing.expect(foo.b == 0x3); |
lib/std/meta.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std.zig"); | 6 | const std = @import("std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const debug = std.debug; | 8 | const debug = std.debug; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
| 10 | const math = std.math; | 10 | const math = std.math; |
lib/std/net.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std.zig"); | 6 | const std = @import("std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const assert = std.debug.assert; | 8 | const assert = std.debug.assert; |
| 9 | const net = @This(); | 9 | const net = @This(); |
| 10 | const mem = std.mem; | 10 | const mem = std.mem; |
lib/std/os.zig+1-1| ... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | ||
| 22 | const root = @import("root"); | 22 | const root = @import("root"); |
| 23 | const std = @import("std.zig"); | 23 | const std = @import("std.zig"); |
| 24 | const builtin = @import("builtin"); | 24 | const builtin = std.builtin; |
| 25 | const assert = std.debug.assert; | 25 | const assert = std.debug.assert; |
| 26 | const math = std.math; | 26 | const math = std.math; |
| 27 | const mem = std.mem; | 27 | const mem = std.mem; |
lib/std/os/bits/linux.zig+12-12| ... | @@ -3,17 +3,17 @@ | ... | @@ -3,17 +3,17 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | ||
| 7 | const std = @import("../../std.zig"); | 6 | const std = @import("../../std.zig"); |
| 8 | const maxInt = std.math.maxInt; | 7 | const maxInt = std.math.maxInt; |
| 8 | const arch = std.Target.current.cpu.arch; | ||
| 9 | usingnamespace @import("../bits.zig"); | 9 | usingnamespace @import("../bits.zig"); |
| 10 | 10 | ||
| 11 | pub usingnamespace switch (builtin.arch) { | 11 | pub usingnamespace switch (arch) { |
| 12 | .mips, .mipsel => @import("linux/errno-mips.zig"), | 12 | .mips, .mipsel => @import("linux/errno-mips.zig"), |
| 13 | else => @import("linux/errno-generic.zig"), | 13 | else => @import("linux/errno-generic.zig"), |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| 16 | pub usingnamespace switch (builtin.arch) { | 16 | pub usingnamespace switch (arch) { |
| 17 | .i386 => @import("linux/i386.zig"), | 17 | .i386 => @import("linux/i386.zig"), |
| 18 | .x86_64 => @import("linux/x86_64.zig"), | 18 | .x86_64 => @import("linux/x86_64.zig"), |
| 19 | .aarch64 => @import("linux/arm64.zig"), | 19 | .aarch64 => @import("linux/arm64.zig"), |
| ... | @@ -30,9 +30,9 @@ pub usingnamespace @import("linux/netlink.zig"); | ... | @@ -30,9 +30,9 @@ pub usingnamespace @import("linux/netlink.zig"); |
| 30 | pub usingnamespace @import("linux/prctl.zig"); | 30 | pub usingnamespace @import("linux/prctl.zig"); |
| 31 | pub usingnamespace @import("linux/securebits.zig"); | 31 | pub usingnamespace @import("linux/securebits.zig"); |
| 32 | 32 | ||
| 33 | const is_mips = builtin.arch.isMIPS(); | 33 | const is_mips = arch.isMIPS(); |
| 34 | const is_ppc64 = builtin.arch.isPPC64(); | 34 | const is_ppc64 = arch.isPPC64(); |
| 35 | const is_sparc = builtin.arch.isSPARC(); | 35 | const is_sparc = arch.isSPARC(); |
| 36 | 36 | ||
| 37 | pub const pid_t = i32; | 37 | pub const pid_t = i32; |
| 38 | pub const fd_t = i32; | 38 | pub const fd_t = i32; |
| ... | @@ -134,7 +134,7 @@ pub const PROT_WRITE = 0x2; | ... | @@ -134,7 +134,7 @@ pub const PROT_WRITE = 0x2; |
| 134 | pub const PROT_EXEC = 0x4; | 134 | pub const PROT_EXEC = 0x4; |
| 135 | 135 | ||
| 136 | /// page may be used for atomic ops | 136 | /// page may be used for atomic ops |
| 137 | pub const PROT_SEM = switch (builtin.arch) { | 137 | pub const PROT_SEM = switch (arch) { |
| 138 | // TODO: also xtensa | 138 | // TODO: also xtensa |
| 139 | .mips, .mipsel, .mips64, .mips64el => 0x10, | 139 | .mips, .mipsel, .mips64, .mips64el => 0x10, |
| 140 | else => 0x8, | 140 | else => 0x8, |
| ... | @@ -1004,7 +1004,7 @@ pub const sigset_t = [1024 / 32]u32; | ... | @@ -1004,7 +1004,7 @@ pub const sigset_t = [1024 / 32]u32; |
| 1004 | pub const all_mask: sigset_t = [_]u32{0xffffffff} ** sigset_t.len; | 1004 | pub const all_mask: sigset_t = [_]u32{0xffffffff} ** sigset_t.len; |
| 1005 | pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30; | 1005 | pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30; |
| 1006 | 1006 | ||
| 1007 | pub const k_sigaction = switch (builtin.arch) { | 1007 | pub const k_sigaction = switch (arch) { |
| 1008 | .mips, .mipsel => extern struct { | 1008 | .mips, .mipsel => extern struct { |
| 1009 | flags: c_uint, | 1009 | flags: c_uint, |
| 1010 | handler: ?fn (c_int) callconv(.C) void, | 1010 | handler: ?fn (c_int) callconv(.C) void, |
| ... | @@ -1121,7 +1121,7 @@ pub const epoll_data = extern union { | ... | @@ -1121,7 +1121,7 @@ pub const epoll_data = extern union { |
| 1121 | 1121 | ||
| 1122 | // On x86_64 the structure is packed so that it matches the definition of its | 1122 | // On x86_64 the structure is packed so that it matches the definition of its |
| 1123 | // 32bit counterpart | 1123 | // 32bit counterpart |
| 1124 | pub const epoll_event = switch (builtin.arch) { | 1124 | pub const epoll_event = switch (arch) { |
| 1125 | .x86_64 => packed struct { | 1125 | .x86_64 => packed struct { |
| 1126 | events: u32, | 1126 | events: u32, |
| 1127 | data: epoll_data, | 1127 | data: epoll_data, |
| ... | @@ -1288,12 +1288,12 @@ pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { | ... | @@ -1288,12 +1288,12 @@ pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { |
| 1288 | //#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set) | 1288 | //#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set) |
| 1289 | //#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2) | 1289 | //#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2) |
| 1290 | 1290 | ||
| 1291 | pub const MINSIGSTKSZ = switch (builtin.arch) { | 1291 | pub const MINSIGSTKSZ = switch (arch) { |
| 1292 | .i386, .x86_64, .arm, .mipsel => 2048, | 1292 | .i386, .x86_64, .arm, .mipsel => 2048, |
| 1293 | .aarch64 => 5120, | 1293 | .aarch64 => 5120, |
| 1294 | else => @compileError("MINSIGSTKSZ not defined for this architecture"), | 1294 | else => @compileError("MINSIGSTKSZ not defined for this architecture"), |
| 1295 | }; | 1295 | }; |
| 1296 | pub const SIGSTKSZ = switch (builtin.arch) { | 1296 | pub const SIGSTKSZ = switch (arch) { |
| 1297 | .i386, .x86_64, .arm, .mipsel => 8192, | 1297 | .i386, .x86_64, .arm, .mipsel => 8192, |
| 1298 | .aarch64 => 16384, | 1298 | .aarch64 => 16384, |
| 1299 | else => @compileError("SIGSTKSZ not defined for this architecture"), | 1299 | else => @compileError("SIGSTKSZ not defined for this architecture"), |
| ... | @@ -2053,7 +2053,7 @@ pub const B3000000 = 0o0010015; | ... | @@ -2053,7 +2053,7 @@ pub const B3000000 = 0o0010015; |
| 2053 | pub const B3500000 = 0o0010016; | 2053 | pub const B3500000 = 0o0010016; |
| 2054 | pub const B4000000 = 0o0010017; | 2054 | pub const B4000000 = 0o0010017; |
| 2055 | 2055 | ||
| 2056 | pub usingnamespace switch (builtin.arch) { | 2056 | pub usingnamespace switch (arch) { |
| 2057 | .powerpc, .powerpc64, .powerpc64le => struct { | 2057 | .powerpc, .powerpc64, .powerpc64le => struct { |
| 2058 | pub const VINTR = 0; | 2058 | pub const VINTR = 0; |
| 2059 | pub const VQUIT = 1; | 2059 | pub const VQUIT = 1; |
lib/std/os/darwin.zig-1| ... | @@ -3,7 +3,6 @@ | ... | @@ -3,7 +3,6 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | ||
| 7 | const std = @import("../std.zig"); | 6 | const std = @import("../std.zig"); |
| 8 | pub usingnamespace std.c; | 7 | pub usingnamespace std.c; |
| 9 | pub usingnamespace @import("bits.zig"); | 8 | pub usingnamespace @import("bits.zig"); |
lib/std/os/linux.zig+24-23| ... | @@ -11,14 +11,15 @@ | ... | @@ -11,14 +11,15 @@ |
| 11 | // provide `rename` when only the `renameat` syscall exists. | 11 | // provide `rename` when only the `renameat` syscall exists. |
| 12 | // * Does not support POSIX thread cancellation. | 12 | // * Does not support POSIX thread cancellation. |
| 13 | const std = @import("../std.zig"); | 13 | const std = @import("../std.zig"); |
| 14 | const builtin = std.builtin; | ||
| 15 | const assert = std.debug.assert; | 14 | const assert = std.debug.assert; |
| 16 | const maxInt = std.math.maxInt; | 15 | const maxInt = std.math.maxInt; |
| 17 | const elf = std.elf; | 16 | const elf = std.elf; |
| 18 | const vdso = @import("linux/vdso.zig"); | 17 | const vdso = @import("linux/vdso.zig"); |
| 19 | const dl = @import("../dynamic_library.zig"); | 18 | const dl = @import("../dynamic_library.zig"); |
| 19 | const native_arch = std.Target.current.cpu.arch; | ||
| 20 | const native_endian = native_arch.endian(); | ||
| 20 | 21 | ||
| 21 | pub usingnamespace switch (builtin.arch) { | 22 | pub usingnamespace switch (native_arch) { |
| 22 | .i386 => @import("linux/i386.zig"), | 23 | .i386 => @import("linux/i386.zig"), |
| 23 | .x86_64 => @import("linux/x86_64.zig"), | 24 | .x86_64 => @import("linux/x86_64.zig"), |
| 24 | .aarch64 => @import("linux/arm64.zig"), | 25 | .aarch64 => @import("linux/arm64.zig"), |
| ... | @@ -58,7 +59,7 @@ const require_aligned_register_pair = | ... | @@ -58,7 +59,7 @@ const require_aligned_register_pair = |
| 58 | 59 | ||
| 59 | // Split a 64bit value into a {LSB,MSB} pair. | 60 | // Split a 64bit value into a {LSB,MSB} pair. |
| 60 | fn splitValue64(val: u64) [2]u32 { | 61 | fn splitValue64(val: u64) [2]u32 { |
| 61 | switch (builtin.endian) { | 62 | switch (native_endian) { |
| 62 | .Little => return [2]u32{ | 63 | .Little => return [2]u32{ |
| 63 | @truncate(u32, val), | 64 | @truncate(u32, val), |
| 64 | @truncate(u32, val >> 32), | 65 | @truncate(u32, val >> 32), |
| ... | @@ -113,7 +114,7 @@ pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*: | ... | @@ -113,7 +114,7 @@ pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*: |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | pub fn fork() usize { | 116 | pub fn fork() usize { |
| 116 | if (comptime builtin.arch.isSPARC()) { | 117 | if (comptime native_arch.isSPARC()) { |
| 117 | return syscall_fork(); | 118 | return syscall_fork(); |
| 118 | } else if (@hasField(SYS, "fork")) { | 119 | } else if (@hasField(SYS, "fork")) { |
| 119 | return syscall0(.fork); | 120 | return syscall0(.fork); |
| ... | @@ -431,7 +432,7 @@ pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { | ... | @@ -431,7 +432,7 @@ pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { |
| 431 | } | 432 | } |
| 432 | 433 | ||
| 433 | pub fn pipe(fd: *[2]i32) usize { | 434 | pub fn pipe(fd: *[2]i32) usize { |
| 434 | if (comptime (builtin.arch.isMIPS() or builtin.arch.isSPARC())) { | 435 | if (comptime (native_arch.isMIPS() or native_arch.isSPARC())) { |
| 435 | return syscall_pipe(fd); | 436 | return syscall_pipe(fd); |
| 436 | } else if (@hasField(SYS, "pipe")) { | 437 | } else if (@hasField(SYS, "pipe")) { |
| 437 | return syscall1(.pipe, @ptrToInt(fd)); | 438 | return syscall1(.pipe, @ptrToInt(fd)); |
| ... | @@ -912,7 +913,7 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact | ... | @@ -912,7 +913,7 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact |
| 912 | const ksa_arg = if (act != null) @ptrToInt(&ksa) else 0; | 913 | const ksa_arg = if (act != null) @ptrToInt(&ksa) else 0; |
| 913 | const oldksa_arg = if (oact != null) @ptrToInt(&oldksa) else 0; | 914 | const oldksa_arg = if (oact != null) @ptrToInt(&oldksa) else 0; |
| 914 | 915 | ||
| 915 | const result = switch (builtin.arch) { | 916 | const result = switch (native_arch) { |
| 916 | // The sparc version of rt_sigaction needs the restorer function to be passed as an argument too. | 917 | // The sparc version of rt_sigaction needs the restorer function to be passed as an argument too. |
| 917 | .sparc, .sparcv9 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @ptrToInt(ksa.restorer), mask_size), | 918 | .sparc, .sparcv9 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @ptrToInt(ksa.restorer), mask_size), |
| 918 | else => syscall4(.rt_sigaction, sig, ksa_arg, oldksa_arg, mask_size), | 919 | else => syscall4(.rt_sigaction, sig, ksa_arg, oldksa_arg, mask_size), |
| ... | @@ -944,42 +945,42 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool { | ... | @@ -944,42 +945,42 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool { |
| 944 | } | 945 | } |
| 945 | 946 | ||
| 946 | pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { | 947 | pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { |
| 947 | if (builtin.arch == .i386) { | 948 | if (native_arch == .i386) { |
| 948 | return socketcall(SC_getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) }); | 949 | return socketcall(SC_getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) }); |
| 949 | } | 950 | } |
| 950 | return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len)); | 951 | return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len)); |
| 951 | } | 952 | } |
| 952 | 953 | ||
| 953 | pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { | 954 | pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { |
| 954 | if (builtin.arch == .i386) { | 955 | if (native_arch == .i386) { |
| 955 | return socketcall(SC_getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) }); | 956 | return socketcall(SC_getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) }); |
| 956 | } | 957 | } |
| 957 | return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len)); | 958 | return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len)); |
| 958 | } | 959 | } |
| 959 | 960 | ||
| 960 | pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize { | 961 | pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize { |
| 961 | if (builtin.arch == .i386) { | 962 | if (native_arch == .i386) { |
| 962 | return socketcall(SC_socket, &[3]usize{ domain, socket_type, protocol }); | 963 | return socketcall(SC_socket, &[3]usize{ domain, socket_type, protocol }); |
| 963 | } | 964 | } |
| 964 | return syscall3(.socket, domain, socket_type, protocol); | 965 | return syscall3(.socket, domain, socket_type, protocol); |
| 965 | } | 966 | } |
| 966 | 967 | ||
| 967 | pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize { | 968 | pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize { |
| 968 | if (builtin.arch == .i386) { | 969 | if (native_arch == .i386) { |
| 969 | return socketcall(SC_setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) }); | 970 | return socketcall(SC_setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) }); |
| 970 | } | 971 | } |
| 971 | return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen)); | 972 | return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen)); |
| 972 | } | 973 | } |
| 973 | 974 | ||
| 974 | pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize { | 975 | pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize { |
| 975 | if (builtin.arch == .i386) { | 976 | if (native_arch == .i386) { |
| 976 | return socketcall(SC_getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) }); | 977 | return socketcall(SC_getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) }); |
| 977 | } | 978 | } |
| 978 | return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen)); | 979 | return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen)); |
| 979 | } | 980 | } |
| 980 | 981 | ||
| 981 | pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize { | 982 | pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize { |
| 982 | if (builtin.arch == .i386) { | 983 | if (native_arch == .i386) { |
| 983 | return socketcall(SC_sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags }); | 984 | return socketcall(SC_sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags }); |
| 984 | } | 985 | } |
| 985 | return syscall3(.sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags); | 986 | return syscall3(.sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags); |
| ... | @@ -1026,49 +1027,49 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize | ... | @@ -1026,49 +1027,49 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize |
| 1026 | } | 1027 | } |
| 1027 | 1028 | ||
| 1028 | pub fn connect(fd: i32, addr: *const c_void, len: socklen_t) usize { | 1029 | pub fn connect(fd: i32, addr: *const c_void, len: socklen_t) usize { |
| 1029 | if (builtin.arch == .i386) { | 1030 | if (native_arch == .i386) { |
| 1030 | return socketcall(SC_connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len }); | 1031 | return socketcall(SC_connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len }); |
| 1031 | } | 1032 | } |
| 1032 | return syscall3(.connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len); | 1033 | return syscall3(.connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len); |
| 1033 | } | 1034 | } |
| 1034 | 1035 | ||
| 1035 | pub fn recvmsg(fd: i32, msg: *msghdr, flags: u32) usize { | 1036 | pub fn recvmsg(fd: i32, msg: *msghdr, flags: u32) usize { |
| 1036 | if (builtin.arch == .i386) { | 1037 | if (native_arch == .i386) { |
| 1037 | return socketcall(SC_recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags }); | 1038 | return socketcall(SC_recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags }); |
| 1038 | } | 1039 | } |
| 1039 | return syscall3(.recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags); | 1040 | return syscall3(.recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags); |
| 1040 | } | 1041 | } |
| 1041 | 1042 | ||
| 1042 | pub fn recvfrom(fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize { | 1043 | pub fn recvfrom(fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize { |
| 1043 | if (builtin.arch == .i386) { | 1044 | if (native_arch == .i386) { |
| 1044 | return socketcall(SC_recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) }); | 1045 | return socketcall(SC_recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) }); |
| 1045 | } | 1046 | } |
| 1046 | return syscall6(.recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen)); | 1047 | return syscall6(.recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen)); |
| 1047 | } | 1048 | } |
| 1048 | 1049 | ||
| 1049 | pub fn shutdown(fd: i32, how: i32) usize { | 1050 | pub fn shutdown(fd: i32, how: i32) usize { |
| 1050 | if (builtin.arch == .i386) { | 1051 | if (native_arch == .i386) { |
| 1051 | return socketcall(SC_shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) }); | 1052 | return socketcall(SC_shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) }); |
| 1052 | } | 1053 | } |
| 1053 | return syscall2(.shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how))); | 1054 | return syscall2(.shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how))); |
| 1054 | } | 1055 | } |
| 1055 | 1056 | ||
| 1056 | pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize { | 1057 | pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize { |
| 1057 | if (builtin.arch == .i386) { | 1058 | if (native_arch == .i386) { |
| 1058 | return socketcall(SC_bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) }); | 1059 | return socketcall(SC_bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) }); |
| 1059 | } | 1060 | } |
| 1060 | return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len)); | 1061 | return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len)); |
| 1061 | } | 1062 | } |
| 1062 | 1063 | ||
| 1063 | pub fn listen(fd: i32, backlog: u32) usize { | 1064 | pub fn listen(fd: i32, backlog: u32) usize { |
| 1064 | if (builtin.arch == .i386) { | 1065 | if (native_arch == .i386) { |
| 1065 | return socketcall(SC_listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog }); | 1066 | return socketcall(SC_listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog }); |
| 1066 | } | 1067 | } |
| 1067 | return syscall2(.listen, @bitCast(usize, @as(isize, fd)), backlog); | 1068 | return syscall2(.listen, @bitCast(usize, @as(isize, fd)), backlog); |
| 1068 | } | 1069 | } |
| 1069 | 1070 | ||
| 1070 | pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize { | 1071 | pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize { |
| 1071 | if (builtin.arch == .i386) { | 1072 | if (native_arch == .i386) { |
| 1072 | return socketcall(SC_sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) }); | 1073 | return socketcall(SC_sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) }); |
| 1073 | } | 1074 | } |
| 1074 | return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen)); | 1075 | return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen)); |
| ... | @@ -1095,21 +1096,21 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize { | ... | @@ -1095,21 +1096,21 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize { |
| 1095 | } | 1096 | } |
| 1096 | 1097 | ||
| 1097 | pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usize { | 1098 | pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usize { |
| 1098 | if (builtin.arch == .i386) { | 1099 | if (native_arch == .i386) { |
| 1099 | return socketcall(SC_socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) }); | 1100 | return socketcall(SC_socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) }); |
| 1100 | } | 1101 | } |
| 1101 | return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0])); | 1102 | return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0])); |
| 1102 | } | 1103 | } |
| 1103 | 1104 | ||
| 1104 | pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize { | 1105 | pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize { |
| 1105 | if (builtin.arch == .i386) { | 1106 | if (native_arch == .i386) { |
| 1106 | return socketcall(SC_accept, &[4]usize{ fd, addr, len, 0 }); | 1107 | return socketcall(SC_accept, &[4]usize{ fd, addr, len, 0 }); |
| 1107 | } | 1108 | } |
| 1108 | return accept4(fd, addr, len, 0); | 1109 | return accept4(fd, addr, len, 0); |
| 1109 | } | 1110 | } |
| 1110 | 1111 | ||
| 1111 | pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize { | 1112 | pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize { |
| 1112 | if (builtin.arch == .i386) { | 1113 | if (native_arch == .i386) { |
| 1113 | return socketcall(SC_accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags }); | 1114 | return socketcall(SC_accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags }); |
| 1114 | } | 1115 | } |
| 1115 | return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags); | 1116 | return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags); |
| ... | @@ -1388,7 +1389,7 @@ pub fn madvise(address: [*]u8, len: usize, advice: u32) usize { | ... | @@ -1388,7 +1389,7 @@ pub fn madvise(address: [*]u8, len: usize, advice: u32) usize { |
| 1388 | } | 1389 | } |
| 1389 | 1390 | ||
| 1390 | test { | 1391 | test { |
| 1391 | if (builtin.os.tag == .linux) { | 1392 | if (std.Target.current.os.tag == .linux) { |
| 1392 | _ = @import("linux/test.zig"); | 1393 | _ = @import("linux/test.zig"); |
| 1393 | } | 1394 | } |
| 1394 | } | 1395 | } |
lib/std/os/linux/start_pie.zig+1-1| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const elf = std.elf; | 2 | const elf = std.elf; |
| 3 | const builtin = @import("builtin"); | 3 | const builtin = std.builtin; |
| 4 | const assert = std.debug.assert; | 4 | const assert = std.debug.assert; |
| 5 | 5 | ||
| 6 | const R_AMD64_RELATIVE = 8; | 6 | const R_AMD64_RELATIVE = 8; |
lib/std/os/linux/test.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("../../std.zig"); | 6 | const std = @import("../../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const linux = std.os.linux; | 8 | const linux = std.os.linux; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
| 10 | const elf = std.elf; | 10 | const elf = std.elf; |
lib/std/os/linux/tls.zig+8-8| ... | @@ -4,12 +4,12 @@ | ... | @@ -4,12 +4,12 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = std.builtin; | ||
| 8 | const os = std.os; | 7 | const os = std.os; |
| 9 | const mem = std.mem; | 8 | const mem = std.mem; |
| 10 | const elf = std.elf; | 9 | const elf = std.elf; |
| 11 | const math = std.math; | 10 | const math = std.math; |
| 12 | const assert = std.debug.assert; | 11 | const assert = std.debug.assert; |
| 12 | const native_arch = std.Target.current.cpu.arch; | ||
| 13 | 13 | ||
| 14 | // This file implements the two TLS variants [1] used by ELF-based systems. | 14 | // This file implements the two TLS variants [1] used by ELF-based systems. |
| 15 | // | 15 | // |
| ... | @@ -52,14 +52,14 @@ const TLSVariant = enum { | ... | @@ -52,14 +52,14 @@ const TLSVariant = enum { |
| 52 | VariantII, | 52 | VariantII, |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | const tls_variant = switch (builtin.arch) { | 55 | const tls_variant = switch (native_arch) { |
| 56 | .arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64, .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => TLSVariant.VariantI, | 56 | .arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64, .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => TLSVariant.VariantI, |
| 57 | .x86_64, .i386, .sparcv9 => TLSVariant.VariantII, | 57 | .x86_64, .i386, .sparcv9 => TLSVariant.VariantII, |
| 58 | else => @compileError("undefined tls_variant for this architecture"), | 58 | else => @compileError("undefined tls_variant for this architecture"), |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | // Controls how many bytes are reserved for the Thread Control Block | 61 | // Controls how many bytes are reserved for the Thread Control Block |
| 62 | const tls_tcb_size = switch (builtin.arch) { | 62 | const tls_tcb_size = switch (native_arch) { |
| 63 | // ARM EABI mandates enough space for two pointers: the first one points to | 63 | // ARM EABI mandates enough space for two pointers: the first one points to |
| 64 | // the DTV while the second one is unspecified but reserved | 64 | // the DTV while the second one is unspecified but reserved |
| 65 | .arm, .armeb, .aarch64, .aarch64_be => 2 * @sizeOf(usize), | 65 | .arm, .armeb, .aarch64, .aarch64_be => 2 * @sizeOf(usize), |
| ... | @@ -68,7 +68,7 @@ const tls_tcb_size = switch (builtin.arch) { | ... | @@ -68,7 +68,7 @@ const tls_tcb_size = switch (builtin.arch) { |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | // Controls if the TP points to the end of the TCB instead of its beginning | 70 | // Controls if the TP points to the end of the TCB instead of its beginning |
| 71 | const tls_tp_points_past_tcb = switch (builtin.arch) { | 71 | const tls_tp_points_past_tcb = switch (native_arch) { |
| 72 | .riscv32, .riscv64, .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => true, | 72 | .riscv32, .riscv64, .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => true, |
| 73 | else => false, | 73 | else => false, |
| 74 | }; | 74 | }; |
| ... | @@ -76,12 +76,12 @@ const tls_tp_points_past_tcb = switch (builtin.arch) { | ... | @@ -76,12 +76,12 @@ const tls_tp_points_past_tcb = switch (builtin.arch) { |
| 76 | // Some architectures add some offset to the tp and dtv addresses in order to | 76 | // Some architectures add some offset to the tp and dtv addresses in order to |
| 77 | // make the generated code more efficient | 77 | // make the generated code more efficient |
| 78 | 78 | ||
| 79 | const tls_tp_offset = switch (builtin.arch) { | 79 | const tls_tp_offset = switch (native_arch) { |
| 80 | .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => 0x7000, | 80 | .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => 0x7000, |
| 81 | else => 0, | 81 | else => 0, |
| 82 | }; | 82 | }; |
| 83 | 83 | ||
| 84 | const tls_dtv_offset = switch (builtin.arch) { | 84 | const tls_dtv_offset = switch (native_arch) { |
| 85 | .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => 0x8000, | 85 | .mips, .mipsel, .powerpc, .powerpc64, .powerpc64le => 0x8000, |
| 86 | .riscv32, .riscv64 => 0x800, | 86 | .riscv32, .riscv64 => 0x800, |
| 87 | else => 0, | 87 | else => 0, |
| ... | @@ -114,7 +114,7 @@ const TLSImage = struct { | ... | @@ -114,7 +114,7 @@ const TLSImage = struct { |
| 114 | pub var tls_image: TLSImage = undefined; | 114 | pub var tls_image: TLSImage = undefined; |
| 115 | 115 | ||
| 116 | pub fn setThreadPointer(addr: usize) void { | 116 | pub fn setThreadPointer(addr: usize) void { |
| 117 | switch (builtin.arch) { | 117 | switch (native_arch) { |
| 118 | .i386 => { | 118 | .i386 => { |
| 119 | var user_desc = std.os.linux.user_desc{ | 119 | var user_desc = std.os.linux.user_desc{ |
| 120 | .entry_number = tls_image.gdt_entry_number, | 120 | .entry_number = tls_image.gdt_entry_number, |
| ... | @@ -228,7 +228,7 @@ fn initTLS() void { | ... | @@ -228,7 +228,7 @@ fn initTLS() void { |
| 228 | // ARMv6 targets (and earlier) have no support for TLS in hardware | 228 | // ARMv6 targets (and earlier) have no support for TLS in hardware |
| 229 | // FIXME: Elide the check for targets >= ARMv7 when the target feature API | 229 | // FIXME: Elide the check for targets >= ARMv7 when the target feature API |
| 230 | // becomes less verbose (and more usable). | 230 | // becomes less verbose (and more usable). |
| 231 | if (comptime builtin.arch.isARM()) { | 231 | if (comptime native_arch.isARM()) { |
| 232 | if (at_hwcap & std.os.linux.HWCAP_TLS == 0) { | 232 | if (at_hwcap & std.os.linux.HWCAP_TLS == 0) { |
| 233 | // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls | 233 | // FIXME: Make __aeabi_read_tp call the kernel helper kuser_get_tls |
| 234 | // For the time being use a simple abort instead of a @panic call to | 234 | // For the time being use a simple abort instead of a @panic call to |
lib/std/os/test.zig+1-1| ... | @@ -18,7 +18,7 @@ const Thread = std.Thread; | ... | @@ -18,7 +18,7 @@ const Thread = std.Thread; |
| 18 | 18 | ||
| 19 | const a = std.testing.allocator; | 19 | const a = std.testing.allocator; |
| 20 | 20 | ||
| 21 | const builtin = @import("builtin"); | 21 | const builtin = std.builtin; |
| 22 | const AtomicRmwOp = builtin.AtomicRmwOp; | 22 | const AtomicRmwOp = builtin.AtomicRmwOp; |
| 23 | const AtomicOrder = builtin.AtomicOrder; | 23 | const AtomicOrder = builtin.AtomicOrder; |
| 24 | const tmpDir = std.testing.tmpDir; | 24 | const tmpDir = std.testing.tmpDir; |
lib/std/os/windows.zig+1-1| ... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
| 9 | // * When null-terminated or UTF16LE byte buffers are required, provide APIs which accept | 9 | // * When null-terminated or UTF16LE byte buffers are required, provide APIs which accept |
| 10 | // slices as well as APIs which accept null-terminated UTF16LE byte buffers. | 10 | // slices as well as APIs which accept null-terminated UTF16LE byte buffers. |
| 11 | 11 | ||
| 12 | const builtin = @import("builtin"); | 12 | const builtin = std.builtin; |
| 13 | const std = @import("../std.zig"); | 13 | const std = @import("../std.zig"); |
| 14 | const mem = std.mem; | 14 | const mem = std.mem; |
| 15 | const assert = std.debug.assert; | 15 | const assert = std.debug.assert; |
lib/std/os/windows/bits.zig+3-3| ... | @@ -5,10 +5,10 @@ | ... | @@ -5,10 +5,10 @@ |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | // Platform-dependent types and values that are used along with OS-specific APIs. | 6 | // Platform-dependent types and values that are used along with OS-specific APIs. |
| 7 | 7 | ||
| 8 | const builtin = @import("builtin"); | ||
| 9 | const std = @import("../../std.zig"); | 8 | const std = @import("../../std.zig"); |
| 10 | const assert = std.debug.assert; | 9 | const assert = std.debug.assert; |
| 11 | const maxInt = std.math.maxInt; | 10 | const maxInt = std.math.maxInt; |
| 11 | const arch = std.Target.current.cpu.arch; | ||
| 12 | 12 | ||
| 13 | pub usingnamespace @import("win32error.zig"); | 13 | pub usingnamespace @import("win32error.zig"); |
| 14 | pub usingnamespace @import("ntstatus.zig"); | 14 | pub usingnamespace @import("ntstatus.zig"); |
| ... | @@ -24,7 +24,7 @@ pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1; | ... | @@ -24,7 +24,7 @@ pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1; |
| 24 | /// The standard error device. Initially, this is the active console screen buffer, CONOUT$. | 24 | /// The standard error device. Initially, this is the active console screen buffer, CONOUT$. |
| 25 | pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1; | 25 | pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1; |
| 26 | 26 | ||
| 27 | pub const WINAPI: builtin.CallingConvention = if (builtin.arch == .i386) | 27 | pub const WINAPI: std.builtin.CallingConvention = if (arch == .i386) |
| 28 | .Stdcall | 28 | .Stdcall |
| 29 | else | 29 | else |
| 30 | .C; | 30 | .C; |
| ... | @@ -937,7 +937,7 @@ pub const EXCEPTION_RECORD = extern struct { | ... | @@ -937,7 +937,7 @@ pub const EXCEPTION_RECORD = extern struct { |
| 937 | ExceptionInformation: [15]usize, | 937 | ExceptionInformation: [15]usize, |
| 938 | }; | 938 | }; |
| 939 | 939 | ||
| 940 | pub usingnamespace switch (builtin.arch) { | 940 | pub usingnamespace switch (arch) { |
| 941 | .i386 => struct { | 941 | .i386 => struct { |
| 942 | pub const FLOATING_SAVE_AREA = extern struct { | 942 | pub const FLOATING_SAVE_AREA = extern struct { |
| 943 | ControlWord: DWORD, | 943 | ControlWord: DWORD, |
lib/std/os/windows/user32.zig+1-1| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | usingnamespace @import("bits.zig"); | 6 | usingnamespace @import("bits.zig"); |
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = std.builtin; |
| 9 | const assert = std.debug.assert; | 9 | const assert = std.debug.assert; |
| 10 | const windows = @import("../windows.zig"); | 10 | const windows = @import("../windows.zig"); |
| 11 | const unexpectedError = windows.unexpectedError; | 11 | const unexpectedError = windows.unexpectedError; |
lib/std/packed_int_array.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const debug = std.debug; | 8 | const debug = std.debug; |
| 9 | const testing = std.testing; | 9 | const testing = std.testing; |
| 10 | 10 |
lib/std/pdb.zig+1-1| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = std.builtin; |
| 7 | const std = @import("std.zig"); | 7 | const std = @import("std.zig"); |
| 8 | const io = std.io; | 8 | const io = std.io; |
| 9 | const math = std.math; | 9 | const math = std.math; |
lib/std/rand.zig+1-1| ... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
| 13 | //! TODO(tiehuis): Benchmark these against other reference implementations. | 13 | //! TODO(tiehuis): Benchmark these against other reference implementations. |
| 14 | 14 | ||
| 15 | const std = @import("std.zig"); | 15 | const std = @import("std.zig"); |
| 16 | const builtin = @import("builtin"); | 16 | const builtin = std.builtin; |
| 17 | const assert = std.debug.assert; | 17 | const assert = std.debug.assert; |
| 18 | const expect = std.testing.expect; | 18 | const expect = std.testing.expect; |
| 19 | const expectEqual = std.testing.expectEqual; | 19 | const expectEqual = std.testing.expectEqual; |
lib/std/sort.zig+1-1| ... | @@ -8,7 +8,7 @@ const assert = std.debug.assert; | ... | @@ -8,7 +8,7 @@ const assert = std.debug.assert; |
| 8 | const testing = std.testing; | 8 | const testing = std.testing; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const builtin = @import("builtin"); | 11 | const builtin = std.builtin; |
| 12 | 12 | ||
| 13 | pub fn binarySearch( | 13 | pub fn binarySearch( |
| 14 | comptime T: type, | 14 | comptime T: type, |
lib/std/special/c.zig+10-7| ... | @@ -10,19 +10,22 @@ | ... | @@ -10,19 +10,22 @@ |
| 10 | // such as memcpy, memset, and some math functions. | 10 | // such as memcpy, memset, and some math functions. |
| 11 | 11 | ||
| 12 | const std = @import("std"); | 12 | const std = @import("std"); |
| 13 | const builtin = @import("builtin"); | 13 | const builtin = std.builtin; |
| 14 | const maxInt = std.math.maxInt; | 14 | const maxInt = std.math.maxInt; |
| 15 | const isNan = std.math.isNan; | 15 | const isNan = std.math.isNan; |
| 16 | const native_arch = std.Target.current.cpu.arch; | ||
| 17 | const native_abi = std.Target.current.abi; | ||
| 18 | const native_os = std.Target.current.os.tag; | ||
| 16 | 19 | ||
| 17 | const is_wasm = switch (builtin.arch) { | 20 | const is_wasm = switch (native_arch) { |
| 18 | .wasm32, .wasm64 => true, | 21 | .wasm32, .wasm64 => true, |
| 19 | else => false, | 22 | else => false, |
| 20 | }; | 23 | }; |
| 21 | const is_msvc = switch (builtin.abi) { | 24 | const is_msvc = switch (native_abi) { |
| 22 | .msvc => true, | 25 | .msvc => true, |
| 23 | else => false, | 26 | else => false, |
| 24 | }; | 27 | }; |
| 25 | const is_freestanding = switch (builtin.os.tag) { | 28 | const is_freestanding = switch (native_os) { |
| 26 | .freestanding => true, | 29 | .freestanding => true, |
| 27 | else => false, | 30 | else => false, |
| 28 | }; | 31 | }; |
| ... | @@ -174,7 +177,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn | ... | @@ -174,7 +177,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn |
| 174 | @setCold(true); | 177 | @setCold(true); |
| 175 | std.debug.panic("{s}", .{msg}); | 178 | std.debug.panic("{s}", .{msg}); |
| 176 | } | 179 | } |
| 177 | if (builtin.os.tag != .freestanding and builtin.os.tag != .other) { | 180 | if (native_os != .freestanding and native_os != .other) { |
| 178 | std.os.abort(); | 181 | std.os.abort(); |
| 179 | } | 182 | } |
| 180 | while (true) {} | 183 | while (true) {} |
| ... | @@ -275,7 +278,7 @@ test "test_bcmp" { | ... | @@ -275,7 +278,7 @@ test "test_bcmp" { |
| 275 | } | 278 | } |
| 276 | 279 | ||
| 277 | comptime { | 280 | comptime { |
| 278 | if (builtin.os.tag == .linux) { | 281 | if (native_os == .linux) { |
| 279 | @export(clone, .{ .name = "clone" }); | 282 | @export(clone, .{ .name = "clone" }); |
| 280 | } | 283 | } |
| 281 | } | 284 | } |
| ... | @@ -284,7 +287,7 @@ comptime { | ... | @@ -284,7 +287,7 @@ comptime { |
| 284 | // it causes a segfault in release mode. this is a workaround of calling it | 287 | // it causes a segfault in release mode. this is a workaround of calling it |
| 285 | // across .o file boundaries. fix comptime @ptrCast of nakedcc functions. | 288 | // across .o file boundaries. fix comptime @ptrCast of nakedcc functions. |
| 286 | fn clone() callconv(.Naked) void { | 289 | fn clone() callconv(.Naked) void { |
| 287 | switch (builtin.arch) { | 290 | switch (native_arch) { |
| 288 | .i386 => { | 291 | .i386 => { |
| 289 | // __clone(func, stack, flags, arg, ptid, tls, ctid) | 292 | // __clone(func, stack, flags, arg, ptid, tls, ctid) |
| 290 | // +8, +12, +16, +20, +24, +28, +32 | 293 | // +8, +12, +16, +20, +24, +28, +32 |
lib/std/special/compiler_rt.zig+12-9| ... | @@ -6,15 +6,18 @@ | ... | @@ -6,15 +6,18 @@ |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = std.builtin; | 7 | const builtin = std.builtin; |
| 8 | const is_test = builtin.is_test; | 8 | const is_test = builtin.is_test; |
| 9 | const os_tag = std.Target.current.os.tag; | ||
| 10 | const arch = std.Target.current.cpu.arch; | ||
| 11 | const abi = std.Target.current.abi; | ||
| 9 | 12 | ||
| 10 | const is_gnu = std.Target.current.abi.isGnu(); | 13 | const is_gnu = abi.isGnu(); |
| 11 | const is_mingw = builtin.os.tag == .windows and is_gnu; | 14 | const is_mingw = os_tag == .windows and is_gnu; |
| 12 | 15 | ||
| 13 | comptime { | 16 | comptime { |
| 14 | const linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Weak; | 17 | const linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Weak; |
| 15 | const strong_linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Strong; | 18 | const strong_linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Strong; |
| 16 | 19 | ||
| 17 | switch (builtin.arch) { | 20 | switch (arch) { |
| 18 | .i386, | 21 | .i386, |
| 19 | .x86_64, | 22 | .x86_64, |
| 20 | => @export(@import("compiler_rt/stack_probe.zig").zig_probe_stack, .{ | 23 | => @export(@import("compiler_rt/stack_probe.zig").zig_probe_stack, .{ |
| ... | @@ -167,11 +170,11 @@ comptime { | ... | @@ -167,11 +170,11 @@ comptime { |
| 167 | 170 | ||
| 168 | @export(@import("compiler_rt/clzsi2.zig").__clzsi2, .{ .name = "__clzsi2", .linkage = linkage }); | 171 | @export(@import("compiler_rt/clzsi2.zig").__clzsi2, .{ .name = "__clzsi2", .linkage = linkage }); |
| 169 | 172 | ||
| 170 | if (builtin.link_libc and builtin.os.tag == .openbsd) { | 173 | if (builtin.link_libc and os_tag == .openbsd) { |
| 171 | @export(@import("compiler_rt/emutls.zig").__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage }); | 174 | @export(@import("compiler_rt/emutls.zig").__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage }); |
| 172 | } | 175 | } |
| 173 | 176 | ||
| 174 | if ((builtin.arch.isARM() or builtin.arch.isThumb()) and !is_test) { | 177 | if ((arch.isARM() or arch.isThumb()) and !is_test) { |
| 175 | @export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage }); | 178 | @export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage }); |
| 176 | @export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage }); | 179 | @export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage }); |
| 177 | @export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage }); | 180 | @export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage }); |
| ... | @@ -202,7 +205,7 @@ comptime { | ... | @@ -202,7 +205,7 @@ comptime { |
| 202 | @export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage }); | 205 | @export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr4", .linkage = linkage }); |
| 203 | @export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage }); | 206 | @export(@import("compiler_rt/arm.zig").__aeabi_memclr, .{ .name = "__aeabi_memclr8", .linkage = linkage }); |
| 204 | 207 | ||
| 205 | if (builtin.os.tag == .linux) { | 208 | if (os_tag == .linux) { |
| 206 | @export(@import("compiler_rt/arm.zig").__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage }); | 209 | @export(@import("compiler_rt/arm.zig").__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage }); |
| 207 | } | 210 | } |
| 208 | 211 | ||
| ... | @@ -269,7 +272,7 @@ comptime { | ... | @@ -269,7 +272,7 @@ comptime { |
| 269 | @export(@import("compiler_rt/compareXf2.zig").__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage }); | 272 | @export(@import("compiler_rt/compareXf2.zig").__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = linkage }); |
| 270 | } | 273 | } |
| 271 | 274 | ||
| 272 | if (builtin.arch == .i386 and builtin.abi == .msvc) { | 275 | if (arch == .i386 and abi == .msvc) { |
| 273 | // Don't let LLVM apply the stdcall name mangling on those MSVC builtins | 276 | // Don't let LLVM apply the stdcall name mangling on those MSVC builtins |
| 274 | @export(@import("compiler_rt/aulldiv.zig")._alldiv, .{ .name = "\x01__alldiv", .linkage = strong_linkage }); | 277 | @export(@import("compiler_rt/aulldiv.zig")._alldiv, .{ .name = "\x01__alldiv", .linkage = strong_linkage }); |
| 275 | @export(@import("compiler_rt/aulldiv.zig")._aulldiv, .{ .name = "\x01__aulldiv", .linkage = strong_linkage }); | 278 | @export(@import("compiler_rt/aulldiv.zig")._aulldiv, .{ .name = "\x01__aulldiv", .linkage = strong_linkage }); |
| ... | @@ -277,7 +280,7 @@ comptime { | ... | @@ -277,7 +280,7 @@ comptime { |
| 277 | @export(@import("compiler_rt/aullrem.zig")._aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage }); | 280 | @export(@import("compiler_rt/aullrem.zig")._aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage }); |
| 278 | } | 281 | } |
| 279 | 282 | ||
| 280 | if (builtin.arch.isSPARC()) { | 283 | if (arch.isSPARC()) { |
| 281 | // SPARC systems use a different naming scheme | 284 | // SPARC systems use a different naming scheme |
| 282 | @export(@import("compiler_rt/sparc.zig")._Qp_add, .{ .name = "_Qp_add", .linkage = linkage }); | 285 | @export(@import("compiler_rt/sparc.zig")._Qp_add, .{ .name = "_Qp_add", .linkage = linkage }); |
| 283 | @export(@import("compiler_rt/sparc.zig")._Qp_div, .{ .name = "_Qp_div", .linkage = linkage }); | 286 | @export(@import("compiler_rt/sparc.zig")._Qp_div, .{ .name = "_Qp_div", .linkage = linkage }); |
| ... | @@ -334,7 +337,7 @@ comptime { | ... | @@ -334,7 +337,7 @@ comptime { |
| 334 | @export(@import("compiler_rt/stack_probe.zig").__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage }); | 337 | @export(@import("compiler_rt/stack_probe.zig").__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage }); |
| 335 | } | 338 | } |
| 336 | 339 | ||
| 337 | switch (builtin.arch) { | 340 | switch (arch) { |
| 338 | .i386 => { | 341 | .i386 => { |
| 339 | @export(@import("compiler_rt/divti3.zig").__divti3, .{ .name = "__divti3", .linkage = linkage }); | 342 | @export(@import("compiler_rt/divti3.zig").__divti3, .{ .name = "__divti3", .linkage = linkage }); |
| 340 | @export(@import("compiler_rt/modti3.zig").__modti3, .{ .name = "__modti3", .linkage = linkage }); | 343 | @export(@import("compiler_rt/modti3.zig").__modti3, .{ .name = "__modti3", .linkage = linkage }); |
lib/std/special/compiler_rt/atomics.zig+3-2| ... | @@ -5,6 +5,7 @@ | ... | @@ -5,6 +5,7 @@ |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = std.builtin; | 7 | const builtin = std.builtin; |
| 8 | const arch = std.Target.current.cpu.arch; | ||
| 8 | 9 | ||
| 9 | const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 10 | const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; |
| 10 | 11 | ||
| ... | @@ -13,7 +14,7 @@ const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak | ... | @@ -13,7 +14,7 @@ const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak |
| 13 | // Some architectures support atomic load/stores but no CAS, but we ignore this | 14 | // Some architectures support atomic load/stores but no CAS, but we ignore this |
| 14 | // detail to keep the export logic clean and because we need some kind of CAS to | 15 | // detail to keep the export logic clean and because we need some kind of CAS to |
| 15 | // implement the spinlocks. | 16 | // implement the spinlocks. |
| 16 | const supports_atomic_ops = switch (builtin.arch) { | 17 | const supports_atomic_ops = switch (arch) { |
| 17 | .msp430, .avr => false, | 18 | .msp430, .avr => false, |
| 18 | .arm, .armeb, .thumb, .thumbeb => | 19 | .arm, .armeb, .thumb, .thumbeb => |
| 19 | // The ARM v6m ISA has no ldrex/strex and so it's impossible to do CAS | 20 | // The ARM v6m ISA has no ldrex/strex and so it's impossible to do CAS |
| ... | @@ -27,7 +28,7 @@ const supports_atomic_ops = switch (builtin.arch) { | ... | @@ -27,7 +28,7 @@ const supports_atomic_ops = switch (builtin.arch) { |
| 27 | // The size (in bytes) of the biggest object that the architecture can | 28 | // The size (in bytes) of the biggest object that the architecture can |
| 28 | // load/store atomically. | 29 | // load/store atomically. |
| 29 | // Objects bigger than this threshold require the use of a lock. | 30 | // Objects bigger than this threshold require the use of a lock. |
| 30 | const largest_atomic_size = switch (builtin.arch) { | 31 | const largest_atomic_size = switch (arch) { |
| 31 | // XXX: On x86/x86_64 we could check the presence of cmpxchg8b/cmpxchg16b | 32 | // XXX: On x86/x86_64 we could check the presence of cmpxchg8b/cmpxchg16b |
| 32 | // and set this parameter accordingly. | 33 | // and set this parameter accordingly. |
| 33 | else => @sizeOf(usize), | 34 | else => @sizeOf(usize), |
lib/std/special/compiler_rt/muldi3.zig+6-4| ... | @@ -3,14 +3,16 @@ | ... | @@ -3,14 +3,16 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const std = @import("std"); |
| 7 | const is_test = std.builtin.is_test; | ||
| 8 | const native_endian = std.Target.current.cpu.arch.endian(); | ||
| 7 | 9 | ||
| 8 | // Ported from | 10 | // Ported from |
| 9 | // https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/compiler-rt/lib/builtins/muldi3.c | 11 | // https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/compiler-rt/lib/builtins/muldi3.c |
| 10 | 12 | ||
| 11 | const dwords = extern union { | 13 | const dwords = extern union { |
| 12 | all: i64, | 14 | all: i64, |
| 13 | s: switch (builtin.endian) { | 15 | s: switch (native_endian) { |
| 14 | .Little => extern struct { | 16 | .Little => extern struct { |
| 15 | low: u32, | 17 | low: u32, |
| 16 | high: u32, | 18 | high: u32, |
| ... | @@ -23,7 +25,7 @@ const dwords = extern union { | ... | @@ -23,7 +25,7 @@ const dwords = extern union { |
| 23 | }; | 25 | }; |
| 24 | 26 | ||
| 25 | fn __muldsi3(a: u32, b: u32) i64 { | 27 | fn __muldsi3(a: u32, b: u32) i64 { |
| 26 | @setRuntimeSafety(builtin.is_test); | 28 | @setRuntimeSafety(is_test); |
| 27 | 29 | ||
| 28 | const bits_in_word_2 = @sizeOf(i32) * 8 / 2; | 30 | const bits_in_word_2 = @sizeOf(i32) * 8 / 2; |
| 29 | const lower_mask = (~@as(u32, 0)) >> bits_in_word_2; | 31 | const lower_mask = (~@as(u32, 0)) >> bits_in_word_2; |
| ... | @@ -45,7 +47,7 @@ fn __muldsi3(a: u32, b: u32) i64 { | ... | @@ -45,7 +47,7 @@ fn __muldsi3(a: u32, b: u32) i64 { |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | pub fn __muldi3(a: i64, b: i64) callconv(.C) i64 { | 49 | pub fn __muldi3(a: i64, b: i64) callconv(.C) i64 { |
| 48 | @setRuntimeSafety(builtin.is_test); | 50 | @setRuntimeSafety(is_test); |
| 49 | 51 | ||
| 50 | const x = dwords{ .all = a }; | 52 | const x = dwords{ .all = a }; |
| 51 | const y = dwords{ .all = b }; | 53 | const y = dwords{ .all = b }; |
lib/std/special/compiler_rt/multi3.zig+5-3| ... | @@ -3,15 +3,17 @@ | ... | @@ -3,15 +3,17 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | ||
| 7 | const compiler_rt = @import("../compiler_rt.zig"); | 6 | const compiler_rt = @import("../compiler_rt.zig"); |
| 7 | const std = @import("std"); | ||
| 8 | const is_test = std.builtin.is_test; | ||
| 9 | const native_endian = std.Target.current.cpu.arch.endian(); | ||
| 8 | 10 | ||
| 9 | // Ported from git@github.com:llvm-project/llvm-project-20170507.git | 11 | // Ported from git@github.com:llvm-project/llvm-project-20170507.git |
| 10 | // ae684fad6d34858c014c94da69c15e7774a633c3 | 12 | // ae684fad6d34858c014c94da69c15e7774a633c3 |
| 11 | // 2018-08-13 | 13 | // 2018-08-13 |
| 12 | 14 | ||
| 13 | pub fn __multi3(a: i128, b: i128) callconv(.C) i128 { | 15 | pub fn __multi3(a: i128, b: i128) callconv(.C) i128 { |
| 14 | @setRuntimeSafety(builtin.is_test); | 16 | @setRuntimeSafety(is_test); |
| 15 | const x = twords{ .all = a }; | 17 | const x = twords{ .all = a }; |
| 16 | const y = twords{ .all = b }; | 18 | const y = twords{ .all = b }; |
| 17 | var r = twords{ .all = __mulddi3(x.s.low, y.s.low) }; | 19 | var r = twords{ .all = __mulddi3(x.s.low, y.s.low) }; |
| ... | @@ -50,7 +52,7 @@ const twords = extern union { | ... | @@ -50,7 +52,7 @@ const twords = extern union { |
| 50 | all: i128, | 52 | all: i128, |
| 51 | s: S, | 53 | s: S, |
| 52 | 54 | ||
| 53 | const S = if (builtin.endian == .Little) | 55 | const S = if (native_endian == .Little) |
| 54 | struct { | 56 | struct { |
| 55 | low: u64, | 57 | low: u64, |
| 56 | high: u64, | 58 | high: u64, |
lib/std/special/compiler_rt/shift.zig+2-2| ... | @@ -4,8 +4,8 @@ | ... | @@ -4,8 +4,8 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = std.builtin; | ||
| 8 | const Log2Int = std.math.Log2Int; | 7 | const Log2Int = std.math.Log2Int; |
| 8 | const native_endian = std.Target.current.cpu.arch.endian(); | ||
| 9 | 9 | ||
| 10 | fn Dwords(comptime T: type, comptime signed_half: bool) type { | 10 | fn Dwords(comptime T: type, comptime signed_half: bool) type { |
| 11 | return extern union { | 11 | return extern union { |
| ... | @@ -15,7 +15,7 @@ fn Dwords(comptime T: type, comptime signed_half: bool) type { | ... | @@ -15,7 +15,7 @@ fn Dwords(comptime T: type, comptime signed_half: bool) type { |
| 15 | pub const HalfT = if (signed_half) HalfTS else HalfTU; | 15 | pub const HalfT = if (signed_half) HalfTS else HalfTU; |
| 16 | 16 | ||
| 17 | all: T, | 17 | all: T, |
| 18 | s: if (builtin.endian == .Little) | 18 | s: if (native_endian == .Little) |
| 19 | struct { low: HalfT, high: HalfT } | 19 | struct { low: HalfT, high: HalfT } |
| 20 | else | 20 | else |
| 21 | struct { high: HalfT, low: HalfT }, | 21 | struct { high: HalfT, low: HalfT }, |
lib/std/special/compiler_rt/stack_probe.zig+5-5| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const native_arch = @import("std").Target.current.cpu.arch; |
| 7 | 7 | ||
| 8 | // Zig's own stack-probe routine (available only on x86 and x86_64) | 8 | // Zig's own stack-probe routine (available only on x86 and x86_64) |
| 9 | pub fn zig_probe_stack() callconv(.Naked) void { | 9 | pub fn zig_probe_stack() callconv(.Naked) void { |
| ... | @@ -13,7 +13,7 @@ pub fn zig_probe_stack() callconv(.Naked) void { | ... | @@ -13,7 +13,7 @@ pub fn zig_probe_stack() callconv(.Naked) void { |
| 13 | // invalid so let's update it on the go, otherwise we'll get a segfault | 13 | // invalid so let's update it on the go, otherwise we'll get a segfault |
| 14 | // instead of triggering the stack growth. | 14 | // instead of triggering the stack growth. |
| 15 | 15 | ||
| 16 | switch (builtin.arch) { | 16 | switch (native_arch) { |
| 17 | .x86_64 => { | 17 | .x86_64 => { |
| 18 | // %rax = probe length, %rsp = stack pointer | 18 | // %rax = probe length, %rsp = stack pointer |
| 19 | asm volatile ( | 19 | asm volatile ( |
| ... | @@ -65,7 +65,7 @@ pub fn zig_probe_stack() callconv(.Naked) void { | ... | @@ -65,7 +65,7 @@ pub fn zig_probe_stack() callconv(.Naked) void { |
| 65 | fn win_probe_stack_only() void { | 65 | fn win_probe_stack_only() void { |
| 66 | @setRuntimeSafety(false); | 66 | @setRuntimeSafety(false); |
| 67 | 67 | ||
| 68 | switch (builtin.arch) { | 68 | switch (native_arch) { |
| 69 | .x86_64 => { | 69 | .x86_64 => { |
| 70 | asm volatile ( | 70 | asm volatile ( |
| 71 | \\ push %%rcx | 71 | \\ push %%rcx |
| ... | @@ -117,7 +117,7 @@ fn win_probe_stack_only() void { | ... | @@ -117,7 +117,7 @@ fn win_probe_stack_only() void { |
| 117 | fn win_probe_stack_adjust_sp() void { | 117 | fn win_probe_stack_adjust_sp() void { |
| 118 | @setRuntimeSafety(false); | 118 | @setRuntimeSafety(false); |
| 119 | 119 | ||
| 120 | switch (builtin.arch) { | 120 | switch (native_arch) { |
| 121 | .x86_64 => { | 121 | .x86_64 => { |
| 122 | asm volatile ( | 122 | asm volatile ( |
| 123 | \\ push %%rcx | 123 | \\ push %%rcx |
| ... | @@ -191,7 +191,7 @@ pub fn _chkstk() callconv(.Naked) void { | ... | @@ -191,7 +191,7 @@ pub fn _chkstk() callconv(.Naked) void { |
| 191 | } | 191 | } |
| 192 | pub fn __chkstk() callconv(.Naked) void { | 192 | pub fn __chkstk() callconv(.Naked) void { |
| 193 | @setRuntimeSafety(false); | 193 | @setRuntimeSafety(false); |
| 194 | switch (builtin.arch) { | 194 | switch (native_arch) { |
| 195 | .i386 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}), | 195 | .i386 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}), |
| 196 | .x86_64 => @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}), | 196 | .x86_64 => @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}), |
| 197 | else => unreachable, | 197 | else => unreachable, |
lib/std/special/compiler_rt/udivmod.zig+2-1| ... | @@ -5,8 +5,9 @@ | ... | @@ -5,8 +5,9 @@ |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | const is_test = builtin.is_test; | 7 | const is_test = builtin.is_test; |
| 8 | const native_endian = @import("std").Target.current.cpu.arch.endian(); | ||
| 8 | 9 | ||
| 9 | const low = switch (builtin.endian) { | 10 | const low = switch (native_endian) { |
| 10 | .Big => 1, | 11 | .Big => 1, |
| 11 | .Little => 0, | 12 | .Little => 0, |
| 12 | }; | 13 | }; |
lib/std/start.zig+13-13| ... | @@ -11,10 +11,12 @@ const builtin = @import("builtin"); | ... | @@ -11,10 +11,12 @@ const builtin = @import("builtin"); |
| 11 | const assert = std.debug.assert; | 11 | const assert = std.debug.assert; |
| 12 | const uefi = std.os.uefi; | 12 | const uefi = std.os.uefi; |
| 13 | const tlcsprng = @import("crypto/tlcsprng.zig"); | 13 | const tlcsprng = @import("crypto/tlcsprng.zig"); |
| 14 | const native_arch = std.Target.current.cpu.arch; | ||
| 15 | const native_os = std.Target.current.os.tag; | ||
| 14 | 16 | ||
| 15 | var argc_argv_ptr: [*]usize = undefined; | 17 | var argc_argv_ptr: [*]usize = undefined; |
| 16 | 18 | ||
| 17 | const start_sym_name = if (builtin.arch.isMIPS()) "__start" else "_start"; | 19 | const start_sym_name = if (native_arch.isMIPS()) "__start" else "_start"; |
| 18 | 20 | ||
| 19 | comptime { | 21 | comptime { |
| 20 | // The self-hosted compiler is not fully capable of handling all of this start.zig file. | 22 | // The self-hosted compiler is not fully capable of handling all of this start.zig file. |
| ... | @@ -23,9 +25,7 @@ comptime { | ... | @@ -23,9 +25,7 @@ comptime { |
| 23 | if (builtin.zig_is_stage2) { | 25 | if (builtin.zig_is_stage2) { |
| 24 | if (builtin.output_mode == .Exe) { | 26 | if (builtin.output_mode == .Exe) { |
| 25 | if (builtin.link_libc or builtin.object_format == .c) { | 27 | if (builtin.link_libc or builtin.object_format == .c) { |
| 26 | if (!@hasDecl(root, "main")) { | 28 | @export(main2, "main"); |
| 27 | @export(main2, "main"); | ||
| 28 | } | ||
| 29 | } else { | 29 | } else { |
| 30 | if (!@hasDecl(root, "_start")) { | 30 | if (!@hasDecl(root, "_start")) { |
| 31 | @export(_start2, "_start"); | 31 | @export(_start2, "_start"); |
| ... | @@ -34,7 +34,7 @@ comptime { | ... | @@ -34,7 +34,7 @@ comptime { |
| 34 | } | 34 | } |
| 35 | } else { | 35 | } else { |
| 36 | if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) { | 36 | if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) { |
| 37 | if (builtin.os.tag == .windows and !@hasDecl(root, "_DllMainCRTStartup")) { | 37 | if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) { |
| 38 | @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" }); | 38 | @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" }); |
| 39 | } | 39 | } |
| 40 | } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) { | 40 | } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) { |
| ... | @@ -42,7 +42,7 @@ comptime { | ... | @@ -42,7 +42,7 @@ comptime { |
| 42 | if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { | 42 | if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { |
| 43 | @export(main, .{ .name = "main", .linkage = .Weak }); | 43 | @export(main, .{ .name = "main", .linkage = .Weak }); |
| 44 | } | 44 | } |
| 45 | } else if (builtin.os.tag == .windows) { | 45 | } else if (native_os == .windows) { |
| 46 | if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and | 46 | if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and |
| 47 | !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup")) | 47 | !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup")) |
| 48 | { | 48 | { |
| ... | @@ -56,11 +56,11 @@ comptime { | ... | @@ -56,11 +56,11 @@ comptime { |
| 56 | { | 56 | { |
| 57 | @export(wWinMainCRTStartup, .{ .name = "wWinMainCRTStartup" }); | 57 | @export(wWinMainCRTStartup, .{ .name = "wWinMainCRTStartup" }); |
| 58 | } | 58 | } |
| 59 | } else if (builtin.os.tag == .uefi) { | 59 | } else if (native_os == .uefi) { |
| 60 | if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" }); | 60 | if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" }); |
| 61 | } else if (builtin.arch.isWasm() and builtin.os.tag == .freestanding) { | 61 | } else if (native_arch.isWasm() and native_os == .freestanding) { |
| 62 | if (!@hasDecl(root, start_sym_name)) @export(wasm_freestanding_start, .{ .name = start_sym_name }); | 62 | if (!@hasDecl(root, start_sym_name)) @export(wasm_freestanding_start, .{ .name = start_sym_name }); |
| 63 | } else if (builtin.os.tag != .other and builtin.os.tag != .freestanding) { | 63 | } else if (native_os != .other and native_os != .freestanding) { |
| 64 | if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name }); | 64 | if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name }); |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| ... | @@ -80,7 +80,7 @@ fn _start2() callconv(.Naked) noreturn { | ... | @@ -80,7 +80,7 @@ fn _start2() callconv(.Naked) noreturn { |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | fn exit2(code: u8) noreturn { | 82 | fn exit2(code: u8) noreturn { |
| 83 | switch (builtin.arch) { | 83 | switch (native_arch) { |
| 84 | .x86_64 => { | 84 | .x86_64 => { |
| 85 | asm volatile ("syscall" | 85 | asm volatile ("syscall" |
| 86 | : | 86 | : |
| ... | @@ -157,13 +157,13 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv | ... | @@ -157,13 +157,13 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | fn _start() callconv(.Naked) noreturn { | 159 | fn _start() callconv(.Naked) noreturn { |
| 160 | if (builtin.os.tag == .wasi) { | 160 | if (native_os == .wasi) { |
| 161 | // This is marked inline because for some reason LLVM in release mode fails to inline it, | 161 | // This is marked inline because for some reason LLVM in release mode fails to inline it, |
| 162 | // and we want fewer call frames in stack traces. | 162 | // and we want fewer call frames in stack traces. |
| 163 | std.os.wasi.proc_exit(@call(.{ .modifier = .always_inline }, callMain, .{})); | 163 | std.os.wasi.proc_exit(@call(.{ .modifier = .always_inline }, callMain, .{})); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | switch (builtin.arch) { | 166 | switch (native_arch) { |
| 167 | .x86_64 => { | 167 | .x86_64 => { |
| 168 | argc_argv_ptr = asm volatile ( | 168 | argc_argv_ptr = asm volatile ( |
| 169 | \\ xor %%rbp, %%rbp | 169 | \\ xor %%rbp, %%rbp |
| ... | @@ -273,7 +273,7 @@ fn posixCallMainAndExit() noreturn { | ... | @@ -273,7 +273,7 @@ fn posixCallMainAndExit() noreturn { |
| 273 | while (envp_optional[envp_count]) |_| : (envp_count += 1) {} | 273 | while (envp_optional[envp_count]) |_| : (envp_count += 1) {} |
| 274 | const envp = @ptrCast([*][*:0]u8, envp_optional)[0..envp_count]; | 274 | const envp = @ptrCast([*][*:0]u8, envp_optional)[0..envp_count]; |
| 275 | 275 | ||
| 276 | if (builtin.os.tag == .linux) { | 276 | if (native_os == .linux) { |
| 277 | // Find the beginning of the auxiliary vector | 277 | // Find the beginning of the auxiliary vector |
| 278 | const auxv = @ptrCast([*]std.elf.Auxv, @alignCast(@alignOf(usize), envp.ptr + envp_count + 1)); | 278 | const auxv = @ptrCast([*]std.elf.Auxv, @alignCast(@alignOf(usize), envp.ptr + envp_count + 1)); |
| 279 | std.os.linux.elf_aux_maybe = auxv; | 279 | std.os.linux.elf_aux_maybe = auxv; |
lib/std/target.zig+1-5| ... | @@ -1225,11 +1225,7 @@ pub const Target = struct { | ... | @@ -1225,11 +1225,7 @@ pub const Target = struct { |
| 1225 | } | 1225 | } |
| 1226 | }; | 1226 | }; |
| 1227 | 1227 | ||
| 1228 | pub const current = Target{ | 1228 | pub const current = builtin.target; |
| 1229 | .cpu = builtin.cpu, | ||
| 1230 | .os = builtin.os, | ||
| 1231 | .abi = builtin.abi, | ||
| 1232 | }; | ||
| 1233 | 1229 | ||
| 1234 | pub const stack_align = 16; | 1230 | pub const stack_align = 16; |
| 1235 | 1231 |
lib/std/testing.zig+1-1| ... | @@ -309,7 +309,7 @@ pub const TmpDir = struct { | ... | @@ -309,7 +309,7 @@ pub const TmpDir = struct { |
| 309 | }; | 309 | }; |
| 310 | 310 | ||
| 311 | fn getCwdOrWasiPreopen() std.fs.Dir { | 311 | fn getCwdOrWasiPreopen() std.fs.Dir { |
| 312 | if (@import("builtin").os.tag == .wasi) { | 312 | if (std.builtin.os.tag == .wasi) { |
| 313 | var preopens = std.fs.wasi.PreopenList.init(allocator); | 313 | var preopens = std.fs.wasi.PreopenList.init(allocator); |
| 314 | defer preopens.deinit(); | 314 | defer preopens.deinit(); |
| 315 | preopens.populate() catch | 315 | preopens.populate() catch |
lib/std/unicode.zig+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const std = @import("./std.zig"); | 6 | const std = @import("./std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = std.builtin; |
| 8 | const assert = std.debug.assert; | 8 | const assert = std.debug.assert; |
| 9 | const testing = std.testing; | 9 | const testing = std.testing; |
| 10 | const mem = std.mem; | 10 | const mem = std.mem; |
lib/std/valgrind.zig+1-1| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. | 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies | 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. | 5 | // and substantial portions of the software. |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = std.builtin; |
| 7 | const std = @import("std.zig"); | 7 | const std = @import("std.zig"); |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | 9 |
lib/std/zig/system.zig+2-1| ... | @@ -14,6 +14,7 @@ const process = std.process; | ... | @@ -14,6 +14,7 @@ const process = std.process; |
| 14 | const Target = std.Target; | 14 | const Target = std.Target; |
| 15 | const CrossTarget = std.zig.CrossTarget; | 15 | const CrossTarget = std.zig.CrossTarget; |
| 16 | const macos = @import("system/macos.zig"); | 16 | const macos = @import("system/macos.zig"); |
| 17 | const native_endian = std.Target.current.cpu.arch.endian(); | ||
| 17 | pub const windows = @import("system/windows.zig"); | 18 | pub const windows = @import("system/windows.zig"); |
| 18 | 19 | ||
| 19 | pub const getSDKPath = macos.getSDKPath; | 20 | pub const getSDKPath = macos.getSDKPath; |
| ... | @@ -603,7 +604,7 @@ pub const NativeTargetInfo = struct { | ... | @@ -603,7 +604,7 @@ pub const NativeTargetInfo = struct { |
| 603 | elf.ELFDATA2MSB => .Big, | 604 | elf.ELFDATA2MSB => .Big, |
| 604 | else => return error.InvalidElfEndian, | 605 | else => return error.InvalidElfEndian, |
| 605 | }; | 606 | }; |
| 606 | const need_bswap = elf_endian != std.builtin.endian; | 607 | const need_bswap = elf_endian != native_endian; |
| 607 | if (hdr32.e_ident[elf.EI_VERSION] != 1) return error.InvalidElfVersion; | 608 | if (hdr32.e_ident[elf.EI_VERSION] != 1) return error.InvalidElfVersion; |
| 608 | 609 | ||
| 609 | const is_64 = switch (hdr32.e_ident[elf.EI_CLASS]) { | 610 | const is_64 = switch (hdr32.e_ident[elf.EI_CLASS]) { |