Skip to content

Commit

Permalink
macros.h: Alphabetize the compiler-specific macros
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrv committed Apr 5, 2024
1 parent f04ab32 commit 04609cd
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions cpp/src/arrow/util/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,42 @@
// 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) \
if (!(expr)) { \
__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

// ----------------------------------------------------------------------
Expand Down

0 comments on commit 04609cd

Please sign in to comment.