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) {
2525};
2626
2727pub 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");
77const assert = std.debug.assert;
88const maxInt = std.math.maxInt;
99
10pub usingnamespace @import("posix.zig");
11
1012// See: https://opensource.apple.com/source/xnu/xnu-6153.141.1/bsd/sys/_types.h.auto.html
1113// TODO: audit mode_t/pid_t, should likely be u16/i32
1214pub const fd_t = c_int;
lib/std/os/bits/dragonfly.zig+2
......@@ -6,6 +6,8 @@
66const std = @import("../../std.zig");
77const maxInt = std.math.maxInt;
88
9pub usingnamespace @import("posix.zig");
10
911pub fn S_ISCHR(m: u32) bool {
1012 return m & S_IFMT == S_IFCHR;
1113}
lib/std/os/bits/freebsd.zig+2
......@@ -7,6 +7,8 @@ const std = @import("../../std.zig");
77const builtin = @import("builtin");
88const maxInt = std.math.maxInt;
99
10pub usingnamespace @import("posix.zig");
11
1012pub const blksize_t = i32;
1113pub const blkcnt_t = i64;
1214pub const clockid_t = i32;
lib/std/os/bits/haiku.zig+2
......@@ -6,6 +6,8 @@
66const std = @import("../../std.zig");
77const maxInt = std.math.maxInt;
88
9pub usingnamespace @import("posix.zig");
10
911pub const fd_t = c_int;
1012pub const pid_t = c_int;
1113pub const uid_t = u32;
lib/std/os/bits/linux.zig+1-1
......@@ -6,7 +6,7 @@
66const std = @import("../../std.zig");
77const maxInt = std.math.maxInt;
88const arch = @import("builtin").target.cpu.arch;
9usingnamespace @import("../bits.zig");
9pub usingnamespace @import("posix.zig");
1010
1111pub usingnamespace switch (arch) {
1212 .mips, .mipsel => @import("linux/errno-mips.zig"),
lib/std/os/bits/netbsd.zig+2
......@@ -7,6 +7,8 @@ const std = @import("../../std.zig");
77const builtin = std.builtin;
88const maxInt = std.math.maxInt;
99
10pub usingnamespace @import("posix.zig");
11
1012pub const blkcnt_t = i64;
1113pub const blksize_t = i32;
1214pub const clock_t = u32;
lib/std/os/bits/openbsd.zig+2
......@@ -7,6 +7,8 @@ const std = @import("../../std.zig");
77const builtin = std.builtin;
88const maxInt = std.math.maxInt;
99
10pub usingnamespace @import("posix.zig");
11
1012pub const blkcnt_t = i64;
1113pub const blksize_t = i32;
1214pub 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 @@
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
66// 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
711pub const STDIN_FILENO = 0;
812pub const STDOUT_FILENO = 1;
913pub const STDERR_FILENO = 2;
lib/std/os/bits/windows.zig+5
......@@ -8,6 +8,11 @@
88usingnamespace @import("../windows/bits.zig");
99const 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
1116pub const fd_t = HANDLE;
1217pub const ino_t = LARGE_INTEGER;
1318pub const pid_t = HANDLE;
lib/std/os/linux/arm-eabi.zig-1
......@@ -3,7 +3,6 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6usingnamespace @import("../bits.zig");
76usingnamespace @import("../bits/linux.zig");
87
98pub fn syscall0(number: SYS) usize {
lib/std/os/linux/arm64.zig-1
......@@ -3,7 +3,6 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6usingnamespace @import("../bits.zig");
76usingnamespace @import("../bits/linux.zig");
87
98pub fn syscall0(number: SYS) usize {
lib/std/os/linux/i386.zig-1
......@@ -3,7 +3,6 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6usingnamespace @import("../bits.zig");
76usingnamespace @import("../bits/linux.zig");
87
98pub fn syscall0(number: SYS) usize {
lib/std/os/linux/mips.zig-1
......@@ -3,7 +3,6 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6usingnamespace @import("../bits.zig");
76usingnamespace @import("../bits/linux.zig");
87
98pub fn syscall0(number: SYS) usize {
lib/std/os/linux/powerpc.zig-1
......@@ -4,7 +4,6 @@
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
66
7usingnamespace @import("../bits.zig");
87usingnamespace @import("../bits/linux.zig");
98
109pub fn syscall0(number: SYS) usize {
lib/std/os/linux/powerpc64.zig-1
......@@ -4,7 +4,6 @@
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
66
7usingnamespace @import("../bits.zig");
87usingnamespace @import("../bits/linux.zig");
98
109pub fn syscall0(number: SYS) usize {
lib/std/os/linux/riscv64.zig-1
......@@ -3,7 +3,6 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6usingnamespace @import("../bits.zig");
76usingnamespace @import("../bits/linux.zig");
87
98pub fn syscall0(number: SYS) usize {
lib/std/os/linux/sparc64.zig-1
......@@ -1,4 +1,3 @@
1usingnamespace @import("../bits.zig");
21usingnamespace @import("../bits/linux.zig");
32
43pub fn syscall_pipe(fd: *[2]i32) usize {
lib/std/os/linux/thumb.zig-1
......@@ -3,7 +3,6 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6usingnamespace @import("../bits.zig");
76usingnamespace @import("../bits/linux.zig");
87
98// 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 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6usingnamespace @import("../bits.zig");
76usingnamespace @import("../bits/linux.zig");
87
98pub fn syscall0(number: SYS) usize {