1
0

atomic_arch.h 882 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #define a_ll a_ll
  2. static inline int a_ll(volatile int *p)
  3. {
  4. int v;
  5. __asm__ __volatile__ (
  6. "ll.w %0, %1"
  7. : "=r"(v)
  8. : "ZC"(*p));
  9. return v;
  10. }
  11. #define a_sc a_sc
  12. static inline int a_sc(volatile int *p, int v)
  13. {
  14. int r;
  15. __asm__ __volatile__ (
  16. "sc.w %0, %1"
  17. : "=r"(r), "=ZC"(*p)
  18. : "0"(v) : "memory");
  19. return r;
  20. }
  21. #define a_ll_p a_ll_p
  22. static inline void *a_ll_p(volatile void *p)
  23. {
  24. void *v;
  25. __asm__ __volatile__ (
  26. "ll.d %0, %1"
  27. : "=r"(v)
  28. : "ZC"(*(void *volatile *)p));
  29. return v;
  30. }
  31. #define a_sc_p a_sc_p
  32. static inline int a_sc_p(volatile void *p, void *v)
  33. {
  34. long r;
  35. __asm__ __volatile__ (
  36. "sc.d %0, %1"
  37. : "=r"(r), "=ZC"(*(void *volatile *)p)
  38. : "0"(v)
  39. : "memory");
  40. return r;
  41. }
  42. #define a_barrier a_barrier
  43. static inline void a_barrier()
  44. {
  45. __asm__ __volatile__ ("dbar 0" : : : "memory");
  46. }
  47. #define a_pre_llsc a_barrier
  48. #define a_post_llsc a_barrier