mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Fully qualify memset and memcpy
And other trivial touches. Ispired by Lucas's DiscoCheck No functional change.
This commit is contained in:
parent
6960f41e03
commit
4ede49cd85
10 changed files with 20 additions and 22 deletions
|
@ -39,9 +39,9 @@ namespace {
|
|||
// bit 6-11: black king square (from SQ_A1 to SQ_H8)
|
||||
// bit 12: side to move (WHITE or BLACK)
|
||||
// bit 13-14: white pawn file (from FILE_A to FILE_D)
|
||||
// bit 15-17: white pawn 6 - rank (from 6 - RANK_7 to 6 - RANK_2)
|
||||
// bit 15-17: white pawn RANK_7 - rank (from RANK_7 - RANK_7 to RANK_7 - RANK_2)
|
||||
unsigned index(Color us, Square bksq, Square wksq, Square psq) {
|
||||
return wksq + (bksq << 6) + (us << 12) + (file_of(psq) << 13) + ((6 - rank_of(psq)) << 15);
|
||||
return wksq + (bksq << 6) + (us << 12) + (file_of(psq) << 13) + ((RANK_7 - rank_of(psq)) << 15);
|
||||
}
|
||||
|
||||
enum Result {
|
||||
|
@ -107,10 +107,10 @@ namespace {
|
|||
|
||||
Result KPKPosition::classify_leaf(unsigned idx) {
|
||||
|
||||
wksq = Square((idx >> 0) & 0x3F);
|
||||
bksq = Square((idx >> 6) & 0x3F);
|
||||
us = Color((idx >> 12) & 0x01);
|
||||
psq = File((idx >> 13) & 3) | Rank(6 - (idx >> 15));
|
||||
wksq = Square((idx >> 0) & 0x3F);
|
||||
bksq = Square((idx >> 6) & 0x3F);
|
||||
us = Color ((idx >> 12) & 0x01);
|
||||
psq = File ((idx >> 13) & 0x03) | Rank(RANK_7 - (idx >> 15));
|
||||
|
||||
// Check if two pieces are on the same square or if a king can be captured
|
||||
if ( wksq == psq || wksq == bksq || bksq == psq
|
||||
|
|
|
@ -318,7 +318,7 @@ namespace {
|
|||
do magics[s] = pick_random(rk, booster);
|
||||
while (popcount<Max15>((magics[s] * masks[s]) >> 56) < 6);
|
||||
|
||||
memset(attacks[s], 0, size * sizeof(Bitboard));
|
||||
std::memset(attacks[s], 0, size * sizeof(Bitboard));
|
||||
|
||||
// A good magic must map every possible occupancy to an index that
|
||||
// looks up the correct sliding attack in the attacks[s] database.
|
||||
|
|
|
@ -1142,7 +1142,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
|
|||
|
||||
stream.str("");
|
||||
stream << std::showpoint << std::showpos << std::fixed << std::setprecision(2);
|
||||
memset(scores, 0, 2 * (TOTAL + 1) * sizeof(Score));
|
||||
std::memset(scores, 0, 2 * (TOTAL + 1) * sizeof(Score));
|
||||
|
||||
Value margin;
|
||||
do_evaluate<true>(pos, margin);
|
||||
|
|
|
@ -150,7 +150,7 @@ Entry* probe(const Position& pos, Table& entries, Endgames& endgames) {
|
|||
if (e->key == key)
|
||||
return e;
|
||||
|
||||
memset(e, 0, sizeof(Entry));
|
||||
std::memset(e, 0, sizeof(Entry));
|
||||
e->key = key;
|
||||
e->factor[WHITE] = e->factor[BLACK] = (uint8_t)SCALE_FACTOR_NORMAL;
|
||||
e->gamePhase = game_phase(pos);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define MOVEPICK_H_INCLUDED
|
||||
|
||||
#include <algorithm> // For std::max
|
||||
#include <cstring> // For memset
|
||||
#include <cstring> // For std::memset
|
||||
|
||||
#include "movegen.h"
|
||||
#include "position.h"
|
||||
|
@ -43,7 +43,7 @@ struct Stats {
|
|||
static const Value Max = Value(2000);
|
||||
|
||||
const T* operator[](Piece p) const { return table[p]; }
|
||||
void clear() { memset(table, 0, sizeof(table)); }
|
||||
void clear() { std::memset(table, 0, sizeof(table)); }
|
||||
|
||||
void update(Piece p, Square to, Move m) {
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ void Position::init() {
|
|||
|
||||
Position& Position::operator=(const Position& pos) {
|
||||
|
||||
memcpy(this, &pos, sizeof(Position));
|
||||
std::memcpy(this, &pos, sizeof(Position));
|
||||
startState = *st;
|
||||
st = &startState;
|
||||
nodes = 0;
|
||||
|
@ -722,7 +722,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
|||
// Copy some fields of old state to our new StateInfo object except the ones
|
||||
// which are going to be recalculated from scratch anyway, then switch our state
|
||||
// pointer to point to the new, ready to be updated, state.
|
||||
memcpy(&newSt, st, StateCopySize64 * sizeof(uint64_t));
|
||||
std::memcpy(&newSt, st, StateCopySize64 * sizeof(uint64_t));
|
||||
|
||||
newSt.previous = st;
|
||||
st = &newSt;
|
||||
|
@ -1089,7 +1089,7 @@ void Position::do_null_move(StateInfo& newSt) {
|
|||
|
||||
assert(!checkers());
|
||||
|
||||
memcpy(&newSt, st, sizeof(StateInfo)); // Fully copy here
|
||||
std::memcpy(&newSt, st, sizeof(StateInfo)); // Fully copy here
|
||||
|
||||
newSt.previous = st;
|
||||
st = &newSt;
|
||||
|
@ -1239,7 +1239,7 @@ int Position::see(Move m, int asymmThreshold) const {
|
|||
|
||||
void Position::clear() {
|
||||
|
||||
memset(this, 0, sizeof(Position));
|
||||
std::memset(this, 0, sizeof(Position));
|
||||
startState.epSquare = SQ_NONE;
|
||||
st = &startState;
|
||||
|
||||
|
|
|
@ -43,14 +43,12 @@
|
|||
|
||||
class RKISS {
|
||||
|
||||
// Keep variables always together
|
||||
struct S { uint64_t a, b, c, d; } s;
|
||||
struct S { uint64_t a, b, c, d; } s; // Keep variables always together
|
||||
|
||||
uint64_t rotate(uint64_t x, uint64_t k) const {
|
||||
return (x << k) | (x >> (64 - k));
|
||||
}
|
||||
|
||||
// Return 64 bit unsigned integer in between [0, 2^64 - 1]
|
||||
uint64_t rand64() {
|
||||
|
||||
const uint64_t
|
||||
|
|
|
@ -298,7 +298,7 @@ namespace {
|
|||
int depth, prevBestMoveChanges;
|
||||
Value bestValue, alpha, beta, delta;
|
||||
|
||||
memset(ss-1, 0, 4 * sizeof(Stack));
|
||||
std::memset(ss-1, 0, 4 * sizeof(Stack));
|
||||
(ss-1)->currentMove = MOVE_NULL; // Hack to skip update gains
|
||||
|
||||
depth = BestMoveChanges = 0;
|
||||
|
@ -1673,7 +1673,7 @@ void Thread::idle_loop() {
|
|||
Stack stack[MAX_PLY_PLUS_2], *ss = stack+1; // To allow referencing (ss-1)
|
||||
Position pos(*sp->pos, this);
|
||||
|
||||
memcpy(ss-1, sp->ss-1, 4 * sizeof(Stack));
|
||||
std::memcpy(ss-1, sp->ss-1, 4 * sizeof(Stack));
|
||||
ss->splitPoint = sp;
|
||||
|
||||
sp->mutex.lock();
|
||||
|
|
|
@ -79,7 +79,7 @@ struct RootMove {
|
|||
|
||||
struct LimitsType {
|
||||
|
||||
LimitsType() { memset(this, 0, sizeof(LimitsType)); }
|
||||
LimitsType() { std::memset(this, 0, sizeof(LimitsType)); }
|
||||
bool use_time_management() const { return !(mate | movetime | depth | nodes | infinite); }
|
||||
|
||||
int time[COLOR_NB], inc[COLOR_NB], movestogo, depth, nodes, movetime, mate, infinite, ponder;
|
||||
|
|
|
@ -60,7 +60,7 @@ void TranspositionTable::set_size(size_t mbSize) {
|
|||
|
||||
void TranspositionTable::clear() {
|
||||
|
||||
memset(table, 0, (hashMask + ClusterSize) * sizeof(TTEntry));
|
||||
std::memset(table, 0, (hashMask + ClusterSize) * sizeof(TTEntry));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue