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#include "string_utils.h"
12
13namespace scudo {
14
15#if !defined(SCUDO_PAGE_SIZE)
16uptr PageSizeCached = 0;
17uptr PageSizeLogCached = 0;
18
19// This must be called in the init path or there could be a race if multiple
20// threads try to set the cached values.
21uptr getPageSizeSlow() {
22 PageSizeCached = getPageSize();
23 CHECK_NE(PageSizeCached, 0);
24 PageSizeLogCached = getLog2(X: PageSizeCached);
25 return PageSizeCached;
26}
27#endif
28
29} // namespace scudo
30