completion.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef __LINUX_COMPLETION_H
  2. #define __LINUX_COMPLETION_H
  3. /*
  4. * (C) Copyright 2001 Linus Torvalds
  5. *
  6. * Atomic wait-for-completion handler data structures.
  7. * See kernel/sched.c for details.
  8. */
  9. #include <linux/wait.h>
  10. struct completion {
  11. unsigned int done;
  12. wait_queue_head_t wait;
  13. };
  14. #define COMPLETION_INITIALIZER(work) \
  15. { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
  16. #define DECLARE_COMPLETION(work) \
  17. struct completion work = COMPLETION_INITIALIZER(work)
  18. static inline void init_completion(struct completion *x)
  19. {
  20. x->done = 0;
  21. init_waitqueue_head(&x->wait);
  22. }
  23. extern void FASTCALL(wait_for_completion(struct completion *));
  24. extern int FASTCALL(wait_for_completion_interruptible(struct completion *x));
  25. extern unsigned long FASTCALL(wait_for_completion_timeout(struct completion *x,
  26. unsigned long timeout));
  27. extern unsigned long FASTCALL(wait_for_completion_interruptible_timeout(
  28. struct completion *x, unsigned long timeout));
  29. extern void FASTCALL(complete(struct completion *));
  30. extern void FASTCALL(complete_all(struct completion *));
  31. #define INIT_COMPLETION(x) ((x).done = 0)
  32. #endif