Skip to content

Commit

Permalink
Use libc's syscall() and NR_GETENTROPY const
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcco committed Dec 19, 2015
1 parent 314062b commit 9fde3e9
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/libstd/rand/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,6 @@ mod imp {
_dummy: (),
}

extern "C" {
fn syscall(number: c_long, ...) -> c_long;
}

const NR_GETENTROPY: c_long = 7;

impl OsRng {
/// Create a new `OsRng`.
pub fn new() -> io::Result<OsRng> {
Expand All @@ -232,7 +226,7 @@ mod imp {
// getentropy(2) permits a maximum buffer size of 256 bytes
for s in v.chunks_mut(256) {
let ret = unsafe {
syscall(NR_GETENTROPY, s.as_mut_ptr(), s.len())
libc::syscall(libc::NR_GETENTROPY, s.as_mut_ptr(), s.len())
};
if ret == -1 {
panic!("unexpected getentropy error: {}", errno());
Expand Down

0 comments on commit 9fde3e9

Please sign in to comment.