From: Marco Costalba Date: Fri, 14 Sep 2012 07:42:59 +0000 (+0200) Subject: Fix MSVC 2012 64bits warnings X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=afcee1e8a4aadb9c86e17c71d5943d03268ca6d6 Fix MSVC 2012 64bits warnings Reported by Rein. No functional change. --- diff --git a/src/benchmark.cpp b/src/benchmark.cpp index f59ded73..f63cb8e9 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -111,7 +111,7 @@ void benchmark(const Position& current, istream& is) { int64_t nodes = 0; Search::StateStackPtr st; - Time::point t = Time::now(); + Time::point elapsed = Time::now(); for (size_t i = 0; i < fens.size(); i++) { @@ -133,10 +133,10 @@ void benchmark(const Position& current, istream& is) { } } - int e = Time::now() - t + 1; // Assure positive to avoid a 'divide by zero' + elapsed = Time::now() - elapsed + 1; // Assure positive to avoid a 'divide by zero' cerr << "\n===========================" - << "\nTotal time (ms) : " << e + << "\nTotal time (ms) : " << elapsed << "\nNodes searched : " << nodes - << "\nNodes/second : " << 1000 * nodes / e << endl; + << "\nNodes/second : " << 1000 * nodes / elapsed << endl; } diff --git a/src/notation.cpp b/src/notation.cpp index c4d1c439..fb65f6f5 100644 --- a/src/notation.cpp +++ b/src/notation.cpp @@ -186,14 +186,14 @@ const string move_to_san(Position& pos, Move m) { /// appended to the search log file. It uses the two helpers below to pretty /// format time and score respectively. -static string time_to_string(int millisecs) { +static string time_to_string(int64_t msecs) { const int MSecMinute = 1000 * 60; const int MSecHour = 1000 * 60 * 60; - int hours = millisecs / MSecHour; - int minutes = (millisecs % MSecHour) / MSecMinute; - int seconds = ((millisecs % MSecHour) % MSecMinute) / 1000; + int64_t hours = msecs / MSecHour; + int64_t minutes = (msecs % MSecHour) / MSecMinute; + int64_t seconds = ((msecs % MSecHour) % MSecMinute) / 1000; stringstream s; @@ -221,7 +221,7 @@ static string score_to_string(Value v) { return s.str(); } -string pretty_pv(Position& pos, int depth, Value value, int time, Move pv[]) { +string pretty_pv(Position& pos, int depth, Value value, int64_t msecs, Move pv[]) { const int64_t K = 1000; const int64_t M = 1000000; @@ -234,7 +234,7 @@ string pretty_pv(Position& pos, int depth, Value value, int time, Move pv[]) { s << setw(2) << depth << setw(8) << score_to_string(value) - << setw(8) << time_to_string(time); + << setw(8) << time_to_string(msecs); if (pos.nodes_searched() < M) s << setw(8) << pos.nodes_searched() / 1 << " "; diff --git a/src/notation.h b/src/notation.h index 5c23a2ce..0c5f2fed 100644 --- a/src/notation.h +++ b/src/notation.h @@ -30,6 +30,6 @@ std::string score_to_uci(Value v, Value alpha = -VALUE_INFINITE, Value beta = VA Move move_from_uci(const Position& pos, std::string& str); const std::string move_to_uci(Move m, bool chess960); const std::string move_to_san(Position& pos, Move m); -std::string pretty_pv(Position& pos, int depth, Value score, int time, Move pv[]); +std::string pretty_pv(Position& pos, int depth, Value score, int64_t msecs, Move pv[]); #endif // !defined(NOTATION_H_INCLUDED) diff --git a/src/search.cpp b/src/search.cpp index 1cf9428e..219c10aa 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -290,11 +290,11 @@ void Search::think() { if (Options["Use Search Log"]) { - int e = Time::now() - SearchTime; + Time::point elapsed = Time::now() - SearchTime + 1; Log log(Options["Search Log Filename"]); log << "Nodes: " << pos.nodes_searched() - << "\nNodes/second: " << (e > 0 ? pos.nodes_searched() * 1000 / e : 0) + << "\nNodes/second: " << pos.nodes_searched() * 1000 / elapsed << "\nBest move: " << move_to_san(pos, RootMoves[0].pv[0]); StateInfo st; @@ -1536,7 +1536,7 @@ split_point_start: // At split points actual search starts from here string uci_pv(const Position& pos, int depth, Value alpha, Value beta) { std::stringstream s; - int t = Time::now() - SearchTime; + Time::point elaspsed = Time::now() - SearchTime + 1; int selDepth = 0; for (size_t i = 0; i < Threads.size(); i++) @@ -1557,12 +1557,12 @@ split_point_start: // At split points actual search starts from here s << "\n"; s << "info depth " << d - << " seldepth " << selDepth - << " score " << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v)) - << " nodes " << pos.nodes_searched() - << " nps " << (t > 0 ? pos.nodes_searched() * 1000 / t : 0) - << " time " << t - << " multipv " << i + 1 + << " seldepth " << selDepth + << " score " << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v)) + << " nodes " << pos.nodes_searched() + << " nps " << pos.nodes_searched() * 1000 / elaspsed + << " time " << elaspsed + << " multipv " << i + 1 << " pv"; for (size_t j = 0; RootMoves[i].pv[j] != MOVE_NONE; j++) @@ -1760,15 +1760,15 @@ void check_time() { if (Limits.ponder) return; - int e = Time::now() - SearchTime; + Time::point elapsed = Time::now() - SearchTime; bool stillAtFirstMove = Signals.firstRootMove && !Signals.failedLowAtRoot - && e > TimeMgr.available_time(); + && elapsed > TimeMgr.available_time(); - bool noMoreTime = e > TimeMgr.maximum_time() - 2 * TimerResolution + bool noMoreTime = elapsed > TimeMgr.maximum_time() - 2 * TimerResolution || stillAtFirstMove; if ( (Limits.use_time_management() && noMoreTime) - || (Limits.movetime && e >= Limits.movetime)) + || (Limits.movetime && elapsed >= Limits.movetime)) Signals.stop = true; }