mirror of
https://github.com/ziglang/zig.git
synced 2026-02-17 23:10:09 +00:00
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
This commit is contained in:
parent
934df5bd44
commit
871f6343f4
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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"),
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
34
lib/std/os/bits/posix.zig
Normal file
34
lib/std/os/bits/posix.zig
Normal file
@ -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;
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
usingnamespace @import("../bits.zig");
|
||||
usingnamespace @import("../bits/linux.zig");
|
||||
|
||||
pub fn syscall_pipe(fd: *[2]i32) usize {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user