Disintegrate asm/system.h for Score
[linux-2.6.git] / arch / score / include / asm / cmpxchg.h
blobf384839c3ee53e2608209217372423025e21e911
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 #define __HAVE_ARCH_CMPXCHG 1
47 #include <asm-generic/cmpxchg-local.h>
49 #endif /* _ASM_SCORE_CMPXCHG_H */