@@ -13,6 +13,7 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
1313 // Based on `rustix` and `linux-raw-sys` code.
1414 cfg_if ! {
1515 if #[ cfg( target_arch = "arm" ) ] {
16+ // TODO(MSRV-1.78): Also check `target_abi = "eabi"`.
1617 // In thumb-mode, r7 is the frame pointer and is not permitted to be used in
1718 // an inline asm operand, so we have to use a different register and copy it
1819 // into r7 inside the inline asm.
@@ -32,6 +33,11 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
3233 options( nostack, preserves_flags)
3334 ) ;
3435 } else if #[ cfg( target_arch = "aarch64" ) ] {
36+ // TODO(MSRV-1.78): Also check `any(target_abi = "", target_abi = "ilp32")` above.
37+ // According the the ILP32 patch for the kernel that hasn't yet
38+ // been merged into the mainline, "AARCH64/ILP32 ABI uses standard
39+ // syscall table [...] with the exceptions listed below," where
40+ // getrandom is not mentioned as an exception.
3541 const __NR_getrandom: u32 = 278 ;
3642 core:: arch:: asm!(
3743 "svc 0" ,
@@ -42,6 +48,7 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
4248 options( nostack, preserves_flags)
4349 ) ;
4450 } else if #[ cfg( target_arch = "loongarch64" ) ] {
51+ // TODO(MSRV-1.78): Also check `any(target_abi = "", target_abi = "ilp32")` above.
4552 const __NR_getrandom: u32 = 278 ;
4653 core:: arch:: asm!(
4754 "syscall 0" ,
@@ -86,10 +93,10 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
8693 options( nostack, preserves_flags)
8794 ) ;
8895 } else if #[ cfg( target_arch = "x86_64" ) ] {
89- # [ cfg ( target_pointer_width = "64" ) ]
90- const __NR_getrandom : u32 = 318 ;
91- # [ cfg( target_pointer_width = "32" ) ]
92- const __NR_getrandom: u32 = ( 1 << 30 ) + 318 ;
96+ // TODO(MSRV-1.78): Add `any(target_abi = "", target_abi = "x32")` above.
97+ const __X32_SYSCALL_BIT : u32 = 0x40000000 ;
98+ const OFFSET : u32 = if cfg! ( target_pointer_width = "32" ) { __X32_SYSCALL_BIT } else { 0 } ;
99+ const __NR_getrandom: u32 = OFFSET + 318 ;
93100
94101 core:: arch:: asm!(
95102 "syscall" ,
0 commit comments