at v2.6.18-rc1 54 lines 1.5 kB view raw
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.c for details. 9 */ 10 11#include <linux/wait.h> 12 13struct completion { 14 unsigned int done; 15 wait_queue_head_t wait; 16}; 17 18#define COMPLETION_INITIALIZER(work) \ 19 { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) } 20 21#define DECLARE_COMPLETION(work) \ 22 struct completion work = COMPLETION_INITIALIZER(work) 23 24/* 25 * Lockdep needs to run a non-constant initializer for on-stack 26 * completions - so we use the _ONSTACK() variant for those that 27 * are on the kernel stack: 28 */ 29#ifdef CONFIG_LOCKDEP 30# define DECLARE_COMPLETION_ONSTACK(work) \ 31 struct completion work = ({ init_completion(&work); work; }) 32#else 33# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work) 34#endif 35 36static inline void init_completion(struct completion *x) 37{ 38 x->done = 0; 39 init_waitqueue_head(&x->wait); 40} 41 42extern void FASTCALL(wait_for_completion(struct completion *)); 43extern int FASTCALL(wait_for_completion_interruptible(struct completion *x)); 44extern unsigned long FASTCALL(wait_for_completion_timeout(struct completion *x, 45 unsigned long timeout)); 46extern unsigned long FASTCALL(wait_for_completion_interruptible_timeout( 47 struct completion *x, unsigned long timeout)); 48 49extern void FASTCALL(complete(struct completion *)); 50extern void FASTCALL(complete_all(struct completion *)); 51 52#define INIT_COMPLETION(x) ((x).done = 0) 53 54#endif