Skip to content

Commit

Permalink
make macros more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed May 10, 2024
1 parent eed1461 commit 1a05dd0
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/is_utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,13 @@ template <typename T> std::string toBinaryString(T b) {
#ifndef IS_UTF8_IMPLEMENTATION_ARM64
#define IS_UTF8_IMPLEMENTATION_ARM64 (IS_UTF8_IS_ARM64)
#endif
#define IS_UTF8_CAN_ALWAYS_RUN_ARM64 \
IS_UTF8_IMPLEMENTATION_ARM64 &&IS_UTF8_IS_ARM64
#if IS_UTF8_IMPLEMENTATION_ARM64 &&IS_UTF8_IS_ARM64
#define IS_UTF8_CAN_ALWAYS_RUN_ARM64 1
#else
#define IS_UTF8_CAN_ALWAYS_RUN_ARM64 0
#endif
#if IS_UTF8_IMPLEMENTATION_ARM64
Expand Down Expand Up @@ -2343,8 +2348,11 @@ IS_UTF8_POP_DISABLE_WARNINGS
#endif
// To see why (__BMI__) && (__PCLMUL__) && (__LZCNT__) are not part of this
// next line, see https://github.com/simdutf/simdutf/issues/1247
#define IS_UTF8_CAN_ALWAYS_RUN_HASWELL \
((IS_UTF8_IMPLEMENTATION_HASWELL) && (IS_UTF8_IS_X86_64) && (__AVX2__))
#if ((IS_UTF8_IMPLEMENTATION_HASWELL) && (IS_UTF8_IS_X86_64) && (__AVX2__))
#define IS_UTF8_CAN_ALWAYS_RUN_HASWELL 1
#else
#define IS_UTF8_CAN_ALWAYS_RUN_HASWELL 0
#endif

#if IS_UTF8_IMPLEMENTATION_HASWELL

Expand Down Expand Up @@ -3343,9 +3351,11 @@ IS_UTF8_UNTARGET_REGION

#endif

#define IS_UTF8_CAN_ALWAYS_RUN_WESTMERE \
(IS_UTF8_IMPLEMENTATION_WESTMERE && IS_UTF8_IS_X86_64 && __SSE4_2__ && \
__PCLMUL__)
#if IS_UTF8_IMPLEMENTATION_WESTMERE && IS_UTF8_IS_X86_64 && __SSE4_2__ && __PCLMUL__
#define IS_UTF8_CAN_ALWAYS_RUN_WESTMERE 1
#else
#define IS_UTF8_CAN_ALWAYS_RUN_WESTMERE 0
#endif

#if IS_UTF8_IMPLEMENTATION_WESTMERE

Expand Down Expand Up @@ -4412,7 +4422,11 @@ IS_UTF8_UNTARGET_REGION
#endif
#endif

#define IS_UTF8_CAN_ALWAYS_RUN_FALLBACK (IS_UTF8_IMPLEMENTATION_FALLBACK)
#if IS_UTF8_IMPLEMENTATION_FALLBACK
#define IS_UTF8_CAN_ALWAYS_RUN_FALLBACK 1
#else
#define IS_UTF8_CAN_ALWAYS_RUN_FALLBACK 0
#endif

#if IS_UTF8_IMPLEMENTATION_FALLBACK

Expand Down

0 comments on commit 1a05dd0

Please sign in to comment.