|
18 | 18 | // ----------------------------------------------------------------------------- |
19 | 19 |
|
20 | 20 | // GCC version check |
21 | | -#if !defined(__clang__) && !defined(_MSC_VER) && defined(__GNUC__) && __GNUC__ < 7 |
22 | | -#error "You're trying to build ExecuTorch with a too old version of GCC. We need GCC 7 or later." |
| 21 | +#if !defined(__clang__) && !defined(_MSC_VER) && defined(__GNUC__) && \ |
| 22 | + __GNUC__ < 7 |
| 23 | +#error \ |
| 24 | + "You're trying to build ExecuTorch with a too old version of GCC. We need GCC 7 or later." |
23 | 25 | #endif |
24 | 26 |
|
25 | 27 | // Clang version check |
26 | 28 | #if defined(__clang__) && __clang_major__ < 5 |
27 | | -#error "You're trying to build ExecuTorch with a too old version of Clang. We need Clang 5 or later." |
| 29 | +#error \ |
| 30 | + "You're trying to build ExecuTorch with a too old version of Clang. We need Clang 5 or later." |
28 | 31 | #endif |
29 | 32 |
|
30 | 33 | // C++17 check |
|
35 | 38 |
|
36 | 39 | // Windows min/max macro clash |
37 | 40 | #if defined(_MSC_VER) && (defined(min) || defined(max)) |
38 | | -#error "Macro clash with min and max -- define NOMINMAX when compiling your program on Windows" |
| 41 | +#error \ |
| 42 | + "Macro clash with min and max -- define NOMINMAX when compiling your program on Windows" |
39 | 43 | #endif |
40 | 44 |
|
41 | 45 | // ----------------------------------------------------------------------------- |
|
47 | 51 |
|
48 | 52 | // [[deprecated]] |
49 | 53 | #define ET_DEPRECATED [[deprecated]] |
50 | | -#define ET_EXPERIMENTAL [[deprecated("This API is experimental and may change without notice.")]] |
| 54 | +#define ET_EXPERIMENTAL \ |
| 55 | + [[deprecated("This API is experimental and may change without notice.")]] |
51 | 56 |
|
52 | 57 | // [[fallthrough]] |
53 | 58 | #if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 7) |
|
67 | 72 | #define ET_NOINLINE __declspec(noinline) |
68 | 73 | #define ET_INLINE __forceinline |
69 | 74 | #define ET_INLINE_ATTRIBUTE __forceinline |
70 | | -#elif defined(__GNUC__) || defined(__clang__) |
| 75 | +#else |
71 | 76 | #define ET_NOINLINE __attribute__((noinline)) |
72 | 77 | #define ET_INLINE __attribute__((always_inline)) inline |
73 | 78 | #define ET_INLINE_ATTRIBUTE __attribute__((always_inline)) |
74 | | -#else |
75 | | -#define ET_NOINLINE |
76 | | -#define ET_INLINE inline |
77 | | -#define ET_INLINE_ATTRIBUTE |
78 | 79 | #endif |
79 | 80 |
|
80 | 81 | // Unreachable |
81 | | -#if defined(__GNUC__) || defined(__clang__) |
82 | | -#define ET_UNREACHABLE() __builtin_unreachable() |
83 | | -#elif defined(_MSC_VER) |
| 82 | +#if defined(_MSC_VER) |
84 | 83 | #define ET_UNREACHABLE() __assume(0) |
85 | 84 | #else |
86 | | -#define ET_UNREACHABLE() do {} while (1) |
| 85 | +#define ET_UNREACHABLE() __builtin_unreachable() |
87 | 86 | #endif |
88 | 87 |
|
89 | 88 | // Likely/Unlikely |
|
99 | 98 | #if defined(_MSC_VER) |
100 | 99 | // No weak linkage in MSVC |
101 | 100 | #define ET_WEAK |
102 | | -#elif defined(__GNUC__) || defined(__clang__) |
103 | | -#define ET_WEAK __attribute__((weak)) |
104 | 101 | #else |
105 | | -#define ET_WEAK |
| 102 | +#define ET_WEAK __attribute__((weak)) |
106 | 103 | #endif |
107 | 104 |
|
108 | 105 | // Printf-like format checking |
109 | 106 | #if defined(_MSC_VER) |
110 | 107 | #include <sal.h> |
111 | 108 | #define ET_PRINTFLIKE(_string_index, _va_index) _Printf_format_string_ |
112 | | -#elif defined(__GNUC__) || defined(__clang__) |
| 109 | +#else |
113 | 110 | #define ET_PRINTFLIKE(_string_index, _va_index) \ |
114 | 111 | __attribute__((format(printf, _string_index, _va_index))) |
115 | | -#else |
116 | | -#define ET_PRINTFLIKE(_string_index, _va_index) |
117 | 112 | #endif |
118 | 113 |
|
119 | 114 | // ----------------------------------------------------------------------------- |
|
0 commit comments