@@ -18,7 +18,8 @@ pub fn hashmap_random_keys() -> (u64, u64) {
1818 not( target_os = "freebsd" ) ,
1919 not( target_os = "netbsd" ) ,
2020 not( target_os = "fuchsia" ) ,
21- not( target_os = "redox" )
21+ not( target_os = "redox" ) ,
22+ not( target_os = "vxworks" )
2223) ) ]
2324mod imp {
2425 use crate :: fs:: File ;
@@ -237,3 +238,29 @@ mod imp {
237238 file. read_exact ( v) . expect ( "failed to read rand:" )
238239 }
239240}
241+
242+ #[ cfg( target_os = "vxworks" ) ]
243+ mod imp {
244+ use crate :: io;
245+ use core:: sync:: atomic:: { AtomicBool , Ordering :: Relaxed } ;
246+
247+ pub fn fill_bytes ( v : & mut [ u8 ] ) {
248+ static RNG_INIT : AtomicBool = AtomicBool :: new ( false ) ;
249+ while !RNG_INIT . load ( Relaxed ) {
250+ let ret = unsafe { libc:: randSecure ( ) } ;
251+ if ret < 0 {
252+ panic ! ( "couldn't generate random bytes: {}" , io:: Error :: last_os_error( ) ) ;
253+ } else if ret > 0 {
254+ RNG_INIT . store ( true , Relaxed ) ;
255+ break ;
256+ }
257+ unsafe { libc:: usleep ( 10 ) } ;
258+ }
259+ let ret = unsafe {
260+ libc:: randABytes ( v. as_mut_ptr ( ) as * mut libc:: c_uchar , v. len ( ) as libc:: c_int )
261+ } ;
262+ if ret < 0 {
263+ panic ! ( "couldn't generate random bytes: {}" , io:: Error :: last_os_error( ) ) ;
264+ }
265+ }
266+ }
0 commit comments