datapath: Rename linux-2.6 and compat-2.6 directories.
[sliver-openvswitch.git] / datapath / linux / compat / include / linux / workqueue.h
1 #ifndef __LINUX_WORKQUEUE_WRAPPER_H
2 #define __LINUX_WORKQUEUE_WRAPPER_H 1
3
4 #include_next <linux/workqueue.h>
5
6 #include <linux/version.h>
7 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
8
9 /* Older kernels have an implementation of work queues with some very bad
10  * characteristics when trying to cancel work (potential deadlocks, use after
11  * free, etc.  Here we directly use timers instead for delayed work.  It's not
12  * optimal but it is better than the alternative.  Note that work queues
13  * normally run in process context but this will cause them to operate in
14  * softirq context.
15  */
16
17 #include <linux/timer.h>
18
19 #undef DECLARE_DELAYED_WORK
20 #define DECLARE_DELAYED_WORK(n, f) \
21         struct timer_list n = TIMER_INITIALIZER((void (*)(unsigned long))f, 0, 0)
22
23 #define schedule_delayed_work rpl_schedule_delayed_work
24 static inline int schedule_delayed_work(struct timer_list *timer, unsigned long delay)
25 {
26         if (timer_pending(timer))
27                 return 0;
28
29         mod_timer(timer, jiffies + delay);
30         return 1;
31 }
32
33 #define cancel_delayed_work_sync rpl_cancel_delayed_work_sync
34 static inline int cancel_delayed_work_sync(struct timer_list *timer)
35 {
36         return del_timer_sync(timer);
37 }
38
39 #endif /* kernel version < 2.6.23 */
40
41 #endif