diff --git a/src/util_libc.rs b/src/util_libc.rs index 4f1b05e3..696bd9e4 100644 --- a/src/util_libc.rs +++ b/src/util_libc.rs @@ -110,8 +110,6 @@ pub fn getrandom_syscall(buf: &mut [MaybeUninit]) -> libc::ssize_t { // no real truncation here, even when running debug_assert!(buf.len() <= isize::MAX.unsigned_abs()); - // TODO: Add support for x32 and similar ABIs? - // pointers can be passed to libc::syscall. const _: () = assert!( core::mem::size_of::() == core::mem::size_of::<*mut core::ffi::c_void>() @@ -125,6 +123,8 @@ pub fn getrandom_syscall(buf: &mut [MaybeUninit]) -> libc::ssize_t { const ZERO: libc::c_ulong = 0; + // Note that the `libc` crate adds `__X32_SYSCALL_BIT` for x32 targets. + let res: libc::c_long = unsafe { libc::syscall(libc::SYS_getrandom, ptr, len, ZERO) }; // c_long to ssize_t conversion is lossless.