Skip to content

Commit

Permalink
Merge pull request #629 from samueltardieu/issue-610
Browse files Browse the repository at this point in the history
Use syscall from libc on Linux instead of redefining it
  • Loading branch information
dhardy committed Oct 9, 2018
2 parents ad8410e + 92009af commit 0911a4e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/rngs/os.rs
Expand Up @@ -426,16 +426,13 @@ mod imp {
const NR_GETRANDOM: libc::c_long = 0;

fn getrandom(buf: &mut [u8], blocking: bool) -> libc::c_long {
extern "C" {
fn syscall(number: libc::c_long, ...) -> libc::c_long;
}
const GRND_NONBLOCK: libc::c_uint = 0x0001;

if NR_GETRANDOM == 0 { return -1 };

unsafe {
syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(),
if blocking { 0 } else { GRND_NONBLOCK })
libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(),
if blocking { 0 } else { GRND_NONBLOCK })
}
}

Expand Down

0 comments on commit 0911a4e

Please sign in to comment.