| ... | ... | @@ -9,6 +9,20 @@ pub const CPU_SETSIZE = 256; |
| 9 | 9 | pub const cpuset_t = extern struct { |
| 10 | 10 | __bits: [(CPU_SETSIZE + (@bitSizeOf(c_long) - 1)) / @bitSizeOf(c_long)]c_long, |
| 11 | 11 | }; |
| 12 | |
| 13 | // TODO: can eventually serve for the domainset_t's type too. |
| 14 | fn __BIT_COUNT(bits: []const c_long) c_long { |
| 15 | var count: c_long = 0; |
| 16 | for (bits) |b| { |
| 17 | count += @popCount(b); |
| 18 | } |
| 19 | return count; |
| 20 | } |
| 21 | |
| 22 | pub fn CPU_COUNT(set: cpuset_t) c_int { |
| 23 | return @intCast(c_int, __BIT_COUNT(set.__bits[0..])); |
| 24 | } |
| 25 | |
| 12 | 26 | pub const cpulevel_t = c_int; |
| 13 | 27 | pub const cpuwhich_t = c_int; |
| 14 | 28 | pub const id_t = i64; |