]> git.sesse.net Git - stockfish/blobdiff - src/bitboard.h
Introduce make_castle_right() helper
[stockfish] / src / bitboard.h
index 6f3a0048226eb620e6e9c07d9c4185145ad27b68..294025b5266fb9f76aab1181a4ef3583ee8edf90 100644 (file)
 
 #include "types.h"
 
+namespace Bitboards {
+
+extern void init();
+extern void print(Bitboard b);
+
+}
+
 CACHE_LINE_ALIGNMENT
 
 extern Bitboard RMasks[64];
@@ -224,9 +231,15 @@ inline bool single_bit(Bitboard b) {
 #if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
 
 FORCE_INLINE Square first_1(Bitboard b) {
-   unsigned long index;
-   _BitScanForward64(&index, b);
-   return (Square) index;
+  unsigned long index;
+  _BitScanForward64(&index, b);
+  return (Square) index;
+}
+
+FORCE_INLINE Square last_1(Bitboard b) {
+  unsigned long index;
+  _BitScanReverse64(&index, b);
+  return (Square) index;
 }
 #else
 
@@ -235,6 +248,12 @@ FORCE_INLINE Square first_1(Bitboard b) { // Assembly code by Heinz van Saanen
   __asm__("bsfq %1, %0": "=r"(dummy): "rm"(b) );
   return (Square) dummy;
 }
+
+FORCE_INLINE Square last_1(Bitboard b) {
+  Bitboard dummy;
+  __asm__("bsrq %1, %0": "=r"(dummy): "rm"(b) );
+  return (Square) dummy;
+}
 #endif
 
 FORCE_INLINE Square pop_1st_bit(Bitboard* b) {
@@ -246,12 +265,9 @@ FORCE_INLINE Square pop_1st_bit(Bitboard* b) {
 #else // if !defined(USE_BSFQ)
 
 extern Square first_1(Bitboard b);
+extern Square last_1(Bitboard b);
 extern Square pop_1st_bit(Bitboard* b);
 
 #endif
 
-
-extern void print_bitboard(Bitboard b);
-extern void bitboards_init();
-
 #endif // !defined(BITBOARD_H_INCLUDED)