changeset 40229:6abc91ece034

alloca-opt: Fix conflict mingw's new <alloca.h> file. Reported by Eli Zaretskii <eliz@gnu.org>. * lib/alloca.in.h: On mingw systems that have <alloca.h>, include that. * m4/alloca.m4 (gl_FUNC_ALLOCA): Set HAVE_ALLOCA_H. * modules/alloca-opt (Makefile.am): Substitute HAVE_ALLOCA_H.
author Bruno Haible <bruno@clisp.org>
date Sun, 10 Mar 2019 20:39:34 +0100
parents bb9e295185c8
children 25f5a9e7e5fb
files ChangeLog lib/alloca.in.h m4/alloca.m4 modules/alloca-opt
diffstat 4 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Mar 10 10:11:53 2019 -0700
+++ b/ChangeLog	Sun Mar 10 20:39:34 2019 +0100
@@ -1,3 +1,11 @@
+2019-03-10  Bruno Haible  <bruno@clisp.org>
+
+	alloca-opt: Fix conflict mingw's new <alloca.h> file.
+	Reported by Eli Zaretskii <eliz@gnu.org>.
+	* lib/alloca.in.h: On mingw systems that have <alloca.h>, include that.
+	* m4/alloca.m4 (gl_FUNC_ALLOCA): Set HAVE_ALLOCA_H.
+	* modules/alloca-opt (Makefile.am): Substitute HAVE_ALLOCA_H.
+
 2019-03-10  Bruno Haible  <bruno@clisp.org>
 
 	tests: Avoid havoc with "gcc -fcheck-pointer-bounds".
--- a/lib/alloca.in.h	Sun Mar 10 10:11:53 2019 -0700
+++ b/lib/alloca.in.h	Sun Mar 10 20:39:34 2019 +0100
@@ -36,6 +36,12 @@
 
 #ifndef alloca
 # ifdef __GNUC__
+   /* Some version of mingw have an <alloca.h> that causes trouble when
+      included after 'alloca' gets defined as a macro.  As a workaround, include
+      this <alloca.h> first and define 'alloca' as a macro afterwards.  */
+#  if (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
+#   include_next <alloca.h>
+#  endif
 #  define alloca __builtin_alloca
 # elif defined _AIX
 #  define alloca __alloca
--- a/m4/alloca.m4	Sun Mar 10 10:11:53 2019 -0700
+++ b/m4/alloca.m4	Sun Mar 10 20:39:34 2019 +0100
@@ -1,4 +1,4 @@
-# alloca.m4 serial 14
+# alloca.m4 serial 15
 dnl Copyright (C) 2002-2004, 2006-2007, 2009-2019 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -37,6 +37,13 @@
   fi
   AC_SUBST([ALLOCA_H])
   AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"])
+
+  if test $ac_cv_working_alloca_h = yes; then
+    HAVE_ALLOCA_H=1
+  else
+    HAVE_ALLOCA_H=0
+  fi
+  AC_SUBST([HAVE_ALLOCA_H])
 ])
 
 # Prerequisites of lib/alloca.c.
--- a/modules/alloca-opt	Sun Mar 10 10:11:53 2019 -0700
+++ b/modules/alloca-opt	Sun Mar 10 20:39:34 2019 +0100
@@ -21,7 +21,7 @@
 alloca.h: alloca.in.h $(top_builddir)/config.status
 	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  cat $(srcdir)/alloca.in.h; \
+	  sed -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' < $(srcdir)/alloca.in.h; \
 	} > $@-t && \
 	mv -f $@-t $@
 else