objc-lockdebug.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2015 Apple Inc. All Rights Reserved.
  3. *
  4. * @APPLE_LICENSE_HEADER_START@
  5. *
  6. * This file contains Original Code and/or Modifications of Original Code
  7. * as defined in and that are subject to the Apple Public Source License
  8. * Version 2.0 (the 'License'). You may not use this file except in
  9. * compliance with the License. Please obtain a copy of the License at
  10. * http://www.opensource.apple.com/apsl/ and read it before using this
  11. * file.
  12. *
  13. * The Original Code and all software distributed under the License are
  14. * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  15. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  16. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  18. * Please see the License for the specific language governing rights and
  19. * limitations under the License.
  20. *
  21. * @APPLE_LICENSE_HEADER_END@
  22. */
  23. #if LOCKDEBUG
  24. extern void lockdebug_assert_all_locks_locked();
  25. extern void lockdebug_assert_no_locks_locked();
  26. extern void lockdebug_setInForkPrepare(bool);
  27. extern void lockdebug_lock_precedes_lock(const void *oldlock, const void *newlock);
  28. #else
  29. static constexpr inline void lockdebug_assert_all_locks_locked() { }
  30. static constexpr inline void lockdebug_assert_no_locks_locked() { }
  31. static constexpr inline void lockdebug_setInForkPrepare(bool) { }
  32. static constexpr inline void lockdebug_lock_precedes_lock(const void *, const void *) { }
  33. #endif
  34. extern void lockdebug_remember_mutex(mutex_tt<true> *lock);
  35. extern void lockdebug_mutex_lock(mutex_tt<true> *lock);
  36. extern void lockdebug_mutex_try_lock(mutex_tt<true> *lock);
  37. extern void lockdebug_mutex_unlock(mutex_tt<true> *lock);
  38. extern void lockdebug_mutex_assert_locked(mutex_tt<true> *lock);
  39. extern void lockdebug_mutex_assert_unlocked(mutex_tt<true> *lock);
  40. static constexpr inline void lockdebug_remember_mutex(mutex_tt<false> *lock) { }
  41. static constexpr inline void lockdebug_mutex_lock(mutex_tt<false> *lock) { }
  42. static constexpr inline void lockdebug_mutex_try_lock(mutex_tt<false> *lock) { }
  43. static constexpr inline void lockdebug_mutex_unlock(mutex_tt<false> *lock) { }
  44. static constexpr inline void lockdebug_mutex_assert_locked(mutex_tt<false> *lock) { }
  45. static constexpr inline void lockdebug_mutex_assert_unlocked(mutex_tt<false> *lock) { }
  46. extern void lockdebug_remember_monitor(monitor_tt<true> *lock);
  47. extern void lockdebug_monitor_enter(monitor_tt<true> *lock);
  48. extern void lockdebug_monitor_leave(monitor_tt<true> *lock);
  49. extern void lockdebug_monitor_wait(monitor_tt<true> *lock);
  50. extern void lockdebug_monitor_assert_locked(monitor_tt<true> *lock);
  51. extern void lockdebug_monitor_assert_unlocked(monitor_tt<true> *lock);
  52. static constexpr inline void lockdebug_remember_monitor(monitor_tt<false> *lock) { }
  53. static constexpr inline void lockdebug_monitor_enter(monitor_tt<false> *lock) { }
  54. static constexpr inline void lockdebug_monitor_leave(monitor_tt<false> *lock) { }
  55. static constexpr inline void lockdebug_monitor_wait(monitor_tt<false> *lock) { }
  56. static constexpr inline void lockdebug_monitor_assert_locked(monitor_tt<false> *lock) { }
  57. static constexpr inline void lockdebug_monitor_assert_unlocked(monitor_tt<false> *lock) {}
  58. extern void
  59. lockdebug_remember_recursive_mutex(recursive_mutex_tt<true> *lock);
  60. extern void
  61. lockdebug_recursive_mutex_lock(recursive_mutex_tt<true> *lock);
  62. extern void
  63. lockdebug_recursive_mutex_unlock(recursive_mutex_tt<true> *lock);
  64. extern void
  65. lockdebug_recursive_mutex_assert_locked(recursive_mutex_tt<true> *lock);
  66. extern void
  67. lockdebug_recursive_mutex_assert_unlocked(recursive_mutex_tt<true> *lock);
  68. static constexpr inline void
  69. lockdebug_remember_recursive_mutex(recursive_mutex_tt<false> *lock) { }
  70. static constexpr inline void
  71. lockdebug_recursive_mutex_lock(recursive_mutex_tt<false> *lock) { }
  72. static constexpr inline void
  73. lockdebug_recursive_mutex_unlock(recursive_mutex_tt<false> *lock) { }
  74. static constexpr inline void
  75. lockdebug_recursive_mutex_assert_locked(recursive_mutex_tt<false> *lock) { }
  76. static constexpr inline void
  77. lockdebug_recursive_mutex_assert_unlocked(recursive_mutex_tt<false> *lock) { }