From 7f03cfe161a2f7b5abbd00ab1ea29ddd6190d435 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 25 Aug 2021 00:00:39 -0700 Subject: std.os: more reorganization efforts * std lib tests are passing on x86_64-linux with and without -lc * stage2 is building from source on x86_64-linux * down to 38 remaining uses of `usingnamespace` --- lib/std/Thread.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/std/Thread.zig') diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index e322485037..155e057a3f 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -877,8 +877,8 @@ const LinuxThreadImpl = struct { const mapped = os.mmap( null, map_bytes, - os.PROT_NONE, - os.MAP_PRIVATE | os.MAP_ANONYMOUS, + os.PROT.NONE, + os.MAP.PRIVATE | os.MAP.ANONYMOUS, -1, 0, ) catch |err| switch (err) { @@ -893,7 +893,7 @@ const LinuxThreadImpl = struct { // map everything but the guard page as read/write os.mprotect( mapped[guard_offset..], - os.PROT_READ | os.PROT_WRITE, + os.PROT.READ | os.PROT.WRITE, ) catch |err| switch (err) { error.AccessDenied => unreachable, else => |e| return e, @@ -923,10 +923,10 @@ const LinuxThreadImpl = struct { .thread = .{ .mapped = mapped }, }; - const flags: u32 = os.CLONE_THREAD | os.CLONE_DETACHED | - os.CLONE_VM | os.CLONE_FS | os.CLONE_FILES | - os.CLONE_PARENT_SETTID | os.CLONE_CHILD_CLEARTID | - os.CLONE_SIGHAND | os.CLONE_SYSVSEM | os.CLONE_SETTLS; + const flags: u32 = linux.CLONE.THREAD | linux.CLONE.DETACHED | + linux.CLONE.VM | linux.CLONE.FS | linux.CLONE.FILES | + linux.CLONE.PARENT_SETTID | linux.CLONE.CHILD_CLEARTID | + linux.CLONE.SIGHAND | linux.CLONE.SYSVSEM | linux.CLONE.SETTLS; switch (linux.getErrno(linux.clone( Instance.entryFn, @@ -978,7 +978,7 @@ const LinuxThreadImpl = struct { switch (linux.getErrno(linux.futex_wait( &self.thread.child_tid.value, - linux.FUTEX_WAIT, + linux.FUTEX.WAIT, tid, null, ))) { -- cgit v1.2.3 From f8dd4b13d6fe428265229fc1e31c2f8b0cd373b1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 31 Aug 2021 18:24:59 -0700 Subject: std.os reorg: more fixes caught by CI --- lib/std/Thread.zig | 2 +- lib/std/c/dragonfly.zig | 132 +++++++++++---------- lib/std/c/freebsd.zig | 54 +++++---- lib/std/c/haiku.zig | 12 +- lib/std/c/netbsd.zig | 16 ++- lib/std/c/openbsd.zig | 231 ++++++++++++++++++------------------ lib/std/fs.zig | 6 +- lib/std/os.zig | 3 + lib/std/zig/system.zig | 4 +- lib/std/zig/system/darwin/macos.zig | 4 +- src/main.zig | 2 +- 11 files changed, 244 insertions(+), 222 deletions(-) (limited to 'lib/std/Thread.zig') diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 155e057a3f..ac38e5b4c6 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -558,7 +558,7 @@ const PosixThreadImpl = struct { .openbsd => { var count: c_int = undefined; var count_size: usize = @sizeOf(c_int); - const mib = [_]c_int{ os.CTL_HW, os.HW_NCPUONLINE }; + const mib = [_]c_int{ os.CTL.HW, os.HW_NCPUONLINE }; os.sysctl(&mib, &count, &count_size, null, 0) catch |err| switch (err) { error.NameTooLong, error.UnknownName => unreachable, else => |e| return e, diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig index d2356dbf2c..ca9a8b847f 100644 --- a/lib/std/c/dragonfly.zig +++ b/lib/std/c/dragonfly.zig @@ -221,7 +221,7 @@ pub const SA = struct { }; pub const PATH_MAX = 1024; -pub const IOV_MAX = KERN_IOV_MAX; +pub const IOV_MAX = KERN.IOV_MAX; pub const ino_t = c_ulong; @@ -270,69 +270,73 @@ pub const timeval = extern struct { tv_usec: suseconds_t, }; -pub const CTL_UNSPEC = 0; -pub const CTL_KERN = 1; -pub const CTL_VM = 2; -pub const CTL_VFS = 3; -pub const CTL_NET = 4; -pub const CTL_DEBUG = 5; -pub const CTL_HW = 6; -pub const CTL_MACHDEP = 7; -pub const CTL_USER = 8; -pub const CTL_LWKT = 10; -pub const CTL_MAXID = 11; -pub const CTL_MAXNAME = 12; - -pub const KERN_PROC_ALL = 0; -pub const KERN_OSTYPE = 1; -pub const KERN_PROC_PID = 1; -pub const KERN_OSRELEASE = 2; -pub const KERN_PROC_PGRP = 2; -pub const KERN_OSREV = 3; -pub const KERN_PROC_SESSION = 3; -pub const KERN_VERSION = 4; -pub const KERN_PROC_TTY = 4; -pub const KERN_MAXVNODES = 5; -pub const KERN_PROC_UID = 5; -pub const KERN_MAXPROC = 6; -pub const KERN_PROC_RUID = 6; -pub const KERN_MAXFILES = 7; -pub const KERN_PROC_ARGS = 7; -pub const KERN_ARGMAX = 8; -pub const KERN_PROC_CWD = 8; -pub const KERN_PROC_PATHNAME = 9; -pub const KERN_SECURELVL = 9; -pub const KERN_PROC_SIGTRAMP = 10; -pub const KERN_HOSTNAME = 10; -pub const KERN_HOSTID = 11; -pub const KERN_CLOCKRATE = 12; -pub const KERN_VNODE = 13; -pub const KERN_PROC = 14; -pub const KERN_FILE = 15; -pub const KERN_PROC_FLAGMASK = 16; -pub const KERN_PROF = 16; -pub const KERN_PROC_FLAG_LWP = 16; -pub const KERN_POSIX1 = 17; -pub const KERN_NGROUPS = 18; -pub const KERN_JOB_CONTROL = 19; -pub const KERN_SAVED_IDS = 20; -pub const KERN_BOOTTIME = 21; -pub const KERN_NISDOMAINNAME = 22; -pub const KERN_UPDATEINTERVAL = 23; -pub const KERN_OSRELDATE = 24; -pub const KERN_NTP_PLL = 25; -pub const KERN_BOOTFILE = 26; -pub const KERN_MAXFILESPERPROC = 27; -pub const KERN_MAXPROCPERUID = 28; -pub const KERN_DUMPDEV = 29; -pub const KERN_IPC = 30; -pub const KERN_DUMMY = 31; -pub const KERN_PS_STRINGS = 32; -pub const KERN_USRSTACK = 33; -pub const KERN_LOGSIGEXIT = 34; -pub const KERN_IOV_MAX = 35; -pub const KERN_MAXPOSIXLOCKSPERUID = 36; -pub const KERN_MAXID = 37; +pub const CTL = struct { + pub const UNSPEC = 0; + pub const KERN = 1; + pub const VM = 2; + pub const VFS = 3; + pub const NET = 4; + pub const DEBUG = 5; + pub const HW = 6; + pub const MACHDEP = 7; + pub const USER = 8; + pub const LWKT = 10; + pub const MAXID = 11; + pub const MAXNAME = 12; +}; + +pub const KERN = struct { + pub const PROC_ALL = 0; + pub const OSTYPE = 1; + pub const PROC_PID = 1; + pub const OSRELEASE = 2; + pub const PROC_PGRP = 2; + pub const OSREV = 3; + pub const PROC_SESSION = 3; + pub const VERSION = 4; + pub const PROC_TTY = 4; + pub const MAXVNODES = 5; + pub const PROC_UID = 5; + pub const MAXPROC = 6; + pub const PROC_RUID = 6; + pub const MAXFILES = 7; + pub const PROC_ARGS = 7; + pub const ARGMAX = 8; + pub const PROC_CWD = 8; + pub const PROC_PATHNAME = 9; + pub const SECURELVL = 9; + pub const PROC_SIGTRAMP = 10; + pub const HOSTNAME = 10; + pub const HOSTID = 11; + pub const CLOCKRATE = 12; + pub const VNODE = 13; + pub const PROC = 14; + pub const FILE = 15; + pub const PROC_FLAGMASK = 16; + pub const PROF = 16; + pub const PROC_FLAG_LWP = 16; + pub const POSIX1 = 17; + pub const NGROUPS = 18; + pub const JOB_CONTROL = 19; + pub const SAVED_IDS = 20; + pub const BOOTTIME = 21; + pub const NISDOMAINNAME = 22; + pub const UPDATEINTERVAL = 23; + pub const OSRELDATE = 24; + pub const NTP_PLL = 25; + pub const BOOTFILE = 26; + pub const MAXFILESPERPROC = 27; + pub const MAXPROCPERUID = 28; + pub const DUMPDEV = 29; + pub const IPC = 30; + pub const DUMMY = 31; + pub const PS_STRINGS = 32; + pub const USRSTACK = 33; + pub const LOGSIGEXIT = 34; + pub const IOV_MAX = 35; + pub const MAXPOSIXLOCKSPERUID = 36; + pub const MAXID = 37; +}; pub const HOST_NAME_MAX = 255; diff --git a/lib/std/c/freebsd.zig b/lib/std/c/freebsd.zig index 5ffc92e53a..1d0812ccd4 100644 --- a/lib/std/c/freebsd.zig +++ b/lib/std/c/freebsd.zig @@ -349,15 +349,19 @@ pub const sockaddr = extern struct { }; }; -pub const CTL_KERN = 1; -pub const CTL_DEBUG = 5; +pub const CTL = struct { + pub const KERN = 1; + pub const DEBUG = 5; +}; -pub const KERN_PROC = 14; // struct: process entries -pub const KERN_PROC_PATHNAME = 12; // path to executable -pub const KERN_IOV_MAX = 35; +pub const KERN = struct { + pub const PROC = 14; // struct: process entries + pub const PROC_PATHNAME = 12; // path to executable + pub const IOV_MAX = 35; +}; pub const PATH_MAX = 1024; -pub const IOV_MAX = KERN_IOV_MAX; +pub const IOV_MAX = KERN.IOV_MAX; pub const STDIN_FILENO = 0; pub const STDOUT_FILENO = 1; @@ -413,6 +417,25 @@ pub const W = struct { pub const NOWAIT = 8; pub const EXITED = 16; pub const TRAPPED = 32; + + pub fn EXITSTATUS(s: u32) u8 { + return @intCast(u8, (s & 0xff00) >> 8); + } + pub fn TERMSIG(s: u32) u32 { + return s & 0x7f; + } + pub fn STOPSIG(s: u32) u32 { + return EXITSTATUS(s); + } + pub fn IFEXITED(s: u32) bool { + return TERMSIG(s) == 0; + } + pub fn IFSTOPPED(s: u32) bool { + return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; + } + pub fn IFSIGNALED(s: u32) bool { + return (s & 0xffff) -% 1 < 0xff; + } }; pub const SA = struct { @@ -913,25 +936,6 @@ pub const T = struct { pub const IOCSIG = 0x2004745f; }; -pub fn WEXITSTATUS(s: u32) u8 { - return @intCast(u8, (s & 0xff00) >> 8); -} -pub fn WTERMSIG(s: u32) u32 { - return s & 0x7f; -} -pub fn WSTOPSIG(s: u32) u32 { - return WEXITSTATUS(s); -} -pub fn WIFEXITED(s: u32) bool { - return WTERMSIG(s) == 0; -} -pub fn WIFSTOPPED(s: u32) bool { - return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; -} -pub fn WIFSIGNALED(s: u32) bool { - return (s & 0xffff) -% 1 < 0xff; -} - pub const winsize = extern struct { ws_row: u16, ws_col: u16, diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig index b708d235a9..38875d29f9 100644 --- a/lib/std/c/haiku.zig +++ b/lib/std/c/haiku.zig @@ -365,11 +365,15 @@ pub const sockaddr = extern struct { }; }; -pub const CTL_KERN = 1; -pub const CTL_DEBUG = 5; +pub const CTL = struct { + pub const KERN = 1; + pub const DEBUG = 5; +}; -pub const KERN_PROC = 14; // struct: process entries -pub const KERN_PROC_PATHNAME = 12; // path to executable +pub const KERN = struct { + pub const PROC = 14; // struct: process entries + pub const PROC_PATHNAME = 12; // path to executable +}; pub const PATH_MAX = 1024; diff --git a/lib/std/c/netbsd.zig b/lib/std/c/netbsd.zig index 9dedf0997c..d85c8c41b7 100644 --- a/lib/std/c/netbsd.zig +++ b/lib/std/c/netbsd.zig @@ -520,15 +520,19 @@ pub const AI = struct { pub const ADDRCONFIG = 0x00000400; }; -pub const CTL_KERN = 1; -pub const CTL_DEBUG = 5; +pub const CTL = struct { + pub const KERN = 1; + pub const DEBUG = 5; +}; -pub const KERN_PROC_ARGS = 48; // struct: process argv/env -pub const KERN_PROC_PATHNAME = 5; // path to executable -pub const KERN_IOV_MAX = 38; +pub const KERN = struct { + pub const PROC_ARGS = 48; // struct: process argv/env + pub const PROC_PATHNAME = 5; // path to executable + pub const IOV_MAX = 38; +}; pub const PATH_MAX = 1024; -pub const IOV_MAX = KERN_IOV_MAX; +pub const IOV_MAX = KERN.IOV_MAX; pub const STDIN_FILENO = 0; pub const STDOUT_FILENO = 1; diff --git a/lib/std/c/openbsd.zig b/lib/std/c/openbsd.zig index 0ff7b904bd..fb8738d737 100644 --- a/lib/std/c/openbsd.zig +++ b/lib/std/c/openbsd.zig @@ -1215,105 +1215,123 @@ pub const POLL = struct { pub const WRBAND = 0x0100; }; -// sysctl mib -pub const CTL_UNSPEC = 0; -pub const CTL_KERN = 1; -pub const CTL_VM = 2; -pub const CTL_FS = 3; -pub const CTL_NET = 4; -pub const CTL_DEBUG = 5; -pub const CTL_HW = 6; -pub const CTL_MACHDEP = 7; - -pub const CTL_DDB = 9; -pub const CTL_VFS = 10; - -pub const KERN_OSTYPE = 1; -pub const KERN_OSRELEASE = 2; -pub const KERN_OSREV = 3; -pub const KERN_VERSION = 4; -pub const KERN_MAXVNODES = 5; -pub const KERN_MAXPROC = 6; -pub const KERN_MAXFILES = 7; -pub const KERN_ARGMAX = 8; -pub const KERN_SECURELVL = 9; -pub const KERN_HOSTNAME = 10; -pub const KERN_HOSTID = 11; -pub const KERN_CLOCKRATE = 12; - -pub const KERN_PROF = 16; -pub const KERN_POSIX1 = 17; -pub const KERN_NGROUPS = 18; -pub const KERN_JOB_CONTROL = 19; -pub const KERN_SAVED_IDS = 20; -pub const KERN_BOOTTIME = 21; -pub const KERN_DOMAINNAME = 22; -pub const KERN_MAXPARTITIONS = 23; -pub const KERN_RAWPARTITION = 24; -pub const KERN_MAXTHREAD = 25; -pub const KERN_NTHREADS = 26; -pub const KERN_OSVERSION = 27; -pub const KERN_SOMAXCONN = 28; -pub const KERN_SOMINCONN = 29; - -pub const KERN_NOSUIDCOREDUMP = 32; -pub const KERN_FSYNC = 33; -pub const KERN_SYSVMSG = 34; -pub const KERN_SYSVSEM = 35; -pub const KERN_SYSVSHM = 36; - -pub const KERN_MSGBUFSIZE = 38; -pub const KERN_MALLOCSTATS = 39; -pub const KERN_CPTIME = 40; -pub const KERN_NCHSTATS = 41; -pub const KERN_FORKSTAT = 42; -pub const KERN_NSELCOLL = 43; -pub const KERN_TTY = 44; -pub const KERN_CCPU = 45; -pub const KERN_FSCALE = 46; -pub const KERN_NPROCS = 47; -pub const KERN_MSGBUF = 48; -pub const KERN_POOL = 49; -pub const KERN_STACKGAPRANDOM = 50; -pub const KERN_SYSVIPC_INFO = 51; -pub const KERN_ALLOWKMEM = 52; -pub const KERN_WITNESSWATCH = 53; -pub const KERN_SPLASSERT = 54; -pub const KERN_PROC_ARGS = 55; -pub const KERN_NFILES = 56; -pub const KERN_TTYCOUNT = 57; -pub const KERN_NUMVNODES = 58; -pub const KERN_MBSTAT = 59; -pub const KERN_WITNESS = 60; -pub const KERN_SEMINFO = 61; -pub const KERN_SHMINFO = 62; -pub const KERN_INTRCNT = 63; -pub const KERN_WATCHDOG = 64; -pub const KERN_ALLOWDT = 65; -pub const KERN_PROC = 66; -pub const KERN_MAXCLUSTERS = 67; -pub const KERN_EVCOUNT = 68; -pub const KERN_TIMECOUNTER = 69; -pub const KERN_MAXLOCKSPERUID = 70; -pub const KERN_CPTIME2 = 71; -pub const KERN_CACHEPCT = 72; -pub const KERN_FILE = 73; -pub const KERN_WXABORT = 74; -pub const KERN_CONSDEV = 75; -pub const KERN_NETLIVELOCKS = 76; -pub const KERN_POOL_DEBUG = 77; -pub const KERN_PROC_CWD = 78; -pub const KERN_PROC_NOBROADCASTKILL = 79; -pub const KERN_PROC_VMMAP = 80; -pub const KERN_GLOBAL_PTRACE = 81; -pub const KERN_CONSBUFSIZE = 82; -pub const KERN_CONSBUF = 83; -pub const KERN_AUDIO = 84; -pub const KERN_CPUSTATS = 85; -pub const KERN_PFSTATUS = 86; -pub const KERN_TIMEOUT_STATS = 87; -pub const KERN_UTC_OFFSET = 88; -pub const KERN_VIDEO = 89; +pub const CTL = struct { + pub const UNSPEC = 0; + pub const KERN = 1; + pub const VM = 2; + pub const FS = 3; + pub const NET = 4; + pub const DEBUG = 5; + pub const HW = 6; + pub const MACHDEP = 7; + + pub const DDB = 9; + pub const VFS = 10; +}; + +pub const KERN = struct { + pub const OSTYPE = 1; + pub const OSRELEASE = 2; + pub const OSREV = 3; + pub const VERSION = 4; + pub const MAXVNODES = 5; + pub const MAXPROC = 6; + pub const MAXFILES = 7; + pub const ARGMAX = 8; + pub const SECURELVL = 9; + pub const HOSTNAME = 10; + pub const HOSTID = 11; + pub const CLOCKRATE = 12; + + pub const PROF = 16; + pub const POSIX1 = 17; + pub const NGROUPS = 18; + pub const JOB_CONTROL = 19; + pub const SAVED_IDS = 20; + pub const BOOTTIME = 21; + pub const DOMAINNAME = 22; + pub const MAXPARTITIONS = 23; + pub const RAWPARTITION = 24; + pub const MAXTHREAD = 25; + pub const NTHREADS = 26; + pub const OSVERSION = 27; + pub const SOMAXCONN = 28; + pub const SOMINCONN = 29; + + pub const NOSUIDCOREDUMP = 32; + pub const FSYNC = 33; + pub const SYSVMSG = 34; + pub const SYSVSEM = 35; + pub const SYSVSHM = 36; + + pub const MSGBUFSIZE = 38; + pub const MALLOCSTATS = 39; + pub const CPTIME = 40; + pub const NCHSTATS = 41; + pub const FORKSTAT = 42; + pub const NSELCOLL = 43; + pub const TTY = 44; + pub const CCPU = 45; + pub const FSCALE = 46; + pub const NPROCS = 47; + pub const MSGBUF = 48; + pub const POOL = 49; + pub const STACKGAPRANDOM = 50; + pub const SYSVIPC_INFO = 51; + pub const ALLOWKMEM = 52; + pub const WITNESSWATCH = 53; + pub const SPLASSERT = 54; + pub const PROC_ARGS = 55; + pub const NFILES = 56; + pub const TTYCOUNT = 57; + pub const NUMVNODES = 58; + pub const MBSTAT = 59; + pub const WITNESS = 60; + pub const SEMINFO = 61; + pub const SHMINFO = 62; + pub const INTRCNT = 63; + pub const WATCHDOG = 64; + pub const ALLOWDT = 65; + pub const PROC = 66; + pub const MAXCLUSTERS = 67; + pub const EVCOUNT = 68; + pub const TIMECOUNTER = 69; + pub const MAXLOCKSPERUID = 70; + pub const CPTIME2 = 71; + pub const CACHEPCT = 72; + pub const FILE = 73; + pub const WXABORT = 74; + pub const CONSDEV = 75; + pub const NETLIVELOCKS = 76; + pub const POOL_DEBUG = 77; + pub const PROC_CWD = 78; + pub const PROC_NOBROADCASTKILL = 79; + pub const PROC_VMMAP = 80; + pub const GLOBAL_PTRACE = 81; + pub const CONSBUFSIZE = 82; + pub const CONSBUF = 83; + pub const AUDIO = 84; + pub const CPUSTATS = 85; + pub const PFSTATUS = 86; + pub const TIMEOUT_STATS = 87; + pub const UTC_OFFSET = 88; + pub const VIDEO = 89; + + pub const PROC_ALL = 0; + pub const PROC_PID = 1; + pub const PROC_PGRP = 2; + pub const PROC_SESSION = 3; + pub const PROC_TTY = 4; + pub const PROC_UID = 5; + pub const PROC_RUID = 6; + pub const PROC_KTHREAD = 7; + pub const PROC_SHOW_THREADS = 0x40000000; + + pub const PROC_ARGV = 1; + pub const PROC_NARGV = 2; + pub const PROC_ENV = 3; + pub const PROC_NENV = 4; +}; pub const HW_MACHINE = 1; pub const HW_MODEL = 2; @@ -1340,18 +1358,3 @@ pub const HW_ALLOWPOWERDOWN = 22; pub const HW_PERFPOLICY = 23; pub const HW_SMT = 24; pub const HW_NCPUONLINE = 25; - -pub const KERN_PROC_ALL = 0; -pub const KERN_PROC_PID = 1; -pub const KERN_PROC_PGRP = 2; -pub const KERN_PROC_SESSION = 3; -pub const KERN_PROC_TTY = 4; -pub const KERN_PROC_UID = 5; -pub const KERN_PROC_RUID = 6; -pub const KERN_PROC_KTHREAD = 7; -pub const KERN_PROC_SHOW_THREADS = 0x40000000; - -pub const KERN_PROC_ARGV = 1; -pub const KERN_PROC_NARGV = 2; -pub const KERN_PROC_ENV = 3; -pub const KERN_PROC_NENV = 4; diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 3299ddafdc..f1e7de0b5f 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -344,7 +344,7 @@ pub const Dir = struct { self.index = 0; self.end_index = @intCast(usize, rc); } - const darwin_entry = @ptrCast(*align(1) os.darwin.dirent, &self.buf[self.index]); + const darwin_entry = @ptrCast(*align(1) os.dirent, &self.buf[self.index]); const next_index = self.index + darwin_entry.reclen(); self.index = next_index; @@ -2442,14 +2442,14 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { switch (builtin.os.tag) { .linux => return os.readlinkZ("/proc/self/exe", out_buffer), .freebsd, .dragonfly => { - var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC, os.KERN_PROC_PATHNAME, -1 }; + var mib = [4]c_int{ os.CTL.KERN, os.KERN.PROC, os.KERN.PROC_PATHNAME, -1 }; var out_len: usize = out_buffer.len; try os.sysctl(&mib, out_buffer.ptr, &out_len, null, 0); // TODO could this slice from 0 to out_len instead? return mem.spanZ(std.meta.assumeSentinel(out_buffer.ptr, 0)); }, .netbsd => { - var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC_ARGS, -1, os.KERN_PROC_PATHNAME }; + var mib = [4]c_int{ os.CTL.KERN, os.KERN.PROC_ARGS, -1, os.KERN.PROC_PATHNAME }; var out_len: usize = out_buffer.len; try os.sysctl(&mib, out_buffer.ptr, &out_len, null, 0); // TODO could this slice from 0 to out_len instead? diff --git a/lib/std/os.zig b/lib/std/os.zig index 43062948bd..13d12555cf 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -68,6 +68,7 @@ pub const ARCH = system.ARCH; pub const AT = system.AT; pub const CLOCK = system.CLOCK; pub const CPU_COUNT = system.CPU_COUNT; +pub const CTL = system.CTL; pub const DT = system.DT; pub const E = system.E; pub const Elf_Symndx = system.Elf_Symndx; @@ -78,6 +79,7 @@ pub const HOST_NAME_MAX = system.HOST_NAME_MAX; pub const IFNAMESIZE = system.IFNAMESIZE; pub const IOV_MAX = system.IOV_MAX; pub const IPPROTO = system.IPPROTO; +pub const KERN = system.KERN; pub const Kevent = system.Kevent; pub const LOCK = system.LOCK; pub const MADV = system.MADV; @@ -121,6 +123,7 @@ pub const blksize_t = system.blksize_t; pub const clock_t = system.clock_t; pub const cpu_set_t = system.cpu_set_t; pub const dev_t = system.dev_t; +pub const dirent = system.dirent; pub const dl_phdr_info = system.dl_phdr_info; pub const empty_sigset = system.empty_sigset; pub const fd_t = system.fd_t; diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index a2a92b39df..da4057d6e1 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -309,8 +309,8 @@ pub const NativeTargetInfo = struct { }, .openbsd => { const mib: [2]c_int = [_]c_int{ - std.os.CTL_KERN, - std.os.KERN_OSRELEASE, + std.os.CTL.KERN, + std.os.KERN.OSRELEASE, }; var buf: [64]u8 = undefined; var len: usize = buf.len; diff --git a/lib/std/zig/system/darwin/macos.zig b/lib/std/zig/system/darwin/macos.zig index 509faaef29..d374acbc94 100644 --- a/lib/std/zig/system/darwin/macos.zig +++ b/lib/std/zig/system/darwin/macos.zig @@ -404,8 +404,8 @@ fn testVersionEquality(expected: std.builtin.Version, got: std.builtin.Version) } pub fn detectNativeCpuAndFeatures() ?Target.Cpu { - var cpu_family: os.CPUFAMILY = undefined; - var len: usize = @sizeOf(os.CPUFAMILY); + var cpu_family: std.c.CPUFAMILY = undefined; + var len: usize = @sizeOf(std.c.CPUFAMILY); os.sysctlbynameZ("hw.cpufamily", &cpu_family, &len, null, 0) catch |err| switch (err) { error.NameTooLong => unreachable, // constant, known good value error.PermissionDenied => unreachable, // only when setting values, diff --git a/src/main.zig b/src/main.zig index 0e075ff40f..d58c3525c5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3828,7 +3828,7 @@ fn parseCodeModel(arg: []const u8) std.builtin.CodeModel { /// garbage collector to run concurrently to zig processes, and to allow multiple /// zig processes to run concurrently with each other, without clobbering each other. fn gimmeMoreOfThoseSweetSweetFileDescriptors() void { - if (!@hasDecl(std.os, "rlimit")) return; + if (!@hasDecl(std.os.system, "rlimit")) return; const posix = std.os; var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried. -- cgit v1.2.3 From 0932b0d9b309e654951d7c7f94dae823d7cdd154 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 31 Aug 2021 19:27:54 -0700 Subject: std.os reorg: regression fixes to stack_t, and std.Thread --- lib/std/Thread.zig | 2 +- lib/std/c/darwin.zig | 6 +++--- lib/std/c/dragonfly.zig | 6 +++--- lib/std/c/haiku.zig | 6 +++--- lib/std/c/netbsd.zig | 14 ++++++++------ lib/std/c/openbsd.zig | 6 +++--- lib/std/os/linux.zig | 12 ++++++------ lib/std/os/test.zig | 4 ++-- 8 files changed, 29 insertions(+), 27 deletions(-) (limited to 'lib/std/Thread.zig') diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index ac38e5b4c6..1fe8ca89d2 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -558,7 +558,7 @@ const PosixThreadImpl = struct { .openbsd => { var count: c_int = undefined; var count_size: usize = @sizeOf(c_int); - const mib = [_]c_int{ os.CTL.HW, os.HW_NCPUONLINE }; + const mib = [_]c_int{ os.CTL.HW, os.system.HW_NCPUONLINE }; os.sysctl(&mib, &count, &count_size, null, 0) catch |err| switch (err) { error.NameTooLong, error.UnknownName => unreachable, else => |e| return e, diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index a3c57f5204..8bb30efab3 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -1436,9 +1436,9 @@ pub const SS_ONSTACK = 1; pub const SS_DISABLE = 4; pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, + sp: [*]u8, + size: isize, + flags: i32, }; pub const S = struct { diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig index 82e50a5002..35bbeac6a3 100644 --- a/lib/std/c/dragonfly.zig +++ b/lib/std/c/dragonfly.zig @@ -547,9 +547,9 @@ pub const NOTE_FFCOPY = 3221225472; pub const NOTE_PCTRLMASK = 4026531840; pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, + sp: [*]u8, + size: isize, + flags: i32, }; pub const S = struct { diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig index 38875d29f9..1ad51cfadd 100644 --- a/lib/std/c/haiku.zig +++ b/lib/std/c/haiku.zig @@ -1006,9 +1006,9 @@ pub const SS_ONSTACK = 1; pub const SS_DISABLE = 4; pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, + sp: [*]u8, + size: isize, + flags: i32, }; pub const S = struct { diff --git a/lib/std/c/netbsd.zig b/lib/std/c/netbsd.zig index d85c8c41b7..e492ce60fe 100644 --- a/lib/std/c/netbsd.zig +++ b/lib/std/c/netbsd.zig @@ -1039,9 +1039,11 @@ pub const mcontext_t = extern struct { fpregs: [512]u8 align(8), }; -pub const REG_RBP = 12; -pub const REG_RIP = 21; -pub const REG_RSP = 24; +pub const REG = struct { + pub const RBP = 12; + pub const RIP = 21; + pub const RSP = 24; +}; pub const ucontext_t = extern struct { flags: u32, @@ -1206,9 +1208,9 @@ pub const SS_ONSTACK = 1; pub const SS_DISABLE = 4; pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: isize, - ss_flags: i32, + sp: [*]u8, + size: isize, + flags: i32, }; pub const S = struct { diff --git a/lib/std/c/openbsd.zig b/lib/std/c/openbsd.zig index fb8738d737..b3919d4724 100644 --- a/lib/std/c/openbsd.zig +++ b/lib/std/c/openbsd.zig @@ -1007,9 +1007,9 @@ pub const SS_ONSTACK = 0x0001; pub const SS_DISABLE = 0x0004; pub const stack_t = extern struct { - ss_sp: [*]u8, - ss_size: usize, - ss_flags: c_int, + sp: [*]u8, + size: usize, + flags: c_int, }; pub const S = struct { diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index c4309e288d..12a8f3906e 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -3080,15 +3080,15 @@ pub const SS_AUTODISARM = 1 << 31; pub const stack_t = if (is_mips) // IRIX compatible stack_t extern struct { - ss_sp: [*]u8, - ss_size: usize, - ss_flags: i32, + sp: [*]u8, + size: usize, + flags: i32, } else extern struct { - ss_sp: [*]u8, - ss_flags: i32, - ss_size: usize, + sp: [*]u8, + flags: i32, + size: usize, }; pub const sigval = extern union { diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 21a02a8c8f..3a0187f735 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -394,8 +394,8 @@ test "sigaltstack" { var st: os.stack_t = undefined; try os.sigaltstack(null, &st); // Setting a stack size less than MINSIGSTKSZ returns ENOMEM - st.ss_flags = 0; - st.ss_size = 1; + st.flags = 0; + st.size = 1; try testing.expectError(error.SizeTooSmall, os.sigaltstack(&st, null)); } -- cgit v1.2.3