From 54b5b528d9ef6c4f14a2000eead9a5c0686f899e Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Tue, 20 Jan 2015 22:17:22 +0100 Subject: [PATCH] Don't use _pext_u64() directly This intrinsic to call BMI2 PEXT instruction is defined in immintrin.h. This header should be included only when USE_PEXT is defined, otherwise we define _pext_u64 as 0 forcing a nop. But under some mingw platforms, even if we don't include the header, immintrin.h gets included anyhow through an include chain that starts with STL header. So we end up both defining _pext_u64 function and at the same time defining _pext_u64 as 0 leading to a compile error. The correct solution is of not using _pext_u64 directly. This patch fixes a compile error with some mingw64 package when compiling with x86-64. No functional change. Resolves #222 --- src/bitboard.cpp | 2 +- src/bitboard.h | 2 +- src/types.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 4a0e275b..32efaeda 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -275,7 +275,7 @@ namespace { reference[size] = sliding_attack(deltas, s, b); if (HasPext) - attacks[s][_pext_u64(b, masks[s])] = reference[size]; + attacks[s][pext(b, masks[s])] = reference[size]; size++; b = (b - masks[s]) & masks[s]; diff --git a/src/bitboard.h b/src/bitboard.h index 38ddc619..aa4e1711 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -238,7 +238,7 @@ FORCE_INLINE unsigned magic_index(Square s, Bitboard occupied) { unsigned* const Shifts = Pt == ROOK ? RookShifts : BishopShifts; if (HasPext) - return unsigned(_pext_u64(occupied, Masks[s])); + return unsigned(pext(occupied, Masks[s])); if (Is64Bit) return unsigned(((occupied & Masks[s]) * Magics[s]) >> Shifts[s]); diff --git a/src/types.h b/src/types.h index 2d769630..7c5776ab 100644 --- a/src/types.h +++ b/src/types.h @@ -65,8 +65,9 @@ #if defined(USE_PEXT) # include // Header for _pext_u64() intrinsic +# define pext(b, m) _pext_u64(b, m) #else -# define _pext_u64(b, m) (0) +# define pext(b, m) (0) #endif #ifdef _MSC_VER -- 2.39.2