[PATCH] D92271: Implement computeHostNumHardwareThreads() for FreeBSD
Dimitry Andric via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 28 12:44:51 PST 2020
dim updated this revision to Diff 308187.
dim added a comment.
Address comments from review:
- Move FreeBSD specific include under common block
- Use #if #elif #endif for OS specific implementations
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92271/new/
https://reviews.llvm.org/D92271
Files:
llvm/lib/Support/Unix/Threading.inc
Index: llvm/lib/Support/Unix/Threading.inc
===================================================================
--- llvm/lib/Support/Unix/Threading.inc
+++ llvm/lib/Support/Unix/Threading.inc
@@ -26,12 +26,9 @@
#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/cpuset.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <unistd.h>
@@ -286,14 +283,13 @@
#include <thread>
int computeHostNumHardwareThreads() {
-#ifdef __FreeBSD__
+#if defined(__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__
+#elif defined(__linux__)
cpu_set_t Set;
if (sched_getaffinity(0, sizeof(Set), &Set) == 0)
return CPU_COUNT(&Set);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92271.308187.patch
Type: text/x-patch
Size: 996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201128/1e34a78a/attachment.bin>
More information about the llvm-commits
mailing list