diff --git a/Cargo.toml b/Cargo.toml index ea57331..e727e09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/lib.rs b/src/lib.rs index e80ec6f..eda910d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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"), diff --git a/src/yggdrasil.rs b/src/yggdrasil.rs new file mode 100644 index 0000000..51dcc9d --- /dev/null +++ b/src/yggdrasil.rs @@ -0,0 +1,7 @@ +use core::mem::MaybeUninit; + +use crate::Error; + +pub(crate) fn getrandom_inner(buffer: &mut [MaybeUninit]) -> Result<(), Error> { + Ok(unsafe { yggdrasil_rt::sys::get_random(crate::util::slice_assume_init_mut(buffer)) }) +}