diff options
| author | Guan Xuetao <gxt@mprc.pku.edu.cn> | 2012-03-28 13:30:03 -0400 |
|---|---|---|
| committer | David Howells <dhowells@redhat.com> | 2012-03-28 13:30:03 -0400 |
| commit | 8978bfd2288adaa24d39fa15f57eb9e24ffeca12 (patch) | |
| tree | a932d224f63890b38bbf29ca1fd468949c1e544c /arch/unicore32/include/asm/cmpxchg.h | |
| parent | bd119c69239322caafdb64517a806037d0d0c70a (diff) | |
Disintegrate asm/system.h for Unicore32 [based on ver #3, changed by gxt]
Disintegrate asm/system.h for Unicore32. (Compilation successful)
The implementation details are not changed, but only splitted.
BTW, some codestyles are adjusted.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Diffstat (limited to 'arch/unicore32/include/asm/cmpxchg.h')
| -rw-r--r-- | arch/unicore32/include/asm/cmpxchg.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/unicore32/include/asm/cmpxchg.h b/arch/unicore32/include/asm/cmpxchg.h new file mode 100644 index 000000000000..df4d5acfd19f --- /dev/null +++ b/arch/unicore32/include/asm/cmpxchg.h | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | /* | ||
| 2 | * Atomics xchg/cmpxchg for PKUnity SoC and UniCore ISA | ||
| 3 | * | ||
| 4 | * Copyright (C) 2001-2012 GUAN Xue-tao | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | #ifndef __UNICORE_CMPXCHG_H__ | ||
| 11 | #define __UNICORE_CMPXCHG_H__ | ||
| 12 | |||
| 13 | /* | ||
| 14 | * Generate a link failure on undefined symbol if the pointer points to a value | ||
| 15 | * of unsupported size. | ||
| 16 | */ | ||
| 17 | extern void __xchg_bad_pointer(void); | ||
| 18 | |||
| 19 | static inline unsigned long __xchg(unsigned long x, volatile void *ptr, | ||
| 20 | int size) | ||
| 21 | { | ||
| 22 | unsigned long ret; | ||
| 23 | |||
| 24 | switch (size) { | ||
| 25 | case 1: | ||
| 26 | asm volatile("swapb %0, %1, [%2]" | ||
| 27 | : "=&r" (ret) | ||
| 28 | : "r" (x), "r" (ptr) | ||
| 29 | : "memory", "cc"); | ||
| 30 | break; | ||
| 31 | case 4: | ||
| 32 | asm volatile("swapw %0, %1, [%2]" | ||
| 33 | : "=&r" (ret) | ||
| 34 | : "r" (x), "r" (ptr) | ||
| 35 | : "memory", "cc"); | ||
| 36 | break; | ||
| 37 | default: | ||
| 38 | ret = __xchg_bad_pointer(); | ||
| 39 | } | ||
| 40 | |||
| 41 | return ret; | ||
| 42 | } | ||
| 43 | |||
| 44 | #define xchg(ptr, x) \ | ||
| 45 | ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr)))) | ||
| 46 | |||
| 47 | #include <asm-generic/cmpxchg-local.h> | ||
| 48 | |||
| 49 | /* | ||
| 50 | * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make | ||
| 51 | * them available. | ||
| 52 | */ | ||
| 53 | #define cmpxchg_local(ptr, o, n) \ | ||
| 54 | ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \ | ||
| 55 | (unsigned long)(o), (unsigned long)(n), sizeof(*(ptr)))) | ||
| 56 | #define cmpxchg64_local(ptr, o, n) \ | ||
| 57 | __cmpxchg64_local_generic((ptr), (o), (n)) | ||
| 58 | |||
| 59 | #include <asm-generic/cmpxchg.h> | ||
| 60 | |||
| 61 | #endif /* __UNICORE_CMPXCHG_H__ */ | ||
