diff options
Diffstat (limited to 'include/linux/wait.h')
-rw-r--r-- | include/linux/wait.h | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h index 0e686280450b..33a2aa9e02f2 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
@@ -152,14 +152,31 @@ int FASTCALL(out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned)); | |||
152 | int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned)); | 152 | int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned)); |
153 | wait_queue_head_t *FASTCALL(bit_waitqueue(void *, int)); | 153 | wait_queue_head_t *FASTCALL(bit_waitqueue(void *, int)); |
154 | 154 | ||
155 | #define wake_up(x) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1, NULL) | 155 | #define wake_up(x) __wake_up(x, TASK_NORMAL, 1, NULL) |
156 | #define wake_up_nr(x, nr) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, nr, NULL) | 156 | #define wake_up_nr(x, nr) __wake_up(x, TASK_NORMAL, nr, NULL) |
157 | #define wake_up_all(x) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0, NULL) | 157 | #define wake_up_all(x) __wake_up(x, TASK_NORMAL, 0, NULL) |
158 | #define wake_up_locked(x) __wake_up_locked((x), TASK_NORMAL) | ||
159 | |||
158 | #define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL) | 160 | #define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL) |
159 | #define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL) | 161 | #define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL) |
160 | #define wake_up_interruptible_all(x) __wake_up(x, TASK_INTERRUPTIBLE, 0, NULL) | 162 | #define wake_up_interruptible_all(x) __wake_up(x, TASK_INTERRUPTIBLE, 0, NULL) |
161 | #define wake_up_locked(x) __wake_up_locked((x), TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE) | 163 | #define wake_up_interruptible_sync(x) __wake_up_sync((x), TASK_INTERRUPTIBLE, 1) |
162 | #define wake_up_interruptible_sync(x) __wake_up_sync((x),TASK_INTERRUPTIBLE, 1) | 164 | |
165 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
166 | /* | ||
167 | * macro to avoid include hell | ||
168 | */ | ||
169 | #define wake_up_nested(x, s) \ | ||
170 | do { \ | ||
171 | unsigned long flags; \ | ||
172 | \ | ||
173 | spin_lock_irqsave_nested(&(x)->lock, flags, (s)); \ | ||
174 | wake_up_locked(x); \ | ||
175 | spin_unlock_irqrestore(&(x)->lock, flags); \ | ||
176 | } while (0) | ||
177 | #else | ||
178 | #define wake_up_nested(x, s) wake_up(x) | ||
179 | #endif | ||
163 | 180 | ||
164 | #define __wait_event(wq, condition) \ | 181 | #define __wait_event(wq, condition) \ |
165 | do { \ | 182 | do { \ |
@@ -345,6 +362,47 @@ do { \ | |||
345 | __ret; \ | 362 | __ret; \ |
346 | }) | 363 | }) |
347 | 364 | ||
365 | #define __wait_event_killable(wq, condition, ret) \ | ||
366 | do { \ | ||
367 | DEFINE_WAIT(__wait); \ | ||
368 | \ | ||
369 | for (;;) { \ | ||
370 | prepare_to_wait(&wq, &__wait, TASK_KILLABLE); \ | ||
371 | if (condition) \ | ||
372 | break; \ | ||
373 | if (!fatal_signal_pending(current)) { \ | ||
374 | schedule(); \ | ||
375 | continue; \ | ||
376 | } \ | ||
377 | ret = -ERESTARTSYS; \ | ||
378 | break; \ | ||
379 | } \ | ||
380 | finish_wait(&wq, &__wait); \ | ||
381 | } while (0) | ||
382 | |||
383 | /** | ||
384 | * wait_event_killable - sleep until a condition gets true | ||
385 | * @wq: the waitqueue to wait on | ||
386 | * @condition: a C expression for the event to wait for | ||
387 | * | ||
388 | * The process is put to sleep (TASK_KILLABLE) until the | ||
389 | * @condition evaluates to true or a signal is received. | ||
390 | * The @condition is checked each time the waitqueue @wq is woken up. | ||
391 | * | ||
392 | * wake_up() has to be called after changing any variable that could | ||
393 | * change the result of the wait condition. | ||
394 | * | ||
395 | * The function will return -ERESTARTSYS if it was interrupted by a | ||
396 | * signal and 0 if @condition evaluated to true. | ||
397 | */ | ||
398 | #define wait_event_killable(wq, condition) \ | ||
399 | ({ \ | ||
400 | int __ret = 0; \ | ||
401 | if (!(condition)) \ | ||
402 | __wait_event_killable(wq, condition, __ret); \ | ||
403 | __ret; \ | ||
404 | }) | ||
405 | |||
348 | /* | 406 | /* |
349 | * Must be called with the spinlock in the wait_queue_head_t held. | 407 | * Must be called with the spinlock in the wait_queue_head_t held. |
350 | */ | 408 | */ |