X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=4c7c948a8d28d0dfa9e8bc8c08f88471797b2b9d;hp=d187102ff1bf17914dd806c250b85bf8d757049f;hb=ab65d3fd0ecf340842408548bc7f3e6c28ad4c85;hpb=9793fa1906cc204fc2a520ebb8dd3093f7fc7e40 diff --git a/src/bitboard.h b/src/bitboard.h index d187102f..4c7c948a 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -25,8 +25,15 @@ namespace Bitboards { -extern void init(); -extern void print(Bitboard b); +void init(); +void print(Bitboard b); + +} + +namespace Bitbases { + +void init_kpk(); +uint32_t probe_kpk(Square wksq, Square wpsq, Square bksq, Color stm); } @@ -221,51 +228,52 @@ inline Bitboard attacks_bb(Square s, Bitboard occ) { } -/// first_1() finds the least significant nonzero bit in a nonzero bitboard. -/// pop_1st_bit() finds and clears the least significant nonzero bit in a -/// nonzero bitboard. +/// lsb()/msb() finds the least/most significant bit in a nonzero bitboard. +/// pop_lsb() finds and clears the least significant bit in a nonzero bitboard. #if defined(USE_BSFQ) -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +# if defined(_MSC_VER) && !defined(__INTEL_COMPILER) -FORCE_INLINE Square first_1(Bitboard b) { +FORCE_INLINE Square lsb(Bitboard b) { unsigned long index; _BitScanForward64(&index, b); return (Square) index; } -FORCE_INLINE Square last_1(Bitboard b) { +FORCE_INLINE Square msb(Bitboard b) { unsigned long index; _BitScanReverse64(&index, b); return (Square) index; } -#else -FORCE_INLINE Square first_1(Bitboard b) { // Assembly code by Heinz van Saanen - Bitboard dummy; - __asm__("bsfq %1, %0": "=r"(dummy): "rm"(b) ); - return (Square) dummy; +# else + +FORCE_INLINE Square lsb(Bitboard b) { // Assembly code by Heinz van Saanen + Bitboard index; + __asm__("bsfq %1, %0": "=r"(index): "rm"(b) ); + return (Square) index; } -FORCE_INLINE Square last_1(Bitboard b) { - Bitboard dummy; - __asm__("bsrq %1, %0": "=r"(dummy): "rm"(b) ); - return (Square) dummy; +FORCE_INLINE Square msb(Bitboard b) { + Bitboard index; + __asm__("bsrq %1, %0": "=r"(index): "rm"(b) ); + return (Square) index; } -#endif -FORCE_INLINE Square pop_1st_bit(Bitboard* b) { - const Square s = first_1(*b); - *b &= ~(1ULL<