diff --git a/lib/std/os/bits.zig b/lib/std/os/bits.zig index 5d1de28badff951dccdaf405bf8beefaae609abb..5c396091825f358816ad0a0c99e96dd5a94c455b 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 be77722c05780e21873c830689835bd7e6a0f0d3..91705c0d2e44561d81e9049b1639ec41ca4def7f 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 9f6d3088baf5a531cbb752ebfcd575f91ee0d2d7..573721749cd5f167ca81efe612b207afad704366 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 6d227a168a7ed95f42018acbc86d38a7505b4ece..1805941993943c6dbef53fe710ede0f55dcdf472 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 cb31166608e9e4bc6d9b7fa367f03a0f181d5b90..b3ea4aa0e2236e101e2eab99522edae9e6449342 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 81bdfa6608cd6cb001608a4af58b2ce3aef6f41b..28683d47a96f836a54d6354a80e756eb19ca1c77 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 d0240709e3dd110aa15efdd9257639d73247f0bc..f3ece9349334ea529a953b9785e41c66e01151ab 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 3b9f8ccd4aaf40f5052af1f0f43835c0d4a352c9..233ebcbd684b78f7cb9f359753217b56f85d2ae5 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 0000000000000000000000000000000000000000..0f015cd57356c62a2943fd944e631837c13c5f1d --- /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 8b2f5c3351a552c4d5a21a31a7f27bf7fc872b72..5cb133403791b670edc9d3a5f9c2e94404e3f4aa 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 c5b101296bffe199184155b5fd3fc06d5bedadf9..05c50ffe475de3a455b9b98d108c1bdf09e154be 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 0fe74c966520aa7b899b7871250f90e17cd8c503..469b7299d194c3a720ce03acb5c60ca90879ba1a 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 0e1af984934435aa53fe9d38df41aa3f03b8ce93..4c8306c048d980dafefebc1254eb4742c7c478f3 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 df58336eb0da87694c789e0c77fcbfb930fef84c..2ec34bac40f2547c481282bc774427afe3f84ac4 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 2ac029cae8283e3673e79390097dce8d0f5d65a3..85157f04f865f39d14068c7c67fc6a88c80f7db7 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 341eb3f920a775f10791d5b13b4e016fa4b3a58b..611eee1c5f0bd8257d35f0004028379a0b677a53 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 341eb3f920a775f10791d5b13b4e016fa4b3a58b..611eee1c5f0bd8257d35f0004028379a0b677a53 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 cab2ecfbafd973a96e9399f2411d9974eb3d9bf0..3e2b15b599c016cb506c94e38836830805451e14 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 cbe5ee3b704658ccc199c762e52d4921e809b13d..f347a0e88e71b4146037d351ca9dd480dd6c62e8 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 955c3420d431d589cf5f04113a9226a17dcb4b05..85f8bfc52b41c7f3dc2c8889767fc0a5d7f106d2 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 da4206a521354c4bc16247b340dab90ebbdeffd5..5aa32c56c3023da92bb55c876329ca3e237f2188 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 {