Serenity Operating System
at master 36 lines 868 B view raw
1/* 2 * Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/StdLibExtras.h> 10#include <Kernel/Debug.h> 11#if LOCK_DEBUG 12# include <AK/SourceLocation.h> 13#endif 14 15// Abstract SourceLocation away from the kernel's locking API to avoid a 16// significant amount of #ifdefs in Mutex / MutexLocker / etc. 17// 18// To do this we declare LockLocation to be a zero sized struct which will 19// get optimized out during normal compilation. When LOCK_DEBUG is enabled, 20// we forward the implementation to AK::SourceLocation and get rich debugging 21// information for every caller. 22 23namespace Kernel { 24 25#if LOCK_DEBUG 26using LockLocation = SourceLocation; 27#else 28struct LockLocation { 29 static constexpr LockLocation current() { return {}; } 30 31private: 32 constexpr LockLocation() = default; 33}; 34#endif 35 36}