atomic_arch.h 799 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #define a_ll a_ll
  2. static inline int a_ll(volatile int *p)
  3. {
  4. int v;
  5. __asm__ __volatile__ (
  6. ".set push ; .set mips2\n\t"
  7. "ll %0, %1"
  8. "\n\t.set pop"
  9. : "=r"(v) : "m"(*p));
  10. return v;
  11. }
  12. #define a_sc a_sc
  13. static inline int a_sc(volatile int *p, int v)
  14. {
  15. int r;
  16. __asm__ __volatile__ (
  17. ".set push ; .set mips2\n\t"
  18. "sc %0, %1"
  19. "\n\t.set pop"
  20. : "=r"(r), "=m"(*p) : "0"(v) : "memory");
  21. return r;
  22. }
  23. #define a_barrier a_barrier
  24. static inline void a_barrier()
  25. {
  26. /* mips2 sync, but using too many directives causes
  27. * gcc not to inline it, so encode with .long instead. */
  28. __asm__ __volatile__ (".long 0xf" : : : "memory");
  29. #if 0
  30. __asm__ __volatile__ (
  31. ".set push ; .set mips2 ; sync ; .set pop"
  32. : : : "memory");
  33. #endif
  34. }
  35. #define a_pre_llsc a_barrier
  36. #define a_post_llsc a_barrier