Belt and suspenders when calling sysconf
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@174642 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d854ce6bfa
commit
b18165e704
@ -69,7 +69,9 @@ thread::hardware_concurrency() _NOEXCEPT
|
|||||||
long result = sysconf(_SC_NPROCESSORS_ONLN);
|
long result = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
// sysconf returns -1 if the name is invalid, the option does not exist or
|
// sysconf returns -1 if the name is invalid, the option does not exist or
|
||||||
// does not have a definite limit.
|
// 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 0;
|
||||||
return static_cast<unsigned>(result);
|
return static_cast<unsigned>(result);
|
||||||
#else // defined(CTL_HW) && defined(HW_NCPU)
|
#else // defined(CTL_HW) && defined(HW_NCPU)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user