diff --git a/cpp/src/arrow/util/align_util.h b/cpp/src/arrow/util/align_util.h index a03a92cc0a66..0b23c6d77bd9 100644 --- a/cpp/src/arrow/util/align_util.h +++ b/cpp/src/arrow/util/align_util.h @@ -46,7 +46,8 @@ inline BitmapWordAlignParams BitmapWordAlign(const uint8_t* data, int64_t bit_of int64_t length) { // TODO: We can remove this condition once CRAN upgrades its macOS // SDK from 11.3. -#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__) + // __apple_build_version__ should be defined only on Apple clang +#if defined(__apple_build_version__) && !defined(__cpp_lib_bitops) static_assert((ALIGN_IN_BYTES != 0) && ((ALIGN_IN_BYTES & (ALIGN_IN_BYTES - 1)) == 0), "ALIGN_IN_BYTES should be a positive power of two"); #else diff --git a/cpp/src/arrow/util/bit_util.h b/cpp/src/arrow/util/bit_util.h index a6eb540fa9be..bffc3c14a106 100644 --- a/cpp/src/arrow/util/bit_util.h +++ b/cpp/src/arrow/util/bit_util.h @@ -139,9 +139,10 @@ static inline uint64_t TrailingBits(uint64_t v, int num_bits) { static inline int Log2(uint64_t x) { // DCHECK_GT(x, 0); - // TODO: We can remove this condition once CRAN upgrades its macOS - // SDK from 11.3. -#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__) +// TODO: We can remove this condition once CRAN upgrades its macOS +// SDK from 11.3. +// __apple_build_version__ should be defined only on Apple clang +#if defined(__apple_build_version__) && !defined(__cpp_lib_bitops) return std::log2p1(x - 1); #else return std::bit_width(x - 1); diff --git a/cpp/src/arrow/util/rle_encoding_test.cc b/cpp/src/arrow/util/rle_encoding_test.cc index 5cfa64563a09..f33c71c0ad28 100644 --- a/cpp/src/arrow/util/rle_encoding_test.cc +++ b/cpp/src/arrow/util/rle_encoding_test.cc @@ -918,7 +918,8 @@ TEST(BitRle, Random) { } // TODO: We can remove this condition once CRAN upgrades its macOS // SDK from 11.3. -#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__) + // __apple_build_version__ should be defined only on Apple clang +#if defined(__apple_build_version__) && !defined(__cpp_lib_bitops) if (!CheckRoundTrip(values, std::log2p1(values.size()))) { #else if (!CheckRoundTrip(values, std::bit_width(values.size()))) { diff --git a/cpp/src/parquet/chunker_internal.cc b/cpp/src/parquet/chunker_internal.cc index 1e1238e83504..794075b73379 100644 --- a/cpp/src/parquet/chunker_internal.cc +++ b/cpp/src/parquet/chunker_internal.cc @@ -88,7 +88,8 @@ uint64_t CalculateMask(int64_t min_chunk_size, int64_t max_chunk_size, int norm_ // by taking the floor(log2(target_size)) // TODO: We can remove this condition once CRAN upgrades its macOS // SDK from 11.3. -#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__) + // __apple_build_version__ should be defined only on Apple clang +#if defined(__apple_build_version__) && !defined(__cpp_lib_bitops) auto target_bits = std::log2p1(static_cast(target_size)); #else auto target_bits = std::bit_width(static_cast(target_size)); diff --git a/cpp/src/parquet/encoder.cc b/cpp/src/parquet/encoder.cc index 75eccc96a442..2c70f63b6b8e 100644 --- a/cpp/src/parquet/encoder.cc +++ b/cpp/src/parquet/encoder.cc @@ -1169,7 +1169,8 @@ void DeltaBitPackEncoder::FlushBlock() { // See overflow comment above. // TODO: We can remove this condition once CRAN upgrades its macOS // SDK from 11.3. -#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__) + // __apple_build_version__ should be defined only on Apple clang +#if defined(__apple_build_version__) && !defined(__cpp_lib_bitops) const auto bit_width = bit_width_data[i] = std::log2p1(static_cast(max_delta) - static_cast(min_delta)); #else