Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/getrandom/src/vxworks.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / getrandom / src / vxworks.rs` 29 lines ยท 885 bytes Raw Blame History 1 //! Implementation for VxWorks 2 use crate::{util_libc::last_os_error, Error}; 3 use core::{ 4 mem::MaybeUninit, 5 sync::atomic::{AtomicBool, Ordering::Relaxed}, 6 }; 7 8 pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { 9 static RNG_INIT: AtomicBool = AtomicBool::new(false); 10 while !RNG_INIT.load(Relaxed) { 11 let ret = unsafe { libc::randSecure() }; 12 if ret < 0 { 13 return Err(Error::VXWORKS_RAND_SECURE); 14 } else if ret > 0 { 15 RNG_INIT.store(true, Relaxed); 16 break; 17 } 18 unsafe { libc::usleep(10) }; 19 } 20 21 // Prevent overflow of i32 22 for chunk in dest.chunks_mut(i32::max_value() as usize) { 23 let ret = unsafe { libc::randABytes(chunk.as_mut_ptr() as *mut u8, chunk.len() as i32) }; 24 if ret != 0 { 25 return Err(last_os_error()); 26 } 27 } 28 Ok(()) 29 }