53template <
typename B = 
byte>
 
   55  static_assert(std::is_same_v<std::decay_t<B>, 
byte>,
 
   56                "Bitset<B> requires B to be a byte or const byte");
 
   90  void set(
size_t pos, 
bool v = 
true)
 const {
 
   92    m_data[pos / 8] &= ~(0x1 << (pos & 0x7));
 
   93    m_data[pos / 8] |= (
static_cast<byte>(v) << (pos & 0x7));
 
  118  constexpr static size_t NOT_FOUND = std::numeric_limits<size_t>::max();
 
  143      const uint64_t earlier = (uint64_t{1} << start_pos) - 1;
 
  144      const uint64_t unseen = 
all & ~earlier;
 
  150    const auto start_addr = 
reinterpret_cast<uintptr_t
>(
m_data);
 
  151    const size_t start_word_byte_idx =
 
  152        ut::div_ceil(start_addr, uintptr_t{8}) * 8 - start_addr;
 
  153    const auto translate_result = [&start_pos, 
this](
size_t offset) {
 
  155      return found == 
NOT_FOUND ? found : found + offset;
 
  157    if (start_word_byte_idx == 0) {
 
  159      auto *words = 
reinterpret_cast<const uint64_t *
>(
m_data);
 
  160      size_t word_idx = start_pos / 64;
 
  162      if (word_idx < full_words_count) {
 
  163        const uint64_t earlier = (uint64_t{1} << start_pos % 64) - 1;
 
  170        while (word_idx < full_words_count) {
 
  171          if (words[word_idx]) {
 
  172            return word_idx * 64 +
 
  177        start_pos = full_words_count * 64;
 
  179      return translate_result(full_words_count * 64);
 
  182    if (start_pos < start_word_byte_idx * 8) {
 
  188      start_pos = start_word_byte_idx * 8;
 
  190    return translate_result(start_word_byte_idx * 8);
 
  198    return ((
m_data[pos / 8] >> (pos & 0x7)) & 0x1);
 
  216  static constexpr uint64_t 
to_uint64(
const byte *bytes) {
 
  220    return ((uint64_t)(bytes[7]) << 7 * 8) | ((uint64_t)(bytes[6]) << 6 * 8) |
 
  221           ((uint64_t)(bytes[5]) << 5 * 8) | ((uint64_t)(bytes[4]) << 4 * 8) |
 
  222           ((uint64_t)(bytes[3]) << 3 * 8) | ((uint64_t)(bytes[2]) << 2 * 8) |
 
  223           ((uint64_t)(bytes[1]) << 1 * 8) | ((uint64_t)(bytes[0]) << 0 * 8);
 
A simple bitset wrapper class, which lets you access an existing range of bytes (not owned by it!...
Definition: ut0bitset.h:54
 
uint64_t to_uint64() const
Converts the content of the bitset to an uint64_t value, such that (value>>i&1) if and only if test(i...
Definition: ut0bitset.h:110
 
size_t size_bytes() const
Get the size of current bitset in bytes.
Definition: ut0bitset.h:203
 
B * m_data
The buffer containing the bitmap.
Definition: ut0bitset.h:228
 
void reset() const
Set all bits to false.
Definition: ut0bitset.h:100
 
B * data() const
Get the bitset's bytes buffer.
Definition: ut0bitset.h:207
 
bool test(size_t pos) const
Test if the specified bit is set or not.
Definition: ut0bitset.h:196
 
Bitset(B *data, size_t size_bytes)
Definition: ut0bitset.h:61
 
Bitset bytes_subspan(size_t byte_offset) const
Returns a wrapper around fragment of the buffer starting at pos, where pos is measured in bytes.
Definition: ut0bitset.h:76
 
void reset(size_t pos) const
Sets the specified bit to false.
Definition: ut0bitset.h:104
 
size_t m_size_bytes
The length of the buffer containing the bitmap in bytes.
Definition: ut0bitset.h:232
 
void copy_from(const byte *bitset) const
Copy a bits from other buffer into this one.
Definition: ut0bitset.h:83
 
Bitset()
Constructor.
Definition: ut0bitset.h:60
 
void set() const
Set all bits to true.
Definition: ut0bitset.h:97
 
constexpr static size_t NOT_FOUND
Value used by find_set to indicate it could not find a bit set to 1.
Definition: ut0bitset.h:118
 
Bitset bytes_subspan(size_t byte_offset, size_t bytes_count) const
Returns a wrapper around [pos,pos+len) fragment of the buffer, where pos and len are measured in byte...
Definition: ut0bitset.h:68
 
size_t find_set(size_t start_pos) const
Finds the smallest position which is set and is not smaller than start_pos.
Definition: ut0bitset.h:124
 
void set(size_t pos, bool v=true) const
Set the specified bit to the value 'bit'.
Definition: ut0bitset.h:90
 
static constexpr uint64_t to_uint64(const byte *bytes)
Converts 8 bytes to uint64_t value, such that (value>>i&1) equals the i-th bit, i....
Definition: ut0bitset.h:216
 
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
 
constexpr T div_ceil(T numerator, T denominator)
Computes the result of division rounded towards positive infinity.
Definition: ut0math.h:83
 
static int countr_zero(uint64_t x)
Portable replacement for std::countr_zero(uint64_t) from C++20.
Definition: ut0math.h:47
 
Version control for database, common definitions, and include files.
 
Debug utilities for Innobase.
 
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:69
 
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:57
 
static int all(site_def const *s, node_no node)
Definition: xcom_transport.cc:872