authorgravatar for devnexen@gmail.comDavid Carlier <devnexen@gmail.com> 2023-05-02 20:16:19+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-05-03 08:19:46+03:00
logb9841750f91604020268549fc5e2c6b10c1f8477
treef522a9c1cc5851ce8196834eaebe3bc4b6766af6
parent152c7b1885a0ed8e5a2435ef7b51568b357eaea4

std.c: adding freebsd's CPU_COUNT macro portage.


1 files changed, 14 insertions(+), 0 deletions(-)

lib/std/c/freebsd.zig+14
......@@ -9,6 +9,20 @@ pub const CPU_SETSIZE = 256;
99pub const cpuset_t = extern struct {
1010 __bits: [(CPU_SETSIZE + (@bitSizeOf(c_long) - 1)) / @bitSizeOf(c_long)]c_long,
1111};
12
13// TODO: can eventually serve for the domainset_t's type too.
14fn __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
22pub fn CPU_COUNT(set: cpuset_t) c_int {
23 return @intCast(c_int, __BIT_COUNT(set.__bits[0..]));
24}
25
1226pub const cpulevel_t = c_int;
1327pub const cpuwhich_t = c_int;
1428pub const id_t = i64;