| author | |
| committer | |
| log | 2efd0eb884d69c967f8b0c7066d62a8b656f1fda |
| tree | 9716be5ac3cf7831b4c5bcaf95c9342868846ccb |
| parent | 6f5eb9927d5f7713ebc0d104c0590fb037afe275 |
2 files changed, 13 insertions(+), 1 deletions(-)
lib/std/c/darwin.zig+1-1| ... | @@ -573,7 +573,7 @@ pub const vm_region_submap_short_info_64 = extern struct { | ... | @@ -573,7 +573,7 @@ pub const vm_region_submap_short_info_64 = extern struct { |
| 573 | 573 | ||
| 574 | pub const thread_act_t = mach_port_t; | 574 | pub const thread_act_t = mach_port_t; |
| 575 | pub const thread_state_t = *natural_t; | 575 | pub const thread_state_t = *natural_t; |
| 576 | pub const mach_port_array_t = *mach_port_t; | 576 | pub const mach_port_array_t = [*]mach_port_t; |
| 577 | 577 | ||
| 578 | pub extern "c" fn task_threads( | 578 | pub extern "c" fn task_threads( |
| 579 | target_task: mach_port_t, | 579 | target_task: mach_port_t, |
lib/std/os/darwin.zig+12| ... | @@ -438,6 +438,18 @@ const mach_task = if (builtin.target.isDarwin()) struct { | ... | @@ -438,6 +438,18 @@ const mach_task = if (builtin.target.isDarwin()) struct { |
| 438 | }, | 438 | }, |
| 439 | } | 439 | } |
| 440 | } | 440 | } |
| 441 | |||
| 442 | pub fn getThreads(task: MachTask) MachError![]std.c.mach_port_t { | ||
| 443 | var thread_list: std.c.mach_port_array_t = undefined; | ||
| 444 | var thread_count: std.c.mach_msg_type_number_t = undefined; | ||
| 445 | switch (std.c.getKernError(std.c.task_threads(task.port, &thread_list, &thread_count))) { | ||
| 446 | .SUCCESS => return thread_list[0..thread_count], | ||
| 447 | else => |err| { | ||
| 448 | log.err("task_threads kernel call failed with error code: {s}", .{@tagName(err)}); | ||
| 449 | return error.Unexpected; | ||
| 450 | }, | ||
| 451 | } | ||
| 452 | } | ||
| 441 | }; | 453 | }; |
| 442 | 454 | ||
| 443 | pub fn machTaskForPid(pid: std.os.pid_t) MachError!MachTask { | 455 | pub fn machTaskForPid(pid: std.os.pid_t) MachError!MachTask { |