Skip to content

Commit 1e7a708

Browse files
committed
util_libc: Add a note about the x32 ABI.
1 parent 1fe6796 commit 1e7a708

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/util_libc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ pub fn getrandom_syscall(buf: &mut [MaybeUninit<u8>]) -> libc::ssize_t {
110110
// no real truncation here, even when running
111111
debug_assert!(buf.len() <= isize::MAX.unsigned_abs());
112112

113-
// TODO: Add support for x32 and similar ABIs?
114-
115113
// pointers can be passed to libc::syscall.
116114
const _: () = assert!(
117115
core::mem::size_of::<libc::c_long>() == core::mem::size_of::<*mut core::ffi::c_void>()
@@ -125,6 +123,8 @@ pub fn getrandom_syscall(buf: &mut [MaybeUninit<u8>]) -> libc::ssize_t {
125123

126124
const ZERO: libc::c_ulong = 0;
127125

126+
// Note that the `libc` crate adds `__X32_SYSCALL_BIT` for x32 targets.
127+
128128
let res: libc::c_long = unsafe { libc::syscall(libc::SYS_getrandom, ptr, len, ZERO) };
129129

130130
// c_long to ssize_t conversion is lossless.

0 commit comments

Comments
 (0)