Skip to content

Commit f8fd204

Browse files
committed
hardware_physical_concurrency() should return 1 when LLVM is built with LLVM_ENABLE_THREADS=OFF
llvm-svn: 284283
1 parent 797cb4f commit f8fd204

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

llvm/include/llvm/Support/Threading.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ namespace llvm {
118118

119119
/// Get the amount of currency based on physical cores, if available for the
120120
/// host system, otherwise falls back to thread::hardware_concurrency().
121+
/// Returns 1 when LLVM is configured with LLVM_ENABLE_THREADS=OFF
121122
unsigned hardware_physical_concurrency();
122123
}
123124

llvm/lib/Support/Threading.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
119119
#endif
120120

121121
unsigned llvm::hardware_physical_concurrency() {
122+
#if !LLVM_ENABLE_THREADS
123+
return 1;
124+
#endif
122125
int NumPhysical = sys::getHostNumPhysicalCores();
123126
if (NumPhysical == -1)
124127
return thread::hardware_concurrency();

0 commit comments

Comments
 (0)