浏览代码

Replace inline asm with function calls in __kuser_cmpxchg and __kuser_memory_barrier

Amanieu d'Antras 7 年之前
父节点
当前提交
0fe7c79389
共有 1 个文件被更改,包括 4 次插入15 次删除
  1. 4 15
      src/arm_linux.rs

+ 4 - 15
src/arm_linux.rs

@@ -4,23 +4,12 @@ use core::mem;
 // Kernel-provided user-mode helper functions:
 // https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt
 unsafe fn __kuser_cmpxchg(oldval: u32, newval: u32, ptr: *mut u32) -> bool {
-    let out: u32;
-    // FIXME: we can't use BLX on ARMv4
-    asm!("blx ${0}"
-         : "={r0}" (out)
-         : "r" (0xffff0fc0u32)
-           "{r0}" (oldval),
-           "{r1}" (newval),
-           "{r2}" (ptr)
-         : "r3", "r12", "lr", "cc", "memory");
-    out == 0
+    let f: extern "C" fn (u32, u32, *mut u32) -> u32 = mem::transmute(0xffff0fc0u32);
+    f(oldval, newval, ptr) == 0
 }
 unsafe fn __kuser_memory_barrier() {
-    // FIXME: we can't use BLX on ARMv4
-    asm!("blx ${0}"
-         :
-         : "r" (0xffff0fa0u32)
-         : "lr", "memory");
+    let f: extern "C" fn () = mem::transmute(0xffff0fa0u32);
+    f();
 }
 
 // Word-align a pointer