rwlock_types.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef __LINUX_RWLOCK_TYPES_H
  2. #define __LINUX_RWLOCK_TYPES_H
  3. /*
  4. * include/linux/rwlock_types.h - generic rwlock type definitions
  5. * and initializers
  6. *
  7. * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
  8. * Released under the General Public License (GPL).
  9. */
  10. typedef struct {
  11. arch_rwlock_t raw_lock;
  12. #ifdef CONFIG_GENERIC_LOCKBREAK
  13. unsigned int break_lock;
  14. #endif
  15. #ifdef CONFIG_DEBUG_SPINLOCK
  16. unsigned int magic, owner_cpu;
  17. void *owner;
  18. #endif
  19. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  20. struct lockdep_map dep_map;
  21. #endif
  22. } rwlock_t;
  23. #define RWLOCK_MAGIC 0xdeaf1eed
  24. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  25. # define RW_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname }
  26. #else
  27. # define RW_DEP_MAP_INIT(lockname)
  28. #endif
  29. #ifdef CONFIG_DEBUG_SPINLOCK
  30. #define __RW_LOCK_UNLOCKED(lockname) \
  31. (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \
  32. .magic = RWLOCK_MAGIC, \
  33. .owner = SPINLOCK_OWNER_INIT, \
  34. .owner_cpu = -1, \
  35. RW_DEP_MAP_INIT(lockname) }
  36. #else
  37. #define __RW_LOCK_UNLOCKED(lockname) \
  38. (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \
  39. RW_DEP_MAP_INIT(lockname) }
  40. #endif
  41. #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x)
  42. #endif /* __LINUX_RWLOCK_TYPES_H */