vserver 2.0 rc7
[linux-2.6.git] / include / linux / wait.h
index ddb0a16..c9486c3 100644 (file)
@@ -79,7 +79,7 @@ typedef struct __wait_queue_head wait_queue_head_t;
 
 static inline void init_waitqueue_head(wait_queue_head_t *q)
 {
-       q->lock = SPIN_LOCK_UNLOCKED;
+       spin_lock_init(&q->lock);
        INIT_LIST_HEAD(&q->task_list);
 }
 
@@ -169,6 +169,18 @@ do {                                                                       \
        finish_wait(&wq, &__wait);                                      \
 } while (0)
 
+/**
+ * wait_event - sleep until a condition gets true
+ * @wq: the waitqueue to wait on
+ * @condition: a C expression for the event to wait for
+ *
+ * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
+ * @condition evaluates to true. The @condition is checked each time
+ * the waitqueue @wq is woken up.
+ *
+ * wake_up() has to be called after changing any variable that could
+ * change the result of the wait condition.
+ */
 #define wait_event(wq, condition)                                      \
 do {                                                                   \
        if (condition)                                                  \
@@ -191,6 +203,22 @@ do {                                                                       \
        finish_wait(&wq, &__wait);                                      \
 } while (0)
 
+/**
+ * wait_event_timeout - sleep until a condition gets true or a timeout elapses
+ * @wq: the waitqueue to wait on
+ * @condition: a C expression for the event to wait for
+ * @timeout: timeout, in jiffies
+ *
+ * The process is put to sleep (TASK_UNINTERRUPTIBLE) until the
+ * @condition evaluates to true. The @condition is checked each time
+ * the waitqueue @wq is woken up.
+ *
+ * wake_up() has to be called after changing any variable that could
+ * change the result of the wait condition.
+ *
+ * The function returns 0 if the @timeout elapsed, and the remaining
+ * jiffies if the condition evaluated to true before the timeout elapsed.
+ */
 #define wait_event_timeout(wq, condition, timeout)                     \
 ({                                                                     \
        long __ret = timeout;                                           \
@@ -217,6 +245,21 @@ do {                                                                       \
        finish_wait(&wq, &__wait);                                      \
 } while (0)
 
+/**
+ * wait_event_interruptible - sleep until a condition gets true
+ * @wq: the waitqueue to wait on
+ * @condition: a C expression for the event to wait for
+ *
+ * The process is put to sleep (TASK_INTERRUPTIBLE) until the
+ * @condition evaluates to true or a signal is received.
+ * The @condition is checked each time the waitqueue @wq is woken up.
+ *
+ * wake_up() has to be called after changing any variable that could
+ * change the result of the wait condition.
+ *
+ * The function will return -ERESTARTSYS if it was interrupted by a
+ * signal and 0 if @condition evaluated to true.
+ */
 #define wait_event_interruptible(wq, condition)                                \
 ({                                                                     \
        int __ret = 0;                                                  \
@@ -245,6 +288,23 @@ do {                                                                       \
        finish_wait(&wq, &__wait);                                      \
 } while (0)
 
+/**
+ * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses
+ * @wq: the waitqueue to wait on
+ * @condition: a C expression for the event to wait for
+ * @timeout: timeout, in jiffies
+ *
+ * The process is put to sleep (TASK_INTERRUPTIBLE) until the
+ * @condition evaluates to true or a signal is received.
+ * The @condition is checked each time the waitqueue @wq is woken up.
+ *
+ * wake_up() has to be called after changing any variable that could
+ * change the result of the wait condition.
+ *
+ * The function returns 0 if the @timeout elapsed, -ERESTARTSYS if it
+ * was interrupted by a signal, and the remaining jiffies otherwise
+ * if the condition evaluated to true before the timeout elapsed.
+ */
 #define wait_event_interruptible_timeout(wq, condition, timeout)       \
 ({                                                                     \
        long __ret = timeout;                                           \
@@ -326,9 +386,7 @@ int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
        wait_queue_t name = {                                           \
                .task           = current,                              \
                .func           = autoremove_wake_function,             \
-               .task_list      = {     .next = &(name).task_list,      \
-                                       .prev = &(name).task_list,      \
-                               },                                      \
+               .task_list      = LIST_HEAD_INIT((name).task_list),     \
        }
 
 #define DEFINE_WAIT_BIT(name, word, bit)                               \