1 #ifndef __ASM_SH_CMPXCHG_GRB_H
2 #define __ASM_SH_CMPXCHG_GRB_H
4 static inline unsigned long xchg_u32(volatile u32
*m
, unsigned long val
)
10 " mova 1f, r0 \n\t" /* r0 = end point */
12 " mov r15, r1 \n\t" /* r1 = saved sp */
13 " mov #-4, r15 \n\t" /* LOGIN */
14 " mov.l @%1, %0 \n\t" /* load old value */
15 " mov.l %2, @%1 \n\t" /* store new value */
16 "1: mov r1, r15 \n\t" /* LOGOUT */
20 : "memory", "r0", "r1");
25 static inline unsigned long xchg_u8(volatile u8
*m
, unsigned long val
)
29 __asm__
__volatile__ (
31 " mova 1f, r0 \n\t" /* r0 = end point */
32 " mov r15, r1 \n\t" /* r1 = saved sp */
33 " mov #-6, r15 \n\t" /* LOGIN */
34 " mov.b @%1, %0 \n\t" /* load old value */
35 " extu.b %0, %0 \n\t" /* extend as unsigned */
36 " mov.b %2, @%1 \n\t" /* store new value */
37 "1: mov r1, r15 \n\t" /* LOGOUT */
41 : "memory" , "r0", "r1");
46 static inline unsigned long __cmpxchg_u32(volatile int *m
, unsigned long old
,
51 __asm__
__volatile__ (
53 " mova 1f, r0 \n\t" /* r0 = end point */
55 " mov r15, r1 \n\t" /* r1 = saved sp */
56 " mov #-8, r15 \n\t" /* LOGIN */
57 " mov.l @%1, %0 \n\t" /* load old value */
59 " bf 1f \n\t" /* if not equal */
60 " mov.l %3, @%1 \n\t" /* store new value */
61 "1: mov r1, r15 \n\t" /* LOGOUT */
63 : "r" (m
), "r" (old
), "r" (new)
64 : "memory" , "r0", "r1", "t");
69 #endif /* __ASM_SH_CMPXCHG_GRB_H */