Skip to content

Commit 6be2d9a

Browse files
committed
provide thread name to OS for Solarish systems
1 parent 435236b commit 6be2d9a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/libstd/sys/unix/thread.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,21 @@ impl Thread {
122122
name.as_ptr() as *mut libc::c_void);
123123
}
124124
}
125+
126+
#[cfg(target_os = "solaris")]
127+
pub fn set_name(name: &CStr) {
128+
weak! {
129+
fn pthread_setname_np(
130+
libc::pthread_t, *const libc::c_char
131+
) -> libc::c_int
132+
}
133+
134+
if let Some(f) = pthread_setname_np.get() {
135+
unsafe { f(libc::pthread_self(), name.as_ptr()); }
136+
}
137+
}
138+
125139
#[cfg(any(target_env = "newlib",
126-
target_os = "solaris",
127140
target_os = "haiku",
128141
target_os = "l4re",
129142
target_os = "emscripten",

0 commit comments

Comments
 (0)