]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-lockdebug.h
objc4-750.1.tar.gz
[apple/objc4.git] / runtime / objc-lockdebug.h
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
24 #if LOCKDEBUG
25 extern void lockdebug_assert_all_locks_locked();
26 extern void lockdebug_assert_no_locks_locked();
27 extern void lockdebug_setInForkPrepare(bool);
28 extern void lockdebug_lock_precedes_lock(const void *oldlock, const void *newlock);
29 #else
30 static constexpr inline void lockdebug_assert_all_locks_locked() { }
31 static constexpr inline void lockdebug_assert_no_locks_locked() { }
32 static constexpr inline void lockdebug_setInForkPrepare(bool) { }
33 static constexpr inline void lockdebug_lock_precedes_lock(const void *, const void *) { }
34 #endif
35
36 extern void lockdebug_remember_mutex(mutex_tt<true> *lock);
37 extern void lockdebug_mutex_lock(mutex_tt<true> *lock);
38 extern void lockdebug_mutex_try_lock(mutex_tt<true> *lock);
39 extern void lockdebug_mutex_unlock(mutex_tt<true> *lock);
40 extern void lockdebug_mutex_assert_locked(mutex_tt<true> *lock);
41 extern void lockdebug_mutex_assert_unlocked(mutex_tt<true> *lock);
42
43 static constexpr inline void lockdebug_remember_mutex(mutex_tt<false> *lock) { }
44 static constexpr inline void lockdebug_mutex_lock(mutex_tt<false> *lock) { }
45 static constexpr inline void lockdebug_mutex_try_lock(mutex_tt<false> *lock) { }
46 static constexpr inline void lockdebug_mutex_unlock(mutex_tt<false> *lock) { }
47 static constexpr inline void lockdebug_mutex_assert_locked(mutex_tt<false> *lock) { }
48 static constexpr inline void lockdebug_mutex_assert_unlocked(mutex_tt<false> *lock) { }
49
50
51 extern void lockdebug_remember_monitor(monitor_tt<true> *lock);
52 extern void lockdebug_monitor_enter(monitor_tt<true> *lock);
53 extern void lockdebug_monitor_leave(monitor_tt<true> *lock);
54 extern void lockdebug_monitor_wait(monitor_tt<true> *lock);
55 extern void lockdebug_monitor_assert_locked(monitor_tt<true> *lock);
56 extern void lockdebug_monitor_assert_unlocked(monitor_tt<true> *lock);
57
58 static constexpr inline void lockdebug_remember_monitor(monitor_tt<false> *lock) { }
59 static constexpr inline void lockdebug_monitor_enter(monitor_tt<false> *lock) { }
60 static constexpr inline void lockdebug_monitor_leave(monitor_tt<false> *lock) { }
61 static constexpr inline void lockdebug_monitor_wait(monitor_tt<false> *lock) { }
62 static constexpr inline void lockdebug_monitor_assert_locked(monitor_tt<false> *lock) { }
63 static constexpr inline void lockdebug_monitor_assert_unlocked(monitor_tt<false> *lock) {}
64
65
66 extern void
67 lockdebug_remember_recursive_mutex(recursive_mutex_tt<true> *lock);
68 extern void
69 lockdebug_recursive_mutex_lock(recursive_mutex_tt<true> *lock);
70 extern void
71 lockdebug_recursive_mutex_unlock(recursive_mutex_tt<true> *lock);
72 extern void
73 lockdebug_recursive_mutex_assert_locked(recursive_mutex_tt<true> *lock);
74 extern void
75 lockdebug_recursive_mutex_assert_unlocked(recursive_mutex_tt<true> *lock);
76
77 static constexpr inline void
78 lockdebug_remember_recursive_mutex(recursive_mutex_tt<false> *lock) { }
79 static constexpr inline void
80 lockdebug_recursive_mutex_lock(recursive_mutex_tt<false> *lock) { }
81 static constexpr inline void
82 lockdebug_recursive_mutex_unlock(recursive_mutex_tt<false> *lock) { }
83 static constexpr inline void
84 lockdebug_recursive_mutex_assert_locked(recursive_mutex_tt<false> *lock) { }
85 static constexpr inline void
86 lockdebug_recursive_mutex_assert_unlocked(recursive_mutex_tt<false> *lock) { }