2022-03-17 08:49:10 -05:00
|
|
|
// only-linux
|
2019-08-04 14:53:49 -05:00
|
|
|
#![feature(rustc_private)]
|
|
|
|
extern crate libc;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut buf = [0u8; 5];
|
|
|
|
unsafe {
|
2022-06-20 18:00:37 -05:00
|
|
|
assert_eq!(
|
|
|
|
libc::syscall(
|
|
|
|
libc::SYS_getrandom,
|
|
|
|
0 as *mut libc::c_void,
|
|
|
|
0 as libc::size_t,
|
2022-06-20 18:08:00 -05:00
|
|
|
0 as libc::c_uint,
|
2022-06-20 18:00:37 -05:00
|
|
|
),
|
2022-06-20 18:08:00 -05:00
|
|
|
0,
|
2022-06-20 18:00:37 -05:00
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
libc::syscall(
|
|
|
|
libc::SYS_getrandom,
|
|
|
|
buf.as_mut_ptr() as *mut libc::c_void,
|
|
|
|
5 as libc::size_t,
|
2022-06-20 18:08:00 -05:00
|
|
|
0 as libc::c_uint,
|
2022-06-20 18:00:37 -05:00
|
|
|
),
|
2022-06-20 18:08:00 -05:00
|
|
|
5,
|
2022-06-20 18:00:37 -05:00
|
|
|
);
|
2019-08-04 15:11:52 -05:00
|
|
|
|
2022-06-20 18:00:37 -05:00
|
|
|
assert_eq!(
|
|
|
|
libc::getrandom(0 as *mut libc::c_void, 0 as libc::size_t, 0 as libc::c_uint),
|
2022-06-20 18:08:00 -05:00
|
|
|
0,
|
2022-06-20 18:00:37 -05:00
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
libc::getrandom(
|
|
|
|
buf.as_mut_ptr() as *mut libc::c_void,
|
|
|
|
5 as libc::size_t,
|
2022-06-20 18:08:00 -05:00
|
|
|
0 as libc::c_uint,
|
2022-06-20 18:00:37 -05:00
|
|
|
),
|
2022-06-20 18:08:00 -05:00
|
|
|
5,
|
2022-06-20 18:00:37 -05:00
|
|
|
);
|
2019-08-04 14:53:49 -05:00
|
|
|
}
|
|
|
|
}
|