NFSv4.1/flexfiles: Fix a protocol error in layoutreturn
[linux/fpc-iii.git] / arch / score / include / asm / cmpxchg.h
blobcc3f6420b71c1d6438067761c3a905f6033dc36a
1 #ifndef _ASM_SCORE_CMPXCHG_H
2 #define _ASM_SCORE_CMPXCHG_H
4 #include <linux/irqflags.h>
6 struct __xchg_dummy { unsigned long a[100]; };
7 #define __xg(x) ((struct __xchg_dummy *)(x))
9 static inline
10 unsigned long __xchg(volatile unsigned long *m, unsigned long val)
12 unsigned long retval;
13 unsigned long flags;
15 local_irq_save(flags);
16 retval = *m;
17 *m = val;
18 local_irq_restore(flags);
19 return retval;
22 #define xchg(ptr, v) \
23 ((__typeof__(*(ptr))) __xchg((unsigned long *)(ptr), \
24 (unsigned long)(v)))
26 static inline unsigned long __cmpxchg(volatile unsigned long *m,
27 unsigned long old, unsigned long new)
29 unsigned long retval;
30 unsigned long flags;
32 local_irq_save(flags);
33 retval = *m;
34 if (retval == old)
35 *m = new;
36 local_irq_restore(flags);
37 return retval;
40 #define cmpxchg(ptr, o, n) \
41 ((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
42 (unsigned long)(o), \
43 (unsigned long)(n)))
45 #include <asm-generic/cmpxchg-local.h>
47 #endif /* _ASM_SCORE_CMPXCHG_H */