LockLocation.h 763 B

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