GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / include / asm-generic / cmpxchg-local.h
blob4493a72fd6735327950472768c72e54357daf52d
1 /* Modified by Broadcom Corp. Portions Copyright (c) Broadcom Corp, 2012. */
2 #ifndef __ASM_GENERIC_CMPXCHG_LOCAL_H
3 #define __ASM_GENERIC_CMPXCHG_LOCAL_H
5 #include <linux/types.h>
7 #if defined(CONFIG_BUZZZ_FUNC)
8 #ifndef __always_inline__
9 #define __always_inline__ inline __attribute__((always_inline)) __attribute__((no_instrument_function))
10 #endif
11 #else /* !CONFIG_BUZZZ_FUNC */
12 #ifndef __always_inline__
13 #define __always_inline__ inline
14 #endif
15 #endif /* !CONFIG_BUZZZ_FUNC */
17 extern unsigned long wrong_size_cmpxchg(volatile void *ptr);
20 * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
21 * long parameter, supporting various types of architectures.
23 static __always_inline__ unsigned long __cmpxchg_local_generic(volatile void *ptr,
24 unsigned long old, unsigned long new, int size)
26 unsigned long flags, prev;
29 * Sanity checking, compile-time.
31 if (size == 8 && sizeof(unsigned long) != 8)
32 wrong_size_cmpxchg(ptr);
34 local_irq_save(flags);
35 switch (size) {
36 case 1: prev = *(u8 *)ptr;
37 if (prev == old)
38 *(u8 *)ptr = (u8)new;
39 break;
40 case 2: prev = *(u16 *)ptr;
41 if (prev == old)
42 *(u16 *)ptr = (u16)new;
43 break;
44 case 4: prev = *(u32 *)ptr;
45 if (prev == old)
46 *(u32 *)ptr = (u32)new;
47 break;
48 case 8: prev = *(u64 *)ptr;
49 if (prev == old)
50 *(u64 *)ptr = (u64)new;
51 break;
52 default:
53 wrong_size_cmpxchg(ptr);
55 local_irq_restore(flags);
56 return prev;
60 * Generic version of __cmpxchg64_local. Takes an u64 parameter.
62 static __always_inline__ u64 __cmpxchg64_local_generic(volatile void *ptr,
63 u64 old, u64 new)
65 u64 prev;
66 unsigned long flags;
68 local_irq_save(flags);
69 prev = *(u64 *)ptr;
70 if (prev == old)
71 *(u64 *)ptr = new;
72 local_irq_restore(flags);
73 return prev;
76 #endif