[libcxx] r174642 - Belt and suspenders when calling sysconf
Marshall Clow
mclow at qualcomm.com
Thu Feb 7 10:48:09 PST 2013
Author: marshall
Date: Thu Feb 7 12:48:09 2013
New Revision: 174642
URL: http://llvm.org/viewvc/llvm-project?rev=174642&view=rev
Log:
Belt and suspenders when calling sysconf
Modified:
libcxx/trunk/src/thread.cpp
Modified: libcxx/trunk/src/thread.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=174642&r1=174641&r2=174642&view=diff
==============================================================================
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Thu Feb 7 12:48:09 2013
@@ -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)
More information about the cfe-commits
mailing list