#define _ENC_DEC_H
#include <array>
+#include <bit>
#include <cstring>
#include <concepts>
#include <map>
#include <boost/optional.hpp>
#include "include/compat.h"
-#include "include/intarith.h"
#include "include/int_types.h"
#include "include/scope_guard.h"
}
inline void denc_varint_lowz(uint64_t v,
ceph::buffer::list::contiguous_appender& p) {
- int lowznib = v ? (ctz(v) / 4) : 0;
+ int lowznib = v ? (std::countr_zero(v) / 4) : 0;
if (lowznib > 3)
lowznib = 3;
v >>= lowznib * 4;
v = -v;
negative = true;
}
- unsigned lowznib = v ? (ctz(v) / 4) : 0u;
+ unsigned lowznib = v ? (std::countr_zero(std::bit_cast<uint64_t>(v)) / 4) : 0u;
if (lowznib > 3)
lowznib = 3;
v >>= lowznib * 4;
template<class It>
requires (!is_const_iterator<It>)
inline void denc_lba(uint64_t v, It& p) {
- int low_zero_nibbles = v ? (int)(ctz(v) / 4) : 0;
+ int low_zero_nibbles = v ? std::countr_zero(v) / 4 : 0;
int pos;
uint32_t word;
int t = low_zero_nibbles - 3;
zoned_cleaner_thread(this),
#endif
min_alloc_size(_min_alloc_size),
- min_alloc_size_order(ctz(_min_alloc_size)),
+ min_alloc_size_order(std::countr_zero(_min_alloc_size)),
mempool_thread(this)
{
_init_logger();
// initialize global block parameters
block_size = bdev->get_block_size();
block_mask = ~(block_size - 1);
- block_size_order = ctz(block_size);
+ block_size_order = std::countr_zero(block_size);
ceph_assert(block_size == 1u << block_size_order);
_set_max_defer_interval();
// and set cache_size based on device type
uint64_t val;
decode(val, p);
min_alloc_size = val;
- min_alloc_size_order = ctz(val);
+ min_alloc_size_order = std::countr_zero(val);
min_alloc_size_mask = min_alloc_size - 1;
ceph_assert(min_alloc_size == 1u << min_alloc_size_order);
if (wi.compressed) {
final_length = wi.compressed_bl.length();
csum_length = final_length;
- unsigned csum_order = ctz(csum_length);
+ unsigned csum_order = std::countr_zero(csum_length);
l = &wi.compressed_bl;
dblob.set_compressed(wi.blob_length, wi.compressed_len);
if (csum != Checksummer::CSUM_NONE) {
<< block_size_order << dendl;
csum_order = block_size_order;
} else {
- csum_order = std::min(wctx->csum_order, ctz(l->length()));
+ csum_order = std::min<unsigned>(wctx->csum_order, std::countr_zero(l->length()));
}
// try to align blob with max_blob_size to improve
// its reuse ratio, e.g. in case of reverse write
if (o->onode.expected_write_size) {
wctx->csum_order = std::max(min_alloc_size_order,
- (uint8_t)ctz(o->onode.expected_write_size));
+ (uint8_t)std::countr_zero(o->onode.expected_write_size));
} else {
wctx->csum_order = min_alloc_size_order;
}
//-----------------------------------------------------------------------------------
static void copy_simple_bitmap_to_allocator(SimpleBitmap* sbmap, Allocator* dest_alloc, uint64_t alloc_size)
{
- int alloc_size_shift = ctz(alloc_size);
+ int alloc_size_shift = std::countr_zero(alloc_size);
uint64_t offset = 0;
extent_t ext = sbmap->get_next_clr_extent(offset);
while (ext.length != 0) {