futex-cas.h 689 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef __ASM_SH_FUTEX_CAS_H
  2. #define __ASM_SH_FUTEX_CAS_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. "1:\n\t"
  10. "cas.l %2, %1, @r0\n"
  11. "2:\n\t"
  12. #ifdef CONFIG_MMU
  13. ".section .fixup,\"ax\"\n"
  14. "3:\n\t"
  15. "mov.l 4f, %0\n\t"
  16. "jmp @%0\n\t"
  17. " mov %3, %0\n\t"
  18. ".balign 4\n"
  19. "4: .long 2b\n\t"
  20. ".previous\n"
  21. ".section __ex_table,\"a\"\n\t"
  22. ".long 1b, 3b\n\t"
  23. ".previous"
  24. #endif
  25. :"+r" (err), "+r" (newval)
  26. :"r" (oldval), "i" (-EFAULT), "z" (uaddr)
  27. :"t", "memory");
  28. if (err) return err;
  29. *uval = newval;
  30. return 0;
  31. }
  32. #endif /* __ASM_SH_FUTEX_CAS_H */