spinlock_types.h
上传用户:szlgq88
上传日期:2009-04-28
资源大小:48287k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. #ifndef __LINUX_SPINLOCK_TYPES_H
  2. #define __LINUX_SPINLOCK_TYPES_H
  3. /*
  4.  * include/linux/spinlock_types.h - generic spinlock 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. #if defined(CONFIG_SMP)
  11. # include <asm/spinlock_types.h>
  12. #else
  13. # include <linux/spinlock_types_up.h>
  14. #endif
  15. typedef struct {
  16. raw_spinlock_t raw_lock;
  17. #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
  18. unsigned int break_lock;
  19. #endif
  20. #ifdef CONFIG_DEBUG_SPINLOCK
  21. unsigned int magic, owner_cpu;
  22. void *owner;
  23. #endif
  24. } spinlock_t;
  25. #define SPINLOCK_MAGIC 0xdead4ead
  26. typedef struct {
  27. raw_rwlock_t raw_lock;
  28. #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
  29. unsigned int break_lock;
  30. #endif
  31. #ifdef CONFIG_DEBUG_SPINLOCK
  32. unsigned int magic, owner_cpu;
  33. void *owner;
  34. #endif
  35. } rwlock_t;
  36. #define RWLOCK_MAGIC 0xdeaf1eed
  37. #define SPINLOCK_OWNER_INIT ((void *)-1L)
  38. #ifdef CONFIG_DEBUG_SPINLOCK
  39. # define SPIN_LOCK_UNLOCKED
  40. (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED,
  41. .magic = SPINLOCK_MAGIC,
  42. .owner = SPINLOCK_OWNER_INIT,
  43. .owner_cpu = -1 }
  44. #define RW_LOCK_UNLOCKED
  45. (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED,
  46. .magic = RWLOCK_MAGIC,
  47. .owner = SPINLOCK_OWNER_INIT,
  48. .owner_cpu = -1 }
  49. #else
  50. # define SPIN_LOCK_UNLOCKED 
  51. (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED }
  52. #define RW_LOCK_UNLOCKED 
  53. (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED }
  54. #endif
  55. #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
  56. #define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED
  57. #endif /* __LINUX_SPINLOCK_TYPES_H */