atomic_arch.h 438 B

123456789101112131415161718192021
  1. #define a_barrier a_barrier
  2. static inline void a_barrier()
  3. {
  4. __asm__ __volatile__ ("fence rw,rw" : : : "memory");
  5. }
  6. #define a_cas a_cas
  7. static inline int a_cas(volatile int *p, int t, int s)
  8. {
  9. int old, tmp;
  10. __asm__ __volatile__ (
  11. "\n1: lr.w.aqrl %0, (%2)\n"
  12. " bne %0, %3, 1f\n"
  13. " sc.w.aqrl %1, %4, (%2)\n"
  14. " bnez %1, 1b\n"
  15. "1:"
  16. : "=&r"(old), "=&r"(tmp)
  17. : "r"(p), "r"((long)t), "r"((long)s)
  18. : "memory");
  19. return old;
  20. }