From 747d19326b3e9a87eca74947afb97cca74b843fa Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 1 Apr 2024 10:01:21 +0100 Subject: [PATCH] std::thread: adding get_name implementation for solaris/illumos. THREAD_NAME_MAX is 32 (31 max + 1 for the null terminator). --- library/std/src/sys/pal/unix/thread.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 77e31d802a3..79e4c4788c4 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -225,13 +225,19 @@ pub fn set_name(_name: &CStr) { // Newlib, Emscripten, and VxWorks have no way to set a thread name. } - #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd",))] + #[cfg(any( + target_os = "linux", + target_os = "freebsd", + target_os = "netbsd", + target_os = "solaris", + target_os = "illumos" + ))] pub fn get_name() -> Option { #[cfg(target_os = "linux")] const TASK_COMM_LEN: usize = 16; #[cfg(target_os = "freebsd")] const TASK_COMM_LEN: usize = libc::MAXCOMLEN + 1; - #[cfg(target_os = "netbsd")] + #[cfg(any(target_os = "netbsd", target_os = "solaris", target_os = "illumos"))] const TASK_COMM_LEN: usize = 32; let mut name = vec![0u8; TASK_COMM_LEN]; let res = unsafe { @@ -282,7 +288,9 @@ pub fn get_name() -> Option { target_os = "ios", target_os = "tvos", target_os = "watchos", - target_os = "haiku" + target_os = "haiku", + target_os = "solaris", + target_os = "illumos" )))] pub fn get_name() -> Option { None