@@ -3,7 +3,12 @@ use crate::mem::{self, ManuallyDrop};
3
3
use crate :: num:: NonZero ;
4
4
#[ cfg( all( target_os = "linux" , target_env = "gnu" ) ) ]
5
5
use crate :: sys:: weak:: dlsym;
6
- #[ cfg( any( target_os = "solaris" , target_os = "illumos" , target_os = "nto" ) ) ]
6
+ #[ cfg( any(
7
+ target_os = "solaris" ,
8
+ target_os = "illumos" ,
9
+ target_os = "nto" ,
10
+ target_os = "vxworks"
11
+ ) ) ]
7
12
use crate :: sys:: weak:: weak;
8
13
use crate :: sys:: { os, stack_overflow} ;
9
14
use crate :: time:: Duration ;
@@ -212,12 +217,33 @@ impl Thread {
212
217
}
213
218
}
214
219
220
+ #[ cfg( target_os = "vxworks" ) ]
221
+ pub fn set_name ( name : & CStr ) {
222
+ // FIXME: adding real STATUS type, OK, ERROR ... to libc crate eventually.
223
+ weak ! {
224
+ fn taskNameSet(
225
+ libc:: TASK_ID , * mut libc:: c_char
226
+ ) -> libc:: c_int
227
+ }
228
+
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: if minimum version supported is 7, then let's try 31.
233
+ if let Some ( f) = taskNameSet. get ( ) {
234
+ const VX_TASK_NAME_LEN : usize = 10 ;
235
+
236
+ let name = truncate_cstr :: < { VX_TASK_NAME_LEN } > ( name) ;
237
+ let status = unsafe { f ( libc:: taskIdSelf ( ) , name. as_ptr ( ) as * mut libc:: c_char ) } ;
238
+ debug_assert_eq ! ( res, 0 ) ;
239
+ }
240
+ }
241
+
215
242
#[ cfg( any(
216
243
target_env = "newlib" ,
217
244
target_os = "l4re" ,
218
245
target_os = "emscripten" ,
219
246
target_os = "redox" ,
220
- target_os = "vxworks" ,
221
247
target_os = "hurd" ,
222
248
target_os = "aix" ,
223
249
) ) ]
@@ -291,6 +317,7 @@ impl Drop for Thread {
291
317
target_os = "nto" ,
292
318
target_os = "solaris" ,
293
319
target_os = "illumos" ,
320
+ target_os = "vxworks" ,
294
321
target_vendor = "apple" ,
295
322
) ) ]
296
323
fn truncate_cstr < const MAX_WITH_NUL : usize > ( cstr : & CStr ) -> [ libc:: c_char ; MAX_WITH_NUL ] {
0 commit comments