Skip to content

Commit 96ecb13

Browse files
authored
GH-49424: [C++] Use std::bit_width instead of missing std::log2p1 on emscripten clang (#49425)
### Rationale for this change The current Emscripten job fails due to macro check targeting CRAN macOS being used for emscripten. ### What changes are included in this PR? Avoid using workaround for Emscripten. ### Are these changes tested? Yes via CI ### Are there any user-facing changes? No * GitHub Issue: #49424 Authored-by: Raúl Cumplido <raulcumplido@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 0124d5b commit 96ecb13

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

cpp/src/arrow/util/align_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ inline BitmapWordAlignParams BitmapWordAlign(const uint8_t* data, int64_t bit_of
4646
int64_t length) {
4747
// TODO: We can remove this condition once CRAN upgrades its macOS
4848
// SDK from 11.3.
49-
#if defined(__clang__) && !defined(__cpp_lib_bitops)
49+
#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__)
5050
static_assert((ALIGN_IN_BYTES != 0) && ((ALIGN_IN_BYTES & (ALIGN_IN_BYTES - 1)) == 0),
5151
"ALIGN_IN_BYTES should be a positive power of two");
5252
#else

cpp/src/arrow/util/bit_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static inline int Log2(uint64_t x) {
141141

142142
// TODO: We can remove this condition once CRAN upgrades its macOS
143143
// SDK from 11.3.
144-
#if defined(__clang__) && !defined(__cpp_lib_bitops)
144+
#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__)
145145
return std::log2p1(x - 1);
146146
#else
147147
return std::bit_width(x - 1);

cpp/src/arrow/util/rle_encoding_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ TEST(BitRle, Random) {
918918
}
919919
// TODO: We can remove this condition once CRAN upgrades its macOS
920920
// SDK from 11.3.
921-
#if defined(__clang__) && !defined(__cpp_lib_bitops)
921+
#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__)
922922
if (!CheckRoundTrip(values, std::log2p1(values.size()))) {
923923
#else
924924
if (!CheckRoundTrip(values, std::bit_width(values.size()))) {

cpp/src/parquet/chunker_internal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ uint64_t CalculateMask(int64_t min_chunk_size, int64_t max_chunk_size, int norm_
8888
// by taking the floor(log2(target_size))
8989
// TODO: We can remove this condition once CRAN upgrades its macOS
9090
// SDK from 11.3.
91-
#if defined(__clang__) && !defined(__cpp_lib_bitops)
91+
#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__)
9292
auto target_bits = std::log2p1(static_cast<uint64_t>(target_size));
9393
#else
9494
auto target_bits = std::bit_width(static_cast<uint64_t>(target_size));

cpp/src/parquet/encoder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ void DeltaBitPackEncoder<DType>::FlushBlock() {
11691169
// See overflow comment above.
11701170
// TODO: We can remove this condition once CRAN upgrades its macOS
11711171
// SDK from 11.3.
1172-
#if defined(__clang__) && !defined(__cpp_lib_bitops)
1172+
#if defined(__clang__) && !defined(__cpp_lib_bitops) && !defined(__EMSCRIPTEN__)
11731173
const auto bit_width = bit_width_data[i] =
11741174
std::log2p1(static_cast<UT>(max_delta) - static_cast<UT>(min_delta));
11751175
#else

0 commit comments

Comments
 (0)