From 6be2d9ae864ae2a9b7f9d68ef8c073aad2b1efdc Mon Sep 17 00:00:00 2001 From: John Levon Date: Fri, 2 Aug 2019 09:16:20 +0100 Subject: [PATCH] provide thread name to OS for Solarish systems --- src/libstd/sys/unix/thread.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index f4a1783ce8903..122fc11ec2725 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -122,8 +122,21 @@ impl Thread { name.as_ptr() as *mut libc::c_void); } } + + #[cfg(target_os = "solaris")] + pub fn set_name(name: &CStr) { + weak! { + fn pthread_setname_np( + libc::pthread_t, *const libc::c_char + ) -> libc::c_int + } + + if let Some(f) = pthread_setname_np.get() { + unsafe { f(libc::pthread_self(), name.as_ptr()); } + } + } + #[cfg(any(target_env = "newlib", - target_os = "solaris", target_os = "haiku", target_os = "l4re", target_os = "emscripten",