diff options
| author | David Carlier <devnexen@gmail.com> | 2024-03-30 14:19:05 +0000 |
|---|---|---|
| committer | David Carlier <devnexen@gmail.com> | 2024-03-30 16:01:47 +0000 |
| commit | c749483e2670162a0d185376cd2d97526eeb6695 (patch) | |
| tree | db94b2aeefe4653fc4449a11e0cf7bf6dad3b786 | |
| parent | 7e0ed43287a658be61dab00b68827865f2fc9c5a (diff) | |
| download | rust-c749483e2670162a0d185376cd2d97526eeb6695.tar.gz rust-c749483e2670162a0d185376cd2d97526eeb6695.zip | |
std::thread: adding freebsd/netbsd to the linux's get_name implementation.
| -rw-r--r-- | library/std/src/sys/pal/unix/thread.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 4cd7c0e3059..01e3c3cbc6f 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -225,9 +225,14 @@ impl Thread { // Newlib, Emscripten, and VxWorks have no way to set a thread name. } - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd",))] pub fn get_name() -> Option<CString> { + #[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")] + const TASK_COMM_LEN: usize = 32; let mut name = vec![0u8; TASK_COMM_LEN]; let res = unsafe { libc::pthread_getname_np(libc::pthread_self(), name.as_mut_ptr().cast(), name.len()) @@ -254,6 +259,8 @@ impl Thread { #[cfg(not(any( target_os = "linux", + target_os = "freebsd", + target_os = "netbsd", target_os = "macos", target_os = "ios", target_os = "tvos", |
