From e57fcac8dc3cb1f8c906cf1f8f7179050927df1b Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Tue, 6 Jun 2023 16:43:21 +0300 Subject: [PATCH] emscripten: use getentropy from libc (#362) --- .github/workflows/tests.yml | 2 +- src/emscripten.rs | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 800a4361..2f74f43e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -78,7 +78,7 @@ jobs: with: targets: ${{ matrix.target }} - name: Install multilib - run: sudo apt-get install gcc-multilib + run: sudo apt-get update && sudo apt-get install gcc-multilib - uses: Swatinem/rust-cache@v2 - run: cargo test --target=${{ matrix.target }} --features=std diff --git a/src/emscripten.rs b/src/emscripten.rs index a50372f5..30221c6e 100644 --- a/src/emscripten.rs +++ b/src/emscripten.rs @@ -2,15 +2,10 @@ use crate::{util_libc::last_os_error, Error}; use core::mem::MaybeUninit; -// Not yet defined in libc crate. -extern "C" { - fn getentropy(buffer: *mut libc::c_void, length: usize) -> libc::c_int; -} - pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { // Emscripten 2.0.5 added getentropy, so we can use it unconditionally. // Unlike other getentropy implementations, there is no max buffer length. - let ret = unsafe { getentropy(dest.as_mut_ptr() as *mut libc::c_void, dest.len()) }; + let ret = unsafe { libc::getentropy(dest.as_mut_ptr() as *mut libc::c_void, dest.len()) }; if ret < 0 { return Err(last_os_error()); }