Skip to content

Commit

Permalink
macOS: avoid calling pthread_self() twice
Browse files Browse the repository at this point in the history
  • Loading branch information
kubo39 committed Feb 16, 2020
1 parent 0cbcb17 commit 67068f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libstd/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ pub mod guard {

#[cfg(target_os = "macos")]
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize
- libc::pthread_get_stacksize_np(libc::pthread_self());
let th = libc::pthread_self();
let stackaddr =
libc::pthread_get_stackaddr_np(th) as usize - libc::pthread_get_stacksize_np(th);
Some(stackaddr as *mut libc::c_void)
}

Expand Down

0 comments on commit 67068f3

Please sign in to comment.