Skip to content

Commit c76ea76

Browse files
committed
UPDATE: assume for older gnu and clnag
Changes to be committed: - modified: inc/ae2f/cc.h
1 parent 5d92548 commit c76ea76

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

inc/ae2f/cc.h

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@
2222
#define N_ae2f_gnuc(a) a
2323
#endif
2424

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+
2542
/**
2643
* @def _ae2f_msvc
2744
* @brief Available when compiled with msvc.
@@ -58,7 +75,7 @@
5875
* @brief Keyword as `[[const]]` on C23..
5976
* */
6077
#undef ae2f_ccconst
61-
#if _ae2f_gnuc(!)0
78+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
6279
#define ae2f_ccconst __attribute__((const))
6380
#elif __ae2f_stdcheck_C(202300L) && ae2f_stdcc_v
6481
#define ae2f_ccconst [[const]]
@@ -71,7 +88,7 @@
7188
* @brief Keyword as `restrict` on C99.
7289
* */
7390
#undef ae2f_restrict
74-
#if _ae2f_gnuc(!)0
91+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
7592
#define ae2f_restrict __restrict
7693
#elif _ae2f_msvc(!)0
7794
#define ae2f_restrict __restrict
@@ -86,9 +103,9 @@
86103
* @brief The returning pointer does not alias to existing object.
87104
* */
88105
#undef ae2f_retnew
89-
#if _ae2f_msvc(1) +0
106+
#if _ae2f_msvc(!)0
90107
#define ae2f_retnew __declspec(restrict)
91-
#elif _ae2f_gnuc(!)0
108+
#elif _ae2f_gnuc(!)0 || _ae2f_clang(!)0
92109
#define ae2f_retnew __attribute__((malloc))
93110
#else
94111
#define ae2f_retnew
@@ -99,7 +116,7 @@
99116
* @brief Function declare for shared object
100117
* */
101118
#undef ae2f_decl
102-
#if _ae2f_msvc(1) +0
119+
#if _ae2f_msvc(!)0
103120
#define ae2f_decl __declspec(dllimport)
104121
#else
105122
#define ae2f_decl
@@ -110,7 +127,7 @@
110127
* @brief Function implementation for shared object
111128
* */
112129
#undef ae2f_impl
113-
#if _ae2f_gnuc(!)0
130+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
114131
#define ae2f_impl __attribute__((visibility("default")))
115132
#elif _ae2f_msvc(!)0
116133
#define ae2f_impl __declspec(dllexport)
@@ -123,7 +140,7 @@
123140
* @brief marker that this function does not throw something.
124141
* */
125142
#undef ae2f_noexcept
126-
#if _ae2f_gnuc(!)0
143+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
127144
#define ae2f_noexcept __attribute__((nothrow))
128145
#elif _ae2f_msvc(!)0
129146
#define ae2f_noexcept __declspec(nothrow)
@@ -139,7 +156,7 @@
139156
* @brief `inline`
140157
* */
141158
#undef ae2f_inline
142-
#if _ae2f_gnuc(!)0
159+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
143160
#define ae2f_inline __inline__
144161
#elif _ae2f_msvc(!)0
145162
#define ae2f_inline __inline
@@ -154,7 +171,7 @@
154171
* @brief explicitly tells compiler that fallthrough on switch is expected.
155172
* */
156173
#undef ae2f_fallthrough
157-
#if _ae2f_gnuc(!)0
174+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
158175
#define ae2f_fallthrough __attribute__((fallthrough))
159176
#elif _ae2f_msvc(!)0 && _MSC_VER >= 1934
160177
#define ae2f_fallthrough [[fallthrough]]
@@ -174,7 +191,7 @@
174191
* */
175192
#undef ae2f_expected
176193
#undef ae2f_expected_not
177-
#if _ae2f_gnuc(!)0
194+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
178195
#define ae2f_expected(a) (__builtin_expect(!!(a), 1))
179196
#define ae2f_expected_not(a) (__builtin_expect(!!(a), 0))
180197
#elif _ae2f_msvc(!)0 && defined(_MSVC_LANG) && _MSVC_LANG >= 202002L || ae2f_stdcc_v >= 202002L
@@ -205,7 +222,7 @@
205222
* @brief tells the compiler that below this keyword is not expected to be reached.
206223
* */
207224
#undef ae2f_unreachable
208-
#if _ae2f_gnuc(!)0
225+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
209226
#define ae2f_unreachable() __builtin_unreachable()
210227
#elif _ae2f_msvc(!)0
211228
#define ae2f_unreachable() __assume(0)
@@ -222,6 +239,8 @@
222239
#undef ae2f_assume
223240
#if _ae2f_gnuc(!)0 && (__GNUC__ >= 13)
224241
#define ae2f_assume(a) __attribute__((__assume__(a)))
242+
#elif _ae2f_gnuc(!)0 || _ae2f_clang(!)0
243+
#define ae2f_assume(a) __builtin_assume(a)
225244
#elif _ae2f_msvc(!)0
226245
#define ae2f_assume(a) __assume(a)
227246
#else
@@ -234,7 +253,7 @@
234253
* @see [[maybe_unused]]
235254
* */
236255
#ifndef ae2f_unused
237-
#if _ae2f_gnuc(!)0
256+
#if _ae2f_gnuc(!)0 || _ae2f_clang(!)0
238257
#define ae2f_unused __attribute__((unused))
239258
#elif ae2f_stdcc_v >= 201700L || ae2f_stdc_v >= 202300L
240259
#define ae2f_unused [[maybe_unused]]

0 commit comments

Comments
 (0)