Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
has_thread_safety_analysis.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_PLATFORM_QUERIES_HAS_THREAD_SAFETY_ANALYSIS_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_PLATFORM_QUERIES_HAS_THREAD_SAFETY_ANALYSIS_HPP_
7
8// IWYU pragma: private, include "arene/base/compiler_support/platform_queries.hpp"
9// IWYU pragma: friend "arene/base/compiler_support/platform_queries/.*"
10
11// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
12#include "arene/base/compiler_support/platform_queries/compiler_info.hpp"
13#include "arene/base/compiler_support/preprocessor.hpp"
14// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
15
16// NOLINTBEGIN(cppcoreguidelines-macro-usage) Explicitly providing compiler support macro functions
17// parasoft-begin-suppress AUTOSAR-A16_0_1-d-2 "Conditional defines permitted by A16-0-1 Permit #2"
18// parasoft-begin-suppress AUTOSAR-A16_0_1-a-2 "Conditional defines permitted by A16-0-1 Permit #2"
19
20/// @def ARENE_HAS_THREAD_SAFETY_ANALYSIS
21/// @brief A platform support query for testing if Thread Safety Analysis is supported on the current compiler.
22///
23/// Usage:
24/// @code{c++}
25/// #if ARENE_IS_ON(ARENE_HAS_THREAD_SAFETY_ANALYSIS)
26/// @endcode
27///
28/// The value of this query is determined as follows, in order of precedence:
29/// 1. If @c ARENE_HAS_THREAD_SAFETY_ANALYSIS has been explicitly defined via a @c -D flag to the compiler or
30/// similar:
31/// * @c ARENE_ON if it is truthy
32/// * @c ARENE_OFF if it is not truthy
33/// 1. If @c ARENE_IS_ON(ARENE_COMPILER_CLANG) is truthy, it is @c ARENE_ON_BY_DEFAULT
34/// 1. Otherwise, it is @c ARENE_OFF_BY_DEFAULT
35
36#if defined(ARENE_HAS_THREAD_SAFETY_ANALYSIS)
37#if (ARENE_HAS_THREAD_SAFETY_ANALYSIS != 0)
38#define ARENE_HAS_THREAD_SAFETY_ANALYSIS_I_ ARENE_ON
39#else
40#define ARENE_HAS_THREAD_SAFETY_ANALYSIS_I_ ARENE_OFF
41#endif
42#elif ARENE_IS_ON(ARENE_COMPILER_CLANG)
43#define ARENE_HAS_THREAD_SAFETY_ANALYSIS_I_ ARENE_ON_BY_DEFAULT
44#else
45#define ARENE_HAS_THREAD_SAFETY_ANALYSIS_I_ ARENE_OFF_BY_DEFAULT
46#endif
47
48#ifdef ARENE_DOC_GENERATION_RUNNING // make this appear when running doxygen, as it won't otherwise.
49#ifndef ARENE_HAS_THREAD_SAFETY_ANALYSIS
50#define ARENE_HAS_THREAD_SAFETY_ANALYSIS
51#endif
52#endif
53
54// NOLINTEND(cppcoreguidelines-macro-usage) Explicitly providing compiler support macro functions
55// parasoft-end-suppress AUTOSAR-A16_0_1-d-2
56// parasoft-end-suppress AUTOSAR-A16_0_1-a-2
57
58#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_PLATFORM_QUERIES_HAS_THREAD_SAFETY_ANALYSIS_HPP_