Skip to content

Lock Validator Assertions

include/sync/lock_chk_assert.h View source View on GitHub

Assert that the current thread holds the lock. When DEBUG_LOCK_CHK is on and the lock is checked, this actually gets to use the provable engine. But otherwise, it falls back to a naive read of the lock word. RWLOCK needs RWLOCK_READ/RWLOCK_WRITE, which is why we have _1 and _2, so all locks regardless of type can funnel through this callsite

#define LOCK_CHK_ASSERT_HELD_1(l)
source
#define LOCK_CHK_ASSERT_HELD_2(l, mode)
source
Expansion
#define LOCK_CHK_ASSERT_HELD_2(l, mode) \
    cc_generic((l), struct rwlock * : rwlock_assert_held_full)( \
        (l), (mode), LOCK_CHK_SITE_HERE())
#define LOCK_CHK_ASSERT_HELD(...)
source
Expansion
#define LOCK_CHK_ASSERT_HELD(...) PP_CALL(LOCK_CHK_ASSERT_HELD, __VA_ARGS__)
#define LOCK_CHK_ASSERT_NOT_HELD(l)
source
#define LOCK_CHK_ASSERT_HELD_STATE(l, m)
source
Expansion
#define LOCK_CHK_ASSERT_HELD_STATE(l, m) \
    do { \
        if ((m) == LOCK_HELD) { \
            LOCK_CHK_ASSERT_HELD((l)); \
        } else if ((m) == LOCK_NOT_HELD) { \
            LOCK_CHK_ASSERT_NOT_HELD((l)); \
        } else { \
            unreachable("mode %d", (m)); \
        } \
    } while (0)