aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/wait.h
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2013-10-02 05:22:21 -0400
committerIngo Molnar <mingo@kernel.org>2013-10-04 04:14:46 -0400
commit41a1431b178c3b731d6dfc40b987528b333dd93e (patch)
tree471463407abfba85648ffb6f0a720ea55e1dbe0b /include/linux/wait.h
parentbb632bc44970f75b66df102e831a4fc0692e9159 (diff)
sched/wait: Introduce ___wait_event()
There's far too much duplication in the __wait_event macros; in order to fix this introduce ___wait_event() a macro with the capability to replace most other macros. With the previous patches changing the various __wait_event*() implementations to be more uniform; we can now collapse the lot without also changing generated code. Reviewed-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20131002092528.181897111@infradead.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/wait.h')
-rw-r--r--include/linux/wait.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 7d7819dafcc5..29d0249e03ab 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -187,6 +187,42 @@ wait_queue_head_t *bit_waitqueue(void *, int);
187 __cond || !ret; \ 187 __cond || !ret; \
188}) 188})
189 189
190#define ___wait_signal_pending(state) \
191 ((state == TASK_INTERRUPTIBLE && signal_pending(current)) || \
192 (state == TASK_KILLABLE && fatal_signal_pending(current)))
193
194#define ___wait_nop_ret int ret __always_unused
195
196#define ___wait_event(wq, condition, state, exclusive, ret, cmd) \
197do { \
198 __label__ __out; \
199 DEFINE_WAIT(__wait); \
200 \
201 for (;;) { \
202 if (exclusive) \
203 prepare_to_wait_exclusive(&wq, &__wait, state); \
204 else \
205 prepare_to_wait(&wq, &__wait, state); \
206 \
207 if (condition) \
208 break; \
209 \
210 if (___wait_signal_pending(state)) { \
211 ret = -ERESTARTSYS; \
212 if (exclusive) { \
213 abort_exclusive_wait(&wq, &__wait, \
214 state, NULL); \
215 goto __out; \
216 } \
217 break; \
218 } \
219 \
220 cmd; \
221 } \
222 finish_wait(&wq, &__wait); \
223__out: ; \
224} while (0)
225
190#define __wait_event(wq, condition) \ 226#define __wait_event(wq, condition) \
191do { \ 227do { \
192 DEFINE_WAIT(__wait); \ 228 DEFINE_WAIT(__wait); \