| author | |
| committer | |
| log | 86a5edca6238f4c9b861931e40d8cbe005568819 |
| tree | 1f5c382a3a98f239b177235eb9663f429c87ac32 |
| parent | e1fdd21f0e1d7aaa2a18af0fe35c921d93089b41 |
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 { | ... | @@ -18,41 +18,10 @@ fn __BIT_COUNT(bits: []const c_long) c_long { |
| 18 | return count; | 18 | return count; |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | fn __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 | |||
| 26 | pub fn CPU_COUNT(set: cpuset_t) c_int { | 21 | pub fn CPU_COUNT(set: cpuset_t) c_int { |
| 27 | return @as(c_int, @intCast(__BIT_COUNT(set.__bits[0..]))); | 22 | return @as(c_int, @intCast(__BIT_COUNT(set.__bits[0..]))); |
| 28 | } | 23 | } |
| 29 | 24 | ||
| 30 | pub fn CPU_ZERO(set: *cpuset_t) void { | ||
| 31 | @memset((set.*).__bits[0..], 0); | ||
| 32 | } | ||
| 33 | |||
| 34 | pub 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 | |||
| 41 | pub 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 | |||
| 49 | pub 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 | |||
| 56 | pub const cpulevel_t = c_int; | 25 | pub const cpulevel_t = c_int; |
| 57 | pub const cpuwhich_t = c_int; | 26 | pub const cpuwhich_t = c_int; |
| 58 | pub const id_t = i64; | 27 | pub 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 | ... | @@ -5537,19 +5537,6 @@ pub fn sched_setaffinity(pid: pid_t, cpus: []usize) SchedSetAffinityError!cpu_se |
| 5537 | .PERM => return error.PermissionDenied, | 5537 | .PERM => return error.PermissionDenied, |
| 5538 | else => |err| return unexpectedErrno(err), | 5538 | else => |err| return unexpectedErrno(err), |
| 5539 | } | 5539 | } |
| 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 | } | ||
| 5553 | } else { | 5540 | } else { |
| 5554 | @compileError("unsupported platform"); | 5541 | @compileError("unsupported platform"); |
| 5555 | } | 5542 | } |