futex-llsc.h 831 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef __ASM_SH_FUTEX_LLSC_H
  2. #define __ASM_SH_FUTEX_LLSC_H
  3. static inline int atomic_futex_op_cmpxchg_inatomic(u32 *uval,
  4. u32 __user *uaddr,
  5. u32 oldval, u32 newval)
  6. {
  7. int err = 0;
  8. __asm__ __volatile__(
  9. "synco\n"
  10. "1:\n\t"
  11. "movli.l @%2, r0\n\t"
  12. "mov r0, %1\n\t"
  13. "cmp/eq %1, %4\n\t"
  14. "bf 2f\n\t"
  15. "mov %5, r0\n\t"
  16. "movco.l r0, @%2\n\t"
  17. "bf 1b\n"
  18. "2:\n\t"
  19. "synco\n\t"
  20. #ifdef CONFIG_MMU
  21. ".section .fixup,\"ax\"\n"
  22. "3:\n\t"
  23. "mov.l 4f, %0\n\t"
  24. "jmp @%0\n\t"
  25. " mov %3, %0\n\t"
  26. ".balign 4\n"
  27. "4: .long 2b\n\t"
  28. ".previous\n"
  29. ".section __ex_table,\"a\"\n\t"
  30. ".long 1b, 3b\n\t"
  31. ".previous"
  32. #endif
  33. :"+r" (err), "=&r" (*uval)
  34. :"r" (uaddr), "i" (-EFAULT), "r" (oldval), "r" (newval)
  35. :"t", "memory", "r0");
  36. if (err) return err;
  37. return 0;
  38. }
  39. #endif /* __ASM_SH_FUTEX_LLSC_H */