about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee <46493976+workingjubilee@users.noreply.github.com>2024-04-01 17:22:10 -0700
committerGitHub <noreply@github.com>2024-04-01 17:22:10 -0700
commit48b2a517fca479d4b66a97fcfce52738e4e0332d (patch)
treefc2ab841935d2b64a91fa1f0c65a106ca665f8e6
parent1684a753dbca5d23b2e03568e6fbbb48eb72d0e6 (diff)
parentca36fe310e8970a66461ff7fc8496a76c75b70ed (diff)
downloadrust-48b2a517fca479d4b66a97fcfce52738e4e0332d.tar.gz
rust-48b2a517fca479d4b66a97fcfce52738e4e0332d.zip
Rollup merge of #123323 - devnexen:thread_set_name_solaris_fix, r=workingjubilee
std::thread: set_name change for solaris/illumos.

truncate down to 32 (31 + 1) for solaris/illumos.
-rw-r--r--library/std/src/sys/pal/unix/thread.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs
index f1feeb530b3..a9ed7e7c75e 100644
--- a/library/std/src/sys/pal/unix/thread.rs
+++ b/library/std/src/sys/pal/unix/thread.rs
@@ -182,8 +182,11 @@ 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);
+            const THREAD_NAME_MAX: usize = libc::_NTO_THREAD_NAME_MAX as usize;
+            #[cfg(any(target_os = "solaris", target_os = "illumos"))]
+            const THREAD_NAME_MAX: usize = 32;
 
+            let name = truncate_cstr::<{ THREAD_NAME_MAX }>(name);
             let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
             debug_assert_eq!(res, 0);
         }
@@ -368,6 +371,8 @@ impl Drop for Thread {
     target_os = "tvos",
     target_os = "watchos",
     target_os = "nto",
+    target_os = "solaris",
+    target_os = "illumos",
 ))]
 fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
     let mut result = [0; MAX_WITH_NUL];