Initial import
[sliver-openvswitch.git] / datapath / linux-2.4 / compat-2.4 / include / linux / kernel.h
1 #ifndef __LINUX_KERNEL_WRAPPER_H
2 #define __LINUX_KERNEL_WRAPPER_H 1
3
4 #include_next <linux/kernel.h>
5
6 /**
7  * container_of - cast a member of a structure out to the containing structure
8  * @ptr:        the pointer to the member.
9  * @type:       the type of the container struct this is embedded in.
10  * @member:     the name of the member within the struct.
11  *
12  */
13 #define container_of(ptr, type, member) ({                      \
14         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
15         (type *)( (char *)__mptr - offsetof(type,member) );})
16
17 /*
18  * Check at compile time that something is of a particular type.
19  * Always evaluates to 1 so you may use it easily in comparisons.
20  */
21 #define typecheck(type,x) \
22 ({      type __dummy; \
23         typeof(x) __dummy2; \
24         (void)(&__dummy == &__dummy2); \
25         1; \
26 })
27
28 /*
29  * Check at compile time that 'function' is a certain type, or is a pointer
30  * to that type (needs to use typedef for the function type.)
31  */
32 #define typecheck_fn(type,function) \
33 ({      typeof(type) __tmp = function; \
34         (void)__tmp; \
35 })
36
37 int vprintk(const char *msg, ...)
38         __attribute__((format(printf, 1, 0)));
39
40 /* Force a compilation error if condition is true */
41 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
42
43 #endif