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 Jun 1, 2024
1 parent dd91660 commit d9b4a3a
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 @@ -110,8 +110,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 @@ -125,6 +123,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 d9b4a3a

Please sign in to comment.