Skip to content

Commit 0a380b5

Browse files
committed
fix: processor checks inconsistently problem
1 parent 3f87f95 commit 0a380b5

File tree

4 files changed

+98
-50
lines changed

4 files changed

+98
-50
lines changed

include/simdjson/arm64/bitmanipulation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ SIMDJSON_NO_SANITIZE_UNDEFINED
1919
// See issue https://github.com/simdjson/simdjson/issues/1965
2020
SIMDJSON_NO_SANITIZE_MEMORY
2121
simdjson_inline int trailing_zeroes(uint64_t input_num) {
22-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
22+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
2323
unsigned long ret;
2424
// Search the mask data from least significant bit (LSB)
2525
// to the most significant bit (MSB) for a set bit (1).
@@ -43,7 +43,7 @@ simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
4343
SIMDJSON_NO_SANITIZE_UNDEFINED
4444
/* result might be undefined when input_num is zero */
4545
simdjson_inline int leading_zeroes(uint64_t input_num) {
46-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
46+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
4747
unsigned long leading_zero = 0;
4848
// Search the mask data from most significant bit (MSB)
4949
// to least significant bit (LSB) for a set bit (1).
@@ -96,7 +96,7 @@ simdjson_inline uint64_t zero_leading_bit(uint64_t rev_bits, int leading_zeroes)
9696
#endif
9797

9898
simdjson_inline bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
99-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
99+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
100100
*result = value1 + value2;
101101
return *result < value1;
102102
#else

include/simdjson/arm64/simd.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace arm64 {
1212
namespace {
1313
namespace simd {
1414

15-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
15+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1616
namespace {
1717
// Start of private section with Visual Studio workaround
1818

@@ -121,7 +121,7 @@ namespace {
121121
// We return uint32_t instead of uint16_t because that seems to be more efficient for most
122122
// purposes (cutting it down to uint16_t costs performance in some compilers).
123123
simdjson_inline uint32_t to_bitmask() const {
124-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
124+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
125125
const uint8x16_t bit_mask = simdjson_make_uint8x16_t(0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
126126
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
127127
#else
@@ -152,7 +152,7 @@ namespace {
152152
// Splat constructor
153153
simdjson_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
154154
// Member-by-member initialization
155-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
155+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
156156
simdjson_inline simd8(
157157
uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7,
158158
uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15
@@ -246,7 +246,7 @@ namespace {
246246
uint64x2_t shufmask64 = {thintable_epi8[mask1], thintable_epi8[mask2]};
247247
uint8x16_t shufmask = vreinterpretq_u8_u64(shufmask64);
248248
// we increment by 0x08 the second half of the mask
249-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
249+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
250250
uint8x16_t inc = simdjson_make_uint8x16_t(0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08);
251251
#else
252252
uint8x16_t inc = {0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
@@ -276,7 +276,7 @@ namespace {
276276
uint8x8_t compactmask1 = vcreate_u8(thintable_epi8[mask1]);
277277
uint8x8_t compactmask2 = vcreate_u8(thintable_epi8[mask2]);
278278
// we increment by 0x08 the second half of the mask
279-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
279+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
280280
uint8x8_t inc = simdjson_make_uint8x8_t(0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08);
281281
#else
282282
uint8x8_t inc = {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
@@ -328,7 +328,7 @@ namespace {
328328
// Array constructor
329329
simdjson_inline simd8(const int8_t* values) : simd8(load(values)) {}
330330
// Member-by-member initialization
331-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
331+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
332332
simdjson_inline simd8(
333333
int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7,
334334
int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15
@@ -449,7 +449,7 @@ namespace {
449449
}
450450

451451
simdjson_inline uint64_t to_bitmask() const {
452-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
452+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
453453
const uint8x16_t bit_mask = simdjson_make_uint8x16_t(
454454
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
455455
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80

singleheader/simdjson.cpp

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ using std::size_t;
124124
#ifdef __clang__
125125
// clang under visual studio
126126
#define SIMDJSON_CLANG_VISUAL_STUDIO 1
127+
#define SIMDJSON_REGULAR_VISUAL_STUDIO 0
127128
#else
128129
// just regular visual studio (best guess)
130+
#define SIMDJSON_CLANG_VISUAL_STUDIO 0
129131
#define SIMDJSON_REGULAR_VISUAL_STUDIO 1
130132
#endif // __clang__
133+
#else
134+
#define SIMDJSON_VISUAL_STUDIO 0
131135
#endif // _MSC_VER
132136

133137
#if (defined(__x86_64__) || defined(_M_AMD64)) && !defined(_M_ARM64EC)
@@ -158,6 +162,26 @@ using std::size_t;
158162
#define SIMDJSON_IS_32BITS 0
159163
#endif
160164

165+
#ifndef SIMDJSON_IS_X86_64
166+
#define SIMDJSON_IS_X86_64 0
167+
#endif
168+
169+
#ifndef SIMDJSON_IS_ARM64
170+
#define SIMDJSON_IS_ARM64 0
171+
#endif
172+
173+
#ifndef SIMDJSON_IS_RISCV64
174+
#define SIMDJSON_IS_RISCV64 0
175+
#endif
176+
177+
#ifndef SIMDJSON_IS_LOONGARCH64
178+
#define SIMDJSON_IS_LOONGARCH64 0
179+
#endif
180+
181+
#ifndef SIMDJSON_IS_PPC64_VMX
182+
#define SIMDJSON_IS_PPC64_VMX 0
183+
#endif
184+
161185
#if SIMDJSON_IS_32BITS
162186
#ifndef SIMDJSON_NO_PORTABILITY_WARNING
163187
// In the future, we should allow programmers
@@ -7788,7 +7812,7 @@ SIMDJSON_NO_SANITIZE_UNDEFINED
77887812
// See issue https://github.com/simdjson/simdjson/issues/1965
77897813
SIMDJSON_NO_SANITIZE_MEMORY
77907814
simdjson_inline int trailing_zeroes(uint64_t input_num) {
7791-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
7815+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
77927816
unsigned long ret;
77937817
// Search the mask data from least significant bit (LSB)
77947818
// to the most significant bit (MSB) for a set bit (1).
@@ -7812,7 +7836,7 @@ simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
78127836
SIMDJSON_NO_SANITIZE_UNDEFINED
78137837
/* result might be undefined when input_num is zero */
78147838
simdjson_inline int leading_zeroes(uint64_t input_num) {
7815-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
7839+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
78167840
unsigned long leading_zero = 0;
78177841
// Search the mask data from most significant bit (MSB)
78187842
// to least significant bit (LSB) for a set bit (1).
@@ -7865,7 +7889,7 @@ simdjson_inline uint64_t zero_leading_bit(uint64_t rev_bits, int leading_zeroes)
78657889
#endif
78667890

78677891
simdjson_inline bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
7868-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
7892+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
78697893
*result = value1 + value2;
78707894
return *result < value1;
78717895
#else
@@ -8008,7 +8032,7 @@ namespace arm64 {
80088032
namespace {
80098033
namespace simd {
80108034

8011-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
8035+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
80128036
namespace {
80138037
// Start of private section with Visual Studio workaround
80148038

@@ -8117,7 +8141,7 @@ namespace {
81178141
// We return uint32_t instead of uint16_t because that seems to be more efficient for most
81188142
// purposes (cutting it down to uint16_t costs performance in some compilers).
81198143
simdjson_inline uint32_t to_bitmask() const {
8120-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
8144+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
81218145
const uint8x16_t bit_mask = simdjson_make_uint8x16_t(0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
81228146
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
81238147
#else
@@ -8148,7 +8172,7 @@ namespace {
81488172
// Splat constructor
81498173
simdjson_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
81508174
// Member-by-member initialization
8151-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
8175+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
81528176
simdjson_inline simd8(
81538177
uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7,
81548178
uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15
@@ -8242,7 +8266,7 @@ namespace {
82428266
uint64x2_t shufmask64 = {thintable_epi8[mask1], thintable_epi8[mask2]};
82438267
uint8x16_t shufmask = vreinterpretq_u8_u64(shufmask64);
82448268
// we increment by 0x08 the second half of the mask
8245-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
8269+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
82468270
uint8x16_t inc = simdjson_make_uint8x16_t(0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08);
82478271
#else
82488272
uint8x16_t inc = {0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
@@ -8272,7 +8296,7 @@ namespace {
82728296
uint8x8_t compactmask1 = vcreate_u8(thintable_epi8[mask1]);
82738297
uint8x8_t compactmask2 = vcreate_u8(thintable_epi8[mask2]);
82748298
// we increment by 0x08 the second half of the mask
8275-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
8299+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
82768300
uint8x8_t inc = simdjson_make_uint8x8_t(0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08);
82778301
#else
82788302
uint8x8_t inc = {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
@@ -8324,7 +8348,7 @@ namespace {
83248348
// Array constructor
83258349
simdjson_inline simd8(const int8_t* values) : simd8(load(values)) {}
83268350
// Member-by-member initialization
8327-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
8351+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
83288352
simdjson_inline simd8(
83298353
int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7,
83308354
int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15
@@ -8445,7 +8469,7 @@ namespace {
84458469
}
84468470

84478471
simdjson_inline uint64_t to_bitmask() const {
8448-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
8472+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
84498473
const uint8x16_t bit_mask = simdjson_make_uint8x16_t(
84508474
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
84518475
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80
@@ -10555,7 +10579,7 @@ SIMDJSON_NO_SANITIZE_UNDEFINED
1055510579
// See issue https://github.com/simdjson/simdjson/issues/1965
1055610580
SIMDJSON_NO_SANITIZE_MEMORY
1055710581
simdjson_inline int trailing_zeroes(uint64_t input_num) {
10558-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
10582+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1055910583
unsigned long ret;
1056010584
// Search the mask data from least significant bit (LSB)
1056110585
// to the most significant bit (MSB) for a set bit (1).
@@ -10579,7 +10603,7 @@ simdjson_inline uint64_t clear_lowest_bit(uint64_t input_num) {
1057910603
SIMDJSON_NO_SANITIZE_UNDEFINED
1058010604
/* result might be undefined when input_num is zero */
1058110605
simdjson_inline int leading_zeroes(uint64_t input_num) {
10582-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
10606+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1058310607
unsigned long leading_zero = 0;
1058410608
// Search the mask data from most significant bit (MSB)
1058510609
// to least significant bit (LSB) for a set bit (1).
@@ -10632,7 +10656,7 @@ simdjson_inline uint64_t zero_leading_bit(uint64_t rev_bits, int leading_zeroes)
1063210656
#endif
1063310657

1063410658
simdjson_inline bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *result) {
10635-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
10659+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1063610660
*result = value1 + value2;
1063710661
return *result < value1;
1063810662
#else
@@ -10775,7 +10799,7 @@ namespace arm64 {
1077510799
namespace {
1077610800
namespace simd {
1077710801

10778-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
10802+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1077910803
namespace {
1078010804
// Start of private section with Visual Studio workaround
1078110805

@@ -10884,7 +10908,7 @@ namespace {
1088410908
// We return uint32_t instead of uint16_t because that seems to be more efficient for most
1088510909
// purposes (cutting it down to uint16_t costs performance in some compilers).
1088610910
simdjson_inline uint32_t to_bitmask() const {
10887-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
10911+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1088810912
const uint8x16_t bit_mask = simdjson_make_uint8x16_t(0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
1088910913
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
1089010914
#else
@@ -10915,7 +10939,7 @@ namespace {
1091510939
// Splat constructor
1091610940
simdjson_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
1091710941
// Member-by-member initialization
10918-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
10942+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1091910943
simdjson_inline simd8(
1092010944
uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3, uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7,
1092110945
uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11, uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15
@@ -11009,7 +11033,7 @@ namespace {
1100911033
uint64x2_t shufmask64 = {thintable_epi8[mask1], thintable_epi8[mask2]};
1101011034
uint8x16_t shufmask = vreinterpretq_u8_u64(shufmask64);
1101111035
// we increment by 0x08 the second half of the mask
11012-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
11036+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1101311037
uint8x16_t inc = simdjson_make_uint8x16_t(0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08);
1101411038
#else
1101511039
uint8x16_t inc = {0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
@@ -11039,7 +11063,7 @@ namespace {
1103911063
uint8x8_t compactmask1 = vcreate_u8(thintable_epi8[mask1]);
1104011064
uint8x8_t compactmask2 = vcreate_u8(thintable_epi8[mask2]);
1104111065
// we increment by 0x08 the second half of the mask
11042-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
11066+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1104311067
uint8x8_t inc = simdjson_make_uint8x8_t(0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08);
1104411068
#else
1104511069
uint8x8_t inc = {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08};
@@ -11091,7 +11115,7 @@ namespace {
1109111115
// Array constructor
1109211116
simdjson_inline simd8(const int8_t* values) : simd8(load(values)) {}
1109311117
// Member-by-member initialization
11094-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
11118+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1109511119
simdjson_inline simd8(
1109611120
int8_t v0, int8_t v1, int8_t v2, int8_t v3, int8_t v4, int8_t v5, int8_t v6, int8_t v7,
1109711121
int8_t v8, int8_t v9, int8_t v10, int8_t v11, int8_t v12, int8_t v13, int8_t v14, int8_t v15
@@ -11212,7 +11236,7 @@ namespace {
1121211236
}
1121311237

1121411238
simdjson_inline uint64_t to_bitmask() const {
11215-
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
11239+
#if SIMDJSON_REGULAR_VISUAL_STUDIO
1121611240
const uint8x16_t bit_mask = simdjson_make_uint8x16_t(
1121711241
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80,
1121811242
0x01, 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80

0 commit comments

Comments
 (0)