• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! linux_raw syscalls supporting `rustix::rand`.
2 //!
3 //! # Safety
4 //!
5 //! See the `rustix::backend` module documentation for details.
6 #![allow(unsafe_code)]
7 #![allow(clippy::undocumented_unsafe_blocks)]
8 
9 use super::super::conv::{ret_usize, slice_mut};
10 use crate::io;
11 use crate::rand::GetRandomFlags;
12 
13 #[inline]
getrandom(buf: &mut [u8], flags: GetRandomFlags) -> io::Result<usize>14 pub(crate) fn getrandom(buf: &mut [u8], flags: GetRandomFlags) -> io::Result<usize> {
15     let (buf_addr_mut, buf_len) = slice_mut(buf);
16     unsafe { ret_usize(syscall!(__NR_getrandom, buf_addr_mut, buf_len, flags)) }
17 }
18