alnyan/yggdrasil: add Yggdrasil getrandom

This commit is contained in:
Mark Poliakov 2024-01-28 18:54:42 +02:00
parent f68a940b4d
commit 69a646b970
3 changed files with 12 additions and 0 deletions

View File

@ -23,6 +23,9 @@ libc = { version = "0.2.149", default-features = false }
[target.'cfg(target_os = "wasi")'.dependencies]
wasi = { version = "0.11", default-features = false }
[target.'cfg(target_os = "yggdrasil")'.dependencies]
yggdrasil-rt = { git = "https://git.alnyan.me/yggdrasil/yggdrasil-rt.git" }
[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dependencies]
wasm-bindgen = { version = "0.2.62", default-features = false, optional = true }
js-sys = { version = "0.3", optional = true }

View File

@ -284,6 +284,8 @@ cfg_if! {
} else if #[cfg(target_os = "hurd")] {
mod util_libc;
#[path = "hurd.rs"] mod imp;
} else if #[cfg(target_os = "yggdrasil")] {
#[path = "yggdrasil.rs"] mod imp;
} else if #[cfg(feature = "custom")] {
use custom as imp;
} else if #[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"),

7
src/yggdrasil.rs Normal file
View File

@ -0,0 +1,7 @@
use core::mem::MaybeUninit;
use crate::Error;
pub(crate) fn getrandom_inner(buffer: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
Ok(unsafe { yggdrasil_rt::sys::get_random(crate::util::slice_assume_init_mut(buffer)) })
}