about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-08-06 11:21:28 +0900
committerGitHub <noreply@github.com>2021-08-06 11:21:28 +0900
commit4b068dd657aad9e39be9cac1e8c3dee281c92cd4 (patch)
treeedceabde949977ba9702bc05c9633926deea770c /library/std/src/sys
parente2f79572fbcbe103346c950d95d7335f6c804d83 (diff)
parent52371f4b16c76001e054761023a6ef4e817d42ad (diff)
downloadrust-4b068dd657aad9e39be9cac1e8c3dee281c92cd4.tar.gz
rust-4b068dd657aad9e39be9cac1e8c3dee281c92cd4.zip
Rollup merge of #87561 - devnexen:haiku_thread_build_fix, r=yaahc
thread set_name haiku implementation.
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/unix/thread.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs
index 1488bf94841..bc61f472a2b 100644
--- a/library/std/src/sys/unix/thread.rs
+++ b/library/std/src/sys/unix/thread.rs
@@ -164,16 +164,23 @@ impl Thread {
         }
     }
 
+    #[cfg(target_os = "haiku")]
+    pub fn set_name(name: &CStr) {
+        unsafe {
+            let thread_self = libc::find_thread(ptr::null_mut());
+            libc::rename_thread(thread_self, name.as_ptr());
+        }
+    }
+
     #[cfg(any(
         target_env = "newlib",
-        target_os = "haiku",
         target_os = "l4re",
         target_os = "emscripten",
         target_os = "redox",
         target_os = "vxworks"
     ))]
     pub fn set_name(_name: &CStr) {
-        // Newlib, Haiku, Emscripten, and VxWorks have no way to set a thread name.
+        // Newlib, Emscripten, and VxWorks have no way to set a thread name.
     }
 
     pub fn sleep(dur: Duration) {