X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=7c4a55f00f4a98b9d864b5c924d3a837951d476c;hp=cd6c280c8c444d9e349c1895b4c792ef8325d77d;hb=c014444f09ace05e908909d9c5c60127e998b538;hpb=c556fe1d716fcef3215c239f02b314ec7b42f0d1 diff --git a/src/bitboard.h b/src/bitboard.h index cd6c280c..7c4a55f0 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -21,9 +21,9 @@ #ifndef BITBOARD_H_INCLUDED #define BITBOARD_H_INCLUDED -#include "types.h" +#include -extern Bitboard pext(Bitboard b, Bitboard mask); +#include "types.h" namespace Bitboards { @@ -57,8 +57,6 @@ const Bitboard Rank6BB = Rank1BB << (8 * 5); const Bitboard Rank7BB = Rank1BB << (8 * 6); const Bitboard Rank8BB = Rank1BB << (8 * 7); -CACHE_LINE_ALIGNMENT - extern Bitboard RMasks[SQUARE_NB]; extern Bitboard RMagics[SQUARE_NB]; extern Bitboard* RAttacks[SQUARE_NB]; @@ -114,17 +112,12 @@ inline bool more_than_one(Bitboard b) { return b & (b - 1); } -inline int square_distance(Square s1, Square s2) { - return SquareDistance[s1][s2]; -} +template inline int distance(T x, T y) { return x < y ? y - x : x - y; } +template<> inline int distance(Square x, Square y) { return SquareDistance[x][y]; } -inline int file_distance(Square s1, Square s2) { - return abs(file_of(s1) - file_of(s2)); -} - -inline int rank_distance(Square s1, Square s2) { - return abs(rank_of(s1) - rank_of(s2)); -} +template inline int distance(T2 x, T2 y); +template<> inline int distance(Square x, Square y) { return distance(file_of(x), file_of(y)); } +template<> inline int distance(Square x, Square y) { return distance(rank_of(x), rank_of(y)); } /// shift_bb() moves bitboard one step along direction Delta. Mainly for pawns. @@ -244,7 +237,7 @@ FORCE_INLINE unsigned magic_index(Square s, Bitboard occ) { unsigned* const Shifts = Pt == ROOK ? RShifts : BShifts; if (HasPext) - return unsigned(pext(occ, Masks[s])); + return unsigned(_pext_u64(occ, Masks[s])); if (Is64Bit) return unsigned(((occ & Masks[s]) * Magics[s]) >> Shifts[s]);