This source file includes following definitions.
- __xchg
1
2
3
4
5
6
7
8 #ifndef _ASM_C6X_CMPXCHG_H
9 #define _ASM_C6X_CMPXCHG_H
10
11 #include <linux/irqflags.h>
12
13
14
15
16 static inline unsigned int __xchg(unsigned int x, volatile void *ptr, int size)
17 {
18 unsigned int tmp;
19 unsigned long flags;
20
21 local_irq_save(flags);
22
23 switch (size) {
24 case 1:
25 tmp = 0;
26 tmp = *((unsigned char *) ptr);
27 *((unsigned char *) ptr) = (unsigned char) x;
28 break;
29 case 2:
30 tmp = 0;
31 tmp = *((unsigned short *) ptr);
32 *((unsigned short *) ptr) = x;
33 break;
34 case 4:
35 tmp = 0;
36 tmp = *((unsigned int *) ptr);
37 *((unsigned int *) ptr) = x;
38 break;
39 }
40 local_irq_restore(flags);
41 return tmp;
42 }
43
44 #define xchg(ptr, x) \
45 ((__typeof__(*(ptr)))__xchg((unsigned int)(x), (void *) (ptr), \
46 sizeof(*(ptr))))
47
48 #include <asm-generic/cmpxchg-local.h>
49
50
51
52
53
54 #define cmpxchg_local(ptr, o, n) \
55 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
56 (unsigned long)(o), \
57 (unsigned long)(n), \
58 sizeof(*(ptr))))
59 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
60
61 #include <asm-generic/cmpxchg.h>
62
63 #endif