VSF Documented
wait.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_WAIT_H__
2#define __VSF_LINUX_WAIT_H__
3
4#include "kernel/vsf_kernel.h"
5#include <linux/spinlock.h>
6#include <linux/list.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12struct wait_queue_entry;
13typedef int (*wait_queue_func_t)(struct wait_queue_entry *wqe, unsigned mode, int flags, void *key);
14
15#define WQ_FLAG_EXCLUSIVE 0x01
16#define WQ_FLAG_WOKEN 0x02
17#define WQ_FLAG_BOOKMARK 0x04
18#define WQ_FLAG_CUSTOM 0x08
19#define WQ_FLAG_DONE 0x10
20#define WQ_FLAG_PRIORITY 0x20
21
22typedef struct wait_queue_entry {
23 unsigned int flags;
26
29
30typedef struct wait_queue_head {
34
35static inline void init_waitqueue_head(struct wait_queue_head *wqh)
36{
37 spin_lock_init(&wqh->lock);
38 INIT_LIST_HEAD(&wqh->head);
39}
40
41extern void init_wait_entry(struct wait_queue_entry *wqe, int flags);
42extern void prepare_to_wait(struct wait_queue_head *wqh, struct wait_queue_entry *wqe, int state);
43extern bool prepare_to_wait_exclusive(struct wait_queue_head *wqh, struct wait_queue_entry *wqe, int state);
44extern long prepare_to_wait_event(struct wait_queue_head *wqh, struct wait_queue_entry *wqe, int state);
45extern void finish_wait(struct wait_queue_head *wqh, struct wait_queue_entry *wqe);
46extern long wait_woken(struct wait_queue_entry *wqe, unsigned mode, long timeout);
47extern int woken_wake_function(struct wait_queue_entry *wqe, unsigned mode, int sync, void *key);
48extern int autoremove_wake_function(struct wait_queue_entry *wqe, unsigned mode, int sync, void *key);
49
50#define __wait_event_timeout(__wqh, __cond, __timeout) ({ \
51 struct wait_queue_entry __wqe; \
52 long local_timeout = (__timeout); \
53 vsf_trig_t trig; \
54 vsf_eda_trig_init(&trig, false, true); \
55 __wqe.__trig = &trig; \
56 init_wait_entry(&__wqe, 0); \
57 while (1) { \
58 prepare_to_wait_event(&__wqh, &__wqe, 0); \
59 if (__cond) { \
60 break; \
61 } \
62 vsf_thread_trig_pend(&trig, local_timeout); \
63 } \
64 finish_wait(&__wqh, &__wqe); \
65 local_timeout; \
66})
67
68#define wait_event_timeout(__wqh, __cond, __timeout) ({ \
69 long local_timeout = (__timeout); \
70 bool local_cond = (__cond); \
71 if (local_cond && !local_timeout) { \
72 local_timeout = 1; \
73 } \
74 if (!(local_cond || !local_timeout)) { \
75 local_timeout = __wait_event_timeout(__wqh, __cond, __timeout); \
76 } \
77 local_timeout; \
78})
79
80#define wait_event(__wqh, __cond) wait_event_timeout(__wqh, __cond, -1)
81extern void wake_up_nr(struct wait_queue_head *wqh, int nr);
82#define wake_up(__wqh) wake_up_nr((__wqh), 1)
83#define wake_up_all(__wqh) wake_up_nr((__wqh), -1)
84
85#ifdef __cplusplus
86}
87#endif
88
89#endif
Definition vsf_eda.h:864
__le16 timeout
Definition ieee80211.h:94
#define spin_lock_init(lock)
Definition spinlock.h:29
int spinlock_t
Definition spinlock.h:26
int autoremove_wake_function(struct wait_queue_entry *wqe, unsigned mode, int sync, void *key)
Definition vsf_linux_core.c:445
void prepare_to_wait(struct wait_queue_head *wqh, struct wait_queue_entry *wqe, int state)
int(* wait_queue_func_t)(struct wait_queue_entry *wqe, unsigned mode, int flags, void *key)
Definition wait.h:13
void finish_wait(struct wait_queue_head *wqh, struct wait_queue_entry *wqe)
Definition vsf_linux_core.c:470
int woken_wake_function(struct wait_queue_entry *wqe, unsigned mode, int sync, void *key)
long prepare_to_wait_event(struct wait_queue_head *wqh, struct wait_queue_entry *wqe, int state)
Definition vsf_linux_core.c:451
void wake_up_nr(struct wait_queue_head *wqh, int nr)
Definition vsf_linux_core.c:480
void init_wait_entry(struct wait_queue_entry *wqe, int flags)
Definition vsf_linux_core.c:462
struct wait_queue_head wait_queue_head_t
long wait_woken(struct wait_queue_entry *wqe, unsigned mode, long timeout)
struct wait_queue_entry wait_queue_entry_t
bool prepare_to_wait_exclusive(struct wait_queue_head *wqh, struct wait_queue_entry *wqe, int state)
Definition list.h:77
Definition wait.h:22
wait_queue_func_t func
Definition wait.h:24
unsigned int flags
Definition wait.h:23
vsf_trig_t * __trig
Definition wait.h:27
struct list_head entry
Definition wait.h:25
Definition wait.h:30
spinlock_t lock
Definition wait.h:31
struct list_head head
Definition wait.h:32
void sync(void)
Definition vsf_linux_fs.c:2146
uint8_t state
Definition vsf_msg_tree.h:247