aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-03-21 11:37:28 +0100
committerThomas White <taw@physics.org>2018-03-21 11:37:28 +0100
commit12e5aaa14841a7b6b8b80a1e32a2512354801f10 (patch)
treecb3d357f736d8c2a585f5b776828159621e82c43
parentf686ee8e039b6145b12bff3420d02784e95d2621 (diff)
Improve/fix tests for clock_gettime and sched_setaffinity
-rw-r--r--CMakeLists.txt8
-rw-r--r--libcrystfel/src/thread-pool.c9
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"