Skip to content

Commit 15a93c5

Browse files
committed
std/thread: Use default stack size from menuconfig for NuttX
* Update comments to clarify the usage of zero as an indication for default stack size configuration * Adjust conditional compilation to reflect the changes in stack size handling for the NuttX platform This change improves clarity and consistency in stack size configuration across platforms. Signed-off-by: Huang Qi <[email protected]>
1 parent ae06b79 commit 15a93c5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

+11-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ use crate::sys::weak::weak;
88
use crate::sys::{os, stack_overflow};
99
use crate::time::Duration;
1010
use crate::{cmp, io, ptr};
11-
#[cfg(not(any(target_os = "l4re", target_os = "vxworks", target_os = "espidf")))]
11+
#[cfg(not(any(
12+
target_os = "l4re",
13+
target_os = "vxworks",
14+
target_os = "espidf",
15+
target_os = "nuttx"
16+
)))]
1217
pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
1318
#[cfg(target_os = "l4re")]
1419
pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
1520
#[cfg(target_os = "vxworks")]
1621
pub const DEFAULT_MIN_STACK_SIZE: usize = 256 * 1024;
17-
#[cfg(target_os = "espidf")]
18-
pub const DEFAULT_MIN_STACK_SIZE: usize = 0; // 0 indicates that the stack size configured in the ESP-IDF menuconfig system should be used
22+
#[cfg(any(target_os = "espidf", target_os = "nuttx"))]
23+
pub const DEFAULT_MIN_STACK_SIZE: usize = 0; // 0 indicates that the stack size configured in the ESP-IDF/NuttX menuconfig system should be used
1924

2025
#[cfg(target_os = "fuchsia")]
2126
mod zircon {
@@ -52,10 +57,10 @@ impl Thread {
5257
let mut attr: mem::MaybeUninit<libc::pthread_attr_t> = mem::MaybeUninit::uninit();
5358
assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0);
5459

55-
#[cfg(target_os = "espidf")]
60+
#[cfg(any(target_os = "espidf", target_os = "nuttx"))]
5661
if stack > 0 {
5762
// Only set the stack if a non-zero value is passed
58-
// 0 is used as an indication that the default stack size configured in the ESP-IDF menuconfig system should be used
63+
// 0 is used as an indication that the default stack size configured in the ESP-IDF/NuttX menuconfig system should be used
5964
assert_eq!(
6065
libc::pthread_attr_setstacksize(
6166
attr.as_mut_ptr(),
@@ -65,7 +70,7 @@ impl Thread {
6570
);
6671
}
6772

68-
#[cfg(not(target_os = "espidf"))]
73+
#[cfg(not(any(target_os = "espidf", target_os = "nuttx")))]
6974
{
7075
let stack_size = cmp::max(stack, min_stack_size(attr.as_ptr()));
7176

0 commit comments

Comments
 (0)