QNX: pass a truncated thread name to the OS
The maximum length the thread name can have is `_NTO_THREAD_NAME_MAX`
This commit is contained in:
parent
0f7f6b7061
commit
f58b2548dc
1 changed files with 4 additions and 0 deletions
|
@ -182,6 +182,9 @@ impl Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(f) = pthread_setname_np.get() {
|
if let Some(f) = pthread_setname_np.get() {
|
||||||
|
#[cfg(target_os = "nto")]
|
||||||
|
let name = truncate_cstr::<{ libc::_NTO_THREAD_NAME_MAX as usize }>(name);
|
||||||
|
|
||||||
let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
|
let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
|
||||||
debug_assert_eq!(res, 0);
|
debug_assert_eq!(res, 0);
|
||||||
}
|
}
|
||||||
|
@ -290,6 +293,7 @@ impl Drop for Thread {
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
target_os = "tvos",
|
target_os = "tvos",
|
||||||
target_os = "watchos",
|
target_os = "watchos",
|
||||||
|
target_os = "nto",
|
||||||
))]
|
))]
|
||||||
fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
|
fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
|
||||||
let mut result = [0; MAX_WITH_NUL];
|
let mut result = [0; MAX_WITH_NUL];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue