[AMDGPU] Infer amdgpu-no-flat-scratch-init attribute in AMDGPUAttributor (#94647)
[llvm-project.git] / compiler-rt / lib / scudo / standalone / common.cpp
blob80134c39e757de3dd4d2293231bc69b78fd9c6cb
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 //===----------------------------------------------------------------------===//
9 #include "common.h"
10 #include "atomic_helpers.h"
11 #include "string_utils.h"
13 namespace scudo {
15 #if !defined(SCUDO_PAGE_SIZE)
16 uptr PageSizeCached = 0;
17 uptr PageSizeLogCached = 0;
19 // Must be defined in platform specific code.
20 uptr getPageSize();
22 // This must be called in the init path or there could be a race if multiple
23 // threads try to set the cached values.
24 uptr getPageSizeSlow() {
25 PageSizeCached = getPageSize();
26 CHECK_NE(PageSizeCached, 0);
27 PageSizeLogCached = getLog2(PageSizeCached);
28 return PageSizeCached;
30 #endif
32 } // namespace scudo