From b18165e704640ab7c4e2798529e0829bfbd29c3c Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 7 Feb 2013 18:48:09 +0000 Subject: [PATCH] Belt and suspenders when calling sysconf git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@174642 91177308-0d34-0410-b5e6-96231b3b80d8 --- src/thread.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/thread.cpp b/src/thread.cpp index 184d81e6..447eca7b 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -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(result); #else // defined(CTL_HW) && defined(HW_NCPU)