patch by Jeffrey Yasskin for porting to Ubuntu Hardy. Everything was accepted except there were some bug fixes needed in <locale> for the __nolocale_* series. For the apple branch I ended up using templates instead of the var_args solution because it seemed both safer and more efficient.
llvm-svn: 104516
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 128ba7191da78d948b72b9c7adddc37002b391ef
diff --git a/src/thread.cpp b/src/thread.cpp
index 4a7904d..2a6b205 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -15,7 +15,7 @@
thread::~thread()
{
- if (__t_ != nullptr)
+ if (__t_ != 0)
terminate();
}
@@ -25,7 +25,7 @@
int ec = pthread_join(__t_, 0);
if (ec)
throw system_error(error_code(ec, system_category()), "thread::join failed");
- __t_ = nullptr;
+ __t_ = 0;
}
void
@@ -45,11 +45,17 @@
unsigned
thread::hardware_concurrency()
{
+#if defined(CTL_HW) && defined(HW_NCPU)
int n;
int mib[2] = {CTL_HW, HW_NCPU};
std::size_t s = sizeof(n);
sysctl(mib, 2, &n, &s, 0, 0);
return n;
+#else // !defined(CTL_HW && HW_NCPU)
+ // TODO: grovel through /proc or check cpuid on x86 and similar
+ // instructions on other architectures.
+ return 0; // Means not computable [thread.thread.static]
+#endif
}
namespace this_thread