From 04609cdcbb46763874100f6b4d681dc19ccdbf8a Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Fri, 5 Apr 2024 11:12:05 -0300 Subject: [PATCH] macros.h: Alphabetize the compiler-specific macros --- cpp/src/arrow/util/macros.h | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/cpp/src/arrow/util/macros.h b/cpp/src/arrow/util/macros.h index 0860eb1dd552d..65c4727960cff 100644 --- a/cpp/src/arrow/util/macros.h +++ b/cpp/src/arrow/util/macros.h @@ -58,15 +58,10 @@ // https://blog.regehr.org/archives/1096 #define ARROW_UNUSED(x) (void)(x) #define ARROW_ARG_UNUSED(x) -#if defined(__GNUC__) // GCC and clang -#define ARROW_NORETURN __attribute__((noreturn)) -#define ARROW_NOINLINE __attribute__((noinline)) -#define ARROW_FORCE_INLINE __attribute__((always_inline)) -#define ARROW_PREDICT_FALSE(x) (__builtin_expect(!!(x), 0)) -#define ARROW_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) -#define ARROW_PREFETCH(addr) __builtin_prefetch(addr) -#define ARROW_RESTRICT __restrict -#if defined(__clang__) // clang-specific +#if defined(__GNUC__) +// Both GCC and clang define __GNUC__ +#if defined(__clang__) +// Only clang defines __clang__ #define ARROW_COMPILER_ASSUME(expr) __builtin_assume(expr) #else #define ARROW_COMPILER_ASSUME(expr) \ @@ -74,24 +69,31 @@ __builtin_unreachable(); \ } #endif +#define ARROW_FORCE_INLINE __attribute__((always_inline)) +#define ARROW_NOINLINE __attribute__((noinline)) +#define ARROW_NORETURN __attribute__((noreturn)) +#define ARROW_PREDICT_FALSE(x) (__builtin_expect(!!(x), 0)) +#define ARROW_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) +#define ARROW_PREFETCH(addr) __builtin_prefetch(addr) +#define ARROW_RESTRICT __restrict #elif defined(_MSC_VER) // MSVC -#define ARROW_NORETURN __declspec(noreturn) -#define ARROW_NOINLINE __declspec(noinline) +#define ARROW_COMPILER_ASSUME(expr) __assume(expr) #define ARROW_FORCE_INLINE __declspec(forceinline) +#define ARROW_NOINLINE __declspec(noinline) +#define ARROW_NORETURN __declspec(noreturn) #define ARROW_PREDICT_FALSE(x) (x) #define ARROW_PREDICT_TRUE(x) (x) #define ARROW_PREFETCH(addr) #define ARROW_RESTRICT __restrict -#define ARROW_COMPILER_ASSUME(expr) __assume(expr) #else -#define ARROW_NORETURN -#define ARROW_NOINLINE +#define ARROW_COMPILER_ASSUME(expr) #define ARROW_FORCE_INLINE +#define ARROW_NOINLINE +#define ARROW_NORETURN #define ARROW_PREDICT_FALSE(x) (x) #define ARROW_PREDICT_TRUE(x) (x) #define ARROW_PREFETCH(addr) #define ARROW_RESTRICT -#define ARROW_COMPILER_ASSUME(expr) #endif // ----------------------------------------------------------------------