Skip to content

Commit f9ee6d5

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 f9ee6d5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
1414
pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
1515
#[cfg(target_os = "vxworks")]
1616
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
17+
#[cfg(any(target_os = "espidf", target_os = "nuttx"))]
18+
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
1919

2020
#[cfg(target_os = "fuchsia")]
2121
mod zircon {
@@ -52,10 +52,10 @@ impl Thread {
5252
let mut attr: mem::MaybeUninit<libc::pthread_attr_t> = mem::MaybeUninit::uninit();
5353
assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0);
5454

55-
#[cfg(target_os = "espidf")]
55+
#[cfg(any(target_os = "espidf", target_os = "nuttx"))]
5656
if stack > 0 {
5757
// 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
58+
// 0 is used as an indication that the default stack size configured in the ESP-IDF/NuttX menuconfig system should be used
5959
assert_eq!(
6060
libc::pthread_attr_setstacksize(
6161
attr.as_mut_ptr(),
@@ -65,7 +65,7 @@ impl Thread {
6565
);
6666
}
6767

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

0 commit comments

Comments
 (0)