about summary refs log tree commit diff
path: root/library/std/src/sys/unix/thread.rs
diff options
context:
space:
mode:
authorJorge Aparicio <jorge.aparicio@ferrous-systems.com>2023-08-18 14:47:12 +0200
committerJorge Aparicio <jorge.aparicio@ferrous-systems.com>2023-08-18 14:47:12 +0200
commitf58b2548dc702ebc64a1b6e63f0eb1f99dc7851b (patch)
tree5479a2ce49ae9036c6d0ef249d3585ddf46a2306 /library/std/src/sys/unix/thread.rs
parent0f7f6b70617fbcda9f73755fa9b560bfb0a588eb (diff)
downloadrust-f58b2548dc702ebc64a1b6e63f0eb1f99dc7851b.tar.gz
rust-f58b2548dc702ebc64a1b6e63f0eb1f99dc7851b.zip
QNX: pass a truncated thread name to the OS
The maximum length the thread name can have is `_NTO_THREAD_NAME_MAX`
Diffstat (limited to 'library/std/src/sys/unix/thread.rs')
-rw-r--r--library/std/src/sys/unix/thread.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs
index 4f2d9cf3655..7c242d4d334 100644
--- a/library/std/src/sys/unix/thread.rs
+++ b/library/std/src/sys/unix/thread.rs
@@ -182,6 +182,9 @@ impl Thread {
         }
 
         if let Some(f) = pthread_setname_np.get() {
+            #[cfg(target_os = "nto")]
+            let name = truncate_cstr::<{ libc::_NTO_THREAD_NAME_MAX as usize }>(name);
+
             let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
             debug_assert_eq!(res, 0);
         }
@@ -290,6 +293,7 @@ impl Drop for Thread {
     target_os = "ios",
     target_os = "tvos",
     target_os = "watchos",
+    target_os = "nto",
 ))]
 fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
     let mut result = [0; MAX_WITH_NUL];