Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
cache_line.hpp
Go to the documentation of this file.
1// Copyright 2024, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_HARDWARE_QUERIES_CACHE_LINE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_HARDWARE_QUERIES_CACHE_LINE_HPP_
7
8// IWYU pragma: private, include "arene/base/compiler_support/hardware_queries.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
12#include "arene/base/stdlib_choice/cstddef.hpp"
13
14// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
15// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
16
17// To respect AUTOSAR C++14 constraints on C++ preprocessor usage A16-0-1
18// We do use preprocessor only to conditionally include a file
19
20#if (defined(__arm__) && defined(__ARM_ARCH_5T__))
21
22#include "arene/base/compiler_support/hardware_queries/detail/cache_line_impl_32.hpp" // IWYU pragma: export
23
24#else
25// Default value to 64 bytes
26// Should be a good fit most of the cases (x86_64, x86, aarch64)
27
28#include "arene/base/compiler_support/hardware_queries/detail/cache_line_impl_64.hpp" // IWYU pragma: export
29
30#endif
31
32namespace arene {
33namespace base {
34
35/// @brief The minimum memory spacing required between two items to avoid false-sharing
36///
37/// Backport of C++17's
38/// [std::hardware_destructive_interference_size](https://en.cppreference.com/w/cpp/thread/hardware_destructive_interference_size).
39/// See [P0154R0](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0154r0.html) for more details
41 compiler_support::detail::l1_cache_line_size
42};
43
44} // namespace base
45} // namespace arene
46
47#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_HARDWARE_QUERIES_CACHE_LINE_HPP_
#define ARENE_MAYBE_UNUSED
An alias for [[maybe_unused]] , or a no-op if the attribute is not supported.
Definition maybe_unused.hpp:25
Definition accumulate.hpp:37
ARENE_MAYBE_UNUSED constexpr std::size_t hardware_destructive_interference_size
The minimum memory spacing required between two items to avoid false-sharing.
Definition cache_line.hpp:40
Definition accumulate.hpp:36
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29