Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
fork
Configure Feed
Select the types of activity you want to include in your feed.
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 */