Skip to content

Commit

Permalink
GH-40370: [C++] Define ARROW_FORCE_INLINE for non-MSVC builds (#40372)
Browse files Browse the repository at this point in the history
### Rationale for this change

Compiler macros should behave consistently (as much as possible) across differently compilers.

### What changes are included in this PR?

 - Define `ARROW_FORCE_INLINE` correctly
 - Move it from `visibility.h` to `macros.h`

### Are these changes tested?

By being the base commit in changes that I'm compiling successfully and benchmarking.

* GitHub Issue: #40370

Authored-by: Felipe Oliveira Carvalho <[email protected]>
Signed-off-by: Felipe Oliveira Carvalho <[email protected]>
  • Loading branch information
felipecrv authored Mar 7, 2024
1 parent 1d966e9 commit 49cdb0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cpp/src/arrow/util/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@
#define ARROW_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
#define ARROW_NORETURN __attribute__((noreturn))
#define ARROW_NOINLINE __attribute__((noinline))
#define ARROW_FORCE_INLINE __attribute__((always_inline))
#define ARROW_PREFETCH(addr) __builtin_prefetch(addr)
#elif defined(_MSC_VER)
#define ARROW_NORETURN __declspec(noreturn)
#define ARROW_NOINLINE __declspec(noinline)
#define ARROW_FORCE_INLINE __declspec(forceinline)
#define ARROW_PREDICT_FALSE(x) (x)
#define ARROW_PREDICT_TRUE(x) (x)
#define ARROW_PREFETCH(addr)
#else
#define ARROW_NORETURN
#define ARROW_NOINLINE
#define ARROW_FORCE_INLINE
#define ARROW_PREDICT_FALSE(x) (x)
#define ARROW_PREDICT_TRUE(x) (x)
#define ARROW_PREFETCH(addr)
Expand Down
3 changes: 0 additions & 3 deletions cpp/src/arrow/util/visibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@
#endif

#define ARROW_NO_EXPORT
#define ARROW_FORCE_INLINE __forceinline

#else

// Non-Windows

#define ARROW_FORCE_INLINE

#if defined(__cplusplus) && (defined(__GNUC__) || defined(__clang__))
#ifndef ARROW_EXPORT
#define ARROW_EXPORT [[gnu::visibility("default")]]
Expand Down

0 comments on commit 49cdb0f

Please sign in to comment.