Improve Gromacs portability
[alexxy/gromacs.git] / src / gromacs / gmxlib / gmx_thread_affinity.c
index 90970b6bd29aeb590e2d3bd0686aeb16ba2b11d1..fb2064213ef6fe7bdd5de74ee8bdcb8d60c817b8 100644 (file)
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GETAFFINITY)
-#define _GNU_SOURCE
-#include <sched.h>
-#include <sys/syscall.h>
+#if defined(HAVE_SCHED_H)
+#  ifndef _GNU_SOURCE
+#    define _GNU_SOURCE 1
+#  endif
+#  include <sched.h>
+#  include <sys/syscall.h>
 #endif
 #include <string.h>
 #include <errno.h>
@@ -375,7 +377,7 @@ gmx_check_thread_affinity_set(FILE            gmx_unused *fplog,
                               int             gmx_unused  nthreads_hw_avail,
                               gmx_bool        gmx_unused  bAfterOpenmpInit)
 {
-#ifdef HAVE_SCHED_GETAFFINITY
+#ifdef HAVE_SCHED_AFFINITY
     cpu_set_t mask_current;
     int       i, ret, cpu_count, cpu_set;
     gmx_bool  bAllSet;
@@ -459,5 +461,5 @@ gmx_check_thread_affinity_set(FILE            gmx_unused *fplog,
             fprintf(debug, "Default affinity mask found\n");
         }
     }
-#endif /* HAVE_SCHED_GETAFFINITY */
+#endif /* HAVE_SCHED_AFFINITY */
 }