authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-31 11:23:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-31 11:23:38-07:00
logb5df1bfcdb927e6d4340ef50899cfee4f3e90569
tree396729780a7a2b7c4de0389d2c425b0aff6dc1d7
parent14353590f211b6600e511390250e9a1fa98e483a

Revert "os: expand sched_getaffinity wrapper and update freebsd's cpuset api flags."

This reverts commit dbdafb6cc503ce5820713dfa79cc956438b7957a.

2 files changed, 8 insertions(+), 40 deletions(-)

lib/std/c/freebsd.zig-13
...@@ -13,19 +13,6 @@ pub const cpulevel_t = c_int;...@@ -13,19 +13,6 @@ pub const cpulevel_t = c_int;
13pub const cpuwhich_t = c_int;13pub const cpuwhich_t = c_int;
14pub const id_t = i64;14pub const id_t = i64;
1515
16pub const CPU_LEVEL_ROOT: cpulevel_t = 1;
17pub const CPU_LEVEL_CPUSET: cpulevel_t = 2;
18pub const CPU_LEVEL_WHICH: cpulevel_t = 3;
19pub const CPU_WHICH_TID: cpuwhich_t = 1;
20pub const CPU_WHICH_PID: cpuwhich_t = 2;
21pub const CPU_WHICH_CPUSET: cpuwhich_t = 3;
22pub const CPU_WHICH_IRQ: cpuwhich_t = 4;
23pub const CPU_WHICH_JAIL: cpuwhich_t = 5;
24pub const CPU_WHICH_DOMAIN: cpuwhich_t = 6;
25pub const CPU_WHICH_INTRHANDLER: cpuwhich_t = 7;
26pub const CPU_WHICH_ITHREAD: cpuwhich_t = 8;
27pub const CPU_WHICH_TIDPID: cpuwhich_t = 8;
28
29extern "c" fn __error() *c_int;16extern "c" fn __error() *c_int;
30pub const _errno = __error;17pub const _errno = __error;
3118
lib/std/os.zig+8-27
...@@ -146,12 +146,7 @@ pub const addrinfo = system.addrinfo;...@@ -146,12 +146,7 @@ pub const addrinfo = system.addrinfo;
146pub const blkcnt_t = system.blkcnt_t;146pub const blkcnt_t = system.blkcnt_t;
147pub const blksize_t = system.blksize_t;147pub const blksize_t = system.blksize_t;
148pub const clock_t = system.clock_t;148pub const clock_t = system.clock_t;
149pub const cpu_set_t = if (builtin.os.tag == .linux)149pub const cpu_set_t = system.cpu_set_t;
150 system.cpu_set_t
151else if (builtin.os.tag == .freebsd)
152 freebsd.cpuset_t
153else
154 u32;
155pub const dev_t = system.dev_t;150pub const dev_t = system.dev_t;
156pub const dl_phdr_info = system.dl_phdr_info;151pub const dl_phdr_info = system.dl_phdr_info;
157pub const empty_sigset = system.empty_sigset;152pub const empty_sigset = system.empty_sigset;
...@@ -5492,27 +5487,13 @@ pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError;...@@ -5492,27 +5487,13 @@ pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError;
54925487
5493pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t {5488pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t {
5494 var set: cpu_set_t = undefined;5489 var set: cpu_set_t = undefined;
5495 if (builtin.os.tag == .linux) {5490 switch (errno(system.sched_getaffinity(pid, @sizeOf(cpu_set_t), &set))) {
5496 switch (errno(system.sched_getaffinity(pid, @sizeOf(cpu_set_t), &set))) {5491 .SUCCESS => return set,
5497 .SUCCESS => return set,5492 .FAULT => unreachable,
5498 .FAULT => unreachable,5493 .INVAL => unreachable,
5499 .INVAL => unreachable,5494 .SRCH => unreachable,
5500 .SRCH => unreachable,5495 .PERM => return error.PermissionDenied,
5501 .PERM => return error.PermissionDenied,5496 else => |err| return unexpectedErrno(err),
5502 else => |err| return unexpectedErrno(err),
5503 }
5504 } else if (builtin.os.tag == .freebsd) {
5505 switch (errno(freebsd.cpuset_getaffinity(freebsd.CPU_LEVEL_WHICH, freebsd.CPU_WHICH_PID, pid, @sizeOf(cpu_set_t), &set))) {
5506 .SUCCESS => return set,
5507 .FAULT => unreachable,
5508 .INVAL => unreachable,
5509 .SRCH => unreachable,
5510 .EDEADLK => unreachable,
5511 .PERM => return error.PermissionDenied,
5512 else => |err| return unexpectedErrno(err),
5513 }
5514 } else {
5515 @compileError("unsupported platform");
5516 }5497 }
5517}5498}
55185499