aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/percpu.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-04-10 15:02:40 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-10 15:36:18 -0400
commit066123a535927b3f17cac2305258cc71abdb0d92 (patch)
tree0913cbe29cd9f08cf98d828e50a109181351087a /include/linux/percpu.h
parent36cd3c9f925b9307236505ae7ad1ad7ac4d4357c (diff)
percpu: unbreak alpha percpu
For the time being, move the generic percpu_*() accessors to linux/percpu.h. asm-generic/percpu.h is meant to carry generic stuff for low level stuff - declarations, definitions and pointer offset calculation and so on but not for generic interface. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/percpu.h')
-rw-r--r--include/linux/percpu.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index ee5615d65211..cfda2d5ad319 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -168,4 +168,56 @@ static inline void free_percpu(void *p)
168#define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \ 168#define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \
169 __alignof__(type)) 169 __alignof__(type))
170 170
171/*
172 * Optional methods for optimized non-lvalue per-cpu variable access.
173 *
174 * @var can be a percpu variable or a field of it and its size should
175 * equal char, int or long. percpu_read() evaluates to a lvalue and
176 * all others to void.
177 *
178 * These operations are guaranteed to be atomic w.r.t. preemption.
179 * The generic versions use plain get/put_cpu_var(). Archs are
180 * encouraged to implement single-instruction alternatives which don't
181 * require preemption protection.
182 */
183#ifndef percpu_read
184# define percpu_read(var) \
185 ({ \
186 typeof(per_cpu_var(var)) __tmp_var__; \
187 __tmp_var__ = get_cpu_var(var); \
188 put_cpu_var(var); \
189 __tmp_var__; \
190 })
191#endif
192
193#define __percpu_generic_to_op(var, val, op) \
194do { \
195 get_cpu_var(var) op val; \
196 put_cpu_var(var); \
197} while (0)
198
199#ifndef percpu_write
200# define percpu_write(var, val) __percpu_generic_to_op(var, (val), =)
201#endif
202
203#ifndef percpu_add
204# define percpu_add(var, val) __percpu_generic_to_op(var, (val), +=)
205#endif
206
207#ifndef percpu_sub
208# define percpu_sub(var, val) __percpu_generic_to_op(var, (val), -=)
209#endif
210
211#ifndef percpu_and
212# define percpu_and(var, val) __percpu_generic_to_op(var, (val), &=)
213#endif
214
215#ifndef percpu_or
216# define percpu_or(var, val) __percpu_generic_to_op(var, (val), |=)
217#endif
218
219#ifndef percpu_xor
220# define percpu_xor(var, val) __percpu_generic_to_op(var, (val), ^=)
221#endif
222
171#endif /* __LINUX_PERCPU_H */ 223#endif /* __LINUX_PERCPU_H */