This is an automated email from the ASF dual-hosted git repository.
felipecrv pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 49cdb0fe4e GH-40370: [C++] Define ARROW_FORCE_INLINE for non-MSVC
builds (#40372)
49cdb0fe4e is described below
commit 49cdb0fe4e98fda19031c864a18e6156c6edbf3c
Author: Felipe Oliveira Carvalho <[email protected]>
AuthorDate: Wed Mar 6 23:00:52 2024 -0300
GH-40370: [C++] Define ARROW_FORCE_INLINE for non-MSVC builds (#40372)
### 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]>
---
cpp/src/arrow/util/macros.h | 4 ++++
cpp/src/arrow/util/visibility.h | 3 ---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/cpp/src/arrow/util/macros.h b/cpp/src/arrow/util/macros.h
index b5675faa14..1d23e829d7 100644
--- a/cpp/src/arrow/util/macros.h
+++ b/cpp/src/arrow/util/macros.h
@@ -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)
diff --git a/cpp/src/arrow/util/visibility.h b/cpp/src/arrow/util/visibility.h
index b0fd790295..c06ae51b8e 100644
--- a/cpp/src/arrow/util/visibility.h
+++ b/cpp/src/arrow/util/visibility.h
@@ -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")]]