Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / include / lwk / percpu.h
1 #ifndef _LWK_PERCPU_H
2 #define _LWK_PERCPU_H
3 #include <lwk/smp.h>
4 #include <lwk/string.h>
5 #include <arch/percpu.h>
6
7 /* Enough to cover all DEFINE_PER_CPU()'s in kernel. */
8 #ifndef PERCPU_ENOUGH_ROOM
9 #define PERCPU_ENOUGH_ROOM 32768
10 #endif
11
12 /* Must be an lvalue. */
13 #define get_cpu_var(var) __get_cpu_var(var)
14 #define put_cpu_var(var) 
15
16 struct percpu_data {
17         void *ptrs[NR_CPUS];
18 };
19
20 /* 
21  * Use this to get to a cpu's version of the per-cpu object allocated using
22  * alloc_percpu.  Non-atomic access to the current CPU's version should
23  * probably be combined with get_cpu()/put_cpu().
24  */ 
25 #define per_cpu_ptr(ptr, cpu)                   \
26 ({                                              \
27         struct percpu_data *__p = (struct percpu_data *)~(unsigned long)(ptr); \
28         (__typeof__(ptr))__p->ptrs[(cpu)];      \
29 })
30
31 extern void *__alloc_percpu(size_t size);
32 extern void free_percpu(const void *);
33
34 /* Simple wrapper for the common case: zeros memory. */
35 #define alloc_percpu(type)      ((type *)(__alloc_percpu(sizeof(type))))
36
37 extern void setup_per_cpu_areas(void);
38
39 #endif /* _LWK_PERCPU_H */