common.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //===-- common.cpp ----------------------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "common.h"
  9. #include "atomic_helpers.h"
  10. #include "string_utils.h"
  11. namespace scudo {
  12. uptr PageSizeCached;
  13. uptr getPageSize();
  14. uptr getPageSizeSlow() {
  15. PageSizeCached = getPageSize();
  16. CHECK_NE(PageSizeCached, 0);
  17. return PageSizeCached;
  18. }
  19. // Fatal internal map() or unmap() error (potentially OOM related).
  20. void NORETURN dieOnMapUnmapError(uptr SizeIfOOM) {
  21. char Error[128] = "Scudo ERROR: internal map or unmap failure\n";
  22. if (SizeIfOOM) {
  23. formatString(
  24. Error, sizeof(Error),
  25. "Scudo ERROR: internal map failure (NO MEMORY) requesting %zuKB\n",
  26. SizeIfOOM >> 10);
  27. }
  28. outputRaw(Error);
  29. setAbortMessage(Error);
  30. die();
  31. }
  32. #if !SCUDO_LINUX
  33. uptr GetRSS() { return 0; }
  34. #endif
  35. } // namespace scudo