]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/wait.h
sched/wait: Introduce ___wait_event()
[karo-tx-linux.git] / include / linux / wait.h
index 7d7819dafcc566ad4f77e0bf26a700bbf8e9e6d4..29d0249e03ababd8cffdb944e15536344382649e 100644 (file)
@@ -187,6 +187,42 @@ wait_queue_head_t *bit_waitqueue(void *, int);
        __cond || !ret;                                                 \
 })
 
+#define ___wait_signal_pending(state)                                  \
+       ((state == TASK_INTERRUPTIBLE && signal_pending(current)) ||    \
+        (state == TASK_KILLABLE && fatal_signal_pending(current)))
+
+#define ___wait_nop_ret                int ret __always_unused
+
+#define ___wait_event(wq, condition, state, exclusive, ret, cmd)       \
+do {                                                                   \
+       __label__ __out;                                                \
+       DEFINE_WAIT(__wait);                                            \
+                                                                       \
+       for (;;) {                                                      \
+               if (exclusive)                                          \
+                       prepare_to_wait_exclusive(&wq, &__wait, state); \
+               else                                                    \
+                       prepare_to_wait(&wq, &__wait, state);           \
+                                                                       \
+               if (condition)                                          \
+                       break;                                          \
+                                                                       \
+               if (___wait_signal_pending(state)) {                    \
+                       ret = -ERESTARTSYS;                             \
+                       if (exclusive) {                                \
+                               abort_exclusive_wait(&wq, &__wait,      \
+                                                    state, NULL);      \
+                               goto __out;                             \
+                       }                                               \
+                       break;                                          \
+               }                                                       \
+                                                                       \
+               cmd;                                                    \
+       }                                                               \
+       finish_wait(&wq, &__wait);                                      \
+__out: ;                                                               \
+} while (0)
+
 #define __wait_event(wq, condition)                                    \
 do {                                                                   \
        DEFINE_WAIT(__wait);                                            \