]> granicus.if.org Git - llvm/commitdiff
[FuzzerUtil] Partially revert D38481 on FuzzerUtil
authorTim Shen <timshen91@gmail.com>
Wed, 4 Oct 2017 01:05:34 +0000 (01:05 +0000)
committerTim Shen <timshen91@gmail.com>
Wed, 4 Oct 2017 01:05:34 +0000 (01:05 +0000)
This is because lib/Fuzzer doesn't really depend on llvm infrastucture.
It's not easy to access the llvm hardware_concurrency here.

Differential Reivision: https://reviews.llvm.org/D38481

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314870 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerUtil.cpp

index 5f76ddc3678631a230f2cd5456dc56abb94334de..f5a7773744932b82411b0cfcdb40259d716755fc 100644 (file)
@@ -195,7 +195,15 @@ void PrintPC(const char *SymbolizedFMT, const char *FallbackFMT, uintptr_t PC) {
     Printf(FallbackFMT, PC);
 }
 
-unsigned NumberOfCpuCores() { return hardware_concurrency(); }
+unsigned NumberOfCpuCores() {
+  unsigned N = std::thread::hardware_concurrency();
+  if (!N) {
+    Printf("WARNING: std::thread::hardware_concurrency not well defined for "
+           "your platform. Assuming CPU count of 1.\n");
+    N = 1;
+  }
+  return N;
+}
 
 size_t SimpleFastHash(const uint8_t *Data, size_t Size) {
   size_t Res = 0;