tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
attributes.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_CONFIG_ATTRIBUTES_HPP
5#define TETL_CONFIG_ATTRIBUTES_HPP
6
7#if __has_attribute(always_inline)
8 #define TETL_ALWAYS_INLINE [[gnu::always_inline]]
9#elif defined(_MSC_VER)
10 #define TETL_ALWAYS_INLINE [[msvc::forceinline]]
11#else
12 #define TETL_ALWAYS_INLINE
13#endif
14
15#if __has_attribute(noinline)
16 #define TETL_NO_INLINE [[gnu::noinline]]
17#elif defined(_MSC_VER)
18 #define TETL_NO_INLINE [[msvc::noinline]]
19#else
20 #define TETL_NO_INLINE
21#endif
22
23#if __has_attribute(cold)
24 #define TETL_COLD [[gnu::cold]]
25#else
26 #define TETL_COLD
27#endif
28
29#if defined(__GNUC__) or defined(__clang__)
30 #define TETL_MAY_ALIAS [[gnu::may_alias]]
31#else
32 #define TETL_MAY_ALIAS
33#endif
34
35#if defined(_MSC_VER) and not defined(__clang__)
36 #define TETL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
37#elif defined(_MSC_VER) and defined(__clang__) and (__clang_major__ >= 18)
38 #define TETL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
39#elif defined(_MSC_VER) and defined(__clang__)
40 #define TETL_NO_UNIQUE_ADDRESS
41#else
42 #define TETL_NO_UNIQUE_ADDRESS [[no_unique_address]]
43#endif
44
45#if defined(__clang__)
46 #define TETL_TRIVIAL_ABI [[clang::trivial_abi]]
47#else
48 #define TETL_TRIVIAL_ABI
49#endif
50
51#if defined(__clang__)
52 #define TETL_NO_UNROLL _Pragma("nounroll")
53#elif defined(__GNUC__)
54 // TODO: _Pragma("GCC unroll 0") should work, but causes 'error: ignoring loop annotation'
55 // when used in class templates
56 #define TETL_NO_UNROLL /*_Pragma("GCC unroll 0")*/
57#else
58 #define TETL_NO_UNROLL
59#endif
60
61#endif // TETL_CONFIG_ATTRIBUTES_HPP