| ... | @@ -141,7 +141,12 @@ pub const addrinfo = system.addrinfo; | ... | @@ -141,7 +141,12 @@ pub const addrinfo = system.addrinfo; |
| 141 | pub const blkcnt_t = system.blkcnt_t; | 141 | pub const blkcnt_t = system.blkcnt_t; |
| 142 | pub const blksize_t = system.blksize_t; | 142 | pub const blksize_t = system.blksize_t; |
| 143 | pub const clock_t = system.clock_t; | 143 | pub const clock_t = system.clock_t; |
| 144 | pub const cpu_set_t = system.cpu_set_t; | 144 | pub const cpu_set_t = if (builtin.os.tag == .linux) |
| | 145 | system.cpu_set_t |
| | 146 | else if (builtin.os.tag == .freebsd) |
| | 147 | freebsd.cpuset_t |
| | 148 | else |
| | 149 | u32; |
| 145 | pub const dev_t = system.dev_t; | 150 | pub const dev_t = system.dev_t; |
| 146 | pub const dl_phdr_info = system.dl_phdr_info; | 151 | pub const dl_phdr_info = system.dl_phdr_info; |
| 147 | pub const empty_sigset = system.empty_sigset; | 152 | pub const empty_sigset = system.empty_sigset; |
| ... | @@ -5518,13 +5523,27 @@ pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError; | ... | @@ -5518,13 +5523,27 @@ pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError; |
| 5518 | | 5523 | |
| 5519 | pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { | 5524 | pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t { |
| 5520 | var set: cpu_set_t = undefined; | 5525 | var set: cpu_set_t = undefined; |
| 5521 | switch (errno(system.sched_getaffinity(pid, @sizeOf(cpu_set_t), &set))) { | 5526 | if (builtin.os.tag == .linux) { |
| 5522 | .SUCCESS => return set, | 5527 | switch (errno(system.sched_getaffinity(pid, @sizeOf(cpu_set_t), &set))) { |
| 5523 | .FAULT => unreachable, | 5528 | .SUCCESS => return set, |
| 5524 | .INVAL => unreachable, | 5529 | .FAULT => unreachable, |
| 5525 | .SRCH => unreachable, | 5530 | .INVAL => unreachable, |
| 5526 | .PERM => return error.PermissionDenied, | 5531 | .SRCH => unreachable, |
| 5527 | else => |err| return unexpectedErrno(err), | 5532 | .PERM => return error.PermissionDenied, |
| | 5533 | else => |err| return unexpectedErrno(err), |
| | 5534 | } |
| | 5535 | } else if (builtin.os.tag == .freebsd) { |
| | 5536 | switch (errno(freebsd.cpuset_getaffinity(freebsd.CPU_LEVEL_WHICH, freebsd.CPU_WHICH_PID, pid, @sizeOf(cpu_set_t), &set))) { |
| | 5537 | .SUCCESS => return set, |
| | 5538 | .FAULT => unreachable, |
| | 5539 | .INVAL => unreachable, |
| | 5540 | .SRCH => unreachable, |
| | 5541 | .EDEADLK => unreachable, |
| | 5542 | .PERM => return error.PermissionDenied, |
| | 5543 | else => |err| return unexpectedErrno(err), |
| | 5544 | } |
| | 5545 | } else { |
| | 5546 | @compileError("unsupported platform"); |
| 5528 | } | 5547 | } |
| 5529 | } | 5548 | } |
| 5530 | | 5549 | |