cmpxchg-cas.h 510 B

12345678910111213141516171819202122232425
  1. #ifndef __ASM_SH_CMPXCHG_CAS_H
  2. #define __ASM_SH_CMPXCHG_CAS_H
  3. static inline unsigned long
  4. __cmpxchg_u32(volatile u32 *m, unsigned long old, unsigned long new)
  5. {
  6. __asm__ __volatile__("cas.l %1,%0,@r0"
  7. : "+r"(new)
  8. : "r"(old), "z"(m)
  9. : "t", "memory" );
  10. return new;
  11. }
  12. static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
  13. {
  14. unsigned long old;
  15. do old = *m;
  16. while (__cmpxchg_u32(m, old, val) != old);
  17. return old;
  18. }
  19. #include <asm/cmpxchg-xchg.h>
  20. #endif /* __ASM_SH_CMPXCHG_CAS_H */