]> git.sesse.net Git - stockfish/commitdiff
Fix compile error in cpu_count()
authorMarco Costalba <mcostalba@gmail.com>
Mon, 31 Oct 2011 19:03:30 +0000 (20:03 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 31 Oct 2011 19:03:30 +0000 (20:03 +0100)
The std::min() template function requires both arguments
to be of the same type.

But here we have the integer MAX_THREADS compared to a long:

long sysconf(int name);

So cast to integer and fix the compile.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/misc.cpp

index 10c779ed846f4d0a37f146efc636d0e687cbaedf..0920f7f08838b132f7413ee41c2a4229e0c80966 100644 (file)
@@ -161,12 +161,12 @@ int cpu_count() {
 #else
 
 #  if defined(_SC_NPROCESSORS_ONLN)
 #else
 
 #  if defined(_SC_NPROCESSORS_ONLN)
-  return std::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;
 #  elif defined(__hpux)
   struct pst_dynamic psd;
   if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) == -1)
       return 1;
-  return std::min(psd.psd_proc_cnt, MAX_THREADS);
+  return std::min((int)psd.psd_proc_cnt, MAX_THREADS);
 #  else
   return 1;
 #  endif
 #  else
   return 1;
 #  endif