[llvm] 041a355 - [CMake] Delete HAVE_SCHED_GETAFFINITY and HAVE_CPU_COUNT

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 19 08:57:12 PDT 2020


Author: Fangrui Song
Date: 2020-04-19T08:50:23-07:00
New Revision: 041a3557f05ed19f0ca82c9ce894d2e50bf8291a

URL: https://github.com/llvm/llvm-project/commit/041a3557f05ed19f0ca82c9ce894d2e50bf8291a
DIFF: https://github.com/llvm/llvm-project/commit/041a3557f05ed19f0ca82c9ce894d2e50bf8291a.diff

LOG: [CMake] Delete HAVE_SCHED_GETAFFINITY and HAVE_CPU_COUNT

sched_getaffinity (Linux specific) has been available

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

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 612ce5bdbcbe..d9624c42da66 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -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})

diff  --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index 1a38bc15ab9d..290f74bd02d2 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -160,12 +160,6 @@
 /* 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}
 

diff  --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 307a24469144..5c1bfc5620c6 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -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);

diff  --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
index f8e1026475f5..9f29caddd79e 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -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=",
     ]
   }


        


More information about the llvm-commits mailing list