authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-31 10:58:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-31 10:58:03-07:00
log86a5edca6238f4c9b861931e40d8cbe005568819
tree1f5c382a3a98f239b177235eb9663f429c87ac32
parente1fdd21f0e1d7aaa2a18af0fe35c921d93089b41

Revert "std.os: implementing sched_setaffinity wrapper for freebsd"

This reverts commit 05268bb9677ef0545cca6c788169b2707842dc8d.

2 files changed, 0 insertions(+), 44 deletions(-)

lib/std/c/freebsd.zig-31
......@@ -18,41 +18,10 @@ fn __BIT_COUNT(bits: []const c_long) c_long {
1818 return count;
1919}
2020
21fn __BIT_MASK(s: usize) c_long {
22 var x = s % CPU_SETSIZE;
23 return @as(c_long, @bitCast(@as(c_ulong, @intCast(1)) << @as(u6, @intCast(x))));
24}
25
2621pub fn CPU_COUNT(set: cpuset_t) c_int {
2722 return @as(c_int, @intCast(__BIT_COUNT(set.__bits[0..])));
2823}
2924
30pub fn CPU_ZERO(set: *cpuset_t) void {
31 @memset((set.*).__bits[0..], 0);
32}
33
34pub fn CPU_SET(cpu: usize, set: *cpuset_t) void {
35 const x = cpu / @sizeOf(c_long);
36 if (x < @sizeOf(cpuset_t)) {
37 (set.*).__bits[x] |= __BIT_MASK(x);
38 }
39}
40
41pub fn CPU_ISSET(cpu: usize, set: cpuset_t) void {
42 const x = cpu / @sizeOf(c_long);
43 if (x < @sizeOf(cpuset_t)) {
44 return set.__bits[x] & __BIT_MASK(x);
45 }
46 return false;
47}
48
49pub fn CPU_CLR(cpu: usize, set: *cpuset_t) void {
50 const x = cpu / @sizeOf(c_long);
51 if (x < @sizeOf(cpuset_t)) {
52 (set.*).__bits[x] &= !__BIT_MASK(x);
53 }
54}
55
5625pub const cpulevel_t = c_int;
5726pub const cpuwhich_t = c_int;
5827pub const id_t = i64;
lib/std/os.zig-13
......@@ -5537,19 +5537,6 @@ pub fn sched_setaffinity(pid: pid_t, cpus: []usize) SchedSetAffinityError!cpu_se
55375537 .PERM => return error.PermissionDenied,
55385538 else => |err| return unexpectedErrno(err),
55395539 }
5540 } else if (builtin.os.tag == .freebsd) {
5541 freebsd.CPU_ZERO(&set);
5542 for (cpus) |cpu| {
5543 freebsd.CPU_SET(cpu, &set);
5544 }
5545 switch (errno(freebsd.cpuset_setaffinity(freebsd.CPU_LEVEL_WHICH, freebsd.CPU_WHICH_PID, pid, @sizeOf(cpu_set_t), &set))) {
5546 .SUCCESS => return set,
5547 .FAULT => unreachable,
5548 .SRCH => unreachable,
5549 .INVAL => return error.InvalidCpu,
5550 .PERM => return error.PermissionDenied,
5551 else => |err| return unexpectedErrno(err),
5552 }
55535540 } else {
55545541 @compileError("unsupported platform");
55555542 }