cmpxchg-cas.h 549 B

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