Dynamic Tools Team | 517193e | 2019-09-11 14:48:41 +0000 | [diff] [blame] | 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" |
Kostya Kortchinsky | 4d022f5 | 2021-05-24 09:26:21 -0700 | [diff] [blame^] | 11 | #include "string_utils.h" |
Dynamic Tools Team | 517193e | 2019-09-11 14:48:41 +0000 | [diff] [blame] | 12 | |
| 13 | namespace scudo { |
| 14 | |
| 15 | uptr PageSizeCached; |
| 16 | uptr getPageSize(); |
| 17 | |
| 18 | uptr getPageSizeSlow() { |
| 19 | PageSizeCached = getPageSize(); |
| 20 | CHECK_NE(PageSizeCached, 0); |
| 21 | return PageSizeCached; |
| 22 | } |
| 23 | |
| 24 | // Fatal internal map() or unmap() error (potentially OOM related). |
Kostya Kortchinsky | 4d022f5 | 2021-05-24 09:26:21 -0700 | [diff] [blame^] | 25 | void NORETURN dieOnMapUnmapError(uptr SizeIfOOM) { |
| 26 | char Error[128] = "Scudo ERROR: internal map or unmap failure\n"; |
| 27 | if (SizeIfOOM) { |
| 28 | formatString( |
| 29 | Error, sizeof(Error), |
| 30 | "Scudo ERROR: internal map failure (NO MEMORY) requesting %zuKB\n", |
| 31 | SizeIfOOM >> 10); |
| 32 | } |
| 33 | outputRaw(Error); |
| 34 | setAbortMessage(Error); |
Dynamic Tools Team | 517193e | 2019-09-11 14:48:41 +0000 | [diff] [blame] | 35 | die(); |
| 36 | } |
| 37 | |
| 38 | } // namespace scudo |