qlock.h 920 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #ifndef _PLAN9_SOURCE
  10. This header file is an extension to ANSI/POSIX
  11. #endif
  12. #ifndef __QLOCK_H_
  13. #define __QLOCK_H_
  14. #pragma lib "/$M/lib/ape/lib9.a"
  15. #include <u.h>
  16. #include <lock.h>
  17. typedef struct QLp QLp;
  18. struct QLp
  19. {
  20. int inuse;
  21. QLp *next;
  22. char state;
  23. };
  24. typedef
  25. struct QLock
  26. {
  27. Lock lock;
  28. int locked;
  29. QLp *head;
  30. QLp *tail;
  31. } QLock;
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. extern void qlock(QLock*);
  36. extern void qunlock(QLock*);
  37. extern int canqlock(QLock*);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif