list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
endif()
# This check requires _GNU_SOURCE
-check_symbol_exists(sched_getaffinity sched.h HAVE_SCHED_GETAFFINITY)
-check_symbol_exists(CPU_COUNT sched.h HAVE_CPU_COUNT)
if (NOT PURE_WINDOWS)
if (LLVM_PTHREAD_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB})
/* Define to 1 if you have the `setenv' function. */
#cmakedefine HAVE_SETENV ${HAVE_SETENV}
-/* Define to 1 if you have the `sched_getaffinity' function. */
-#cmakedefine HAVE_SCHED_GETAFFINITY ${HAVE_SCHED_GETAFFINITY}
-
-/* Define to 1 if you have the `CPU_COUNT' macro. */
-#cmakedefine HAVE_CPU_COUNT ${HAVE_CPU_COUNT}
-
/* Define to 1 if you have the `setrlimit' function. */
#cmakedefine HAVE_SETRLIMIT ${HAVE_SETRLIMIT}
#endif
#if defined(__linux__)
+#include <sched.h> // For sched_getaffinity
#include <sys/syscall.h> // For syscall codes
#include <unistd.h> // For syscall()
#endif
#include <thread>
int computeHostNumHardwareThreads() {
-#if defined(HAVE_SCHED_GETAFFINITY) && defined(HAVE_CPU_COUNT)
+#ifdef __linux__
cpu_set_t Set;
if (sched_getaffinity(0, sizeof(Set), &Set) == 0)
return CPU_COUNT(&Set);
"HAVE_LSEEK64=1",
"HAVE_MALLINFO=1",
"HAVE_POSIX_FALLOCATE=1",
- "HAVE_SCHED_GETAFFINITY=1",
- "HAVE_CPU_COUNT=1",
"HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=1",
]
} else {
"HAVE_LSEEK64=",
"HAVE_MALLINFO=",
"HAVE_POSIX_FALLOCATE=",
- "HAVE_SCHED_GETAFFINITY=",
- "HAVE_CPU_COUNT=",
"HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=",
]
}