]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass-dep/shims/libc-getrandom-without-isolation.rs
Auto merge of #106884 - clubby789:fieldless-enum-debug, r=michaelwoerister
[rust.git] / src / tools / miri / tests / pass-dep / shims / libc-getrandom-without-isolation.rs
1 //@only-target-linux
2 //@compile-flags: -Zmiri-disable-isolation
3
4 use std::ptr;
5
6 fn main() {
7     let mut buf = [0u8; 5];
8     unsafe {
9         assert_eq!(
10             libc::syscall(
11                 libc::SYS_getrandom,
12                 ptr::null_mut::<libc::c_void>(),
13                 0 as libc::size_t,
14                 0 as libc::c_uint,
15             ),
16             0,
17         );
18         assert_eq!(
19             libc::syscall(
20                 libc::SYS_getrandom,
21                 buf.as_mut_ptr() as *mut libc::c_void,
22                 5 as libc::size_t,
23                 0 as libc::c_uint,
24             ),
25             5,
26         );
27
28         assert_eq!(
29             libc::getrandom(ptr::null_mut::<libc::c_void>(), 0 as libc::size_t, 0 as libc::c_uint),
30             0,
31         );
32         assert_eq!(
33             libc::getrandom(
34                 buf.as_mut_ptr() as *mut libc::c_void,
35                 5 as libc::size_t,
36                 0 as libc::c_uint,
37             ),
38             5,
39         );
40     }
41 }