mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
Kernel: Introduce LockLocation abstraction from SourceLocation
Introduce a zero sized type to represent a SourceLocation, when we don't want to compile with SourceLocation support.
This commit is contained in:
parent
0a5312730c
commit
6c18b4e558
1 changed files with 31 additions and 0 deletions
31
Kernel/Locking/LockLocation.h
Normal file
31
Kernel/Locking/LockLocation.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if LOCK_DEBUG
|
||||
# include <AK/SourceLocation.h>
|
||||
#endif
|
||||
|
||||
// Abstract SourceLocation away from the kernel's locking API to avoid a
|
||||
// significant amount of #ifdefs in Mutex / MutexLocker / etc.
|
||||
//
|
||||
// To do this we declare LockLocation to be a zero sized struct which will
|
||||
// get optimized out during normal compilation. When LOCK_DEBUG is enabled,
|
||||
// we forward the implementation to AK::SourceLocation and get rich debugging
|
||||
// information for every caller.
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
#if LOCK_DEBUG
|
||||
using LockLocation = SourceLocation;
|
||||
#else
|
||||
struct LockLocation {
|
||||
static constexpr LockLocation current() { return {}; }
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue