inline SNMALLOC_FAST_PATH size_t clz()

in src/ds/bits.h [50:85]


    inline SNMALLOC_FAST_PATH size_t clz(size_t x)
    {
      SNMALLOC_ASSERT(x != 0); // Calling with 0 is UB on some implementations
#if defined(_MSC_VER)
#  ifdef USE_LZCNT
#    ifdef SNMALLOC_VA_BITS_64
      return __lzcnt64(x);
#    else
      return __lzcnt((uint32_t)x);
#    endif
#  else
      unsigned long index;

#    ifdef SNMALLOC_VA_BITS_64
      _BitScanReverse64(&index, x);
#    else
      _BitScanReverse(&index, (unsigned long)x);
#    endif

      return BITS - index - 1;
#  endif
#else
      if constexpr (std::is_same_v<unsigned long, std::size_t>)
      {
        return static_cast<size_t>(__builtin_clzl(x));
      }
      else if constexpr (std::is_same_v<unsigned long long, std::size_t>)
      {
        return static_cast<size_t>(__builtin_clzll(x));
      }
      else if constexpr (std::is_same_v<unsigned int, std::size_t>)
      {
        return static_cast<size_t>(__builtin_clz(x));
      }
#endif
    }