]> git.sesse.net Git - stockfish/blobdiff - src/misc.cpp
Fix compile error in cpu_count()
[stockfish] / src / misc.cpp
index 2a476504995959074e27b509d4688ec98ecab25b..0920f7f08838b132f7413ee41c2a4229e0c80966 100644 (file)
@@ -29,6 +29,7 @@
 #else
 
 #define _CRT_SECURE_NO_DEPRECATE
+#define NOMINMAX // disable macros min() and max()
 #include <windows.h>
 #include <sys/timeb.h>
 
@@ -43,6 +44,7 @@
 #include <iomanip>
 #include <iostream>
 #include <sstream>
+#include <algorithm>
 
 #include "bitcount.h"
 #include "misc.h"
@@ -54,7 +56,7 @@ using namespace std;
 /// current date (in the format YYMMDD) is used as a version number.
 
 static const string AppName = "Stockfish";
-static const string EngineVersion = "2.1.1";
+static const string EngineVersion = "";
 static const string AppTag  = "";
 
 
@@ -103,14 +105,14 @@ static uint64_t dbg_mean_cnt1;
 void dbg_print_hit_rate() {
 
   if (dbg_hit_cnt0)
-      cout << "Total " << dbg_hit_cnt0 << " Hit " << dbg_hit_cnt1
+      cerr << "Total " << dbg_hit_cnt0 << " Hit " << dbg_hit_cnt1
            << " hit rate (%) " << 100 * dbg_hit_cnt1 / dbg_hit_cnt0 << endl;
 }
 
 void dbg_print_mean() {
 
   if (dbg_mean_cnt0)
-      cout << "Total " << dbg_mean_cnt0 << " Mean "
+      cerr << "Total " << dbg_mean_cnt0 << " Mean "
            << (float)dbg_mean_cnt1 / dbg_mean_cnt0 << endl;
 }
 
@@ -155,16 +157,16 @@ int cpu_count() {
 #if defined(_MSC_VER)
   SYSTEM_INFO s;
   GetSystemInfo(&s);
-  return Min(s.dwNumberOfProcessors, MAX_THREADS);
+  return std::min(int(s.dwNumberOfProcessors), MAX_THREADS);
 #else
 
 #  if defined(_SC_NPROCESSORS_ONLN)
-  return Min(sysconf(_SC_NPROCESSORS_ONLN), MAX_THREADS);
+  return std::min((int)sysconf(_SC_NPROCESSORS_ONLN), MAX_THREADS);
 #  elif defined(__hpux)
   struct pst_dynamic psd;
   if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) == -1)
       return 1;
-  return Min(psd.psd_proc_cnt, MAX_THREADS);
+  return std::min((int)psd.psd_proc_cnt, MAX_THREADS);
 #  else
   return 1;
 #  endif
@@ -232,7 +234,7 @@ int input_available() {
   GetNumberOfConsoleInputEvents(inh, &nchars);
 
   // Read data from console without removing it from the buffer
-  if (nchars <= 0 || !PeekConsoleInput(inh, rec, Min(nchars, 256), &recCnt))
+  if (nchars <= 0 || !PeekConsoleInput(inh, rec, std::min(int(nchars), 256), &recCnt))
       return 0;
 
   // Search for at least one keyboard event