mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
darwin: wrap task_threads mach syscall
This commit is contained in:
parent
6f5eb9927d
commit
2efd0eb884
@ -573,7 +573,7 @@ pub const vm_region_submap_short_info_64 = extern struct {
|
||||
|
||||
pub const thread_act_t = mach_port_t;
|
||||
pub const thread_state_t = *natural_t;
|
||||
pub const mach_port_array_t = *mach_port_t;
|
||||
pub const mach_port_array_t = [*]mach_port_t;
|
||||
|
||||
pub extern "c" fn task_threads(
|
||||
target_task: mach_port_t,
|
||||
|
||||
@ -438,6 +438,18 @@ const mach_task = if (builtin.target.isDarwin()) struct {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn getThreads(task: MachTask) MachError![]std.c.mach_port_t {
|
||||
var thread_list: std.c.mach_port_array_t = undefined;
|
||||
var thread_count: std.c.mach_msg_type_number_t = undefined;
|
||||
switch (std.c.getKernError(std.c.task_threads(task.port, &thread_list, &thread_count))) {
|
||||
.SUCCESS => return thread_list[0..thread_count],
|
||||
else => |err| {
|
||||
log.err("task_threads kernel call failed with error code: {s}", .{@tagName(err)});
|
||||
return error.Unexpected;
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub fn machTaskForPid(pid: std.os.pid_t) MachError!MachTask {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user