Skip to content

Commit 807534e

Browse files
authored
Use const operand in the ARM branch
1 parent 49a0c3f commit 807534e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backends/linux_raw.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -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+
const __NR_getrandom: u32 = 384;
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.
@@ -21,9 +22,10 @@ unsafe fn getrandom_syscall(buf: *mut u8, buflen: usize, flags: u32) -> isize {
2122
// bother with it.
2223
core::arch::asm!(
2324
"mov {tmp}, r7",
24-
"mov r7, #384", // __NR_getrandom = 384
25+
"mov r7, {nr}",
2526
"svc 0",
2627
"mov r7, {tmp}",
28+
nr = const __NR_getrandom,
2729
tmp = out(reg) _,
2830
inlateout("r0") buf => r0,
2931
in("r1") buflen,

0 commit comments

Comments
 (0)