Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / thread_mpi / pthreads.c
index 62d8c52cae70df7c1950717c3ede8d5ecd983f36..d49dc1245c0f75122539971ce0873d9f2bde6da3 100644 (file)
@@ -273,7 +273,19 @@ int tMPI_Thread_equal(tMPI_Thread_t t1, tMPI_Thread_t t2)
 enum tMPI_Thread_setaffinity_support tMPI_Thread_setaffinity_support(void)
 {
 #ifdef HAVE_PTHREAD_SETAFFINITY
-    return TMPI_SETAFFINITY_SUPPORT_YES;
+    cpu_set_t set;
+    int ret;
+
+    /* run getaffinity to check whether we get back ENOSYS */
+    ret=pthread_getaffinity_np(pthread_self(), sizeof(set), &set);
+    if (ret == 0)
+    {
+        return TMPI_SETAFFINITY_SUPPORT_YES;
+    }
+    else
+    {
+        return TMPI_SETAFFINITY_SUPPORT_NO;
+    }
 #else
     return TMPI_SETAFFINITY_SUPPORT_NO;
 #endif