@@ -13,6 +13,7 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
13
13
// Based on `rustix` and `linux-raw-sys` code.
14
14
cfg_if ! {
15
15
if #[ cfg( target_arch = "arm" ) ] {
16
+ // TODO(MSRV-1.78): Also check `target_abi = "eabi"`.
16
17
// In thumb-mode, r7 is the frame pointer and is not permitted to be used in
17
18
// an inline asm operand, so we have to use a different register and copy it
18
19
// into r7 inside the inline asm.
@@ -32,6 +33,11 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
32
33
options( nostack, preserves_flags)
33
34
) ;
34
35
} 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.
35
41
const __NR_getrandom: u32 = 278 ;
36
42
core:: arch:: asm!(
37
43
"svc 0" ,
@@ -42,6 +48,7 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
42
48
options( nostack, preserves_flags)
43
49
) ;
44
50
} else if #[ cfg( target_arch = "loongarch64" ) ] {
51
+ // TODO(MSRV-1.78): Also check `any(target_abi = "", target_abi = "ilp32")` above.
45
52
const __NR_getrandom: u32 = 278 ;
46
53
core:: arch:: asm!(
47
54
"syscall 0" ,
@@ -86,10 +93,10 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
86
93
options( nostack, preserves_flags)
87
94
) ;
88
95
} 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 ;
93
100
94
101
core:: arch:: asm!(
95
102
"syscall" ,
0 commit comments