Whamcloud - gitweb
New tag 2.15.91
[fs/lustre-release.git] / libcfs / include / libcfs / linux / linux-wait.h
index d406666..b54370f 100644 (file)
 #define wait_queue_entry_t wait_queue_t
 #endif
 
+#ifndef HAVE_PREPARE_TO_WAIT_EVENT
+#define __add_wait_queue_entry_tail __add_wait_queue_tail
+#endif
+
 #ifndef HAVE_WAIT_BIT_HEADER_H
 struct wait_bit_queue_entry {
        struct wait_bit_key     key;
@@ -136,6 +140,20 @@ do {                                                                       \
                __ret = __wait_var_event_timeout(var, condition, timeout); \
        __ret;                                                          \
 })
+#else /* !HAVE_WAIT_VAR_EVENT */
+/* linux-3.10.0-1062.el7 defines wait_var_event_timeout() using
+ * __wait_cond_timeout(), but doesn't define __wait_cond_timeout !!!
+ */
+# ifndef __wait_cond_timeout
+# define ___wait_cond_timeout(condition)                               \
+({                                                                     \
+       bool __cond = (condition);                                      \
+       if (__cond && !__ret)                                           \
+               __ret = 1;                                              \
+       __cond || !__ret;                                               \
+})
+# endif /* __wait_cond_timeout */
+
 #endif /* ! HAVE_WAIT_VAR_EVENT */
 
 /*
@@ -176,12 +194,12 @@ static inline void prepare_to_wait_exclusive_head(
 #define ___wait_event(wq_head, condition, state, exclusive, ret, cmd)  \
 ({                                                                     \
        __label__ __out;                                                \
-       wait_queue_entry_ __wq_entry;                                   \
+       wait_queue_entry_t __wq_entry;                                  \
        long __ret = ret;       /* explicit shadow */                   \
                                                                        \
        init_wait(&__wq_entry);                                         \
        if (exclusive)                                                  \
-               __wq_entry.flags = WQ_FLAG_EXCLUSIVE                    \
+               __wq_entry.flags = WQ_FLAG_EXCLUSIVE;                   \
        for (;;) {                                                      \
                long __int = prepare_to_wait_event(&wq_head,            \
                                                  &__wq_entry, state);  \
@@ -203,6 +221,8 @@ __out:      __ret;                                                          \
 
 #ifndef TASK_NOLOAD
 
+#define TASK_IDLE TASK_INTERRUPTIBLE
+
 #define ___wait_event_idle(wq_head, condition, exclusive, ret, cmd)    \
 ({                                                                     \
        wait_queue_entry_t __wq_entry;                                  \
@@ -567,4 +587,11 @@ do {                                                                       \
        __ret;                                                          \
 })
 
+#ifndef HAVE_WAIT_WOKEN
+#define WQ_FLAG_WOKEN          0x02
+long wait_woken(wait_queue_entry_t *wait, unsigned int mode, long timeout);
+int woken_wake_function(wait_queue_entry_t *wait, unsigned int mode,
+                       int sync, void *key);
+#endif /* HAVE_WAIT_WOKEN */
+
 #endif /* __LICBFS_LINUX_WAIT_BIT_H */