[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gnulib] Re: getdate don't need alloca
From: |
Paul Eggert |
Subject: |
Re: [bug-gnulib] Re: getdate don't need alloca |
Date: |
Sun, 19 Dec 2004 05:52:03 -0800 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Simon Josefsson <address@hidden> writes:
> Not using alloca is still an option, I'm not sure what the other
> options are.
I thought of one more option: use a much smaller limit on the stack size.
This is feasible for getdate's grammar.
A couple of other things. The Bison documentation says that
YYSTACK_USE_ALLOCA must be defined to 0 if it is defined to anything.
And there's an obsolete comment about AIX and alloca -- we no longer
use the alloca pragma, so this shouldn't be a problem.
I merged everybody's suggestions, tested the result with coreutils,
and installed the following patch, in both gnulib and coreutils.
2004-12-19 Paul Eggert <address@hidden>
* lib/alloca_.h: Conditionalize on _GNULIB_ALLOCA_H, not _ALLOCA_H.
Remove now-obsolete comment about AIX.
* lib/getdate.y: Include <alloca.h> only if HAVE_ALLOCA.
(YYSTACK_USE_ALLOCA): Define to 0 if !HAVE_ALLOCA.
(YYMAXDEPTH): New macro.
* modules/getdate: Depend on alloca-opt, not alloca.
Index: lib/alloca_.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/alloca_.h,v
retrieving revision 1.6
diff -p -u -r1.6 alloca_.h
--- lib/alloca_.h 11 Nov 2004 09:25:55 -0000 1.6
+++ lib/alloca_.h 19 Dec 2004 13:38:13 -0000
@@ -18,12 +18,10 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
-/* When this file is included, it may be preceded only by preprocessor
- declarations. Thanks to AIX. Therefore we include it right after
- "config.h", not later. */
-
-#ifndef _ALLOCA_H
-# define _ALLOCA_H
+/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
+ means there is a real alloca function. */
+#ifndef _GNULIB_ALLOCA_H
+# define _GNULIB_ALLOCA_H
/* alloca (N) returns a pointer to N bytes of memory
allocated on the stack, which will last until the function returns.
@@ -51,4 +49,4 @@ extern "C"
void *alloca (size_t);
#endif
-#endif /* _ALLOCA_H */
+#endif /* _GNULIB_ALLOCA_H */
Index: lib/getdate.y
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/getdate.y,v
retrieving revision 1.91
diff -p -u -r1.91 getdate.y
--- lib/getdate.y 8 Dec 2004 22:25:43 -0000 1.91
+++ lib/getdate.y 19 Dec 2004 13:38:13 -0000
@@ -36,7 +36,18 @@
#include "getdate.h"
-#include <alloca.h>
+/* Use alloca only if it is known to be builtin. */
+#if HAVE_ALLOCA
+# include <alloca.h>
+#else
+# define YYSTACK_USE_ALLOCA 0
+#endif
+
+/* Tell Bison ow much stack space is needed. 20 should be plenty for
+ this grammar, which is not right recursive. Beware setting it too
+ high, since that might cause problems on machines whose alloca
+ implementations have lame stack-overflow checking. */
+#define YYMAXDEPTH 20
/* Since the code of getdate.y is not included in the Emacs executable
itself, there is no need to #define static in this file. Even if
Index: modules/getdate
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/getdate,v
retrieving revision 1.9
diff -p -u -r1.9 getdate
--- modules/getdate 29 Oct 2004 21:00:24 -0000 1.9
+++ modules/getdate 19 Dec 2004 13:44:38 -0000
@@ -16,7 +16,7 @@ gettime
mktime
setenv
xalloc
-alloca
+alloca-opt
configure.ac:
gl_GETDATE
@@ -34,4 +34,3 @@ GPL
Maintainer:
Paul Eggert
-
- Re: [bug-gnulib] Re: getdate don't need alloca,
Paul Eggert <=