interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / getrandom / src / solid.rs

18 lines · 625 bytes Raw Blame History
1//! Implementation for SOLID
2use crate::Error;
3use core::{mem::MaybeUninit, num::NonZeroU32};
4
5extern "C" {
6 pub fn SOLID_RNG_SampleRandomBytes(buffer: *mut u8, length: usize) -> i32;
7}
8
9pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
10 let ret = unsafe { SOLID_RNG_SampleRandomBytes(dest.as_mut_ptr() as *mut u8, dest.len()) };
11 if ret >= 0 {
12 Ok(())
13 } else {
14 // ITRON error numbers are always negative, so we negate it so that it
15 // falls in the dedicated OS error range (1..INTERNAL_START).
16 Err(NonZeroU32::new((-ret) as u32).unwrap().into())
17 }
18}