Skip to content

Commit 0c9a1eb

Browse files
matthiaskrgrgitbot
authored and
gitbot
committed
Rollup merge of rust-lang#135991 - no1wudi:master, r=thomcc
Fix set_name in thread mod for NuttX Replace `pthread_set_name_np` with `pthread_setname_np` for NuttX in the `set_name` function, this change aligns the implementation with the correct API available on NuttX This patch ensures thread naming works correctly on NuttX platforms. See also: https://github.com/rust-lang/libc/blob/0f9f8c91adb0365c0d13b34ec27ac8019818cf1f/src/unix/nuttx/mod.rs#L562 https://github.com/apache/nuttx/blob/8f3a2a6f7645dd95b6a7608b9cde3cb693b118c2/include/pthread.h#L511-L514
2 parents b90df2b + 1a43c91 commit 0c9a1eb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ impl Thread {
130130
}
131131
}
132132

133-
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly"))]
133+
#[cfg(any(
134+
target_os = "linux",
135+
target_os = "freebsd",
136+
target_os = "dragonfly",
137+
target_os = "nuttx"
138+
))]
134139
pub fn set_name(name: &CStr) {
135140
unsafe {
136141
cfg_if::cfg_if! {
@@ -139,7 +144,7 @@ impl Thread {
139144
const TASK_COMM_LEN: usize = 16;
140145
let name = truncate_cstr::<{ TASK_COMM_LEN }>(name);
141146
} else {
142-
// FreeBSD and DragonFly BSD do not enforce length limits.
147+
// FreeBSD, DragonFly, FreeBSD and NuttX do not enforce length limits.
143148
}
144149
};
145150
// Available since glibc 2.12, musl 1.1.16, and uClibc 1.0.20 for Linux,
@@ -150,7 +155,7 @@ impl Thread {
150155
}
151156
}
152157

153-
#[cfg(any(target_os = "openbsd", target_os = "nuttx"))]
158+
#[cfg(target_os = "openbsd")]
154159
pub fn set_name(name: &CStr) {
155160
unsafe {
156161
libc::pthread_set_name_np(libc::pthread_self(), name.as_ptr());

0 commit comments

Comments
 (0)