Skip to content

Commit 9d311f9

Browse files
committed
Auto merge of #114967 - japaric:ja-gh114966, r=Mark-Simulacrum
QNX: pass a truncated thread name to the OS The maximum length the thread name can have is `_NTO_THREAD_NAME_MAX` fixes #114966
2 parents 030e4d3 + f58b254 commit 9d311f9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ impl Thread {
182182
}
183183

184184
if let Some(f) = pthread_setname_np.get() {
185+
#[cfg(target_os = "nto")]
186+
let name = truncate_cstr::<{ libc::_NTO_THREAD_NAME_MAX as usize }>(name);
187+
185188
let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
186189
debug_assert_eq!(res, 0);
187190
}
@@ -290,6 +293,7 @@ impl Drop for Thread {
290293
target_os = "ios",
291294
target_os = "tvos",
292295
target_os = "watchos",
296+
target_os = "nto",
293297
))]
294298
fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
295299
let mut result = [0; MAX_WITH_NUL];

0 commit comments

Comments
 (0)