aboutsummaryrefslogtreecommitdiff
path: root/src/sync.h
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2022-04-20 16:49:33 +1000
committerAnthony Towns <aj@erisian.com.au>2022-05-12 02:25:56 +1000
commit436ce0233c276e263dcb441255dc0b881cb39cfb (patch)
tree5f406b00debd824d6e0334fe038c57bc6dfdfa16 /src/sync.h
parent7d73f58e9cea8f4b0bc16512983898fddde3d764 (diff)
downloadbitcoin-436ce0233c276e263dcb441255dc0b881cb39cfb.tar.xz
sync.h: strengthen AssertLockNotHeld assertion
Diffstat (limited to 'src/sync.h')
-rw-r--r--src/sync.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/sync.h b/src/sync.h
index c69b58741b..a175926113 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -83,8 +83,6 @@ void AssertLockNotHeldInternal(const char* pszName, const char* pszFile, int nLi
inline void DeleteLock(void* cs) {}
inline bool LockStackEmpty() { return true; }
#endif
-#define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs)
-#define AssertLockNotHeld(cs) AssertLockNotHeldInternal(#cs, __FILE__, __LINE__, &cs)
/**
* Template mixin that adds -Wthread-safety locking annotations and lock order
@@ -129,7 +127,13 @@ public:
using RecursiveMutex = AnnotatedMixin<std::recursive_mutex>;
/** Wrapped mutex: supports waiting but not recursive locking */
-typedef AnnotatedMixin<std::mutex> Mutex;
+using Mutex = AnnotatedMixin<std::mutex>;
+
+#define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs)
+
+inline void AssertLockNotHeldInline(const char* name, const char* file, int line, Mutex* cs) EXCLUSIVE_LOCKS_REQUIRED(!cs) { AssertLockNotHeldInternal(name, file, line, cs); }
+inline void AssertLockNotHeldInline(const char* name, const char* file, int line, RecursiveMutex* cs) LOCKS_EXCLUDED(cs) { AssertLockNotHeldInternal(name, file, line, cs); }
+#define AssertLockNotHeld(cs) AssertLockNotHeldInline(#cs, __FILE__, __LINE__, &cs)
/** Wrapper around std::unique_lock style lock for Mutex. */
template <typename Mutex, typename Base = typename Mutex::UniqueLock>