INN commit: branches/2.6/m4 (iov-max.m4)
INN Commit
rra at isc.org
Thu Oct 31 01:38:00 UTC 2019
Date: Wednesday, October 30, 2019 @ 18:37:59
Author: eagle
Revision: 10352
Make IOV_MAX Autoconf check more cross-compile-friendly
The IOV_MAX Autoconf check always compiled and ran a program
and relied on the output from that program to indicate that
IOV_MAX was set in limits.h, which causes problems with
cross-compilation. Instead, use AC_CHECK_DECL to check for the
common case that IOV_MAX is defined in limits.h, and only
compile and run a program for the uncommon case that this fails.
Tested only on Linux, but by changing the probe to look for
something other than IOV_MAX and then for something other than
UIO_MAXIOV, to make sure all the branches work.
Thanks, Helmut Grohne.
Modified:
branches/2.6/m4/iov-max.m4
------------+
iov-max.m4 | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
Modified: iov-max.m4
===================================================================
--- iov-max.m4 2019-10-31 01:36:42 UTC (rev 10351)
+++ iov-max.m4 2019-10-31 01:37:59 UTC (rev 10352)
@@ -38,12 +38,9 @@
FILE *f = fopen ("conftestval", "w");
if (f == NULL)
return 1;
-#ifdef IOV_MAX
- fprintf (f, "set in limits.h\n");
+#ifdef UIO_MAXIOV
+ fprintf (f, "%d\n", UIO_MAXIOV);
#else
-# ifdef UIO_MAXIOV
- fprintf (f, "%d\n", UIO_MAXIOV);
-# else
fd = open ("/dev/null", O_WRONLY, 0666);
if (fd < 0)
return 1;
@@ -60,25 +57,31 @@
}
}
fprintf (f, "1024\n");
-# endif /* UIO_MAXIOV */
-#endif /* IOV_MAX */
+#endif /* UIO_MAXIOV */
return 0;
}
]])])
+dnl Headers to use for checking for an IOV_MAX definition.
+define([_INN_MACRO_IOV_MAX_HEADERS],
+[AC_INCLUDES_DEFAULT
+#ifdef HAVE_LIMITS_H
+# include <limits.h>
+#endif
+])
+
dnl Do the actual check.
AC_DEFUN([INN_MACRO_IOV_MAX],
-[AC_CACHE_CHECK([value of IOV_MAX],
- [inn_cv_macro_iov_max],
- [AC_RUN_IFELSE([_INN_MACRO_IOV_MAX_SOURCE],
- inn_cv_macro_iov_max=`cat conftestval`,
- inn_cv_macro_iov_max=error,
- 16)
- if test x"$inn_cv_macro_iov_max" = xerror ; then
- AC_MSG_WARN([probe failure, assuming 16])
- inn_cv_macro_iov_max=16
- fi])
- if test x"$inn_cv_macro_iov_max" != x"set in limits.h" ; then
- AC_DEFINE_UNQUOTED(IOV_MAX, $inn_cv_macro_iov_max,
- [Define to the max vectors in an iovec.])
- fi])
+[AC_CHECK_DECL([IOV_MAX], [],
+ [AC_CACHE_CHECK([value of IOV_MAX],
+ [inn_cv_macro_iov_max],
+ [AC_RUN_IFELSE([_INN_MACRO_IOV_MAX_SOURCE],
+ inn_cv_macro_iov_max=`cat conftestval`,
+ inn_cv_macro_iov_max=error,
+ 16)
+ AS_IF([test x"$inn_cv_macro_iov_max" = xerror],
+ [AC_MSG_WARN([probe failure, assuming 16])
+ inn_cv_macro_iov_max=16])])
+ AC_DEFINE_UNQUOTED([IOV_MAX], [$inn_cv_macro_iov_max],
+ [Define to the max vectors in an iovec.])],
+ [_INN_MACRO_IOV_MAX_HEADERS])])
More information about the inn-committers
mailing list