[NETFILTER]: sip conntrack: make header shortcuts optional
[hh.org.git] / include / asm-avr32 / system.h
blobac596058697dce633b4a82092f82c3932903a159
1 /*
2 * Copyright (C) 2004-2006 Atmel Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8 #ifndef __ASM_AVR32_SYSTEM_H
9 #define __ASM_AVR32_SYSTEM_H
11 #include <linux/compiler.h>
12 #include <linux/types.h>
14 #include <asm/ptrace.h>
15 #include <asm/sysreg.h>
17 #define xchg(ptr,x) \
18 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
20 #define nop() asm volatile("nop")
22 #define mb() asm volatile("" : : : "memory")
23 #define rmb() mb()
24 #define wmb() asm volatile("sync 0" : : : "memory")
25 #define read_barrier_depends() do { } while(0)
26 #define set_mb(var, value) do { var = value; mb(); } while(0)
29 * Help PathFinder and other Nexus-compliant debuggers keep track of
30 * the current PID by emitting an Ownership Trace Message each time we
31 * switch task.
33 #ifdef CONFIG_OWNERSHIP_TRACE
34 #include <asm/ocd.h>
35 #define finish_arch_switch(prev) \
36 do { \
37 __mtdr(DBGREG_PID, prev->pid); \
38 __mtdr(DBGREG_PID, current->pid); \
39 } while(0)
40 #endif
43 * switch_to(prev, next, last) should switch from task `prev' to task
44 * `next'. `prev' will never be the same as `next'.
46 * We just delegate everything to the __switch_to assembly function,
47 * which is implemented in arch/avr32/kernel/switch_to.S
49 * mb() tells GCC not to cache `current' across this call.
51 struct cpu_context;
52 struct task_struct;
53 extern struct task_struct *__switch_to(struct task_struct *,
54 struct cpu_context *,
55 struct cpu_context *);
56 #define switch_to(prev, next, last) \
57 do { \
58 last = __switch_to(prev, &prev->thread.cpu_context + 1, \
59 &next->thread.cpu_context); \
60 } while (0)
62 #ifdef CONFIG_SMP
63 # error "The AVR32 port does not support SMP"
64 #else
65 # define smp_mb() barrier()
66 # define smp_rmb() barrier()
67 # define smp_wmb() barrier()
68 # define smp_read_barrier_depends() do { } while(0)
69 #endif
71 #include <linux/irqflags.h>
73 extern void __xchg_called_with_bad_pointer(void);
75 #ifdef __CHECKER__
76 extern unsigned long __builtin_xchg(void *ptr, unsigned long x);
77 #endif
79 #define xchg_u32(val, m) __builtin_xchg((void *)m, val)
81 static inline unsigned long __xchg(unsigned long x,
82 volatile void *ptr,
83 int size)
85 switch(size) {
86 case 4:
87 return xchg_u32(x, ptr);
88 default:
89 __xchg_called_with_bad_pointer();
90 return x;
94 static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
95 unsigned long new)
97 __u32 ret;
99 asm volatile(
100 "1: ssrf 5\n"
101 " ld.w %[ret], %[m]\n"
102 " cp.w %[ret], %[old]\n"
103 " brne 2f\n"
104 " stcond %[m], %[new]\n"
105 " brne 1b\n"
106 "2:\n"
107 : [ret] "=&r"(ret), [m] "=m"(*m)
108 : "m"(m), [old] "ir"(old), [new] "r"(new)
109 : "memory", "cc");
110 return ret;
113 extern unsigned long __cmpxchg_u64_unsupported_on_32bit_kernels(
114 volatile int * m, unsigned long old, unsigned long new);
115 #define __cmpxchg_u64 __cmpxchg_u64_unsupported_on_32bit_kernels
117 /* This function doesn't exist, so you'll get a linker error
118 if something tries to do an invalid cmpxchg(). */
119 extern void __cmpxchg_called_with_bad_pointer(void);
121 #define __HAVE_ARCH_CMPXCHG 1
123 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
124 unsigned long new, int size)
126 switch (size) {
127 case 4:
128 return __cmpxchg_u32(ptr, old, new);
129 case 8:
130 return __cmpxchg_u64(ptr, old, new);
133 __cmpxchg_called_with_bad_pointer();
134 return old;
137 #define cmpxchg(ptr, old, new) \
138 ((typeof(*(ptr)))__cmpxchg((ptr), (unsigned long)(old), \
139 (unsigned long)(new), \
140 sizeof(*(ptr))))
142 struct pt_regs;
143 extern void __die(const char *, struct pt_regs *, unsigned long,
144 const char *, const char *, unsigned long);
145 extern void __die_if_kernel(const char *, struct pt_regs *, unsigned long,
146 const char *, const char *, unsigned long);
148 #define die(msg, regs, err) \
149 __die(msg, regs, err, __FILE__ ":", __FUNCTION__, __LINE__)
150 #define die_if_kernel(msg, regs, err) \
151 __die_if_kernel(msg, regs, err, __FILE__ ":", __FUNCTION__, __LINE__)
153 #define arch_align_stack(x) (x)
155 #endif /* __ASM_AVR32_SYSTEM_H */