mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57:35 +00:00
Kernel: Reduce LOCK_DEBUG ifdefs by utilizing Kernel::LockLocation
The LOCK_DEBUG conditional code is pretty ugly for a feature that we only use rarely. We can remove a significant amount of this code by utilizing a zero sized fake type when not building in LOCK_DEBUG mode. This lets us keep the same API, but just let the compiler optimize it away when don't actually care about the location the caller came from.
This commit is contained in:
parent
6c18b4e558
commit
bea74f4b77
4 changed files with 13 additions and 53 deletions
|
@ -4,22 +4,16 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#ifdef LOCK_DEBUG
|
||||
# include <AK/SourceLocation.h>
|
||||
#endif
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Locking/LockLocation.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
#include <Kernel/Locking/SpinLock.h>
|
||||
#include <Kernel/Thread.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
#if LOCK_DEBUG
|
||||
void Mutex::lock(Mode mode, const SourceLocation& location)
|
||||
#else
|
||||
void Mutex::lock(Mode mode)
|
||||
#endif
|
||||
void Mutex::lock(Mode mode, [[maybe_unused]] const LockLocation& location)
|
||||
{
|
||||
// NOTE: This may be called from an interrupt handler (not an IRQ handler)
|
||||
// and also from within critical sections!
|
||||
|
@ -318,11 +312,7 @@ auto Mutex::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
|
|||
return current_mode;
|
||||
}
|
||||
|
||||
#if LOCK_DEBUG
|
||||
void Mutex::restore_lock(Mode mode, u32 lock_count, const SourceLocation& location)
|
||||
#else
|
||||
void Mutex::restore_lock(Mode mode, u32 lock_count)
|
||||
#endif
|
||||
void Mutex::restore_lock(Mode mode, u32 lock_count, [[maybe_unused]] const LockLocation& location)
|
||||
{
|
||||
VERIFY(mode != Mode::Unlocked);
|
||||
VERIFY(lock_count > 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue