Skip to content

Commit 50212bd

Browse files
josephlrnewpavlov
authored andcommitted
linux: Use libc::GRND_NONBLOCK (#29)
We don't need to define this ourself. Introduced in libc 0.2.34: See: rust-lang/libc#830
1 parent ce4a089 commit 50212bd

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ members = ["tests/wasm_bindgen"]
2121
log = { version = "0.4", optional = true }
2222

2323
[target.'cfg(unix)'.dependencies]
24-
libc = "0.2.29"
24+
libc = "0.2.34"
2525

2626
[target.'cfg(windows)'.dependencies]
2727
winapi = { version = "0.3.6", features = ["minwindef", "ntsecapi", "winnt"] }

src/linux_android.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use core::num::NonZeroU32;
1717
use core::sync::atomic::{AtomicBool, Ordering};
1818

1919
// This flag tells getrandom() to return EAGAIN instead of blocking.
20-
const GRND_NONBLOCK: libc::c_uint = 0x0001;
2120
static RNG_INIT: AtomicBool = AtomicBool::new(false);
2221

2322
enum RngSource {
@@ -30,7 +29,7 @@ thread_local!(
3029
);
3130

3231
fn syscall_getrandom(dest: &mut [u8], block: bool) -> Result<(), io::Error> {
33-
let flags = if block { 0 } else { GRND_NONBLOCK };
32+
let flags = if block { 0 } else { libc::GRND_NONBLOCK };
3433
let ret = unsafe {
3534
libc::syscall(libc::SYS_getrandom, dest.as_mut_ptr(), dest.len(), flags)
3635
};

0 commit comments

Comments
 (0)