From 8807408e198fb7c0aeade3d2c86c64e48ea2081d Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:13:54 +0200 Subject: [PATCH] Add binding of getrandom for Redox OS Relibc definition for getrandom: https://gitlab.redox-os.org/redox-os/relibc/-/blob/5f6afb52692e62dae79154f4dbec2d0e79a07602/src/header/sys_random/mod.rs --- src/unix/redox/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 8b07653db49d..1c327cabd172 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -778,6 +778,10 @@ pub const MS_ASYNC: c_int = 0x0001; pub const MS_INVALIDATE: c_int = 0x0002; pub const MS_SYNC: c_int = 0x0004; +// sys/random.h +pub const GRND_NONBLOCK: c_uint = 1; +pub const GRND_RANDOM: c_uint = 2; + // sys/resource.h pub const RLIM_INFINITY: rlim_t = !0; pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; @@ -1389,6 +1393,9 @@ extern "C" { pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; + // sys/random.h + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + // sys/resource.h pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;