Skip to content

Commit

Permalink
util_libc: Add a note about the x32 ABI.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed May 31, 2024
1 parent 125a3e6 commit 135e5d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util_libc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ pub fn getrandom_syscall(buf: &mut [MaybeUninit<u8>]) -> 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::<libc::c_long>() == core::mem::size_of::<*mut core::ffi::c_void>()
Expand All @@ -124,6 +122,8 @@ pub fn getrandom_syscall(buf: &mut [MaybeUninit<u8>]) -> 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.
Expand Down

0 comments on commit 135e5d3

Please sign in to comment.