[patch] wait_event_interruptible_timeout (1/3)

Urban Widmark (urban@teststation.com)
Sun, 29 Sep 2002 22:19:59 +0200 (CEST)


smbfs wants a wait_event_interruptible_timeout to be able to replace
interruptible_sleep_on_timeout.

Please apply.

/Urban

diff -urN -X exclude linux-2.5.39-orig/include/linux/sched.h linux-2.5.39-smbfs/include/linux/sched.h
--- linux-2.5.39-orig/include/linux/sched.h Sun Sep 29 09:32:32 2002
+++ linux-2.5.39-smbfs/include/linux/sched.h Sun Sep 29 18:51:21 2002
@@ -720,6 +720,45 @@
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.
@@ -740,14 +779,6 @@
__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)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/