Add getrandom and sys/random.h

This commit is contained in:
Jeremy Soller
2020-05-22 11:50:54 -06:00
parent 2cf3ccae72
commit a6fffd3fb5
7 changed files with 77 additions and 0 deletions
+1
View File
@@ -50,6 +50,7 @@ pub mod _wctype;
pub mod arch_aarch64_user;
pub mod arch_x64_user;
pub mod sys_procfs;
pub mod sys_random;
pub mod sys_uio;
pub mod sys_un;
pub mod sys_utsname;
+9
View File
@@ -0,0 +1,9 @@
sys_includes = ["sys/types.h"]
include_guard = "_SYS_RANDOM_H"
language = "C"
style = "Tag"
no_includes = true
cpp_compat = true
[enum]
prefix_with_name = true
+14
View File
@@ -0,0 +1,14 @@
use core::slice;
use crate::platform::{Pal, Sys, types::*};
pub const GRND_NONBLOCK: c_uint = 1;
pub const GRND_RANDOM: c_uint = 2;
#[no_mangle]
unsafe extern "C" fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t {
Sys::getrandom(slice::from_raw_parts_mut(
buf as *mut u8,
buflen as usize
), flags)
}