From 62fd18078ce414e703e4e01c2bb9b224133334a3 Mon Sep 17 00:00:00 2001 From: Ivaylo Enchev Date: Mon, 25 Aug 2025 11:13:46 -0700 Subject: [PATCH] ET compiler specific macros for decorators Put restrict behind macros that we can switch based on type of compiler Additional windows specific issue is passing static constexpr const char op_name[] as template argument. Hide that decoration behind a macro as well to not affect the rest of the builds. Differential Revision: [D78854133](https://our.internmc.facebook.com/intern/diff/D78854133/) [ghstack-poisoned] --- runtime/platform/compiler.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/runtime/platform/compiler.h b/runtime/platform/compiler.h index c7bf4b7de1e..a515ea97194 100644 --- a/runtime/platform/compiler.h +++ b/runtime/platform/compiler.h @@ -55,8 +55,27 @@ */ #define ET_NORETURN [[noreturn]] + +#ifdef _MSC_VER +#define ET_NOINLINE __declspec(noinline) +#else #define ET_NOINLINE __attribute__((noinline)) +#endif + #define ET_INLINE __attribute__((always_inline)) inline + +#ifdef _MSC_VER +#define ET_ALWAYS_INLINE __forceinline +#else +#define ET_ALWAYS_INLINE inline __attribute__((always_inline)) +#endif + +#ifdef _MSC_VER +#define ET_RESTRICT __restrict +#else +#define ET_RESTRICT __restrict__ +#endif + #define ET_INLINE_ATTRIBUTE __attribute__((always_inline)) #if defined(__GNUC__) @@ -173,6 +192,13 @@ using ssize_t = ptrdiff_t; #endif +#ifdef _MSC_VER +// MSVC has issues passing static constexpr const char names as template parameter +#define ET_OP_NAME_SPECIFIER +#else +#define ET_OP_NAME_SPECIFIER constexpr +#endif + #ifdef __EXCEPTIONS #define ET_HAS_EXCEPTIONS 1 #elif defined(_MSC_VER) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS