about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-02-18 20:09:04 +0900
committerGitHub <noreply@github.com>2020-02-18 20:09:04 +0900
commit284acafe61fa76eb56ca2dddd479a2b5f9a262cd (patch)
treeceb4293293edbc3fc95fda0cb0c80c5caabfcfa7 /src/libstd
parentae81241eae061ee9fb2af798b109508c27f208f1 (diff)
parent67068f35dd41409c8e79710f1335cc9dc64f1860 (diff)
downloadrust-284acafe61fa76eb56ca2dddd479a2b5f9a262cd.tar.gz
rust-284acafe61fa76eb56ca2dddd479a2b5f9a262cd.zip
Rollup merge of #68767 - kubo39:patch-macos, r=shepmaster
macOS: avoid calling pthread_self() twice
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys/unix/thread.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index 3ca778354e4..674d4c71138 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -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)
     }