Skip to content

Commit 632cb49

Browse files
committed
use log2p1 instead of bit_width
1 parent a0c9a4b commit 632cb49

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

cpp/src/arrow/util/bit_util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,14 @@ static inline uint64_t TrailingBits(uint64_t v, int num_bits) {
138138
// Returns ceil(log2(x)).
139139
static inline int Log2(uint64_t x) {
140140
// DCHECK_GT(x, 0);
141+
142+
// TODO: We can remove this condition once CRAN upgrades its macOS
143+
// SDK from 11.3.
144+
#if defined(__clang__) && !defined(__cpp_lib_bitops)
145+
return std::log2p1(x - 1);
146+
#else
141147
return std::bit_width(x - 1);
148+
#endif
142149
}
143150

144151
//

0 commit comments

Comments
 (0)