We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8981ee4 commit fdcee4dCopy full SHA for fdcee4d
std/src/sys/pal/unix/thread.rs
@@ -717,5 +717,14 @@ unsafe fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
717
718
#[cfg(target_os = "netbsd")]
719
unsafe fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
720
- 2048 // just a guess
+ static STACK: crate::sync::OnceLock<usize> = crate::sync::OnceLock::new();
721
+
722
+ *STACK.get_or_init(|| {
723
+ let mut stack = unsafe { libc::sysconf(libc::_SC_THREAD_STACK_MIN) };
724
+ if stack < 0 {
725
+ stack = 2048; // just a guess
726
+ }
727
728
+ stack as usize
729
+ })
730
}
0 commit comments