Belt and suspenders when calling sysconf

llvm-svn: 174642
This commit is contained in:
Marshall Clow 2013-02-07 18:48:09 +00:00
parent 32dc724920
commit 0749262a11
1 changed files with 3 additions and 1 deletions

View File

@ -69,7 +69,9 @@ thread::hardware_concurrency() _NOEXCEPT
long result = sysconf(_SC_NPROCESSORS_ONLN);
// sysconf returns -1 if the name is invalid, the option does not exist or
// does not have a definite limit.
if (result == -1)
// if sysconf returns some other negative number, we have no idea
// what is going on. Default to something safe.
if (result < 0)
return 0;
return static_cast<unsigned>(result);
#else // defined(CTL_HW) && defined(HW_NCPU)