common.cpp revision 360784
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
12namespace scudo {
13
14uptr PageSizeCached;
15uptr getPageSize();
16
17uptr getPageSizeSlow() {
18  PageSizeCached = getPageSize();
19  CHECK_NE(PageSizeCached, 0);
20  return PageSizeCached;
21}
22
23// Fatal internal map() or unmap() error (potentially OOM related).
24void 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