diff options
| author | N00byEdge <hannesbredberg@gmail.com> | 2021-07-30 19:27:41 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2021-08-02 11:05:05 +0000 |
| commit | 871f6343f4d36c5c048f3307e2a38d184e248826 (patch) | |
| tree | 26ee969fa8a7238461f0a7a2caeb399f9388bc85 /lib | |
| parent | 934df5bd448e7e27f2142d0d9ceec534f391c7f5 (diff) | |
| download | zig-871f6343f4d36c5c048f3307e2a38d184e248826.tar.gz zig-871f6343f4d36c5c048f3307e2a38d184e248826.zip | |
Move iovec and log levels to bits/posix.zig
This lets only the OSes that uses them to import them, and removes
dependencies on bits.zig for the os/<os>/<arch>.zig files
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/os/bits.zig | 29 | ||||
| -rw-r--r-- | lib/std/os/bits/darwin.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/bits/dragonfly.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/bits/freebsd.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/bits/haiku.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/bits/linux.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/bits/netbsd.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/bits/openbsd.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/bits/posix.zig | 34 | ||||
| -rw-r--r-- | lib/std/os/bits/wasi.zig | 4 | ||||
| -rw-r--r-- | lib/std/os/bits/windows.zig | 5 | ||||
| -rw-r--r-- | lib/std/os/linux/arm-eabi.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/arm64.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/i386.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/mips.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/powerpc.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/powerpc64.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/riscv64.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/sparc64.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/thumb.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/x86_64.zig | 1 |
21 files changed, 56 insertions, 40 deletions
diff --git a/lib/std/os/bits.zig b/lib/std/os/bits.zig index 5d1de28bad..5c39609182 100644 --- a/lib/std/os/bits.zig +++ b/lib/std/os/bits.zig @@ -25,32 +25,3 @@ pub usingnamespace switch (std.Target.current.os.tag) { }; pub usingnamespace if (@hasDecl(root, "os") and @hasDecl(root.os, "bits")) root.os.bits else struct {}; - -pub const iovec = extern struct { - iov_base: [*]u8, - iov_len: usize, -}; - -pub const iovec_const = extern struct { - iov_base: [*]const u8, - iov_len: usize, -}; - -// syslog - -/// system is unusable -pub const LOG_EMERG = 0; -/// action must be taken immediately -pub const LOG_ALERT = 1; -/// critical conditions -pub const LOG_CRIT = 2; -/// error conditions -pub const LOG_ERR = 3; -/// warning conditions -pub const LOG_WARNING = 4; -/// normal but significant condition -pub const LOG_NOTICE = 5; -/// informational -pub const LOG_INFO = 6; -/// debug-level messages -pub const LOG_DEBUG = 7; diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig index be77722c05..91705c0d2e 100644 --- a/lib/std/os/bits/darwin.zig +++ b/lib/std/os/bits/darwin.zig @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); const assert = std.debug.assert; const maxInt = std.math.maxInt; +pub usingnamespace @import("posix.zig"); + // See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html // TODO: audit mode_t/pid_t, should likely be u16/i32 pub const fd_t = c_int; diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig index 9f6d3088ba..573721749c 100644 --- a/lib/std/os/bits/dragonfly.zig +++ b/lib/std/os/bits/dragonfly.zig @@ -6,6 +6,8 @@ const std = @import("../../std.zig"); const maxInt = std.math.maxInt; +pub usingnamespace @import("posix.zig"); + pub fn S_ISCHR(m: u32) bool { return m & S_IFMT == S_IFCHR; } diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig index 6d227a168a..1805941993 100644 --- a/lib/std/os/bits/freebsd.zig +++ b/lib/std/os/bits/freebsd.zig @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); const builtin = @import("builtin"); const maxInt = std.math.maxInt; +pub usingnamespace @import("posix.zig"); + pub const blksize_t = i32; pub const blkcnt_t = i64; pub const clockid_t = i32; diff --git a/lib/std/os/bits/haiku.zig b/lib/std/os/bits/haiku.zig index cb31166608..b3ea4aa0e2 100644 --- a/lib/std/os/bits/haiku.zig +++ b/lib/std/os/bits/haiku.zig @@ -6,6 +6,8 @@ const std = @import("../../std.zig"); const maxInt = std.math.maxInt; +pub usingnamespace @import("posix.zig"); + pub const fd_t = c_int; pub const pid_t = c_int; pub const uid_t = u32; diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index 81bdfa6608..28683d47a9 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -6,7 +6,7 @@ const std = @import("../../std.zig"); const maxInt = std.math.maxInt; const arch = @import("builtin").target.cpu.arch; -usingnamespace @import("../bits.zig"); +pub usingnamespace @import("posix.zig"); pub usingnamespace switch (arch) { .mips, .mipsel => @import("linux/errno-mips.zig"), diff --git a/lib/std/os/bits/netbsd.zig b/lib/std/os/bits/netbsd.zig index d0240709e3..f3ece93493 100644 --- a/lib/std/os/bits/netbsd.zig +++ b/lib/std/os/bits/netbsd.zig @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); const builtin = std.builtin; const maxInt = std.math.maxInt; +pub usingnamespace @import("posix.zig"); + pub const blkcnt_t = i64; pub const blksize_t = i32; pub const clock_t = u32; diff --git a/lib/std/os/bits/openbsd.zig b/lib/std/os/bits/openbsd.zig index 3b9f8ccd4a..233ebcbd68 100644 --- a/lib/std/os/bits/openbsd.zig +++ b/lib/std/os/bits/openbsd.zig @@ -7,6 +7,8 @@ const std = @import("../../std.zig"); const builtin = std.builtin; const maxInt = std.math.maxInt; +pub usingnamespace @import("posix.zig"); + pub const blkcnt_t = i64; pub const blksize_t = i32; pub const clock_t = i64; diff --git a/lib/std/os/bits/posix.zig b/lib/std/os/bits/posix.zig new file mode 100644 index 0000000000..0f015cd573 --- /dev/null +++ b/lib/std/os/bits/posix.zig @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +pub const iovec = extern struct { + iov_base: [*]u8, + iov_len: usize, +}; + +pub const iovec_const = extern struct { + iov_base: [*]const u8, + iov_len: usize, +}; + +// syslog + +/// system is unusable +pub const LOG_EMERG = 0; +/// action must be taken immediately +pub const LOG_ALERT = 1; +/// critical conditions +pub const LOG_CRIT = 2; +/// error conditions +pub const LOG_ERR = 3; +/// warning conditions +pub const LOG_WARNING = 4; +/// normal but significant condition +pub const LOG_NOTICE = 5; +/// informational +pub const LOG_INFO = 6; +/// debug-level messages +pub const LOG_DEBUG = 7; diff --git a/lib/std/os/bits/wasi.zig b/lib/std/os/bits/wasi.zig index 8b2f5c3351..5cb1334037 100644 --- a/lib/std/os/bits/wasi.zig +++ b/lib/std/os/bits/wasi.zig @@ -4,6 +4,10 @@ // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. // Convenience types and consts used by std.os module +const posix = @import("posix.zig"); +pub const iovec = posix.iovec; +pub const iovec_const = posix.iovec_const; + pub const STDIN_FILENO = 0; pub const STDOUT_FILENO = 1; pub const STDERR_FILENO = 2; diff --git a/lib/std/os/bits/windows.zig b/lib/std/os/bits/windows.zig index c5b101296b..05c50ffe47 100644 --- a/lib/std/os/bits/windows.zig +++ b/lib/std/os/bits/windows.zig @@ -8,6 +8,11 @@ usingnamespace @import("../windows/bits.zig"); const ws2_32 = @import("../windows/ws2_32.zig"); +// TODO: Stop using os.iovec in std.fs et al on Windows in the future +const posix = @import("posix.zig"); +pub const iovec = posix.iovec; +pub const iovec_const = posix.iovec_const; + pub const fd_t = HANDLE; pub const ino_t = LARGE_INTEGER; pub const pid_t = HANDLE; diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig index 0fe74c9665..469b7299d1 100644 --- a/lib/std/os/linux/arm-eabi.zig +++ b/lib/std/os/linux/arm-eabi.zig @@ -3,7 +3,6 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall0(number: SYS) usize { diff --git a/lib/std/os/linux/arm64.zig b/lib/std/os/linux/arm64.zig index 0e1af98493..4c8306c048 100644 --- a/lib/std/os/linux/arm64.zig +++ b/lib/std/os/linux/arm64.zig @@ -3,7 +3,6 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall0(number: SYS) usize { diff --git a/lib/std/os/linux/i386.zig b/lib/std/os/linux/i386.zig index df58336eb0..2ec34bac40 100644 --- a/lib/std/os/linux/i386.zig +++ b/lib/std/os/linux/i386.zig @@ -3,7 +3,6 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall0(number: SYS) usize { diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig index 2ac029cae8..85157f04f8 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -3,7 +3,6 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall0(number: SYS) usize { diff --git a/lib/std/os/linux/powerpc.zig b/lib/std/os/linux/powerpc.zig index 341eb3f920..611eee1c5f 100644 --- a/lib/std/os/linux/powerpc.zig +++ b/lib/std/os/linux/powerpc.zig @@ -4,7 +4,6 @@ // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall0(number: SYS) usize { diff --git a/lib/std/os/linux/powerpc64.zig b/lib/std/os/linux/powerpc64.zig index 341eb3f920..611eee1c5f 100644 --- a/lib/std/os/linux/powerpc64.zig +++ b/lib/std/os/linux/powerpc64.zig @@ -4,7 +4,6 @@ // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall0(number: SYS) usize { diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig index cab2ecfbaf..3e2b15b599 100644 --- a/lib/std/os/linux/riscv64.zig +++ b/lib/std/os/linux/riscv64.zig @@ -3,7 +3,6 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall0(number: SYS) usize { diff --git a/lib/std/os/linux/sparc64.zig b/lib/std/os/linux/sparc64.zig index cbe5ee3b70..f347a0e88e 100644 --- a/lib/std/os/linux/sparc64.zig +++ b/lib/std/os/linux/sparc64.zig @@ -1,4 +1,3 @@ -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall_pipe(fd: *[2]i32) usize { diff --git a/lib/std/os/linux/thumb.zig b/lib/std/os/linux/thumb.zig index 955c3420d4..85f8bfc52b 100644 --- a/lib/std/os/linux/thumb.zig +++ b/lib/std/os/linux/thumb.zig @@ -3,7 +3,6 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); // The syscall interface is identical to the ARM one but we're facing an extra diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig index da4206a521..5aa32c56c3 100644 --- a/lib/std/os/linux/x86_64.zig +++ b/lib/std/os/linux/x86_64.zig @@ -3,7 +3,6 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -usingnamespace @import("../bits.zig"); usingnamespace @import("../bits/linux.zig"); pub fn syscall0(number: SYS) usize { |
