--- configure.ac.orig	2015-12-19 21:05:08.254461650 +0100
+++ configure.ac	2015-12-19 21:06:23.959218929 +0100
@@ -54,8 +54,6 @@ if test "$sys_name" = sunos; then
 fi
 
 
-CFLAGS=
-CXXFLAGS=
 AC_PROG_CC
 AC_PROG_CXX
 
@@ -96,7 +94,7 @@ AC_CHECK_FUNCS([lutimes])
 
 
 # Check for sched_setaffinity.
-AC_CHECK_FUNCS([sched_setaffinity])
+AC_CHECK_FUNCS([sched_setaffinity sched_getcpu])
 
 
 # Check whether the store optimiser can optimise symlinks.
--- src/libutil/affinity.cc.orig	2015-12-19 21:10:00.175521237 +0100
+++ src/libutil/affinity.cc	2015-12-19 21:10:19.551719833 +0100
@@ -3,6 +3,7 @@
 #include "affinity.hh"
 
 #if HAVE_SCHED_H
+#include <string.h>
 #include <sched.h>
 #endif
 
@@ -32,7 +33,7 @@ void setAffinityTo(int cpu)
 
 int lockToCurrentCPU()
 {
-#if HAVE_SCHED_SETAFFINITY
+#if HAVE_SCHED_GETCPU
     int cpu = sched_getcpu();
     if (cpu != -1) setAffinityTo(cpu);
     return cpu;
