1 #ifndef __LINUX_KERNEL_WRAPPER_H
2 #define __LINUX_KERNEL_WRAPPER_H 1
4 #include_next <linux/kernel.h>
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.
13 #define container_of(ptr, type, member) ({ \
14 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
15 (type *)( (char *)__mptr - offsetof(type,member) );})
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.
21 #define typecheck(type,x) \
24 (void)(&__dummy == &__dummy2); \
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.)
32 #define typecheck_fn(type,function) \
33 ({ typeof(type) __tmp = function; \
37 int vprintk(const char *msg, ...)
38 __attribute__((format(printf, 1, 0)));
40 /* Force a compilation error if condition is true */
41 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))