Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fe5adb9

Browse files
committedJun 2, 2024
Auto merge of rust-lang#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.
2 parents cd04000 + fdcee4d commit fe5adb9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎std/src/sys/pal/unix/thread.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -717,5 +717,14 @@ unsafe fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
717717

718718
#[cfg(target_os = "netbsd")]
719719
unsafe fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
720-
2048 // just a guess
720+
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+
})
721730
}

0 commit comments

Comments
 (0)
Failed to load comments.