--- include/affinity.h.orig
+++ include/affinity.h
@@ -11,7 +11,7 @@

 #if defined (_POSIX)
 #include <pthread.h>
-#if defined (__linux__)
+#if defined (__GLIBC__)
 #include <sys/sysctl.h>
 #endif // __linux__
 #endif // _POSIX
--- include/sort_r.h.orig
+++ include/sort_r.h
@@ -187,10 +187,15 @@
         /* no qsort_r in glibc before 2.8, need to use nested qsort */
         sort_r_simple(base, nel, width, compar, arg);

-      #else
+      #elif defined __GLIBC__

         qsort_r(base, nel, width, compar, arg);

+      #else
+
+        /* Fall back to our own quicksort implementation */
+        sort_r_simple(base, nel, width, compar, arg);
+
       #endif

     #elif defined _SORT_R_BSD
