diff options
author | Zachary Turner <zturner@google.com> | 2017-03-03 17:39:24 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-03-03 17:39:24 +0000 |
commit | 91db01fa6ce5d93073fb9d19f8ee877e959e5096 (patch) | |
tree | 01b309ec4671fd4839b7bc6d3f5ff0021ecffb06 /llvm/lib/Support/Threading.cpp | |
parent | bdfcc716b969228e118834871d28aed0f8d5e776 (diff) | |
download | bcm5719-llvm-91db01fa6ce5d93073fb9d19f8ee877e959e5096.tar.gz bcm5719-llvm-91db01fa6ce5d93073fb9d19f8ee877e959e5096.zip |
Don't bring in llvm/Support/thread.h in Threading.cpp
Doing so defines the type llvm::thread. On FreeBSD, we need
to call a macro which references its own ::thread type, which
causes an ambiguity due to ADL when inside of the llvm namespace.
Since we don't even need this unless LLVM_ENABLE_THREADS == 1,
we don't even need this type anyway, as it is always equal to
std::thread, so we can just use that directly.
llvm-svn: 296891
Diffstat (limited to 'llvm/lib/Support/Threading.cpp')
-rw-r--r-- | llvm/lib/Support/Threading.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp index a9ecf9b10bf..2feb16e5d44 100644 --- a/llvm/lib/Support/Threading.cpp +++ b/llvm/lib/Support/Threading.cpp @@ -15,7 +15,6 @@ #include "llvm/Support/Threading.h" #include "llvm/Config/config.h" #include "llvm/Support/Host.h" -#include "llvm/Support/thread.h" #include <cassert> #include <errno.h> @@ -56,10 +55,17 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) { Name.clear(); } #else +#include <thread> unsigned llvm::heavyweight_hardware_concurrency() { + // Since we can't get here unless LLVM_ENABLE_THREADS == 1, it is safe to use + // `std::thread` directly instead of `llvm::thread` (and indeed, doing so + // allows us to not define `thread` in the llvm namespace, which conflicts + // with some platforms such as FreeBSD whose headers also define a struct + // called `thread` in the global namespace which can cause ambiguity due to + // ADL. int NumPhysical = sys::getHostNumPhysicalCores(); if (NumPhysical == -1) - return thread::hardware_concurrency(); + return std::thread::hardware_concurrency(); return NumPhysical; } |