xref: /openbmc/linux/arch/sh/include/asm/cmpxchg-cas.h (revision 82003e04)
1 #ifndef __ASM_SH_CMPXCHG_CAS_H
2 #define __ASM_SH_CMPXCHG_CAS_H
3 
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 
14 static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
15 {
16 	unsigned long old;
17 	do old = *m;
18 	while (__cmpxchg_u32(m, old, val) != old);
19 	return old;
20 }
21 
22 #include <asm/cmpxchg-xchg.h>
23 
24 #endif /* __ASM_SH_CMPXCHG_CAS_H */
25