Skip to content

Commit 8e05abe

Browse files
Add force inline option for MSVC compiler
1 parent 9146c01 commit 8e05abe

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

cpp/src/gandiva/gdv_function_stubs.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ CAST_VARLEN_TYPE_FROM_NUMERIC(VARBINARY)
426426
#undef GDV_FN_CAST_VARCHAR_INTEGER
427427
#undef GDV_FN_CAST_VARCHAR_REAL
428428

429-
FORCE_INLINE
430-
inline int32_t gdv_fn_utf8_char_length(char c) {
429+
GDV_FORCE_INLINE
430+
int32_t gdv_fn_utf8_char_length(char c) {
431431
if ((signed char)c >= 0) { // 1-byte char (0x00 ~ 0x7F)
432432
return 1;
433433
} else if ((c & 0xE0) == 0xC0) { // 2-byte char
@@ -441,8 +441,8 @@ inline int32_t gdv_fn_utf8_char_length(char c) {
441441
return 0;
442442
}
443443

444-
FORCE_INLINE
445-
inline void gdv_fn_set_error_for_invalid_utf8(int64_t execution_context, char val) {
444+
GDV_FORCE_INLINE
445+
void gdv_fn_set_error_for_invalid_utf8(int64_t execution_context, char val) {
446446
char const* fmt = "unexpected byte \\%02hhx encountered while decoding utf8 string";
447447
int size = static_cast<int>(strlen(fmt)) + 64;
448448
char* error = reinterpret_cast<char*>(malloc(size));
@@ -602,8 +602,8 @@ const char* gdv_fn_lower_utf8(int64_t context, const char* data, int32_t data_le
602602
// The Unicode characters also are divided between categories. This link
603603
// https://www.compart.com/en/unicode/category shows
604604
// more information about characters categories.
605-
FORCE_INLINE
606-
inline bool gdv_fn_is_codepoint_for_space(uint32_t val) {
605+
GDV_FORCE_INLINE
606+
bool gdv_fn_is_codepoint_for_space(uint32_t val) {
607607
auto category = utf8proc_category(val);
608608

609609
return category != utf8proc_category_t::UTF8PROC_CATEGORY_LU &&

cpp/src/gandiva/gdv_function_stubs.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ using gdv_utf8 = char*;
4343
using gdv_binary = char*;
4444
using gdv_day_time_interval = int64_t;
4545

46+
#ifdef GANDIVA_UNIT_TEST
47+
// unit tests may be compiled without O2, so inlining may not happen.
48+
#define GDV_FORCE_INLINE
49+
#else
50+
#ifdef _MSC_VER
51+
#define GDV_FORCE_INLINE __forceinline
52+
#else
53+
#define GDV_FORCE_INLINE inline __attribute__((always_inline))
54+
#endif
55+
#endif
56+
4657
bool gdv_fn_like_utf8_utf8(int64_t ptr, const char* data, int data_len,
4758
const char* pattern, int pattern_len);
4859

0 commit comments

Comments
 (0)