diff options
Diffstat (limited to 'system/lib/libcxx/thread.cpp')
-rw-r--r-- | system/lib/libcxx/thread.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/system/lib/libcxx/thread.cpp b/system/lib/libcxx/thread.cpp index 76af3d0c..338a8a24 100644 --- a/system/lib/libcxx/thread.cpp +++ b/system/lib/libcxx/thread.cpp @@ -14,13 +14,19 @@ #include "limits" #include <sys/types.h> #if !defined(_WIN32) -#if !defined(__sun__) && !defined(__linux__) +#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) #include <sys/sysctl.h> -#else +#endif // !__sun__ && !__linux__ && !_AIX #include <unistd.h> -#endif // !__sun__ && !__linux__ #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() @@ -36,6 +42,8 @@ thread::join() #ifndef _LIBCPP_NO_EXCEPTIONS if (ec) throw system_error(error_code(ec, system_category()), "thread::join failed"); +#else + (void)ec; #endif // _LIBCPP_NO_EXCEPTIONS __t_ = 0; } @@ -65,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. @@ -74,9 +82,18 @@ 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. +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("hardware_concurrency not yet implemented") +# else +# warning hardware_concurrency not yet implemented +# endif return 0; // Means not computable [thread.thread.static] #endif // defined(CTL_HW) && defined(HW_NCPU) } |