summaryrefslogtreecommitdiffstats
path: root/src/thread.cpp
diff options
context:
space:
mode:
authortheraven <theraven@FreeBSD.org>2013-07-10 10:49:31 +0000
committertheraven <theraven@FreeBSD.org>2013-07-10 10:49:31 +0000
commit30a0ccc9e6a2233c7d9f03028880be3e205fd7d1 (patch)
treeee42ff7378fd2433cb88e1cfa25b2a65035b0c43 /src/thread.cpp
parent8546120978e348b3bed62936eae651837ccbcafd (diff)
downloadFreeBSD-src-30a0ccc9e6a2233c7d9f03028880be3e205fd7d1.zip
FreeBSD-src-30a0ccc9e6a2233c7d9f03028880be3e205fd7d1.tar.gz
Pull new libc++ into vendor branch.
Diffstat (limited to 'src/thread.cpp')
-rw-r--r--src/thread.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/thread.cpp b/src/thread.cpp
index c6f6748..1fd8bb0 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -16,11 +16,17 @@
#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__)
+#pragma weak pthread_create // Do not create libpthread dependency
+#endif
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
_LIBCPP_BEGIN_NAMESPACE_STD
thread::~thread()
@@ -67,7 +73,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.
@@ -76,9 +82,14 @@ thread::hardware_concurrency() _NOEXCEPT
if (result < 0)
return 0;
return static_cast<unsigned>(result);
+#elif defined(_WIN32)
+ SYSTEM_INFO info;
+ GetSystemInfo(&info);
+ return info.dwNumberOfProcessors;
#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