summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2015-03-27 22:39:07 +0200
committerLasse Collin <lasse.collin@tukaani.org>2015-03-27 22:39:07 +0200
commit4c544d2410903d38402221cb783ed85585b6a007 (patch)
tree21b27a8b98147a14b1dd2dba9b58001547a0bfb3 /m4
parente0ea6737b03e83ccaff4514d00e31bb926f8f0f3 (diff)
downloadxz-4c544d2410903d38402221cb783ed85585b6a007.tar.gz
Fix CPU core count detection on QNX.
It tried to use sysctl() on QNX but - it broke the build because sysctl() needs -lsocket on QNX; - sysctl() doesn't work for detecting the core count on QNX even if it compiled. sysconf() works. An alternative would have been to use QNX-specific SYSPAGE_ENTRY(num_cpu) from <sys/syspage.h>. Thanks to Ole André Vadla Ravnås.
Diffstat (limited to 'm4')
-rw-r--r--m4/tuklib_cpucores.m415
1 files changed, 11 insertions, 4 deletions
diff --git a/m4/tuklib_cpucores.m4 b/m4/tuklib_cpucores.m4
index 08e2cb0..468c2db 100644
--- a/m4/tuklib_cpucores.m4
+++ b/m4/tuklib_cpucores.m4
@@ -11,7 +11,7 @@
# Supported methods:
# - GetSystemInfo(): Windows (including Cygwin)
# - sysctl(): BSDs, OS/2
-# - sysconf(): GNU/Linux, Solaris, Tru64, IRIX, AIX, Cygwin (but
+# - sysconf(): GNU/Linux, Solaris, Tru64, IRIX, AIX, QNX, Cygwin (but
# GetSystemInfo() is used on Cygwin)
# - pstat_getdynamic(): HP-UX
#
@@ -61,10 +61,17 @@ main(void)
}
]])], [tuklib_cv_cpucores_method=cpuset], [
-# Look for sysctl() solution first, because on OS/2, both sysconf()
-# and sysctl() pass the tests in this file, but only sysctl()
-# actually works.
+# On OS/2, both sysconf() and sysctl() pass the tests in this file,
+# but only sysctl() works. On QNX it's the opposite: only sysconf() works
+# (although it assumes that _POSIX_SOURCE, _XOPEN_SOURCE, and _POSIX_C_SOURCE
+# are undefined or alternatively _QNX_SOURCE is defined).
+#
+# We test sysctl() first and intentionally break the sysctl() test on QNX
+# so that sysctl() is never used on QNX.
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#ifdef __QNX__
+compile error
+#endif
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>