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 / getentropy.rs

21 lines · 632 bytes Raw Blame History
1//! Implementation using getentropy(2)
2//!
3//! Available since:
4//! - macOS 10.12
5//! - OpenBSD 5.6
6//! - Emscripten 2.0.5
7//! - vita newlib since Dec 2021
8//!
9//! For these targets, we use getentropy(2) because getrandom(2) doesn't exist.
10use crate::{util_libc::last_os_error, Error};
11use core::mem::MaybeUninit;
12
13pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
14 for chunk in dest.chunks_mut(256) {
15 let ret = unsafe { libc::getentropy(chunk.as_mut_ptr() as *mut libc::c_void, chunk.len()) };
16 if ret != 0 {
17 return Err(last_os_error());
18 }
19 }
20 Ok(())
21}