summaryrefslogtreecommitdiff
path: root/lib/autoconf/functions.m4
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-10-09 09:02:47 -0400
committerZack Weinberg <zackw@panix.com>2020-10-10 11:23:09 -0400
commit326c9a547423d25c621bc5c0ef76edbf6eda8c92 (patch)
treed98731fcaf9ca5a5fecb7e3c77d487c607a84d82 /lib/autoconf/functions.m4
parent09346f1a776b1bba3634f2d3ccf30460fc372d44 (diff)
downloadautoconf-326c9a547423d25c621bc5c0ef76edbf6eda8c92.tar.gz
Fix regressions when using the C++ compiler to perform tests.
The Debian project has done an archive rebuild using autoconf 2.69c, which found several serious regressions from 2.69 where test programs used to be accepted by a C++ compiler, but are now rejected. Part of the problem is that newer C++ compilers are more likely to reject “traditional” sloppy C, but part of it is that bug fixes since 2.69 did not consider the possibility of test macros being used with AC_LANG([C++]) in effect. I’m still working on test suite improvements that will catch these regressions in the future, but I don’t see any reason to delay the actual bugfixes. (I’ve gotten far enough on the test suite changes that I know they _will_ catch the bugs.) * NEWS: Document that AC_FUNC_STRERROR_R no longer tries to detect a strerror_r that exists in the C library but isn’t declared by string.h. * lib/autoconf/c.m4 (AC_LANG_CALL(C++)): New macro. Use a more robust technique for avoiding a type conflict with any intrinsic prototype. (AC_LANG_CALL(C)): Remove #ifdef __cplusplus, this macro is no longer used to generate C++ code. * lib/autoconf/functions.m4 (AC_FUNC_CLOSEDIR_VOID): Rely on <dirent.h> to declare closedir. Simplify test program. Use AC_COMPILE_IFELSE, not AC_RUN_IFELSE. (_AC_FUNC_MALLOC_IF, _AC_FUNC_REALLOC_IF): Use void *, not char *, for variable holding a value returned by malloc/realloc respectively. (AC_FUNC_STRERROR_R): Don’t AC_CHECK_FUNCS_ONCE strerror_r. AC_DEFINE HAVE_STRERROR_R if and only if we are also going to define HAVE_DECL_STRERROR_R. Remove AC_RUN_IFELSE fallback when strerror_r is not declared. * lib/autoconf/headers.m4 (AC_USG): Use "", not 0, for the first argument to rindex.
Diffstat (limited to 'lib/autoconf/functions.m4')
-rw-r--r--lib/autoconf/functions.m471
1 files changed, 30 insertions, 41 deletions
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index aa560a63..4598b408 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -509,25 +509,23 @@ fi
# AC_FUNC_CLOSEDIR_VOID
# ---------------------
# Check whether closedir returns void, and #define CLOSEDIR_VOID in
-# that case.
+# that case. Note: the test program *fails* to compile when closedir
+# returns void.
AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
AC_CACHE_CHECK([whether closedir returns void],
[ac_cv_func_closedir_void],
-[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <$ac_header_dirent>
-#ifndef __cplusplus
-int closedir ();
-#endif
-],
- [[return closedir (opendir (".")) != 0;]])],
+]], [[
+ return closedir(0);
+]])],
[ac_cv_func_closedir_void=no],
- [ac_cv_func_closedir_void=yes],
[ac_cv_func_closedir_void=yes])])
if test $ac_cv_func_closedir_void = yes; then
AC_DEFINE(CLOSEDIR_VOID, 1,
[Define to 1 if the `closedir' function returns void instead
- of `int'.])
+ of int.])
fi
])
@@ -952,13 +950,12 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
[AC_RUN_IFELSE(
-[AC_LANG_PROGRAM(
-[[#include <stdlib.h>
-]],
- [char *p = malloc (0);
- int result = !p;
- free (p);
- return result;])],
+[AC_LANG_PROGRAM([[#include <stdlib.h>
+ ]],
+ [[void *p = malloc (0);
+ int result = !p;
+ free (p);
+ return result;]])],
[ac_cv_func_malloc_0_nonnull=yes],
[ac_cv_func_malloc_0_nonnull=no],
[case "$host_os" in # ((
@@ -1459,13 +1456,12 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
[AC_RUN_IFELSE(
-[AC_LANG_PROGRAM(
-[[#include <stdlib.h>
-]],
- [char *p = realloc (0, 0);
- int result = !p;
- free (p);
- return result;])],
+[AC_LANG_PROGRAM([[#include <stdlib.h>
+ ]],
+ [[void *p = realloc (0, 0);
+ int result = !p;
+ free (p);
+ return result;]])],
[ac_cv_func_realloc_0_nonnull=yes],
[ac_cv_func_realloc_0_nonnull=no],
[case "$host_os" in # ((
@@ -1692,33 +1688,26 @@ AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
AN_FUNCTION([strerror_r], [AC_FUNC_STRERROR_R])
AC_DEFUN([AC_FUNC_STRERROR_R],
[AC_CHECK_DECLS_ONCE([strerror_r])
-AC_CHECK_FUNCS_ONCE([strerror_r])
+if test $ac_cv_have_decl_strerror_r = yes; then
+ # For backward compatibility's sake, define HAVE_STRERROR_R.
+ # (We used to run AC_CHECK_FUNCS_ONCE for strerror_r, as well
+ # as AC_CHECK_DECLS_ONCE.)
+ AC_DEFINE([HAVE_STRERROR_R], [1], [Define if you have `strerror_r'.])
+fi
+
AC_CACHE_CHECK([whether strerror_r returns char *],
- ac_cv_func_strerror_r_char_p,
- [
+ [ac_cv_func_strerror_r_char_p], [
ac_cv_func_strerror_r_char_p=no
if test $ac_cv_have_decl_strerror_r = yes; then
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[[
char buf[100];
char x = *strerror_r (0, buf, sizeof buf);
char *p = strerror_r (0, buf, sizeof buf);
return !p || x;
]])],
- ac_cv_func_strerror_r_char_p=yes)
- else
- # strerror_r is not declared. Choose between
- # systems that have relatively inaccessible declarations for the
- # function. BeOS and DEC UNIX 4.0 fall in this category, but the
- # former has a strerror_r that returns char*, while the latter
- # has a strerror_r that returns `int'.
- # This test should segfault on the DEC system.
- AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
- extern char *strerror_r ();],
- [[char buf[100];
- char x = *strerror_r (0, buf, sizeof buf);
- return ! isalpha (x);]])],
- ac_cv_func_strerror_r_char_p=yes, , :)
+ [ac_cv_func_strerror_r_char_p=yes])
+
fi
])
if test $ac_cv_func_strerror_r_char_p = yes; then