Skip to content

Commit

Permalink
Rollup merge of rust-lang#123323 - devnexen:thread_set_name_solaris_f…
Browse files Browse the repository at this point in the history
…ix, r=workingjubilee

std::thread: set_name change for solaris/illumos.

truncate down to 32 (31 + 1) for solaris/illumos.
  • Loading branch information
workingjubilee authored Apr 1, 2024
2 parents fe114cf + 61289a0 commit b44b609
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion library/std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ impl Thread {

if let Some(f) = pthread_setname_np.get() {
#[cfg(target_os = "nto")]
let name = truncate_cstr::<{ libc::_NTO_THREAD_NAME_MAX as usize }>(name);
const THREAD_NAME_MAX: usize = libc::_NTO_THREAD_NAME_MAX as usize;
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
const THREAD_NAME_MAX: usize = 32;

let name = truncate_cstr::<{ THREAD_NAME_MAX }>(name);
let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
debug_assert_eq!(res, 0);
}
Expand Down

0 comments on commit b44b609

Please sign in to comment.