|
22 | 22 | #define N_ae2f_gnuc(a) a |
23 | 23 | #endif |
24 | 24 |
|
| 25 | +#ifndef _ae2f_clang |
| 26 | +#if defined(__clang__) |
| 27 | +#define _ae2f_clang(a) a |
| 28 | +#else |
| 29 | +#define _ae2f_clang(a) |
| 30 | +#endif |
| 31 | +#endif |
| 32 | + |
| 33 | +#ifndef N_ae2f_clang |
| 34 | +#if defined(__clang__) |
| 35 | +#define N_ae2f_clang(a) |
| 36 | +#else |
| 37 | +#define N_ae2f_clang(a) a |
| 38 | +#endif |
| 39 | +#endif |
| 40 | + |
| 41 | + |
25 | 42 | /** |
26 | 43 | * @def _ae2f_msvc |
27 | 44 | * @brief Available when compiled with msvc. |
|
58 | 75 | * @brief Keyword as `[[const]]` on C23.. |
59 | 76 | * */ |
60 | 77 | #undef ae2f_ccconst |
61 | | -#if _ae2f_gnuc(!)0 |
| 78 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
62 | 79 | #define ae2f_ccconst __attribute__((const)) |
63 | 80 | #elif __ae2f_stdcheck_C(202300L) && ae2f_stdcc_v |
64 | 81 | #define ae2f_ccconst [[const]] |
|
71 | 88 | * @brief Keyword as `restrict` on C99. |
72 | 89 | * */ |
73 | 90 | #undef ae2f_restrict |
74 | | -#if _ae2f_gnuc(!)0 |
| 91 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
75 | 92 | #define ae2f_restrict __restrict |
76 | 93 | #elif _ae2f_msvc(!)0 |
77 | 94 | #define ae2f_restrict __restrict |
|
86 | 103 | * @brief The returning pointer does not alias to existing object. |
87 | 104 | * */ |
88 | 105 | #undef ae2f_retnew |
89 | | -#if _ae2f_msvc(1) +0 |
| 106 | +#if _ae2f_msvc(!)0 |
90 | 107 | #define ae2f_retnew __declspec(restrict) |
91 | | -#elif _ae2f_gnuc(!)0 |
| 108 | +#elif _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
92 | 109 | #define ae2f_retnew __attribute__((malloc)) |
93 | 110 | #else |
94 | 111 | #define ae2f_retnew |
|
99 | 116 | * @brief Function declare for shared object |
100 | 117 | * */ |
101 | 118 | #undef ae2f_decl |
102 | | -#if _ae2f_msvc(1) +0 |
| 119 | +#if _ae2f_msvc(!)0 |
103 | 120 | #define ae2f_decl __declspec(dllimport) |
104 | 121 | #else |
105 | 122 | #define ae2f_decl |
|
110 | 127 | * @brief Function implementation for shared object |
111 | 128 | * */ |
112 | 129 | #undef ae2f_impl |
113 | | -#if _ae2f_gnuc(!)0 |
| 130 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
114 | 131 | #define ae2f_impl __attribute__((visibility("default"))) |
115 | 132 | #elif _ae2f_msvc(!)0 |
116 | 133 | #define ae2f_impl __declspec(dllexport) |
|
123 | 140 | * @brief marker that this function does not throw something. |
124 | 141 | * */ |
125 | 142 | #undef ae2f_noexcept |
126 | | -#if _ae2f_gnuc(!)0 |
| 143 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
127 | 144 | #define ae2f_noexcept __attribute__((nothrow)) |
128 | 145 | #elif _ae2f_msvc(!)0 |
129 | 146 | #define ae2f_noexcept __declspec(nothrow) |
|
139 | 156 | * @brief `inline` |
140 | 157 | * */ |
141 | 158 | #undef ae2f_inline |
142 | | -#if _ae2f_gnuc(!)0 |
| 159 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
143 | 160 | #define ae2f_inline __inline__ |
144 | 161 | #elif _ae2f_msvc(!)0 |
145 | 162 | #define ae2f_inline __inline |
|
154 | 171 | * @brief explicitly tells compiler that fallthrough on switch is expected. |
155 | 172 | * */ |
156 | 173 | #undef ae2f_fallthrough |
157 | | -#if _ae2f_gnuc(!)0 |
| 174 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
158 | 175 | #define ae2f_fallthrough __attribute__((fallthrough)) |
159 | 176 | #elif _ae2f_msvc(!)0 && _MSC_VER >= 1934 |
160 | 177 | #define ae2f_fallthrough [[fallthrough]] |
|
174 | 191 | * */ |
175 | 192 | #undef ae2f_expected |
176 | 193 | #undef ae2f_expected_not |
177 | | -#if _ae2f_gnuc(!)0 |
| 194 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
178 | 195 | #define ae2f_expected(a) (__builtin_expect(!!(a), 1)) |
179 | 196 | #define ae2f_expected_not(a) (__builtin_expect(!!(a), 0)) |
180 | 197 | #elif _ae2f_msvc(!)0 && defined(_MSVC_LANG) && _MSVC_LANG >= 202002L || ae2f_stdcc_v >= 202002L |
|
205 | 222 | * @brief tells the compiler that below this keyword is not expected to be reached. |
206 | 223 | * */ |
207 | 224 | #undef ae2f_unreachable |
208 | | -#if _ae2f_gnuc(!)0 |
| 225 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
209 | 226 | #define ae2f_unreachable() __builtin_unreachable() |
210 | 227 | #elif _ae2f_msvc(!)0 |
211 | 228 | #define ae2f_unreachable() __assume(0) |
|
222 | 239 | #undef ae2f_assume |
223 | 240 | #if _ae2f_gnuc(!)0 && (__GNUC__ >= 13) |
224 | 241 | #define ae2f_assume(a) __attribute__((__assume__(a))) |
| 242 | +#elif _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
| 243 | +#define ae2f_assume(a) __builtin_assume(a) |
225 | 244 | #elif _ae2f_msvc(!)0 |
226 | 245 | #define ae2f_assume(a) __assume(a) |
227 | 246 | #else |
|
234 | 253 | * @see [[maybe_unused]] |
235 | 254 | * */ |
236 | 255 | #ifndef ae2f_unused |
237 | | -#if _ae2f_gnuc(!)0 |
| 256 | +#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0 |
238 | 257 | #define ae2f_unused __attribute__((unused)) |
239 | 258 | #elif ae2f_stdcc_v >= 201700L || ae2f_stdc_v >= 202300L |
240 | 259 | #define ae2f_unused [[maybe_unused]] |
|
0 commit comments