Rollup merge of #68767 - kubo39:patch-macos, r=shepmaster

macOS: avoid calling pthread_self() twice
This commit is contained in:
Yuki Okushi 2020-02-18 20:09:04 +09:00 committed by GitHub
commit 284acafe61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}