summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-06-30 00:14:43 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-06-30 00:14:43 +0000
commit8bd1771abe44d1027460bcd1d7edcab556f75428 (patch)
treec00b5e3fd16c8d84662360c9d25b71e91dd06e33
parent27841fd803ca0b8c81dcacccddf879b0dafd7f66 (diff)
downloadbcm5719-llvm-8bd1771abe44d1027460bcd1d7edcab556f75428.tar.gz
bcm5719-llvm-8bd1771abe44d1027460bcd1d7edcab556f75428.zip
Matthew Dempsky: POSIX defines that the _POSIX_C_SOURCE macros are to be set by user
code to specify what version of POSIX the system should provide. If you want to check what version of POSIX is actually available, you're supposed to test _POSIX_VERSION. However, since sysconf() has been in POSIX since 1995, it's probably safe to assume it's available on any system with a C++11 compiler, especially if _SC_NPROCESSORS_ONLN is defined too. So no point in a complicated preprocessor rule if just we unconditionally include <unistd.h> (on non-Windows systems). Also, I've added a #warning for to help porters detect when a suitable implementation isn't detected at compile-time. Howard: Matthew, can you patch CREDITS.TXT? Thanks. llvm-svn: 185275
-rw-r--r--libcxx/src/thread.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp
index 2b3729f674d..5bf74140d50 100644
--- a/libcxx/src/thread.cpp
+++ b/libcxx/src/thread.cpp
@@ -16,9 +16,8 @@
#if !defined(_WIN32)
#if !defined(__sun__) && !defined(__linux__)
#include <sys/sysctl.h>
-#else
-#include <unistd.h>
#endif // !__sun__ && !__linux__
+#include <unistd.h>
#endif // !_WIN32
#if defined(__NetBSD__)
@@ -71,7 +70,7 @@ thread::hardware_concurrency() _NOEXCEPT
std::size_t s = sizeof(n);
sysctl(mib, 2, &n, &s, 0, 0);
return n;
-#elif (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && defined(_SC_NPROCESSORS_ONLN)) || defined(EMSCRIPTEN)
+#elif defined(_SC_NPROCESSORS_ONLN)
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.
@@ -83,6 +82,7 @@ thread::hardware_concurrency() _NOEXCEPT
#else // defined(CTL_HW) && defined(HW_NCPU)
// TODO: grovel through /proc or check cpuid on x86 and similar
// instructions on other architectures.
+#warning hardware_concurrency not yet implemented
return 0; // Means not computable [thread.thread.static]
#endif // defined(CTL_HW) && defined(HW_NCPU)
}
OpenPOWER on IntegriCloud