1#ifndef __LINUX_WAIT_H__
2#define __LINUX_WAIT_H__
48#include <linux/kernel.h>
87#define WQ_FLAG_EXCLUSIVE 0x01
88#define WQ_FLAG_WOKEN 0x02
93#define DCL_WAIT_EVENT_MS 5000
98 INIT_LIST_HEAD(&wq_head->
head);
101#define DECLARE_WAIT_QUEUE_HEAD(name) \
102 struct wait_queue_head name = { 0, LIST_HEAD_INIT(name.head) }
104#define INIT_WAIT_QUEUE_HEAD(name) init_waitqueue_head(&(name))
111#define __WAITQUEUE_INITIALIZER(name, tsk) { \
113 .func = default_wake_function, \
114 .entry = LIST_HEAD_INIT((name).entry), \
117#define DECLARE_WAITQUEUE(name, tsk) \
118 struct wait_queue_entry name = __WAITQUEUE_INITIALIZER(name, tsk)
121#define DEFINE_WAIT_FUNC(name, function) \
122 struct wait_queue_entry name = { \
123 .private = current, \
124 .func = (function), \
125 .entry = LIST_HEAD_INIT((name).entry), \
134 INIT_LIST_HEAD(&wq_entry->
entry);
137static inline void init_waitqueue_func_entry(
struct wait_queue_entry* wq_entry,
142 wq_entry->
func = func;
143 INIT_LIST_HEAD(&wq_entry->
entry);
153 int nr_exclusive,
void* key);
155#define wake_up(x) __wake_up((x), TASK_NORMAL, 1, 0)
156#define wake_up_all(x) __wake_up((x), TASK_NORMAL, 0, 0)
157#define wake_up_interruptible(x) __wake_up((x), TASK_INTERRUPTIBLE, 1, 0)
158#define wake_up_interruptible_all(x) __wake_up((x), TASK_INTERRUPTIBLE, 0, 0)
159#define wake_up_interruptible_sync(x) __wake_up((x), TASK_INTERRUPTIBLE, 1, 0)
160#define wake_up_poll(x, m) \
161 __wake_up((x), TASK_NORMAL, 1, (void*)(uintptr_t)(m))
162#define wake_up_interruptible_poll(x, m) \
163 __wake_up((x), TASK_INTERRUPTIBLE, 1, (void*)(uintptr_t)(m))
164#define wake_up_interruptible_sync_poll(x, m) \
165 __wake_up((x), TASK_INTERRUPTIBLE, 1, (void*)(uintptr_t)(m))
176 unsigned int state,
long timeout);
219#define _dcl_wait_core(wq_head, condition) \
221 unsigned int _dcl_i = DCL_WAIT_EVENT_MS; \
224 while (!(condition) && _dcl_i) { \
229 _dcl_ok = !!(condition); \
231 dcl_wait_event_timeout(__func__); \
242#define wait_event(wq_head, condition) \
244 (void)_dcl_wait_core(wq_head, condition); \
270#define wait_event_interruptible(wq_head, condition) \
272 _dcl_wait_core(wq_head, condition) \
273 ? 0 : -ERESTARTSYS; \
302#define wait_event_interruptible_timeout(wq_head, condition, timeout) \
304 long _dcl_t = (timeout); \
305 _dcl_wait_core(wq_head, condition) \
322#define wait_event_timeout(wq_head, condition, timeout) \
324 long _dcl_t = (timeout); \
325 _dcl_wait_core(wq_head, condition) \
339#define wait_event_lock_irq(wq_head, condition, lock) \
342 (void)_dcl_wait_core(wq_head, condition); \
361#define DEFINE_WAIT(name) \
362 struct wait_queue_entry name = __WAITQUEUE_INITIALIZER(name, current)
391 if (list_empty(&wq_entry->
entry))
399 if (!list_empty(&wq_entry->
entry))
439#define wait_event_freezable(wq_head, condition) \
441 _dcl_wait_core(wq_head, condition) \
442 ? 0 : -ERESTARTSYS; \
uint8_t flags
Definition virtio.h:0
#define spin_lock_init(l)
Definition kernel.h:225
int spinlock_t
Definition kernel.h:44
#define set_current_state(s)
Definition sched.h:241
#define TASK_RUNNING
Definition sched.h:84
#define __set_current_state(s)
Definition sched.h:242
int const struct list_head const struct list_head struct list_head * head
Definition list_sort.h:13
wait_queue_func_t func
Definition wait.h:71
unsigned int flags
Definition wait.h:69
void * private
Definition wait.h:70
struct list_head entry
Definition wait.h:72
spinlock_t lock
Definition wait.h:76
struct list_head head
Definition wait.h:77
void add_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
void __wake_up(struct wait_queue_head *wq_head, unsigned int mode, int nr_exclusive, void *key)
unsigned int wait_woken(struct wait_queue_entry *wq_entry, unsigned int state, long timeout)
void dcl_wait_event_timeout(const char *func)
void remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
int default_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, int flags, void *key)
int(* wait_queue_func_t)(struct wait_queue_entry *wq_entry, unsigned mode, int flags, void *key)
Definition wait.h:65
int woken_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, int flags, void *key)