initial commit with v2.6.32.60
[linux-2.6.32.60-moxart.git] / tools / perf / util / include / linux / kernel.h
bloba6b87390cb52648e3a5d02c5486f4eb2635504cd
1 #ifndef PERF_LINUX_KERNEL_H_
2 #define PERF_LINUX_KERNEL_H_
4 #ifndef offsetof
5 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
6 #endif
8 #ifndef container_of
9 /**
10 * container_of - cast a member of a structure out to the containing structure
11 * @ptr: the pointer to the member.
12 * @type: the type of the container struct this is embedded in.
13 * @member: the name of the member within the struct.
16 #define container_of(ptr, type, member) ({ \
17 const typeof(((type *)0)->member) * __mptr = (ptr); \
18 (type *)((char *)__mptr - offsetof(type, member)); })
19 #endif
21 #ifndef max
22 #define max(x, y) ({ \
23 typeof(x) _max1 = (x); \
24 typeof(y) _max2 = (y); \
25 (void) (&_max1 == &_max2); \
26 _max1 > _max2 ? _max1 : _max2; })
27 #endif
29 #endif