diff options
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | libcrystfel/src/thread-pool.c | 9 |
2 files changed, 11 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3401a6be..124f17d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,13 @@ if(OpenCL_FOUND) check_include_file(CL/cl.h HAVE_CL_CL_H "-I${OpenCL_INCLUDE_DIRS}") endif(OpenCL_FOUND) -check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) +# Check for nice clock function +check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) + +# Check for CPU affinity functions (Linux-specific) +set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") +check_symbol_exists(sched_setaffinity "sched.h" HAVE_CPU_AFFINITY) +unset(CMAKE_REQUIRED_DEFINITIONS) configure_file(config.h.cmake.in config.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/libcrystfel/src/thread-pool.c b/libcrystfel/src/thread-pool.c index 6824947c..7ce55d85 100644 --- a/libcrystfel/src/thread-pool.c +++ b/libcrystfel/src/thread-pool.c @@ -30,6 +30,10 @@ #include <config.h> #endif +#ifdef HAVE_CPU_AFFINITY +#define _GNU_SOURCE +#include <sched.h> +#endif #include <stdarg.h> #include <stdlib.h> @@ -39,11 +43,6 @@ #include <pthread.h> #include <assert.h> -#ifdef HAVE_CPU_AFFINITY -#include <sched.h> -#endif - - #include "utils.h" |