stacker 0.1.23

A stack growth library useful when implementing deeply recursive algorithms that may accidentally blow the stack.
Documentation
1
2
3
4
5
6
7
8
9
pub unsafe fn guess_os_stack_limit() -> Option<usize> {
    let mut stackinfo = std::mem::MaybeUninit::<libc::stack_t>::uninit();
    let res = libc::pthread_stackseg_np(libc::pthread_self(), stackinfo.as_mut_ptr());
    if res != 0 {
        return None;
    }
    let stackinfo = stackinfo.assume_init();
    Some(stackinfo.ss_sp as usize - stackinfo.ss_size)
}