Skip to content

Commit 569ec79

Browse files
committed
VxWorks: Extern taskNameget and fix thread::setName implementation
1 parent fb1dac2 commit 569ec79

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

library/std/src/sys/pal/unix/thread.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::sys::weak::dlsym;
77
target_os = "solaris",
88
target_os = "illumos",
99
target_os = "nto",
10-
target_os = "vxworks"
1110
))]
1211
use crate::sys::weak::weak;
1312
use crate::sys::{os, stack_overflow};
@@ -220,23 +219,18 @@ impl Thread {
220219
#[cfg(target_os = "vxworks")]
221220
pub fn set_name(name: &CStr) {
222221
// FIXME(libc): adding real STATUS, ERROR type eventually.
223-
weak! {
222+
extern "C" {
224223
fn taskNameSet(
225-
libc::TASK_ID, *mut libc::c_char
226-
) -> libc::c_int
224+
task_id : libc::TASK_ID, task_name : *mut libc::c_char
225+
) -> libc::c_int;
227226
}
228227

229-
// We can't assume taskNameSet is necessarily available.
230-
// VX_TASK_NAME_LEN can be found set to 31,
231-
// however older versions can be set to only 10.
232-
// FIXME(vxworks): if the minimum supported VxWorks is >= 7, the maximum length can be changed to 31.
233-
if let Some(f) = taskNameSet.get() {
234-
const VX_TASK_NAME_LEN: usize = 10;
228+
// VX_TASK_NAME_LEN is 31 in VxWorks 7.
229+
const VX_TASK_NAME_LEN: usize = 31;
235230

236-
let name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
237-
let status = unsafe { f(libc::taskIdSelf(), name.as_mut_ptr()) };
238-
debug_assert_eq!(res, libc::OK);
239-
}
231+
let mut name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
232+
let res = unsafe { taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) };
233+
debug_assert_eq!(res, libc::OK);
240234
}
241235

242236
#[cfg(any(

0 commit comments

Comments
 (0)