Debian Codegraph @

debian/missing-sources/rustix/src/backend/linux_raw/rand/syscalls.rs

raw
1 //! linux_raw syscalls supporting `rustix::rand`.
2 //!
3 //! # Safety
4 //!
5 //! See the `rustix::backend` module documentation for details.
6 #![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
7
8 use crate::backend::conv::{pass_usize, ret_usize};
9 use crate::io;
10 use crate::rand::GetRandomFlags;
11
12 #[inline]
13 pub(crate) unsafe fn getrandom(buf: (*mut u8, usize), flags: GetRandomFlags) -> io::Result<usize> {
14 let r = ret_usize(syscall!(__NR_getrandom, buf.0, pass_usize(buf.1), flags));
15
16 #[cfg(sanitize_memory)]
17 if let Ok(len) = r {
18 crate::msan::unpoison(buf.0, len);
19 }
20
21 r
22 }