~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/completion.h

Version: ~ [ linux-5.3-rc4 ] ~ [ linux-5.2.8 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.66 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.138 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.71 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef __LINUX_COMPLETION_H
  2 #define __LINUX_COMPLETION_H
  3 
  4 /*
  5  * (C) Copyright 2001 Linus Torvalds
  6  *
  7  * Atomic wait-for-completion handler data structures.
  8  * See kernel/sched/completion.c for details.
  9  */
 10 
 11 #include <linux/wait.h>
 12 
 13 /*
 14  * struct completion - structure used to maintain state for a "completion"
 15  *
 16  * This is the opaque structure used to maintain the state for a "completion".
 17  * Completions currently use a FIFO to queue threads that have to wait for
 18  * the "completion" event.
 19  *
 20  * See also:  complete(), wait_for_completion() (and friends _timeout,
 21  * _interruptible, _interruptible_timeout, and _killable), init_completion(),
 22  * reinit_completion(), and macros DECLARE_COMPLETION(),
 23  * DECLARE_COMPLETION_ONSTACK().
 24  */
 25 struct completion {
 26         unsigned int done;
 27         wait_queue_head_t wait;
 28 };
 29 
 30 #define COMPLETION_INITIALIZER(work) \
 31         { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
 32 
 33 #define COMPLETION_INITIALIZER_ONSTACK(work) \
 34         ({ init_completion(&work); work; })
 35 
 36 /**
 37  * DECLARE_COMPLETION - declare and initialize a completion structure
 38  * @work:  identifier for the completion structure
 39  *
 40  * This macro declares and initializes a completion structure. Generally used
 41  * for static declarations. You should use the _ONSTACK variant for automatic
 42  * variables.
 43  */
 44 #define DECLARE_COMPLETION(work) \
 45         struct completion work = COMPLETION_INITIALIZER(work)
 46 
 47 /*
 48  * Lockdep needs to run a non-constant initializer for on-stack
 49  * completions - so we use the _ONSTACK() variant for those that
 50  * are on the kernel stack:
 51  */
 52 /**
 53  * DECLARE_COMPLETION_ONSTACK - declare and initialize a completion structure
 54  * @work:  identifier for the completion structure
 55  *
 56  * This macro declares and initializes a completion structure on the kernel
 57  * stack.
 58  */
 59 #ifdef CONFIG_LOCKDEP
 60 # define DECLARE_COMPLETION_ONSTACK(work) \
 61         struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
 62 #else
 63 # define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
 64 #endif
 65 
 66 /**
 67  * init_completion - Initialize a dynamically allocated completion
 68  * @x:  pointer to completion structure that is to be initialized
 69  *
 70  * This inline function will initialize a dynamically created completion
 71  * structure.
 72  */
 73 static inline void init_completion(struct completion *x)
 74 {
 75         x->done = 0;
 76         init_waitqueue_head(&x->wait);
 77 }
 78 
 79 /**
 80  * reinit_completion - reinitialize a completion structure
 81  * @x:  pointer to completion structure that is to be reinitialized
 82  *
 83  * This inline function should be used to reinitialize a completion structure so it can
 84  * be reused. This is especially important after complete_all() is used.
 85  */
 86 static inline void reinit_completion(struct completion *x)
 87 {
 88         x->done = 0;
 89 }
 90 
 91 extern void wait_for_completion(struct completion *);
 92 extern void wait_for_completion_io(struct completion *);
 93 extern int wait_for_completion_interruptible(struct completion *x);
 94 extern int wait_for_completion_killable(struct completion *x);
 95 extern unsigned long wait_for_completion_timeout(struct completion *x,
 96                                                    unsigned long timeout);
 97 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
 98                                                     unsigned long timeout);
 99 extern long wait_for_completion_interruptible_timeout(
100         struct completion *x, unsigned long timeout);
101 extern long wait_for_completion_killable_timeout(
102         struct completion *x, unsigned long timeout);
103 extern bool try_wait_for_completion(struct completion *x);
104 extern bool completion_done(struct completion *x);
105 
106 extern void complete(struct completion *);
107 extern void complete_all(struct completion *);
108 
109 #endif
110 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp