Verify in fwd_port_input() that we are not passed packets that are shared.
[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 #include <linux/config.h>
6 #include <asm/bug.h>
7
8 /**
9  * container_of - cast a member of a structure out to the containing structure
10  * @ptr:        the pointer to the member.
11  * @type:       the type of the container struct this is embedded in.
12  * @member:     the name of the member within the struct.
13  *
14  */
15 #define container_of(ptr, type, member) ({                      \
16         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
17         (type *)( (char *)__mptr - offsetof(type,member) );})
18
19 /*
20  * Check at compile time that something is of a particular type.
21  * Always evaluates to 1 so you may use it easily in comparisons.
22  */
23 #define typecheck(type,x) \
24 ({      type __dummy; \
25         typeof(x) __dummy2; \
26         (void)(&__dummy == &__dummy2); \
27         1; \
28 })
29
30 /*
31  * Check at compile time that 'function' is a certain type, or is a pointer
32  * to that type (needs to use typedef for the function type.)
33  */
34 #define typecheck_fn(type,function) \
35 ({      typeof(type) __tmp = function; \
36         (void)__tmp; \
37 })
38
39 int vprintk(const char *msg, ...)
40         __attribute__((format(printf, 1, 0)));
41
42 /* Force a compilation error if condition is true */
43 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
44
45 /**
46  * might_sleep - annotation for functions that can sleep
47  *
48  * this macro will print a stack trace if it is executed in an atomic
49  * context (spinlock, irq-handler, ...).
50  *
51  * This is a useful debugging help to be able to catch problems early and not
52  * be bitten later when the calling function happens to sleep when it is not
53  * supposed to.
54  */
55 #define might_resched() do { } while (0)
56
57 #ifdef CONFIG_DEBUG_SPINLOCK
58   void __might_sleep(char *file, int line);
59 # define might_sleep() \
60         do { __might_sleep(__FILE__, __LINE__); might_resched(); } while (0)
61 #else
62 # define might_sleep() do { might_resched(); } while (0)
63 #endif
64
65 #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
66
67 #endif