Skip to content
This repository has been archived by the owner on Jul 30, 2023. It is now read-only.

Commit

Permalink
chore: pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomio committed Jun 25, 2022
1 parent 5dfb607 commit ae3fc3a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/osx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ use std::num::NonZeroUsize;
use std::ptr;

use mach2::kern_return::KERN_SUCCESS;
use mach2::mach_init::mach_thread_self;
use mach2::task::task_threads;
use mach2::traps::mach_task_self;

pub(crate) fn thread_amount() -> Option<NonZeroUsize> {
let mut state = [0u32; 1296];
let mut count: u32 = 0;
let rc = unsafe {
let task = mach_task_self();
let thread = mach_thread_self();

task_threads(task, &mut state as *mut *mut _, &mut count)
};
let rc =
unsafe { task_threads(mask_task_self(), &mut state as *mut *mut _, &mut count as *mut _) };

if rc == KERN_SUCCESS {
NonZeroUsize::new(usize::try_from(count).expect("Failed converting from u32 to usize"))
Expand Down

0 comments on commit ae3fc3a

Please sign in to comment.