tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
builtin_functions.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_CONFIG_BUILTIN_FUNCTIONS_HPP
4
#define TETL_CONFIG_BUILTIN_FUNCTIONS_HPP
5
6
#if __has_builtin(__builtin_COLUMN)
7
#define TETL_BUILTIN_COLUMN() __builtin_COLUMN()
8
#else
9
#define TETL_BUILTIN_COLUMN() 0
10
#endif
11
12
#if __has_builtin(__builtin_LINE)
13
#define TETL_BUILTIN_LINE() __builtin_LINE()
14
#else
15
#define TETL_BUILTIN_LINE() 0
16
#endif
17
18
#if __has_builtin(__builtin_FILE)
19
#define TETL_BUILTIN_FILE() __builtin_FILE()
20
#else
21
#define TETL_BUILTIN_FILE() __FILE__
22
#endif
23
24
#if __has_builtin(__builtin_FUNCTION)
25
#define TETL_BUILTIN_FUNCTION() __builtin_FUNCTION()
26
#else
27
#define TETL_BUILTIN_FUNCTION() ""
28
#endif
29
30
// UNREACHABLE
31
#if __has_builtin(__builtin_unreachable)
32
#define TETL_BUILTIN_UNREACHABLE __builtin_unreachable()
33
#elif defined(TETL_COMPILER_MSVC)
34
#define TETL_BUILTIN_UNREACHABLE __assume(false)
35
#else
36
// https://stackoverflow.com/questions/6031819/emulating-gccs-builtin-unreachable
37
// Answer from user iammilind.
38
#define TETL_BUILTIN_UNREACHABLE \
39
{ \
40
struct etl_builtin_unreachable_t { \
41
etl_builtin_unreachable_t& operator=(etl_builtin_unreachable_t const&); \
42
} x; \
43
x = x; \
44
}
45
#endif
46
47
// NAN
48
#if __has_builtin(__builtin_nanf) or defined(TETL_COMPILER_MSVC) or defined(TETL_COMPILER_GCC)
49
#define TETL_BUILTIN_NANF(arg) (__builtin_nanf(arg))
50
#else
51
#define TETL_BUILTIN_NANF(arg) (0.0F / 0.0F)
52
#endif
53
54
#if __has_builtin(__builtin_nan) or defined(TETL_COMPILER_MSVC) or defined(TETL_COMPILER_GCC)
55
#define TETL_BUILTIN_NAN(arg) (__builtin_nan(arg))
56
#else
57
#define TETL_BUILTIN_NAN (0.0 / 0.0)
58
#endif
59
60
#if __has_builtin(__builtin_nanl) or defined(TETL_COMPILER_GCC)
61
#define TETL_BUILTIN_NANL(arg) (__builtin_nanl(arg))
62
#elif defined(TETL_COMPILER_MSVC)
63
#define TETL_BUILTIN_NANL(arg) (__builtin_nan(arg))
64
#else
65
#define TETL_BUILTIN_NANL(arg) (0.0L / 0.0L)
66
#endif
67
68
// SIGNALING NAN
69
#if __has_builtin(__builtin_nansf) or defined(TETL_COMPILER_MSVC) or defined(TETL_COMPILER_GCC)
70
#define TETL_BUILTIN_NANSF(arg) (__builtin_nansf(arg))
71
#else
72
#define TETL_BUILTIN_NANSF(arg) (0.0F / 0.0F)
73
#endif
74
75
#if __has_builtin(__builtin_nans) or defined(TETL_COMPILER_MSVC) or defined(TETL_COMPILER_GCC)
76
#define TETL_BUILTIN_NANS(arg) (__builtin_nans(arg))
77
#else
78
#define TETL_BUILTIN_NANS(arg) (0.0 / 0.0)
79
#endif
80
81
#if __has_builtin(__builtin_nansl) or defined(TETL_COMPILER_GCC)
82
#define TETL_BUILTIN_NANSL(arg) (__builtin_nansl(arg))
83
#elif defined(TETL_COMPILER_MSVC)
84
#define TETL_BUILTIN_NANSL(arg) (__builtin_nans(arg))
85
#else
86
#define TETL_BUILTIN_NANSL(arg) (0.0L / 0.0L)
87
#endif
88
89
// HUGE VAL
90
#if __has_builtin(__builtin_huge_valf) or defined(TETL_COMPILER_MSVC) or defined(TETL_COMPILER_GCC)
91
#define TETL_BUILTIN_HUGE_VALF (__builtin_huge_valf())
92
#else
93
#define TETL_BUILTIN_HUGE_VALF (1.0F / 0.0F)
94
#endif
95
96
#if __has_builtin(__builtin_huge_val) or defined(TETL_COMPILER_MSVC) or defined(TETL_COMPILER_GCC)
97
#define TETL_BUILTIN_HUGE_VAL (__builtin_huge_val())
98
#else
99
#define TETL_BUILTIN_HUGE_VAL (1.0 / 0.0)
100
#endif
101
102
#if __has_builtin(__builtin_huge_vall) or defined(TETL_COMPILER_GCC)
103
#define TETL_BUILTIN_HUGE_VALL (__builtin_huge_vall())
104
#elif defined(TETL_COMPILER_MSVC)
105
#define TETL_BUILTIN_HUGE_VALL (__builtin_huge_val())
106
#else
107
#define TETL_BUILTIN_HUGE_VALL (1.0L / 0.0L)
108
#endif
109
110
#if defined(TETL_COMPILER_CLANG) or defined(TETL_COMPILER_MSVC)
111
#define TETL_BUILTIN_INT_SEQ(T, N) __make_integer_seq<integer_sequence, T, N>
112
#else
113
#define TETL_BUILTIN_INT_SEQ(T, N) integer_sequence<T, __integer_pack(N)...>
114
#endif
115
116
#endif
// TETL_CONFIG_BUILTIN_FUNCTIONS_HPP
include
etl
_config
builtin_functions.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0