Skip to content

Commit 394e602

Browse files
committed
emscripten: use getentropy from libc
1 parent 53cf0cc commit 394e602

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

.github/workflows/tests.yml

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

src/emscripten.rs

Lines changed: 1 addition & 6 deletions
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)