From 12e5aaa14841a7b6b8b80a1e32a2512354801f10 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 21 Mar 2018 11:37:28 +0100 Subject: Improve/fix tests for clock_gettime and sched_setaffinity --- CMakeLists.txt | 8 +++++++- 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 #endif +#ifdef HAVE_CPU_AFFINITY +#define _GNU_SOURCE +#include +#endif #include #include @@ -39,11 +43,6 @@ #include #include -#ifdef HAVE_CPU_AFFINITY -#include -#endif - - #include "utils.h" -- cgit v1.2.3