summaryrefslogtreecommitdiff
path: root/src/backend/linux_raw/rand/syscalls.rs
blob: c0f497b989a04dc56ae5b3efc5d20dc6d5deea9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//! linux_raw syscalls supporting `rustix::rand`.
//!
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]

use crate::backend::conv::{pass_usize, ret_usize};
use crate::io;
use crate::rand::GetRandomFlags;

#[inline]
pub(crate) unsafe fn getrandom(
    buf: *mut u8,
    cap: usize,
    flags: GetRandomFlags,
) -> io::Result<usize> {
    ret_usize(syscall!(__NR_getrandom, buf, pass_usize(cap), flags))
}