1 #ifndef SIMDJSON_WESTMERE_BITMANIPULATION_H
2 #define SIMDJSON_WESTMERE_BITMANIPULATION_H
4 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
5 #include "simdjson/westmere/base.h"
6 #include "simdjson/westmere/intrinsics.h"
16 SIMDJSON_NO_SANITIZE_UNDEFINED
20 SIMDJSON_NO_SANITIZE_MEMORY
21 simdjson_inline
int trailing_zeroes(uint64_t input_num) {
22 #if SIMDJSON_REGULAR_VISUAL_STUDIO
26 _BitScanForward64(&ret, input_num);
29 return __builtin_ctzll(input_num);
34 simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
35 return input_num & (input_num-1);
39 simdjson_inline
int leading_zeroes(uint64_t input_num) {
40 #if SIMDJSON_REGULAR_VISUAL_STUDIO
41 unsigned long leading_zero = 0;
44 if (_BitScanReverse64(&leading_zero, input_num))
45 return (
int)(63 - leading_zero);
49 return __builtin_clzll(input_num);
53 #if SIMDJSON_REGULAR_VISUAL_STUDIO
54 simdjson_inline
unsigned __int64 count_ones(uint64_t input_num) {
56 return __popcnt64(input_num);
59 simdjson_inline
long long int count_ones(uint64_t input_num) {
60 return _popcnt64(input_num);
64 simdjson_inline
bool add_overflow(uint64_t value1, uint64_t value2,
66 #if SIMDJSON_REGULAR_VISUAL_STUDIO
67 return _addcarry_u64(0, value1, value2,
68 reinterpret_cast<unsigned __int64 *
>(result));
70 return __builtin_uaddll_overflow(value1, value2,
71 reinterpret_cast<unsigned long long *
>(result));
The top level simdjson namespace, containing everything the library provides.