vfs: Make __vfs_write() static
[linux/fpc-iii.git] / arch / h8300 / include / asm / cmpxchg.h
blobc64bb38ce2428bde959432b14a772c6c4fa1f638
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ARCH_H8300_CMPXCHG__
3 #define __ARCH_H8300_CMPXCHG__
5 #include <linux/irqflags.h>
7 #define xchg(ptr, x) \
8 ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), \
9 sizeof(*(ptr))))
11 struct __xchg_dummy { unsigned long a[100]; };
12 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
14 static inline unsigned long __xchg(unsigned long x,
15 volatile void *ptr, int size)
17 unsigned long tmp, flags;
19 local_irq_save(flags);
21 switch (size) {
22 case 1:
23 __asm__ __volatile__
24 ("mov.b %2,%0\n\t"
25 "mov.b %1,%2"
26 : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
27 break;
28 case 2:
29 __asm__ __volatile__
30 ("mov.w %2,%0\n\t"
31 "mov.w %1,%2"
32 : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
33 break;
34 case 4:
35 __asm__ __volatile__
36 ("mov.l %2,%0\n\t"
37 "mov.l %1,%2"
38 : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)));
39 break;
40 default:
41 tmp = 0;
43 local_irq_restore(flags);
44 return tmp;
47 #include <asm-generic/cmpxchg-local.h>
50 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
51 * them available.
53 #define cmpxchg_local(ptr, o, n) \
54 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
55 (unsigned long)(o), \
56 (unsigned long)(n), \
57 sizeof(*(ptr))))
58 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
60 #ifndef CONFIG_SMP
61 #include <asm-generic/cmpxchg.h>
62 #endif
64 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
66 #endif /* __ARCH_H8300_CMPXCHG__ */