Skip to content

Commit 05c6aa9

Browse files
committed
fix inline
1 parent 658c000 commit 05c6aa9

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

runtime/platform/compiler.h

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@
3131
"You're trying to build ExecuTorch with a too old version of Clang. We need Clang 5 or later."
3232
#endif
3333

34-
// C++17 check
3534
#if (defined(_MSC_VER) && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L)) || \
3635
(!defined(_MSC_VER) && __cplusplus < 201703L)
3736
#error "You need C++17 to compile ExecuTorch"
3837
#endif
3938

40-
// Windows min/max macro clash
4139
#if defined(_MSC_VER) && (defined(min) || defined(max))
4240
#error \
4341
"Macro clash with min and max -- define NOMINMAX when compiling your program on Windows"
@@ -58,20 +56,6 @@
5856

5957
#define ET_NORETURN [[noreturn]]
6058

61-
#define ET_DEPRECATED [[deprecated]]
62-
#define ET_EXPERIMENTAL \
63-
[[deprecated("This API is experimental and may change without notice.")]]
64-
65-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 7)
66-
#define ET_FALLTHROUGH [[fallthrough]]
67-
#else
68-
#define ET_FALLTHROUGH
69-
#endif
70-
71-
#define ET_NODISCARD [[nodiscard]]
72-
73-
#define ET_UNUSED [[maybe_unused]]
74-
7559
// Inline/NoInline
7660
#if defined(_MSC_VER)
7761
#define ET_NOINLINE __declspec(noinline)
@@ -99,25 +83,35 @@
9983

10084
#endif // defined(__GNUC__)
10185

86+
#define ET_DEPRECATED [[deprecated]]
87+
#define ET_EXPERIMENTAL \
88+
[[deprecated("This API is experimental and may change without notice.")]]
89+
#define ET_FALLTHROUGH [[fallthrough]]
90+
#define ET_NODISCARD [[nodiscard]]
91+
#define ET_UNUSED [[maybe_unused]]
92+
10293
// UNLIKELY Macro
10394
// example
10495
// if ET_UNLIKELY(a > 10 && b < 5) {
10596
// do something
10697
// }
10798
#if (__cplusplus) >= 202002L
99+
108100
#define ET_LIKELY(expr) (expr) [[likely]]
109101
#define ET_UNLIKELY(expr) (expr) [[unlikely]]
102+
110103
#else
104+
111105
#define ET_LIKELY(expr) (expr)
112106
#define ET_UNLIKELY(expr) (expr)
113-
#endif
107+
108+
#endif // (__cplusplus) >= 202002L
114109

115110
/// Define a C symbol with weak linkage.
116111
#ifdef _MSC_VER
117112
// There currently doesn't seem to be a great way to do this in Windows and
118113
// given that weak linkage is not really critical on Windows, we'll just leave
119114
// it as a stub.
120-
// No weak linkage in MSVC
121115
#define ET_WEAK
122116
#else
123117
#define ET_WEAK __attribute__((weak))
@@ -135,10 +129,6 @@
135129
__attribute__((format(printf, _string_index, _va_index)))
136130
#endif
137131

138-
// -----------------------------------------------------------------------------
139-
// Builtin/Source location helpers
140-
// -----------------------------------------------------------------------------
141-
142132
#ifndef __has_builtin
143133
#define __has_builtin(x) (0)
144134
#endif
@@ -175,15 +165,15 @@
175165

176166
// Whether the compiler supports GNU statement expressions.
177167
// https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
178-
179168
#ifndef ET_HAVE_GNU_STATEMENT_EXPRESSIONS
180169
#if (defined(__GNUC__) && __GNUC__ >= 3) || defined(__clang__)
181170
#define ET_HAVE_GNU_STATEMENT_EXPRESSIONS 1
182171
#else
183172
#define ET_HAVE_GNU_STATEMENT_EXPRESSIONS 0
184173
#endif
185-
#endif
174+
#endif // ifndef
186175

176+
// Define size_t and ssize_t.
187177
#ifndef _MSC_VER
188178
#include <sys/types.h>
189179
#else
@@ -201,7 +191,6 @@ using ssize_t = ptrdiff_t;
201191

202192
// DEPRECATED: Use the non-underscore-prefixed versions instead.
203193
// TODO(T199005537): Remove these once all users have stopped using them.
204-
205194
#define __ET_DEPRECATED ET_DEPRECATED
206195
#define __ET_FALLTHROUGH ET_FALLTHROUGH
207196
#define __ET_FUNCTION ET_FUNCTION

0 commit comments

Comments
 (0)