Sha256: 5beb52344a9b71c75426bbc56eb989f5fcb81642772737d52e92578b315615a1

Contents?: true

Size: 632 Bytes

Versions: 8

Compression:

Stored size: 632 Bytes

Contents

//! Implementation using getentropy(2)
//!
//! Available since:
//!   - macOS 10.12
//!   - OpenBSD 5.6
//!   - Emscripten 2.0.5
//!   - vita newlib since Dec 2021
//!
//! For these targets, we use getentropy(2) because getrandom(2) doesn't exist.
use crate::{util_libc::last_os_error, Error};
use core::mem::MaybeUninit;

pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
    for chunk in dest.chunks_mut(256) {
        let ret = unsafe { libc::getentropy(chunk.as_mut_ptr() as *mut libc::c_void, chunk.len()) };
        if ret != 0 {
            return Err(last_os_error());
        }
    }
    Ok(())
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/getrandom-0.2.15/src/getentropy.rs
wasmtime-28.0.0 ./ext/cargo-vendor/getrandom-0.2.15/src/getentropy.rs
wasmtime-27.0.0 ./ext/cargo-vendor/getrandom-0.2.15/src/getentropy.rs
wasmtime-26.0.0 ./ext/cargo-vendor/getrandom-0.2.15/src/getentropy.rs
wasmtime-25.0.2 ./ext/cargo-vendor/getrandom-0.2.15/src/getentropy.rs
wasmtime-25.0.1 ./ext/cargo-vendor/getrandom-0.2.15/src/getentropy.rs
wasmtime-25.0.0 ./ext/cargo-vendor/getrandom-0.2.15/src/getentropy.rs
wasmtime-24.0.0 ./ext/cargo-vendor/getrandom-0.2.15/src/getentropy.rs