| // Copyright 2026 The Fuchsia Authors |
| // |
| // Use of this source code is governed by a MIT-style |
| // license that can be found in the LICENSE file or at |
| // https://opensource.org/licenses/MIT |
| |
| #include <stdint.h> |
| |
| #include <kernel/brwlock.h> |
| #include <kernel/mutex.h> |
| #include <kernel/spinlock.h> |
| #include <lockdep/lockdep.h> |
| |
| extern "C" { |
| |
| #if UNITTESTS_ENABLED |
| void ksync_tests_link_helper(); |
| #endif |
| |
| bool cpp_verify_mutex_id(const void* lock_ptr, const void* expected_id); |
| bool cpp_verify_critical_mutex_id(const void* lock_ptr, const void* expected_id); |
| bool cpp_verify_spinlock_id(const void* lock_ptr, const void* expected_id); |
| bool cpp_verify_brwlock_id(const void* lock_ptr, const void* expected_id); |
| |
| bool cpp_verify_mutex_id(const void* lock_ptr, const void* expected_id) { |
| #if UNITTESTS_ENABLED |
| ksync_tests_link_helper(); |
| #endif |
| const auto* lock = static_cast<const lockdep::Lock<Mutex>*>(lock_ptr); |
| return lock->id() == reinterpret_cast<lockdep::LockClassId>(expected_id); |
| } |
| |
| bool cpp_verify_critical_mutex_id(const void* lock_ptr, const void* expected_id) { |
| const auto* lock = static_cast<const lockdep::Lock<CriticalMutex>*>(lock_ptr); |
| return lock->id() == reinterpret_cast<lockdep::LockClassId>(expected_id); |
| } |
| |
| bool cpp_verify_spinlock_id(const void* lock_ptr, const void* expected_id) { |
| const auto* lock = static_cast<const lockdep::Lock<SpinLock>*>(lock_ptr); |
| return lock->id() == reinterpret_cast<lockdep::LockClassId>(expected_id); |
| } |
| |
| bool cpp_verify_brwlock_id(const void* lock_ptr, const void* expected_id) { |
| const auto* lock = static_cast<const lockdep::Lock<BrwLockPi>*>(lock_ptr); |
| return lock->id() == reinterpret_cast<lockdep::LockClassId>(expected_id); |
| } |
| |
| } // extern "C" |