1 #ifndef SIMDJSON_FALLBACK_BITMANIPULATION_H
2 #define SIMDJSON_FALLBACK_BITMANIPULATION_H
4 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
5 #include "simdjson/fallback/base.h"
12 #if defined(_MSC_VER) && !defined(_M_ARM64) && !defined(_M_X64)
13 static inline unsigned char _BitScanForward64(
unsigned long* ret, uint64_t x) {
14 unsigned long x0 = (
unsigned long)x, top, bottom;
15 _BitScanForward(&top, (
unsigned long)(x >> 32));
16 _BitScanForward(&bottom, x0);
17 *ret = x0 ? bottom : 32 + top;
20 static unsigned char _BitScanReverse64(
unsigned long* ret, uint64_t x) {
21 unsigned long x1 = (
unsigned long)(x >> 32), top, bottom;
22 _BitScanReverse(&top, x1);
23 _BitScanReverse(&bottom, (
unsigned long)x);
24 *ret = x1 ? top + 32 : bottom;
30 simdjson_inline
int leading_zeroes(uint64_t input_num) {
32 unsigned long leading_zero = 0;
35 if (_BitScanReverse64(&leading_zero, input_num))
36 return (
int)(63 - leading_zero);
40 return __builtin_clzll(input_num);
The top level simdjson namespace, containing everything the library provides.