spinlock_api_up.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef __LINUX_SPINLOCK_API_UP_H
  2. #define __LINUX_SPINLOCK_API_UP_H
  3. #ifndef __LINUX_SPINLOCK_H
  4. # error "please don't include this file directly"
  5. #endif
  6. /*
  7. * include/linux/spinlock_api_up.h
  8. *
  9. * spinlock API implementation on UP-nondebug (inlined implementation)
  10. *
  11. * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
  12. * Released under the General Public License (GPL).
  13. */
  14. #define in_lock_functions(ADDR) 0
  15. #define assert_raw_spin_locked(lock) do { (void)(lock); } while (0)
  16. /*
  17. * In the UP-nondebug case there's no real locking going on, so the
  18. * only thing we have to do is to keep the preempt counts and irq
  19. * flags straight, to suppress compiler warnings of unused lock
  20. * variables, and to add the proper checker annotations:
  21. */
  22. #define ___LOCK(lock) \
  23. do { __acquire(lock); (void)(lock); } while (0)
  24. #define __LOCK(lock) \
  25. do { preempt_disable(); ___LOCK(lock); } while (0)
  26. #define __LOCK_BH(lock) \
  27. do { __local_bh_disable_ip(_THIS_IP_, SOFTIRQ_LOCK_OFFSET); ___LOCK(lock); } while (0)
  28. #define __LOCK_IRQ(lock) \
  29. do { local_irq_disable(); __LOCK(lock); } while (0)
  30. #define __LOCK_IRQSAVE(lock, flags) \
  31. do { local_irq_save(flags); __LOCK(lock); } while (0)
  32. #define ___UNLOCK(lock) \
  33. do { __release(lock); (void)(lock); } while (0)
  34. #define __UNLOCK(lock) \
  35. do { preempt_enable(); ___UNLOCK(lock); } while (0)
  36. #define __UNLOCK_BH(lock) \
  37. do { __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_LOCK_OFFSET); \
  38. ___UNLOCK(lock); } while (0)
  39. #define __UNLOCK_IRQ(lock) \
  40. do { local_irq_enable(); __UNLOCK(lock); } while (0)
  41. #define __UNLOCK_IRQRESTORE(lock, flags) \
  42. do { local_irq_restore(flags); __UNLOCK(lock); } while (0)
  43. #define _raw_spin_lock(lock) __LOCK(lock)
  44. #define _raw_spin_lock_nested(lock, subclass) __LOCK(lock)
  45. #define _raw_spin_lock_bh_nested(lock, subclass) __LOCK(lock)
  46. #define _raw_read_lock(lock) __LOCK(lock)
  47. #define _raw_write_lock(lock) __LOCK(lock)
  48. #define _raw_spin_lock_bh(lock) __LOCK_BH(lock)
  49. #define _raw_read_lock_bh(lock) __LOCK_BH(lock)
  50. #define _raw_write_lock_bh(lock) __LOCK_BH(lock)
  51. #define _raw_spin_lock_irq(lock) __LOCK_IRQ(lock)
  52. #define _raw_read_lock_irq(lock) __LOCK_IRQ(lock)
  53. #define _raw_write_lock_irq(lock) __LOCK_IRQ(lock)
  54. #define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
  55. #define _raw_read_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
  56. #define _raw_write_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
  57. #define _raw_spin_trylock(lock) ({ __LOCK(lock); 1; })
  58. #define _raw_read_trylock(lock) ({ __LOCK(lock); 1; })
  59. #define _raw_write_trylock(lock) ({ __LOCK(lock); 1; })
  60. #define _raw_spin_trylock_bh(lock) ({ __LOCK_BH(lock); 1; })
  61. #define _raw_spin_unlock(lock) __UNLOCK(lock)
  62. #define _raw_read_unlock(lock) __UNLOCK(lock)
  63. #define _raw_write_unlock(lock) __UNLOCK(lock)
  64. #define _raw_spin_unlock_bh(lock) __UNLOCK_BH(lock)
  65. #define _raw_write_unlock_bh(lock) __UNLOCK_BH(lock)
  66. #define _raw_read_unlock_bh(lock) __UNLOCK_BH(lock)
  67. #define _raw_spin_unlock_irq(lock) __UNLOCK_IRQ(lock)
  68. #define _raw_read_unlock_irq(lock) __UNLOCK_IRQ(lock)
  69. #define _raw_write_unlock_irq(lock) __UNLOCK_IRQ(lock)
  70. #define _raw_spin_unlock_irqrestore(lock, flags) \
  71. __UNLOCK_IRQRESTORE(lock, flags)
  72. #define _raw_read_unlock_irqrestore(lock, flags) \
  73. __UNLOCK_IRQRESTORE(lock, flags)
  74. #define _raw_write_unlock_irqrestore(lock, flags) \
  75. __UNLOCK_IRQRESTORE(lock, flags)
  76. #endif /* __LINUX_SPINLOCK_API_UP_H */