Auto merge of #125577 - devnexen:netbsd_stack_min, r=joboet
std::pal::unix::thread fetching min stack size on netbsd. PTHREAD_STACK_MIN is not defined however sysconf/_SC_THREAD_STACK_MIN returns it as it can vary from arch to another.
This commit is contained in:
commit
eda9d7f987
1 changed files with 10 additions and 1 deletions
|
@ -717,5 +717,14 @@ unsafe fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
|
||||||
|
|
||||||
#[cfg(target_os = "netbsd")]
|
#[cfg(target_os = "netbsd")]
|
||||||
unsafe fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
|
unsafe fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
|
||||||
2048 // just a guess
|
static STACK: crate::sync::OnceLock<usize> = crate::sync::OnceLock::new();
|
||||||
|
|
||||||
|
*STACK.get_or_init(|| {
|
||||||
|
let mut stack = unsafe { libc::sysconf(libc::_SC_THREAD_STACK_MIN) };
|
||||||
|
if stack < 0 {
|
||||||
|
stack = 2048; // just a guess
|
||||||
|
}
|
||||||
|
|
||||||
|
stack as usize
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue