summaryrefslogtreecommitdiff
path: root/Kernel/Locking/LockLocation.h
blob: a0fcf7d9a16340c15942d8500a6140daf060b8b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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

}