Skip to content

spinlock

include/sync/spinlock.h View source View on GitHub
struct spinlock {
    struct raw_spinlock  raw;
};
void spinlock_init_chk_internal(struct spinlock *lock, const struct lock_chk_class *class, enum lock_chk_flags flags);
void spinlock_policy_init_internal(struct spinlock *lock, enum lock_chk_flags flags);
void spinlock_shallow_init_internal(struct spinlock *lock);
void spinlock_map_init_internal(struct spinlock *lock, const struct lock_chk_class *class, enum lock_chk_flags flags);
void spinlock_note_use(struct spinlock *lock, bool raw_operation);
bool spinlock_order_checked(struct spinlock *lock);
void spinlock_classify(struct spinlock *lock, enum lock_debug_irq_usage usage, const struct lock_chk_site *site);
bool spinlock_deep_checked(struct spinlock *lock);
struct lock_chk_acquire_request spinlock_chk_acquire_request(struct spinlock *lock, const struct lock_chk_site *site, enum lock_chk_wait_kind wait_kind, uint8_t subclass, bool raw_operation, bool irq_safe);
struct lock_chk_release_request spinlock_chk_release_request(struct spinlock *lock, const struct lock_chk_site *site);
void spinlock_policy_init_internal(struct spinlock *lock, enum lock_chk_flags flags);
void spinlock_shallow_init_internal(struct spinlock *lock);
void spinlock_map_init_internal(struct spinlock *lock, const struct lock_chk_class *class, enum lock_chk_flags flags);
void spinlock_note_use(struct spinlock *lock, bool raw_operation);
bool spinlock_order_checked(struct spinlock *lock);
void spinlock_classify(struct spinlock *lock, enum lock_debug_irq_usage usage, const struct lock_chk_site *site);
bool spinlock_deep_checked(struct spinlock *lock);
bool spin_trylock_physical(struct spinlock *lock);
void spin_lock_physical(struct spinlock *lock);
void spin_unlock_physical(struct spinlock *lock);
void spinlock_init_chk_internal(struct spinlock *lock, const struct lock_chk_class *class, enum lock_chk_flags flags);
void spinlock_restore_interrupts(bool enabled);
bool spin_trylock_raw_internal(struct spinlock *lock, const struct lock_chk_site *site);
void spin_lock_raw_internal(struct spinlock *lock, const struct lock_chk_site *site);
void spin_unlock_raw_internal(struct spinlock *lock, const struct lock_chk_site *site);
void spin_unlock_internal(struct spinlock *lock, enum irql old, const struct lock_chk_site *site);
enum irql spin_lock_subclass_internal(struct spinlock *lock, uint8_t subclass, const struct lock_chk_site *site);
enum irql spin_lock_internal(struct spinlock *lock, const struct lock_chk_site *site);
enum irql spin_lock_irq_disable_internal(struct spinlock *lock, const struct lock_chk_site *site);
bool spin_trylock_internal(struct spinlock *lock, enum irql *out, const struct lock_chk_site *site);
bool spin_trylock_irq_disable_internal(struct spinlock *lock, enum irql *out, const struct lock_chk_site *site);
bool spinlock_locked(struct spinlock *lock);
void spinlock_set_chk_flags(struct spinlock *lock, enum lock_chk_flags flags);
void spinlock_reinit_chk(struct spinlock *lock, const struct lock_chk_class *class, enum lock_chk_flags flags);
void spinlock_assert_held_internal(struct spinlock *lock, const struct lock_chk_site *site);
void spinlock_assert_not_held_internal(struct spinlock *lock, const struct lock_chk_site *site);
#define SPINLOCK_INIT SPINLOCK_INIT_CHK(NULL, LOCK_CHKD_FULL)
#define SPINLOCK_DEFINE(id) struct spinlock id = SPINLOCK_INIT
#define SPINLOCK_DEFINE_CHK(id, class_, flags_) \
    struct spinlock id = SPINLOCK_INIT_CHK((class_), (flags_))
#define spinlock_init_1(lock_) \
    spinlock_init_auto_internal((lock_), LOCK_CHKD_FULL)
#define spinlock_init_2(lock_, flags_) \
    spinlock_init_auto_internal((lock_), (flags_))
#define spinlock_init(...) \
    _DISPATCH(spinlock_init, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
#define __SPINLOCK_SHALLOW_VALUE_INIT \
    , .irq_usage = ATOMIC_VAR_INIT(LOCK_DEBUG_IRQ_NONE)
#define __SPINLOCK_LOCK_CHK_VALUE_INIT(class_, flags_) \
    , .chk = LOCK_CHK_LOCK_VALUE_INIT((class_), (flags_))
#define SPINLOCK_INIT_CHK(class_, flags_) \
    ((struct spinlock) { \
        .raw = RAW_SPINLOCK_INIT __SPINLOCK_LOCK_CHK_VALUE_INIT( \
            (class_), (flags_)) __SPINLOCK_SHALLOW_VALUE_INIT})
#define spinlock_init_chk(lock_, class_, flags_) \
    spinlock_init_chk_internal((lock_), (class_), (flags_))
#define spinlock_init_auto_internal(lock_, flags_) \
    do { \
        static const struct lock_chk_class __auto_class = { \
            .name = #lock_, \
            .file = __RELFILE__, \
            .line = __LINE__, \
        }; \
        spinlock_init_chk_internal((lock_), &__auto_class, (flags_)); \
    } while (0)
#define __SPINLOCK_SHALLOW_VALUE_INIT
#define __SPINLOCK_LOCK_CHK_VALUE_INIT(class_, flags_)
#define SPINLOCK_INIT_CHK(class_, flags_) \
    ((struct spinlock) {.raw = RAW_SPINLOCK_INIT})
#define spinlock_init_chk(lock_, class_, flags_) \
    spinlock_init_chk_internal((lock_), NULL, LOCK_UNCHKD)
#define spinlock_init_auto_internal(lock_, flags_) \
    spinlock_init_chk_internal((lock_), NULL, LOCK_UNCHKD)
#define spin_lock(lock_) spin_lock_internal((lock_), LOCK_CHK_SITE_HERE())
#define spin_lock_subclass(lock_, subclass_) \
    spin_lock_subclass_internal((lock_), (subclass_), LOCK_CHK_SITE_HERE())
#define spin_lock_irq_disable(lock_) \
    spin_lock_irq_disable_internal((lock_), LOCK_CHK_SITE_HERE())
#define spin_trylock(lock_, out_) \
    spin_trylock_internal((lock_), (out_), LOCK_CHK_SITE_HERE())
#define spin_trylock_irq_disable(lock_, out_) \
    spin_trylock_irq_disable_internal((lock_), (out_), LOCK_CHK_SITE_HERE())
#define spin_unlock(lock_, old_) \
    spin_unlock_internal((lock_), (old_), LOCK_CHK_SITE_HERE())
#define spin_lock_raw(lock_) \
    spin_lock_raw_internal((lock_), LOCK_CHK_SITE_HERE())
#define spin_trylock_raw(lock_) \
    spin_trylock_raw_internal((lock_), LOCK_CHK_SITE_HERE())
#define spin_unlock_raw(lock_) \
    spin_unlock_raw_internal((lock_), LOCK_CHK_SITE_HERE())
#define SPINLOCK_ASSERT_LOCKED(l) \
    kassert(spinlock_locked(l), "spinlock not locked")
#define SPINLOCK_ASSERT_HELD(l) \
    spinlock_assert_held_internal((l), LOCK_CHK_SITE_HERE())
#define SPINLOCK_ASSERT_NOT_HELD(l) \
    spinlock_assert_not_held_internal((l), LOCK_CHK_SITE_HERE())