aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-11-18 19:55:24 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-11-18 19:55:24 +0000
commit991f6e7534a9b1a99b7da711676e6714e2cf6680 (patch)
treebf212c2d511994c4ede69fae010c77c65b7c9b88
parent1463aa8cf25173f8dca62c1fa84a16e9664eefc0 (diff)
Notes
-rw-r--r--contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc11
1 files changed, 11 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc b/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc
index 2d0aacabf092..df290d2262ea 100644
--- a/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc
+++ b/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc
@@ -26,6 +26,10 @@
#include <pthread_np.h> // For pthread_getthreadid_np() / pthread_set_name_np()
#endif
+#if defined(__FreeBSD__)
+#include <sys/cpuset.h>
+#endif
+
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <errno.h>
#include <sys/sysctl.h>
@@ -282,6 +286,13 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
#include <thread>
int computeHostNumHardwareThreads() {
+#ifdef __FreeBSD__
+ cpuset_t mask;
+ CPU_ZERO(&mask);
+ if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(mask),
+ &mask) == 0)
+ return CPU_COUNT(&mask);
+#endif
#ifdef __linux__
cpu_set_t Set;
if (sched_getaffinity(0, sizeof(Set), &Set) == 0)