2022-07-17 20:54:10 -05:00
|
|
|
//@only-target-linux
|
2022-07-08 11:08:32 -05:00
|
|
|
//@compile-flags: -Zmiri-disable-isolation
|
2019-08-23 16:30:23 -05:00
|
|
|
|
2022-06-26 20:14:18 -05:00
|
|
|
use std::ptr;
|
|
|
|
|
2019-08-23 16:30:23 -05:00
|
|
|
fn main() {
|
|
|
|
let mut buf = [0u8; 5];
|
|
|
|
unsafe {
|
2022-06-20 18:00:37 -05:00
|
|
|
assert_eq!(
|
|
|
|
libc::syscall(
|
|
|
|
libc::SYS_getrandom,
|
2022-06-26 20:14:18 -05:00
|
|
|
ptr::null_mut::<libc::c_void>(),
|
2022-06-20 18:00:37 -05:00
|
|
|
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-23 16:30:23 -05:00
|
|
|
|
2022-06-20 18:00:37 -05:00
|
|
|
assert_eq!(
|
2022-06-26 20:14:18 -05:00
|
|
|
libc::getrandom(ptr::null_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-23 16:30:23 -05:00
|
|
|
}
|
|
|
|
}
|