aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2013-08-03 13:52:58 +0300
committerLasse Collin <lasse.collin@tukaani.org>2013-08-03 13:52:58 +0300
commit124eb69c7857f618b4807588c51bc9ba21bf8691 (patch)
treef8ba68d7ef2b9ba36448ea60e343a30a9d3c2075 /m4
parentmacosx: separate liblzma package (diff)
downloadxz-124eb69c7857f618b4807588c51bc9ba21bf8691.tar.xz
Windows: Add Windows support to tuklib_cpucores().
It is used for Cygwin too. I'm not sure if that is a good or bad idea. Thanks to Vincent Torri.
Diffstat (limited to '')
-rw-r--r--m4/tuklib_cpucores.m419
1 files changed, 17 insertions, 2 deletions
diff --git a/m4/tuklib_cpucores.m4 b/m4/tuklib_cpucores.m4
index 9e295c8f..64a6b43c 100644
--- a/m4/tuklib_cpucores.m4
+++ b/m4/tuklib_cpucores.m4
@@ -9,8 +9,10 @@
# This information is used by tuklib_cpucores.c.
#
# Supported methods:
+# - GetSystemInfo(): Windows (including Cygwin)
# - sysctl(): BSDs, OS/2
-# - sysconf(): GNU/Linux, Solaris, Tru64, IRIX, AIX, Cygwin
+# - sysconf(): GNU/Linux, Solaris, Tru64, IRIX, AIX, Cygwin (but
+# GetSystemInfo() is used on Cygwin)
# - pstat_getdynamic(): HP-UX
#
# COPYING
@@ -30,6 +32,19 @@ AC_CHECK_HEADERS([sys/param.h])
AC_CACHE_CHECK([how to detect the number of available CPU cores],
[tuklib_cv_cpucores_method], [
+# Maybe checking $host_os would be enough but this matches what
+# tuklib_cpucores.c does.
+#
+# NOTE: IRIX has a compiler that doesn't error out with #error, so use
+# a non-compilable text instead of #error to generate an error.
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#if defined(_WIN32) || defined(__CYGWIN__)
+int main(void) { return 0; }
+#else
+compile error
+#endif
+]])], [tuklib_cv_cpucores_method=special], [
+
# Look for sysctl() solution first, because on OS/2, both sysconf()
# and sysctl() pass the tests in this file, but only sysctl()
# actually works.
@@ -82,7 +97,7 @@ main(void)
]])], [tuklib_cv_cpucores_method=pstat_getdynamic], [
tuklib_cv_cpucores_method=unknown
-])])])])
+])])])])])
case $tuklib_cv_cpucores_method in
sysctl)