1
2#ifndef __LINUX_COMPLETION_H
3#define __LINUX_COMPLETION_H
4
5
6
7
8
9
10
11
12#include <linux/swait.h>
13
14
15
16
17
18
19
20
21
22
23
24
25
26struct completion {
27 unsigned int done;
28 struct swait_queue_head wait;
29};
30
31#define init_completion_map(x, m) init_completion(x)
32static inline void complete_acquire(struct completion *x) {}
33static inline void complete_release(struct completion *x) {}
34
35#define COMPLETION_INITIALIZER(work) \
36 { 0, __SWAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
37
38#define COMPLETION_INITIALIZER_ONSTACK_MAP(work, map) \
39 (*({ init_completion_map(&(work), &(map)); &(work); }))
40
41#define COMPLETION_INITIALIZER_ONSTACK(work) \
42 (*({ init_completion(&work); &work; }))
43
44
45
46
47
48
49
50
51
52#define DECLARE_COMPLETION(work) \
53 struct completion work = COMPLETION_INITIALIZER(work)
54
55
56
57
58
59
60
61
62
63
64
65
66
67#ifdef CONFIG_LOCKDEP
68# define DECLARE_COMPLETION_ONSTACK(work) \
69 struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
70# define DECLARE_COMPLETION_ONSTACK_MAP(work, map) \
71 struct completion work = COMPLETION_INITIALIZER_ONSTACK_MAP(work, map)
72#else
73# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
74# define DECLARE_COMPLETION_ONSTACK_MAP(work, map) DECLARE_COMPLETION(work)
75#endif
76
77
78
79
80
81
82
83
84static inline void init_completion(struct completion *x)
85{
86 x->done = 0;
87 init_swait_queue_head(&x->wait);
88}
89
90
91
92
93
94
95
96
97static inline void reinit_completion(struct completion *x)
98{
99 x->done = 0;
100}
101
102extern void wait_for_completion(struct completion *);
103extern void wait_for_completion_io(struct completion *);
104extern int wait_for_completion_interruptible(struct completion *x);
105extern int wait_for_completion_killable(struct completion *x);
106extern unsigned long wait_for_completion_timeout(struct completion *x,
107 unsigned long timeout);
108extern unsigned long wait_for_completion_io_timeout(struct completion *x,
109 unsigned long timeout);
110extern long wait_for_completion_interruptible_timeout(
111 struct completion *x, unsigned long timeout);
112extern long wait_for_completion_killable_timeout(
113 struct completion *x, unsigned long timeout);
114extern bool try_wait_for_completion(struct completion *x);
115extern bool completion_done(struct completion *x);
116
117extern void complete(struct completion *);
118extern void complete_all(struct completion *);
119
120#endif
121