1
/* copied from linux/wait.h */
3
#ifndef wait_event_timeout
4
#define wait_event_timeout(wq, condition, timeout) \
6
long __ret = timeout; \
8
__wait_event_timeout(wq, condition, __ret); \
12
#define __wait_event_timeout(wq, condition, ret) \
14
wait_queue_t __wait; \
15
init_waitqueue_entry(&__wait, current); \
17
add_wait_queue(&wq, &__wait); \
19
set_current_state(TASK_UNINTERRUPTIBLE); \
22
ret = schedule_timeout(ret); \
26
current->state = TASK_RUNNING; \
27
remove_wait_queue(&wq, &__wait); \
31
#ifndef wait_event_interruptible_timeout
33
/* We need to define these ones here as they only exist in kernels 2.6 and up */
35
#define __wait_event_interruptible_timeout(wq, condition, timeout, ret) \
39
wait_queue_t __wait; \
40
unsigned long expire; \
41
init_waitqueue_entry(&__wait, current); \
43
expire = timeout + jiffies; \
44
add_wait_queue(&wq, &__wait); \
46
set_current_state(TASK_INTERRUPTIBLE); \
49
if (jiffies > expire) { \
50
ret = jiffies - expire; \
53
if (!signal_pending(current)) { \
54
schedule_timeout(timeout); \
60
current->state = TASK_RUNNING; \
61
remove_wait_queue(&wq, &__wait); \
66
retval == 0; condition met; we're good.
67
retval < 0; interrupted by signal.
68
retval > 0; timed out.
70
#define wait_event_interruptible_timeout(wq, condition, timeout) \
74
__wait_event_interruptible_timeout(wq, condition, \
79
#endif /* wait_event_interruptible_timeout not defined */