Skip to content

Commit 02f2aff

Browse files
committed
Fix guess_os_morestack_stack_limit for OSX
1 parent b2a8e15 commit 02f2aff

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,17 @@ cfg_if! {
168168
attr: *mut pthread_attr_t) -> c_int;
169169
}
170170
} else if #[cfg(target_os = "macos")] {
171-
use libc::{c_void, pthread_t};
171+
use libc::{c_void, pthread_t, size_t};
172172

173173
unsafe fn guess_os_morestack_stack_limit() -> usize {
174-
pthread_get_stackaddr_np(pthread_self()) as usize
174+
pthread_get_stackaddr_np(pthread_self()) as usize -
175+
pthread_get_stacksize_np(pthread_self()) as usize
175176
}
176177

177178
extern {
178179
fn pthread_self() -> pthread_t;
179180
fn pthread_get_stackaddr_np(thread: pthread_t) -> *mut c_void;
181+
fn pthread_get_stacksize_np(thread: pthread_t) -> size_t;
180182
}
181183
} else {
182184
unsafe fn guess_os_morestack_stack_limit() -> usize {

0 commit comments

Comments
 (0)