Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions src/isadetection.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,20 @@ static inline uint32_t croaring_detect_supported_architectures(void) {

#endif // CROARING_IS_X64 || CROARING_IS_ARM64

// The cached result of croaring_hardware_support(), which threads calling it
// for the first time all write.
#if CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_CPP
typedef std::atomic<int> croaring_atomic_int;
#define CROARING_SUPPORT_UNKNOWN \
{ 0xFFFFFFF } // no copy before C++17
#elif CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_C
typedef _Atomic int croaring_atomic_int;
#define CROARING_SUPPORT_UNKNOWN 0xFFFFFFF
#else
typedef int croaring_atomic_int;
#define CROARING_SUPPORT_UNKNOWN 0xFFFFFFF
#endif

#if CROARING_IS_X64 // x64

#ifdef ROARING_DISABLE_AVX
Expand All @@ -379,11 +393,7 @@ int croaring_hardware_support(void) {
#elif defined(__AVX2__)

int croaring_hardware_support(void) {
static
#if CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_C
_Atomic
#endif
int support = 0xFFFFFFF;
static croaring_atomic_int support = CROARING_SUPPORT_UNKNOWN;
if (support == 0xFFFFFFF) {
bool avx512_support = false;
#if CROARING_COMPILER_SUPPORTS_AVX512
Expand All @@ -399,11 +409,7 @@ int croaring_hardware_support(void) {
#else

int croaring_hardware_support(void) {
static
#if CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_C
_Atomic
#endif
int support = 0xFFFFFFF;
static croaring_atomic_int support = CROARING_SUPPORT_UNKNOWN;
if (support == 0xFFFFFFF) {
bool has_avx2 = (croaring_detect_supported_architectures() &
CROARING_AVX2) == CROARING_AVX2;
Expand All @@ -424,11 +430,7 @@ int croaring_hardware_support(void) {
#if CROARING_IS_ARM64

int croaring_hardware_support(void) {
static
#if CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_C
_Atomic
#endif
int support = 0xFFFFFFF;
static croaring_atomic_int support = CROARING_SUPPORT_UNKNOWN;
if (support == 0xFFFFFFF) {
uint32_t isa = croaring_detect_supported_architectures();
support = ((isa & CROARING_SVE) ? ROARING_SUPPORTS_SVE : 0) |
Expand Down
Loading