aboutsummaryrefslogtreecommitdiffstats
path: root/arch/score/include/asm/cmpxchg.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/score/include/asm/cmpxchg.h')
-rw-r--r--arch/score/include/asm/cmpxchg.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/arch/score/include/asm/cmpxchg.h b/arch/score/include/asm/cmpxchg.h
new file mode 100644
index 000000000000..f384839c3ee5
--- /dev/null
+++ b/arch/score/include/asm/cmpxchg.h
@@ -0,0 +1,49 @@
1#ifndef _ASM_SCORE_CMPXCHG_H
2#define _ASM_SCORE_CMPXCHG_H
3
4#include <linux/irqflags.h>
5
6struct __xchg_dummy { unsigned long a[100]; };
7#define __xg(x) ((struct __xchg_dummy *)(x))
8
9static inline
10unsigned 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
26static 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 */