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

This reverts commit 05268bb9677ef0545cca6c788169b2707842dc8d.
This commit is contained in:
Andrew Kelley 2023-07-31 10:58:03 -07:00
parent e1fdd21f0e
commit 86a5edca62
2 changed files with 0 additions and 44 deletions

View File

@ -18,41 +18,10 @@ fn __BIT_COUNT(bits: []const c_long) c_long {
return count;
}
fn __BIT_MASK(s: usize) c_long {
var x = s % CPU_SETSIZE;
return @as(c_long, @bitCast(@as(c_ulong, @intCast(1)) << @as(u6, @intCast(x))));
}
pub fn CPU_COUNT(set: cpuset_t) c_int {
return @as(c_int, @intCast(__BIT_COUNT(set.__bits[0..])));
}
pub fn CPU_ZERO(set: *cpuset_t) void {
@memset((set.*).__bits[0..], 0);
}
pub fn CPU_SET(cpu: usize, set: *cpuset_t) void {
const x = cpu / @sizeOf(c_long);
if (x < @sizeOf(cpuset_t)) {
(set.*).__bits[x] |= __BIT_MASK(x);
}
}
pub fn CPU_ISSET(cpu: usize, set: cpuset_t) void {
const x = cpu / @sizeOf(c_long);
if (x < @sizeOf(cpuset_t)) {
return set.__bits[x] & __BIT_MASK(x);
}
return false;
}
pub fn CPU_CLR(cpu: usize, set: *cpuset_t) void {
const x = cpu / @sizeOf(c_long);
if (x < @sizeOf(cpuset_t)) {
(set.*).__bits[x] &= !__BIT_MASK(x);
}
}
pub const cpulevel_t = c_int;
pub const cpuwhich_t = c_int;
pub const id_t = i64;

View File

@ -5537,19 +5537,6 @@ pub fn sched_setaffinity(pid: pid_t, cpus: []usize) SchedSetAffinityError!cpu_se
.PERM => return error.PermissionDenied,
else => |err| return unexpectedErrno(err),
}
} else if (builtin.os.tag == .freebsd) {
freebsd.CPU_ZERO(&set);
for (cpus) |cpu| {
freebsd.CPU_SET(cpu, &set);
}
switch (errno(freebsd.cpuset_setaffinity(freebsd.CPU_LEVEL_WHICH, freebsd.CPU_WHICH_PID, pid, @sizeOf(cpu_set_t), &set))) {
.SUCCESS => return set,
.FAULT => unreachable,
.SRCH => unreachable,
.INVAL => return error.InvalidCpu,
.PERM => return error.PermissionDenied,
else => |err| return unexpectedErrno(err),
}
} else {
@compileError("unsupported platform");
}