xref: /freebsd/contrib/llvm-project/compiler-rt/lib/scudo/standalone/common.cpp (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
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 
9 #include "common.h"
10 #include "atomic_helpers.h"
11 
12 namespace scudo {
13 
14 uptr PageSizeCached;
15 uptr getPageSize();
16 
17 uptr getPageSizeSlow() {
18   PageSizeCached = getPageSize();
19   CHECK_NE(PageSizeCached, 0);
20   return PageSizeCached;
21 }
22 
23 // Fatal internal map() or unmap() error (potentially OOM related).
24 void NORETURN dieOnMapUnmapError(bool OutOfMemory) {
25   outputRaw("Scudo ERROR: internal map or unmap failure");
26   if (OutOfMemory)
27     outputRaw(" (OOM)");
28   outputRaw("\n");
29   die();
30 }
31 
32 } // namespace scudo
33