[CMake] Delete HAVE_SCHED_GETAFFINITY and HAVE_CPU_COUNT
authorFangrui Song <maskray@google.com>
Sun, 19 Apr 2020 15:46:47 +0000 (08:46 -0700)
committerFangrui Song <maskray@google.com>
Sun, 19 Apr 2020 15:50:23 +0000 (08:50 -0700)
sched_getaffinity (Linux specific) has been available

* in glibc since 2002-08-08 (commit 972e719e8154eec5f543b027e2a08dfa285d55d5)
* in musl since the initial check-in.

llvm/cmake/config-ix.cmake
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/Unix/Threading.inc
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn

index 612ce5b..d9624c4 100644 (file)
@@ -274,8 +274,6 @@ if( LLVM_USING_GLIBC )
   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})
index 1a38bc1..290f74b 100644 (file)
 /* 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}
 
index 307a244..5c1bfc5 100644 (file)
@@ -38,6 +38,7 @@
 #endif
 
 #if defined(__linux__)
+#include <sched.h>       // For sched_getaffinity
 #include <sys/syscall.h> // For syscall codes
 #include <unistd.h>      // For syscall()
 #endif
@@ -271,7 +272,7 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
 #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);
index f8e1026..9f29cad 100644 (file)
@@ -141,8 +141,6 @@ write_cmake_config("config") {
       "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 {
@@ -152,8 +150,6 @@ write_cmake_config("config") {
       "HAVE_LSEEK64=",
       "HAVE_MALLINFO=",
       "HAVE_POSIX_FALLOCATE=",
-      "HAVE_SCHED_GETAFFINITY=",
-      "HAVE_CPU_COUNT=",
       "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=",
     ]
   }