diff options
| author | Urban Widmark <urban@teststation.com> | 2002-09-29 02:02:42 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-09-29 02:02:42 -0700 |
| commit | add283989e10afc720bc5db3358e7c0d95d6765b (patch) | |
| tree | 9e5b4fc16af8c877ea376238fe5acaf5c2962f60 /include/linux | |
| parent | edb2350018897ed64540e197d0a6db008f77fd8b (diff) | |
[PATCH] wait_event_interruptible_timeout
smbfs wants a wait_event_interruptible_timeout to be able to replace
interruptible_sleep_on_timeout.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/sched.h | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 3e55dbedfba3..8a361b76cf43 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -717,6 +717,45 @@ do { \ current->state = TASK_RUNNING; \ remove_wait_queue(&wq, &__wait); \ } while (0) + +#define wait_event_interruptible(wq, condition) \ +({ \ + int __ret = 0; \ + if (!(condition)) \ + __wait_event_interruptible(wq, condition, __ret); \ + __ret; \ +}) + +#define __wait_event_interruptible_timeout(wq, condition, ret) \ +do { \ + wait_queue_t __wait; \ + init_waitqueue_entry(&__wait, current); \ + \ + add_wait_queue(&wq, &__wait); \ + for (;;) { \ + set_current_state(TASK_INTERRUPTIBLE); \ + if (condition) \ + break; \ + if (!signal_pending(current)) { \ + ret = schedule_timeout(ret); \ + if (!ret) \ + break; \ + continue; \ + } \ + ret = -ERESTARTSYS; \ + break; \ + } \ + current->state = TASK_RUNNING; \ + remove_wait_queue(&wq, &__wait); \ +} while (0) + +#define wait_event_interruptible_timeout(wq, condition, timeout) \ +({ \ + long __ret = timeout; \ + if (!(condition)) \ + __wait_event_interruptible_timeout(wq, condition, __ret); \ + __ret; \ +}) /* * Must be called with the spinlock in the wait_queue_head_t held. @@ -737,14 +776,6 @@ static inline void remove_wait_queue_locked(wait_queue_head_t *q, __remove_wait_queue(q, wait); } -#define wait_event_interruptible(wq, condition) \ -({ \ - int __ret = 0; \ - if (!(condition)) \ - __wait_event_interruptible(wq, condition, __ret); \ - __ret; \ -}) - #define remove_parent(p) list_del_init(&(p)->sibling) #define add_parent(p, parent) list_add_tail(&(p)->sibling,&(parent)->children) |
