authorgravatar for devnexen@gmail.comDavid Carlier <devnexen@gmail.com> 2023-05-05 17:39:44+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-05-06 00:55:20+03:00
log4bfd37ddb48af4dbfd2e892aec7a90a822c8cbe7
tree380d1873a2379879b15a3723d477857bc19d5118
parentd70853ba39cb1694d91a763ea8492f3aed1494a7

std.c: adding cpu affinity api for macOs (mainly x86_64)


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

lib/std/c/darwin.zig+20
......@@ -3896,3 +3896,23 @@ pub const MIN = struct {
38963896
38973897pub extern "c" fn mincore(addr: *align(std.mem.page_size) const anyopaque, length: usize, vec: [*]u8) c_int;
38983898pub extern "c" fn os_proc_available_memory() usize;
3899
3900pub const thread_affinity_policy = extern struct {
3901 tag: integer_t,
3902};
3903
3904pub const thread_policy_flavor_t = natural_t;
3905pub const thread_policy_t = [*]integer_t;
3906pub const thread_affinity_policy_data_t = thread_affinity_policy;
3907pub const thread_affinity_policy_t = [*]thread_affinity_policy;
3908
3909pub const THREAD_AFFINITY = struct {
3910 pub const POLICY = 0;
3911 pub const POLICY_COUNT = @intCast(mach_msg_type_number_t, @sizeOf(thread_affinity_policy_data_t) / @sizeOf(integer_t));
3912};
3913
3914/// cpu affinity api
3915/// albeit it is also available on arm64, it always fails as in this architecture there is no sense of
3916/// individual cpus (high performance cpus group and low consumption one), thus the pthread QOS api is more appropriate in this case.
3917pub extern "c" fn thread_affinity_get(thread: thread_act_t, flavor: thread_policy_flavor_t, info: thread_policy_t, infocnt: [*]mach_msg_type_number_t, default: *boolean_t) kern_return_t;
3918pub extern "c" fn thread_affinity_set(thread: thread_act_t, flavor: thread_policy_flavor_t, info: thread_policy_t, infocnt: mach_msg_type_number_t) kern_return_t;