diff options
| author | B I Mohammed Abbas <bimohammadabbas@gmail.com> | 2024-08-08 15:16:22 +0530 |
|---|---|---|
| committer | B I Mohammed Abbas <bimohammadabbas@gmail.com> | 2024-08-08 15:16:22 +0530 |
| commit | 2abcc6beeb6abaaf35f4a15d8d4b114b386b9e51 (patch) | |
| tree | a31270484512684afc93dad3335d7b838b8b5712 | |
| parent | 1e3ea293e22f62440c52e87c0c9d11c8fb7dfcbe (diff) | |
| download | rust-2abcc6beeb6abaaf35f4a15d8d4b114b386b9e51.tar.gz rust-2abcc6beeb6abaaf35f4a15d8d4b114b386b9e51.zip | |
Vxworks: Extern taskNameSet and fix build errors
| -rw-r--r-- | library/std/src/sys/pal/unix/thread.rs | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 90aa69f6d14..6f17c73908d 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -3,12 +3,7 @@ use crate::mem::{self, ManuallyDrop}; use crate::num::NonZero; #[cfg(all(target_os = "linux", target_env = "gnu"))] use crate::sys::weak::dlsym; -#[cfg(any( - target_os = "solaris", - target_os = "illumos", - target_os = "nto", - target_os = "vxworks" -))] +#[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto",))] use crate::sys::weak::weak; use crate::sys::{os, stack_overflow}; use crate::time::Duration; @@ -220,23 +215,16 @@ impl Thread { #[cfg(target_os = "vxworks")] pub fn set_name(name: &CStr) { // FIXME(libc): adding real STATUS, ERROR type eventually. - weak! { - fn taskNameSet( - libc::TASK_ID, *mut libc::c_char - ) -> libc::c_int + extern "C" { + fn taskNameSet(task_id: libc::TASK_ID, task_name: *mut libc::c_char) -> libc::c_int; } - // We can't assume taskNameSet is necessarily available. - // VX_TASK_NAME_LEN can be found set to 31, - // however older versions can be set to only 10. - // FIXME(vxworks): if the minimum supported VxWorks is >= 7, the maximum length can be changed to 31. - if let Some(f) = taskNameSet.get() { - const VX_TASK_NAME_LEN: usize = 10; + // VX_TASK_NAME_LEN is 31 in VxWorks 7. + const VX_TASK_NAME_LEN: usize = 31; - let name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name); - let status = unsafe { f(libc::taskIdSelf(), name.as_mut_ptr()) }; - debug_assert_eq!(res, libc::OK); - } + let mut name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name); + let res = unsafe { taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) }; + debug_assert_eq!(res, libc::OK); } #[cfg(any( |
