Skip to content

Commit 67068f3

Browse files
committed
macOS: avoid calling pthread_self() twice
1 parent 0cbcb17 commit 67068f3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libstd/sys/unix/thread.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ pub mod guard {
255255

256256
#[cfg(target_os = "macos")]
257257
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
258-
let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize
259-
- libc::pthread_get_stacksize_np(libc::pthread_self());
258+
let th = libc::pthread_self();
259+
let stackaddr =
260+
libc::pthread_get_stackaddr_np(th) as usize - libc::pthread_get_stacksize_np(th);
260261
Some(stackaddr as *mut libc::c_void)
261262
}
262263

0 commit comments

Comments
 (0)