arm64: dts: Revert "specify console via command line"
[linux/fpc-iii.git] / arch / unicore32 / include / asm / cmpxchg.h
blob87f960a2e4f08ad33e5ed15265faf2c032f1500a
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Atomics xchg/cmpxchg for PKUnity SoC and UniCore ISA
5 * Copyright (C) 2001-2012 GUAN Xue-tao
6 */
7 #ifndef __UNICORE_CMPXCHG_H__
8 #define __UNICORE_CMPXCHG_H__
11 * Generate a link failure on undefined symbol if the pointer points to a value
12 * of unsupported size.
14 extern void __xchg_bad_pointer(void);
16 static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
17 int size)
19 unsigned long ret;
21 switch (size) {
22 case 1:
23 asm volatile("swapb %0, %1, [%2]"
24 : "=&r" (ret)
25 : "r" (x), "r" (ptr)
26 : "memory", "cc");
27 break;
28 case 4:
29 asm volatile("swapw %0, %1, [%2]"
30 : "=&r" (ret)
31 : "r" (x), "r" (ptr)
32 : "memory", "cc");
33 break;
34 default:
35 __xchg_bad_pointer();
38 return ret;
41 #define xchg(ptr, x) \
42 ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
44 #include <asm-generic/cmpxchg-local.h>
47 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
48 * them available.
50 #define cmpxchg_local(ptr, o, n) \
51 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
52 (unsigned long)(o), (unsigned long)(n), sizeof(*(ptr))))
53 #define cmpxchg64_local(ptr, o, n) \
54 __cmpxchg64_local_generic((ptr), (o), (n))
56 #include <asm-generic/cmpxchg.h>
58 #endif /* __UNICORE_CMPXCHG_H__ */