Skip to content

Commit e57fcac

Browse files
authored
emscripten: use getentropy from libc (#362)
1 parent 5aa4105 commit e57fcac

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
with:
7979
targets: ${{ matrix.target }}
8080
- name: Install multilib
81-
run: sudo apt-get install gcc-multilib
81+
run: sudo apt-get update && sudo apt-get install gcc-multilib
8282
- uses: Swatinem/rust-cache@v2
8383
- run: cargo test --target=${{ matrix.target }} --features=std
8484

src/emscripten.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22
use crate::{util_libc::last_os_error, Error};
33
use core::mem::MaybeUninit;
44

5-
// Not yet defined in libc crate.
6-
extern "C" {
7-
fn getentropy(buffer: *mut libc::c_void, length: usize) -> libc::c_int;
8-
}
9-
105
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
116
// Emscripten 2.0.5 added getentropy, so we can use it unconditionally.
127
// Unlike other getentropy implementations, there is no max buffer length.
13-
let ret = unsafe { getentropy(dest.as_mut_ptr() as *mut libc::c_void, dest.len()) };
8+
let ret = unsafe { libc::getentropy(dest.as_mut_ptr() as *mut libc::c_void, dest.len()) };
149
if ret < 0 {
1510
return Err(last_os_error());
1611
}

0 commit comments

Comments
 (0)