Skip to content

Commit 135e5d3

Browse files
committed
util_libc: Add a note about the x32 ABI.
1 parent 125a3e6 commit 135e5d3

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
@@ -109,8 +109,6 @@ pub fn getrandom_syscall(buf: &mut [MaybeUninit<u8>]) -> libc::ssize_t {
109109
// no real truncation here, even when running
110110
debug_assert!(buf.len() <= isize::MAX.unsigned_abs());
111111

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

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

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

129129
// c_long to ssize_t conversion is lossless.

0 commit comments

Comments
 (0)