Skip to content

Commit 9fde3e9

Browse files
committed
Use libc's syscall() and NR_GETENTROPY const
1 parent 314062b commit 9fde3e9

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/libstd/rand/os.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ mod imp {
204204
_dummy: (),
205205
}
206206

207-
extern "C" {
208-
fn syscall(number: c_long, ...) -> c_long;
209-
}
210-
211-
const NR_GETENTROPY: c_long = 7;
212-
213207
impl OsRng {
214208
/// Create a new `OsRng`.
215209
pub fn new() -> io::Result<OsRng> {
@@ -232,7 +226,7 @@ mod imp {
232226
// getentropy(2) permits a maximum buffer size of 256 bytes
233227
for s in v.chunks_mut(256) {
234228
let ret = unsafe {
235-
syscall(NR_GETENTROPY, s.as_mut_ptr(), s.len())
229+
libc::syscall(libc::NR_GETENTROPY, s.as_mut_ptr(), s.len())
236230
};
237231
if ret == -1 {
238232
panic!("unexpected getentropy error: {}", errno());

0 commit comments

Comments
 (0)