diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-05-25 13:07:44 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-05-26 18:32:44 -0400 |
| commit | 7cb6279ac0cec065234347bda5944be64fe8b3da (patch) | |
| tree | 0eb4befe9a7eb24f5a393559e0621e92e26a4c59 /std/os.zig | |
| parent | ca6debcaf4a4f85b7aff94c7b5fe821530b0f195 (diff) | |
| download | zig-7cb6279ac0cec065234347bda5944be64fe8b3da.tar.gz zig-7cb6279ac0cec065234347bda5944be64fe8b3da.zip | |
clean up references to posix
Diffstat (limited to 'std/os.zig')
| -rw-r--r-- | std/os.zig | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/std/os.zig b/std/os.zig index 4cd847cf8f..3b29570fcd 100644 --- a/std/os.zig +++ b/std/os.zig @@ -164,7 +164,7 @@ pub fn raise(sig: u8) RaiseError!void { } if (windows.is_the_target) { - @compileError("TODO implement std.posix.raise for Windows"); + @compileError("TODO implement std.os.raise for Windows"); } var set: system.sigset_t = undefined; @@ -690,20 +690,6 @@ pub fn getenvC(key: [*]const u8) ?[]const u8 { return getenv(mem.toSliceConst(u8, key)); } -/// See std.elf for the constants. -pub fn getauxval(index: usize) usize { - if (builtin.link_libc) { - return usize(system.getauxval(index)); - } else if (linux.elf_aux_maybe) |auxv| { - var i: usize = 0; - while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { - if (auxv[i].a_type == index) - return auxv[i].a_un.a_val; - } - } - return 0; -} - pub const GetCwdError = error{ NameTooLong, CurrentWorkingDirectoryUnlinked, @@ -1198,7 +1184,7 @@ pub fn isatty(handle: fd_t) bool { return windows.kernel32.GetConsoleMode(handle, &out) != 0; } if (wasi.is_the_target) { - @compileError("TODO implement std.os.posix.isatty for WASI"); + @compileError("TODO implement std.os.isatty for WASI"); } if (linux.is_the_target) { var wsz: system.winsize = undefined; @@ -2365,6 +2351,23 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void { } } +pub const SchedGetAffinityError = error{ + PermissionDenied, + Unexpected, +}; + +pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { + var set: cpu_set_t = undefined; + switch (errno(system.sched_getaffinity(pid, &set))) { + 0 => return set, + EFAULT => unreachable, + EINVAL => unreachable, + ESRCH => unreachable, + EPERM => return error.PermissionDenied, + else => |err| return unexpectedErrno(err), + } +} + /// Used to convert a slice to a null terminated slice on the stack. /// TODO https://github.com/ziglang/zig/issues/287 pub fn toPosixPath(file_path: []const u8) ![PATH_MAX]u8 { |
