authorgravatar for hannesbredberg@gmail.comN00byEdge <hannesbredberg@gmail.com> 2021-07-30 19:27:41+02:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-08-02 11:05:05+00:00
log871f6343f4d36c5c048f3307e2a38d184e248826
tree26ee969fa8a7238461f0a7a2caeb399f9388bc85
parent934df5bd448e7e27f2142d0d9ceec534f391c7f5

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

21 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};
2626
27pub usingnamespace if (@hasDecl(root, "os") and @hasDecl(root.os, "bits")) root.os.bits else struct {};27pub usingnamespace if (@hasDecl(root, "os") and @hasDecl(root.os, "bits")) root.os.bits else struct {};
28
29pub const iovec = extern struct {
30 iov_base: [*]u8,
31 iov_len: usize,
32};
33
34pub const iovec_const = extern struct {
35 iov_base: [*]const u8,
36 iov_len: usize,
37};
38
39// syslog
40
41/// system is unusable
42pub const LOG_EMERG = 0;
43/// action must be taken immediately
44pub const LOG_ALERT = 1;
45/// critical conditions
46pub const LOG_CRIT = 2;
47/// error conditions
48pub const LOG_ERR = 3;
49/// warning conditions
50pub const LOG_WARNING = 4;
51/// normal but significant condition
52pub const LOG_NOTICE = 5;
53/// informational
54pub const LOG_INFO = 6;
55/// debug-level messages
56pub 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");
7const assert = std.debug.assert;7const assert = std.debug.assert;
8const maxInt = std.math.maxInt;8const maxInt = std.math.maxInt;
99
10pub usingnamespace @import("posix.zig");
11
10// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html12// 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/i3213// TODO: audit mode_t/pid_t, should likely be u16/i32
12pub const fd_t = c_int;14pub const fd_t = c_int;
lib/std/os/bits/dragonfly.zig+2
...@@ -6,6 +6,8 @@...@@ -6,6 +6,8 @@
6const std = @import("../../std.zig");6const std = @import("../../std.zig");
7const maxInt = std.math.maxInt;7const maxInt = std.math.maxInt;
88
9pub usingnamespace @import("posix.zig");
10
9pub fn S_ISCHR(m: u32) bool {11pub 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");
7const builtin = @import("builtin");7const builtin = @import("builtin");
8const maxInt = std.math.maxInt;8const maxInt = std.math.maxInt;
99
10pub usingnamespace @import("posix.zig");
11
10pub const blksize_t = i32;12pub const blksize_t = i32;
11pub const blkcnt_t = i64;13pub const blkcnt_t = i64;
12pub const clockid_t = i32;14pub const clockid_t = i32;
lib/std/os/bits/haiku.zig+2
...@@ -6,6 +6,8 @@...@@ -6,6 +6,8 @@
6const std = @import("../../std.zig");6const std = @import("../../std.zig");
7const maxInt = std.math.maxInt;7const maxInt = std.math.maxInt;
88
9pub usingnamespace @import("posix.zig");
10
9pub const fd_t = c_int;11pub const fd_t = c_int;
10pub const pid_t = c_int;12pub const pid_t = c_int;
11pub const uid_t = u32;13pub const uid_t = u32;
lib/std/os/bits/linux.zig+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6const std = @import("../../std.zig");6const std = @import("../../std.zig");
7const maxInt = std.math.maxInt;7const maxInt = std.math.maxInt;
8const arch = @import("builtin").target.cpu.arch;8const arch = @import("builtin").target.cpu.arch;
9usingnamespace @import("../bits.zig");9pub usingnamespace @import("posix.zig");
1010
11pub usingnamespace switch (arch) {11pub 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");
7const builtin = std.builtin;7const builtin = std.builtin;
8const maxInt = std.math.maxInt;8const maxInt = std.math.maxInt;
99
10pub usingnamespace @import("posix.zig");
11
10pub const blkcnt_t = i64;12pub const blkcnt_t = i64;
11pub const blksize_t = i32;13pub const blksize_t = i32;
12pub const clock_t = u32;14pub 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");
7const builtin = std.builtin;7const builtin = std.builtin;
8const maxInt = std.math.maxInt;8const maxInt = std.math.maxInt;
99
10pub usingnamespace @import("posix.zig");
11
10pub const blkcnt_t = i64;12pub const blkcnt_t = i64;
11pub const blksize_t = i32;13pub const blksize_t = i32;
12pub const clock_t = i64;14pub 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
7pub const iovec = extern struct {
8 iov_base: [*]u8,
9 iov_len: usize,
10};
11
12pub const iovec_const = extern struct {
13 iov_base: [*]const u8,
14 iov_len: usize,
15};
16
17// syslog
18
19/// system is unusable
20pub const LOG_EMERG = 0;
21/// action must be taken immediately
22pub const LOG_ALERT = 1;
23/// critical conditions
24pub const LOG_CRIT = 2;
25/// error conditions
26pub const LOG_ERR = 3;
27/// warning conditions
28pub const LOG_WARNING = 4;
29/// normal but significant condition
30pub const LOG_NOTICE = 5;
31/// informational
32pub const LOG_INFO = 6;
33/// debug-level messages
34pub 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 copies4// 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 module6// Convenience types and consts used by std.os module
7const posix = @import("posix.zig");
8pub const iovec = posix.iovec;
9pub const iovec_const = posix.iovec_const;
10
7pub const STDIN_FILENO = 0;11pub const STDIN_FILENO = 0;
8pub const STDOUT_FILENO = 1;12pub const STDOUT_FILENO = 1;
9pub const STDERR_FILENO = 2;13pub const STDERR_FILENO = 2;
lib/std/os/bits/windows.zig+5
...@@ -8,6 +8,11 @@...@@ -8,6 +8,11 @@
8usingnamespace @import("../windows/bits.zig");8usingnamespace @import("../windows/bits.zig");
9const ws2_32 = @import("../windows/ws2_32.zig");9const ws2_32 = @import("../windows/ws2_32.zig");
1010
11// TODO: Stop using os.iovec in std.fs et al on Windows in the future
12const posix = @import("posix.zig");
13pub const iovec = posix.iovec;
14pub const iovec_const = posix.iovec_const;
15
11pub const fd_t = HANDLE;16pub const fd_t = HANDLE;
12pub const ino_t = LARGE_INTEGER;17pub const ino_t = LARGE_INTEGER;
13pub const pid_t = HANDLE;18pub 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 copies4// 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.
6usingnamespace @import("../bits.zig");
7usingnamespace @import("../bits/linux.zig");6usingnamespace @import("../bits/linux.zig");
87
9pub fn syscall0(number: SYS) usize {8pub 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 copies4// 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.
6usingnamespace @import("../bits.zig");
7usingnamespace @import("../bits/linux.zig");6usingnamespace @import("../bits/linux.zig");
87
9pub fn syscall0(number: SYS) usize {8pub 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 copies4// 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.
6usingnamespace @import("../bits.zig");
7usingnamespace @import("../bits/linux.zig");6usingnamespace @import("../bits/linux.zig");
87
9pub fn syscall0(number: SYS) usize {8pub 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 copies4// 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.
6usingnamespace @import("../bits.zig");
7usingnamespace @import("../bits/linux.zig");6usingnamespace @import("../bits/linux.zig");
87
9pub fn syscall0(number: SYS) usize {8pub 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 copies4// 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.
66
7usingnamespace @import("../bits.zig");
8usingnamespace @import("../bits/linux.zig");7usingnamespace @import("../bits/linux.zig");
98
10pub fn syscall0(number: SYS) usize {9pub 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 copies4// 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.
66
7usingnamespace @import("../bits.zig");
8usingnamespace @import("../bits/linux.zig");7usingnamespace @import("../bits/linux.zig");
98
10pub fn syscall0(number: SYS) usize {9pub 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 copies4// 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.
6usingnamespace @import("../bits.zig");
7usingnamespace @import("../bits/linux.zig");6usingnamespace @import("../bits/linux.zig");
87
9pub fn syscall0(number: SYS) usize {8pub fn syscall0(number: SYS) usize {
lib/std/os/linux/sparc64.zig-1
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1usingnamespace @import("../bits.zig");
2usingnamespace @import("../bits/linux.zig");1usingnamespace @import("../bits/linux.zig");
32
4pub fn syscall_pipe(fd: *[2]i32) usize {3pub 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 copies4// 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.
6usingnamespace @import("../bits.zig");
7usingnamespace @import("../bits/linux.zig");6usingnamespace @import("../bits/linux.zig");
87
9// The syscall interface is identical to the ARM one but we're facing an extra8// 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 copies4// 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.
6usingnamespace @import("../bits.zig");
7usingnamespace @import("../bits/linux.zig");6usingnamespace @import("../bits/linux.zig");
87
9pub fn syscall0(number: SYS) usize {8pub fn syscall0(number: SYS) usize {