| author | |
| committer | |
| log | 871f6343f4d36c5c048f3307e2a38d184e248826 |
| tree | 26ee969fa8a7238461f0a7a2caeb399f9388bc85 |
| parent | 934df5bd448e7e27f2142d0d9ceec534f391c7f5 |
This lets only the OSes that uses them to import them, and removes
dependencies on bits.zig for the os/<os>/<arch>.zig files21 files changed, 56 insertions(+), 40 deletions(-)
lib/std/os/bits.zig-29| ... | @@ -25,32 +25,3 @@ pub usingnamespace switch (std.Target.current.os.tag) { | ... | @@ -25,32 +25,3 @@ pub usingnamespace switch (std.Target.current.os.tag) { |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | pub usingnamespace if (@hasDecl(root, "os") and @hasDecl(root.os, "bits")) root.os.bits else struct {}; | 27 | pub usingnamespace if (@hasDecl(root, "os") and @hasDecl(root.os, "bits")) root.os.bits else struct {}; |
| 28 | |||
| 29 | pub const iovec = extern struct { | ||
| 30 | iov_base: [*]u8, | ||
| 31 | iov_len: usize, | ||
| 32 | }; | ||
| 33 | |||
| 34 | pub const iovec_const = extern struct { | ||
| 35 | iov_base: [*]const u8, | ||
| 36 | iov_len: usize, | ||
| 37 | }; | ||
| 38 | |||
| 39 | // syslog | ||
| 40 | |||
| 41 | /// system is unusable | ||
| 42 | pub const LOG_EMERG = 0; | ||
| 43 | /// action must be taken immediately | ||
| 44 | pub const LOG_ALERT = 1; | ||
| 45 | /// critical conditions | ||
| 46 | pub const LOG_CRIT = 2; | ||
| 47 | /// error conditions | ||
| 48 | pub const LOG_ERR = 3; | ||
| 49 | /// warning conditions | ||
| 50 | pub const LOG_WARNING = 4; | ||
| 51 | /// normal but significant condition | ||
| 52 | pub const LOG_NOTICE = 5; | ||
| 53 | /// informational | ||
| 54 | pub const LOG_INFO = 6; | ||
| 55 | /// debug-level messages | ||
| 56 | pub const LOG_DEBUG = 7; |
lib/std/os/bits/darwin.zig+2| ... | @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); | ... | @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); |
| 7 | const assert = std.debug.assert; | 7 | const assert = std.debug.assert; |
| 8 | const maxInt = std.math.maxInt; | 8 | const maxInt = std.math.maxInt; |
| 9 | 9 | ||
| 10 | pub usingnamespace @import("posix.zig"); | ||
| 11 | |||
| 10 | // See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html | 12 | // See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html |
| 11 | // TODO: audit mode_t/pid_t, should likely be u16/i32 | 13 | // TODO: audit mode_t/pid_t, should likely be u16/i32 |
| 12 | pub const fd_t = c_int; | 14 | pub const fd_t = c_int; |
lib/std/os/bits/dragonfly.zig+2| ... | @@ -6,6 +6,8 @@ | ... | @@ -6,6 +6,8 @@ |
| 6 | const std = @import("../../std.zig"); | 6 | const std = @import("../../std.zig"); |
| 7 | const maxInt = std.math.maxInt; | 7 | const maxInt = std.math.maxInt; |
| 8 | 8 | ||
| 9 | pub usingnamespace @import("posix.zig"); | ||
| 10 | |||
| 9 | pub fn S_ISCHR(m: u32) bool { | 11 | pub fn S_ISCHR(m: u32) bool { |
| 10 | return m & S_IFMT == S_IFCHR; | 12 | return m & S_IFMT == S_IFCHR; |
| 11 | } | 13 | } |
lib/std/os/bits/freebsd.zig+2| ... | @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); | ... | @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); |
| 7 | const builtin = @import("builtin"); | 7 | const builtin = @import("builtin"); |
| 8 | const maxInt = std.math.maxInt; | 8 | const maxInt = std.math.maxInt; |
| 9 | 9 | ||
| 10 | pub usingnamespace @import("posix.zig"); | ||
| 11 | |||
| 10 | pub const blksize_t = i32; | 12 | pub const blksize_t = i32; |
| 11 | pub const blkcnt_t = i64; | 13 | pub const blkcnt_t = i64; |
| 12 | pub const clockid_t = i32; | 14 | pub const clockid_t = i32; |
lib/std/os/bits/haiku.zig+2| ... | @@ -6,6 +6,8 @@ | ... | @@ -6,6 +6,8 @@ |
| 6 | const std = @import("../../std.zig"); | 6 | const std = @import("../../std.zig"); |
| 7 | const maxInt = std.math.maxInt; | 7 | const maxInt = std.math.maxInt; |
| 8 | 8 | ||
| 9 | pub usingnamespace @import("posix.zig"); | ||
| 10 | |||
| 9 | pub const fd_t = c_int; | 11 | pub const fd_t = c_int; |
| 10 | pub const pid_t = c_int; | 12 | pub const pid_t = c_int; |
| 11 | pub const uid_t = u32; | 13 | pub const uid_t = u32; |
lib/std/os/bits/linux.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 maxInt = std.math.maxInt; | 7 | const maxInt = std.math.maxInt; |
| 8 | const arch = @import("builtin").target.cpu.arch; | 8 | const arch = @import("builtin").target.cpu.arch; |
| 9 | usingnamespace @import("../bits.zig"); | 9 | pub usingnamespace @import("posix.zig"); |
| 10 | 10 | ||
| 11 | pub usingnamespace switch (arch) { | 11 | pub usingnamespace switch (arch) { |
| 12 | .mips, .mipsel => @import("linux/errno-mips.zig"), | 12 | .mips, .mipsel => @import("linux/errno-mips.zig"), |
lib/std/os/bits/netbsd.zig+2| ... | @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); | ... | @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); |
| 7 | const builtin = std.builtin; | 7 | const builtin = std.builtin; |
| 8 | const maxInt = std.math.maxInt; | 8 | const maxInt = std.math.maxInt; |
| 9 | 9 | ||
| 10 | pub usingnamespace @import("posix.zig"); | ||
| 11 | |||
| 10 | pub const blkcnt_t = i64; | 12 | pub const blkcnt_t = i64; |
| 11 | pub const blksize_t = i32; | 13 | pub const blksize_t = i32; |
| 12 | pub const clock_t = u32; | 14 | pub const clock_t = u32; |
lib/std/os/bits/openbsd.zig+2| ... | @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); | ... | @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); |
| 7 | const builtin = std.builtin; | 7 | const builtin = std.builtin; |
| 8 | const maxInt = std.math.maxInt; | 8 | const maxInt = std.math.maxInt; |
| 9 | 9 | ||
| 10 | pub usingnamespace @import("posix.zig"); | ||
| 11 | |||
| 10 | pub const blkcnt_t = i64; | 12 | pub const blkcnt_t = i64; |
| 11 | pub const blksize_t = i32; | 13 | pub const blksize_t = i32; |
| 12 | pub const clock_t = i64; | 14 | pub const clock_t = i64; |
lib/std/os/bits/posix.zig created+34| ... | @@ -0,0 +1,34 @@ | ||
| 1 | // SPDX-License-Identifier: MIT | ||
| 2 | // Copyright (c) 2015-2021 Zig Contributors | ||
| 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 | ||
| 5 | // and substantial portions of the software. | ||
| 6 | |||
| 7 | pub const iovec = extern struct { | ||
| 8 | iov_base: [*]u8, | ||
| 9 | iov_len: usize, | ||
| 10 | }; | ||
| 11 | |||
| 12 | pub const iovec_const = extern struct { | ||
| 13 | iov_base: [*]const u8, | ||
| 14 | iov_len: usize, | ||
| 15 | }; | ||
| 16 | |||
| 17 | // syslog | ||
| 18 | |||
| 19 | /// system is unusable | ||
| 20 | pub const LOG_EMERG = 0; | ||
| 21 | /// action must be taken immediately | ||
| 22 | pub const LOG_ALERT = 1; | ||
| 23 | /// critical conditions | ||
| 24 | pub const LOG_CRIT = 2; | ||
| 25 | /// error conditions | ||
| 26 | pub const LOG_ERR = 3; | ||
| 27 | /// warning conditions | ||
| 28 | pub const LOG_WARNING = 4; | ||
| 29 | /// normal but significant condition | ||
| 30 | pub const LOG_NOTICE = 5; | ||
| 31 | /// informational | ||
| 32 | pub const LOG_INFO = 6; | ||
| 33 | /// debug-level messages | ||
| 34 | pub const LOG_DEBUG = 7; | ||
lib/std/os/bits/wasi.zig+4| ... | @@ -4,6 +4,10 @@ | ... | @@ -4,6 +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 | // Convenience types and consts used by std.os module | 6 | // Convenience types and consts used by std.os module |
| 7 | const posix = @import("posix.zig"); | ||
| 8 | pub const iovec = posix.iovec; | ||
| 9 | pub const iovec_const = posix.iovec_const; | ||
| 10 | |||
| 7 | pub const STDIN_FILENO = 0; | 11 | pub const STDIN_FILENO = 0; |
| 8 | pub const STDOUT_FILENO = 1; | 12 | pub const STDOUT_FILENO = 1; |
| 9 | pub const STDERR_FILENO = 2; | 13 | pub const STDERR_FILENO = 2; |
lib/std/os/bits/windows.zig+5| ... | @@ -8,6 +8,11 @@ | ... | @@ -8,6 +8,11 @@ |
| 8 | usingnamespace @import("../windows/bits.zig"); | 8 | usingnamespace @import("../windows/bits.zig"); |
| 9 | const ws2_32 = @import("../windows/ws2_32.zig"); | 9 | const ws2_32 = @import("../windows/ws2_32.zig"); |
| 10 | 10 | ||
| 11 | // TODO: Stop using os.iovec in std.fs et al on Windows in the future | ||
| 12 | const posix = @import("posix.zig"); | ||
| 13 | pub const iovec = posix.iovec; | ||
| 14 | pub const iovec_const = posix.iovec_const; | ||
| 15 | |||
| 11 | pub const fd_t = HANDLE; | 16 | pub const fd_t = HANDLE; |
| 12 | pub const ino_t = LARGE_INTEGER; | 17 | pub const ino_t = LARGE_INTEGER; |
| 13 | pub const pid_t = HANDLE; | 18 | pub const pid_t = HANDLE; |
lib/std/os/linux/arm-eabi.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 | usingnamespace @import("../bits.zig"); | ||
| 7 | usingnamespace @import("../bits/linux.zig"); | 6 | usingnamespace @import("../bits/linux.zig"); |
| 8 | 7 | ||
| 9 | pub fn syscall0(number: SYS) usize { | 8 | pub fn syscall0(number: SYS) usize { |
lib/std/os/linux/arm64.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 | usingnamespace @import("../bits.zig"); | ||
| 7 | usingnamespace @import("../bits/linux.zig"); | 6 | usingnamespace @import("../bits/linux.zig"); |
| 8 | 7 | ||
| 9 | pub fn syscall0(number: SYS) usize { | 8 | pub fn syscall0(number: SYS) usize { |
lib/std/os/linux/i386.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 | usingnamespace @import("../bits.zig"); | ||
| 7 | usingnamespace @import("../bits/linux.zig"); | 6 | usingnamespace @import("../bits/linux.zig"); |
| 8 | 7 | ||
| 9 | pub fn syscall0(number: SYS) usize { | 8 | pub fn syscall0(number: SYS) usize { |
lib/std/os/linux/mips.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 | usingnamespace @import("../bits.zig"); | ||
| 7 | usingnamespace @import("../bits/linux.zig"); | 6 | usingnamespace @import("../bits/linux.zig"); |
| 8 | 7 | ||
| 9 | pub fn syscall0(number: SYS) usize { | 8 | pub fn syscall0(number: SYS) usize { |
lib/std/os/linux/powerpc.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 | 6 | ||
| 7 | usingnamespace @import("../bits.zig"); | ||
| 8 | usingnamespace @import("../bits/linux.zig"); | 7 | usingnamespace @import("../bits/linux.zig"); |
| 9 | 8 | ||
| 10 | pub fn syscall0(number: SYS) usize { | 9 | pub fn syscall0(number: SYS) usize { |
lib/std/os/linux/powerpc64.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 | 6 | ||
| 7 | usingnamespace @import("../bits.zig"); | ||
| 8 | usingnamespace @import("../bits/linux.zig"); | 7 | usingnamespace @import("../bits/linux.zig"); |
| 9 | 8 | ||
| 10 | pub fn syscall0(number: SYS) usize { | 9 | pub fn syscall0(number: SYS) usize { |
lib/std/os/linux/riscv64.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 | usingnamespace @import("../bits.zig"); | ||
| 7 | usingnamespace @import("../bits/linux.zig"); | 6 | usingnamespace @import("../bits/linux.zig"); |
| 8 | 7 | ||
| 9 | pub fn syscall0(number: SYS) usize { | 8 | pub fn syscall0(number: SYS) usize { |
lib/std/os/linux/sparc64.zig-1| ... | @@ -1,4 +1,3 @@ | ... | @@ -1,4 +1,3 @@ |
| 1 | usingnamespace @import("../bits.zig"); | ||
| 2 | usingnamespace @import("../bits/linux.zig"); | 1 | usingnamespace @import("../bits/linux.zig"); |
| 3 | 2 | ||
| 4 | pub fn syscall_pipe(fd: *[2]i32) usize { | 3 | pub fn syscall_pipe(fd: *[2]i32) usize { |
lib/std/os/linux/thumb.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 | usingnamespace @import("../bits.zig"); | ||
| 7 | usingnamespace @import("../bits/linux.zig"); | 6 | usingnamespace @import("../bits/linux.zig"); |
| 8 | 7 | ||
| 9 | // The syscall interface is identical to the ARM one but we're facing an extra | 8 | // The syscall interface is identical to the ARM one but we're facing an extra |
lib/std/os/linux/x86_64.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 | usingnamespace @import("../bits.zig"); | ||
| 7 | usingnamespace @import("../bits/linux.zig"); | 6 | usingnamespace @import("../bits/linux.zig"); |
| 8 | 7 | ||
| 9 | pub fn syscall0(number: SYS) usize { | 8 | pub fn syscall0(number: SYS) usize { |