Skip to content

Commit 34473aa

Browse files
committed
clean up
1 parent 758148a commit 34473aa

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

runtime/platform/compiler.h

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
// -----------------------------------------------------------------------------
1919

2020
// 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."
2325
#endif
2426

2527
// Clang version check
2628
#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."
2831
#endif
2932

3033
// C++17 check
@@ -35,7 +38,8 @@
3538

3639
// Windows min/max macro clash
3740
#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"
3943
#endif
4044

4145
// -----------------------------------------------------------------------------
@@ -47,7 +51,8 @@
4751

4852
// [[deprecated]]
4953
#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.")]]
5156

5257
// [[fallthrough]]
5358
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 7)
@@ -67,23 +72,17 @@
6772
#define ET_NOINLINE __declspec(noinline)
6873
#define ET_INLINE __forceinline
6974
#define ET_INLINE_ATTRIBUTE __forceinline
70-
#elif defined(__GNUC__) || defined(__clang__)
75+
#else
7176
#define ET_NOINLINE __attribute__((noinline))
7277
#define ET_INLINE __attribute__((always_inline)) inline
7378
#define ET_INLINE_ATTRIBUTE __attribute__((always_inline))
74-
#else
75-
#define ET_NOINLINE
76-
#define ET_INLINE inline
77-
#define ET_INLINE_ATTRIBUTE
7879
#endif
7980

8081
// Unreachable
81-
#if defined(__GNUC__) || defined(__clang__)
82-
#define ET_UNREACHABLE() __builtin_unreachable()
83-
#elif defined(_MSC_VER)
82+
#if defined(_MSC_VER)
8483
#define ET_UNREACHABLE() __assume(0)
8584
#else
86-
#define ET_UNREACHABLE() do {} while (1)
85+
#define ET_UNREACHABLE() __builtin_unreachable()
8786
#endif
8887

8988
// Likely/Unlikely
@@ -99,21 +98,17 @@
9998
#if defined(_MSC_VER)
10099
// No weak linkage in MSVC
101100
#define ET_WEAK
102-
#elif defined(__GNUC__) || defined(__clang__)
103-
#define ET_WEAK __attribute__((weak))
104101
#else
105-
#define ET_WEAK
102+
#define ET_WEAK __attribute__((weak))
106103
#endif
107104

108105
// Printf-like format checking
109106
#if defined(_MSC_VER)
110107
#include <sal.h>
111108
#define ET_PRINTFLIKE(_string_index, _va_index) _Printf_format_string_
112-
#elif defined(__GNUC__) || defined(__clang__)
109+
#else
113110
#define ET_PRINTFLIKE(_string_index, _va_index) \
114111
__attribute__((format(printf, _string_index, _va_index)))
115-
#else
116-
#define ET_PRINTFLIKE(_string_index, _va_index)
117112
#endif
118113

119114
// -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)