Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / arch / score / include / asm / cmpxchg.h
1 #ifndef _ASM_SCORE_CMPXCHG_H
2 #define _ASM_SCORE_CMPXCHG_H
3
4 #include <linux/irqflags.h>
5
6 struct __xchg_dummy { unsigned long a[100]; };
7 #define __xg(x) ((struct __xchg_dummy *)(x))
8
9 static inline
10 unsigned long __xchg(volatile unsigned long *m, unsigned long val)
11 {
12         unsigned long retval;
13         unsigned long flags;
14
15         local_irq_save(flags);
16         retval = *m;
17         *m = val;
18         local_irq_restore(flags);
19         return retval;
20 }
21
22 #define xchg(ptr, v)                                            \
23         ((__typeof__(*(ptr))) __xchg((unsigned long *)(ptr),    \
24                                         (unsigned long)(v)))
25
26 static inline unsigned long __cmpxchg(volatile unsigned long *m,
27                                 unsigned long old, unsigned long new)
28 {
29         unsigned long retval;
30         unsigned long flags;
31
32         local_irq_save(flags);
33         retval = *m;
34         if (retval == old)
35                 *m = new;
36         local_irq_restore(flags);
37         return retval;
38 }
39
40 #define cmpxchg(ptr, o, n)                                      \
41         ((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
42                                         (unsigned long)(o),     \
43                                         (unsigned long)(n)))
44
45 #define __HAVE_ARCH_CMPXCHG     1
46
47 #include <asm-generic/cmpxchg-local.h>
48
49 #endif /* _ASM_SCORE_CMPXCHG_H */