Mercurial > hg > octave-nkf > gnulib-hg
changeset 4156:99ea86c79f44
Make it possibly to simply write: #include <alloca.h>.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 10 Jan 2003 21:06:49 +0000 |
parents | 169783c44219 |
children | b7cbe15d6a90 |
files | ChangeLog lib/ChangeLog lib/alloca_.h lib/getdate.y lib/makepath.c lib/setenv.c lib/userspec.c m4/ChangeLog m4/alloca.m4 modules/alloca |
diffstat | 10 files changed, 117 insertions(+), 95 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-01-10 Bruno Haible <bruno@clisp.org> + + * modules/alloca: Change Makefile.am requirements. Simplify Include + requirements. Add lib/alloca_.h to file list. + 2003-01-09 Bruno Haible <bruno@clisp.org> * modules/stdbool: Change configure.ac, Makefile.am requirements.
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,11 @@ +2003-01-10 Bruno Haible <bruno@clisp.org> + + * alloca_.h: New file. + * getdate.y: Unconditionally include alloca.h. + * makepath.c: Likewise. + * setenv.c: Likewise. + * userspec.c: Likewise. + 2003-01-09 Bruno Haible <bruno@clisp.org> * stdbool.h.in: New file.
new file mode 100644 --- /dev/null +++ b/lib/alloca_.h @@ -0,0 +1,67 @@ +/* Memory allocation on the stack. + Copyright (C) 1995, 1999, 2001-2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software 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 3. Therefore we include it right after + "config.h", not later. */ + +#ifndef _ALLOCA_H +#define _ALLOCA_H + +/* alloca(N) returns a pointer (void* or char*) to N bytes of memory + allocated on the stack, and which will last until the function returns. + Use of alloca should be avoided: + - inside arguments of function calls - undefined behaviour, + - in inline functions - the allocation may actually last until the + calling function returns, + - for huge N (say, N >= 65536) - you never know how large (or small) + the stack is, and when the stack cannot fulfill the memory allocation + request, the program just crashes. + */ + +#ifdef __GNUC__ +# ifndef alloca +# define alloca __builtin_alloca +# endif +#else +# ifdef _MSC_VER +# include <malloc.h> +# define alloca _alloca +# else +# if HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX + #pragma alloca +# else +# ifdef __hpux /* This section must match that of bison generated files. */ +# ifdef __cplusplus +extern "C" void *alloca (unsigned int); +# else /* not __cplusplus */ +extern void *alloca (); +# endif /* not __cplusplus */ +# else /* not __hpux */ +# ifndef alloca +extern char *alloca (); +# endif +# endif /* __hpux */ +# endif +# endif +# endif +#endif + +#endif /* _ALLOCA_H */
--- a/lib/getdate.y +++ b/lib/getdate.y @@ -1,6 +1,6 @@ %{ /* Parse a string into an internal time stamp. - Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,11 +27,10 @@ #ifdef HAVE_CONFIG_H # include <config.h> -# ifdef HAVE_ALLOCA_H -# include <alloca.h> -# endif #endif +#include <alloca.h> + /* 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 the code were included in the Emacs executable, it probably
--- a/lib/makepath.c +++ b/lib/makepath.c @@ -1,5 +1,5 @@ /* makepath.c -- Ensure that a directory path exists. - Copyright (C) 1990, 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1990, 1997-1999, 2000, 2002-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,19 +21,7 @@ # include <config.h> #endif -#if __GNUC__ -# define alloca __builtin_alloca -#else -# if HAVE_ALLOCA_H -# include <alloca.h> -# else -# ifdef _AIX - # pragma alloca -# else -char *alloca (); -# endif -# endif -#endif +#include <alloca.h> #include <stdio.h> #include <sys/types.h>
--- a/lib/setenv.c +++ b/lib/setenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc. +/* Copyright (C) 1992,1995-1999,2000-2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -20,36 +20,7 @@ # include <config.h> #endif -#ifdef __GNUC__ -# ifndef alloca -# define alloca __builtin_alloca -# endif -#else -# ifdef _MSC_VER -# include <malloc.h> -# define alloca _alloca -# else -# if HAVE_ALLOCA_H -# include <alloca.h> -# else -# ifdef _AIX - #pragma alloca -# else -# ifdef __hpux /* This section must match that of bison generated files. */ -# ifdef __cplusplus -extern "C" void *alloca (unsigned int); -# else /* not __cplusplus */ -void *alloca (); -# endif /* not __cplusplus */ -# else /* not __hpux */ -# ifndef alloca -char *alloca (); -# endif -# endif /* __hpux */ -# endif -# endif -# endif -#endif +#include <alloca.h> #include <errno.h> #if !_LIBC
--- a/lib/userspec.c +++ b/lib/userspec.c @@ -1,5 +1,5 @@ /* userspec.c -- Parse a user and group string. - Copyright (C) 1989-1992, 1997, 1998, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,19 +21,7 @@ # include <config.h> #endif -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# if HAVE_ALLOCA_H -# include <alloca.h> -# else -# ifdef _AIX - # pragma alloca -# else -char *alloca (); -# endif -# endif -#endif +#include <alloca.h> #include <stdio.h> #include <sys/types.h>
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2003-01-10 Bruno Haible <bruno@clisp.org> + + * alloca.m4 (gl_FUNC_ALLOCA): Also define ALLOCA_H. + 2003-01-09 Bruno Haible <bruno@clisp.org> * stdbool.m4 (AM_STDBOOL_H): New macro.
--- a/m4/alloca.m4 +++ b/m4/alloca.m4 @@ -1,5 +1,5 @@ -# alloca.m4 serial 1 -dnl Copyright (C) 2002 Free Software Foundation, Inc. +# alloca.m4 serial 2 +dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program @@ -12,6 +12,17 @@ if test $ac_cv_func_alloca_works = no; then gl_PREREQ_ALLOCA fi + + # Define an additional variable used in the Makefile substitution. + + AC_EGREP_CPP([Need own alloca], [ +#if defined __GNUC__ || defined _MSC_VER || !HAVE_ALLOCA_H + Need own alloca +#endif + ], + ALLOCA_H=alloca.h, + ALLOCA_H=) + AC_SUBST([ALLOCA_H]) ]) # Prerequisites of lib/alloca.c.
--- a/modules/alloca +++ b/modules/alloca @@ -1,6 +1,8 @@ Description: +Memory allocation on the stack. Files: +lib/alloca_.h lib/alloca.c m4/alloca.m4 @@ -11,36 +13,15 @@ gl_FUNC_ALLOCA Makefile.am: +EXTRA_DIST += alloca_.h + +# The following is needed in order to create an <alloca.h> when the system +# doesn't have one that works with the given compiler. +all-local: @ALLOCA_H@ +alloca.h: alloca_.h + cp $(srcdir)/alloca_.h alloca.h +MOSTLYCLEANFILES += alloca.h Include: -#ifdef __GNUC__ -# ifndef alloca -# define alloca __builtin_alloca -# endif -#else -# ifdef _MSC_VER -# include <malloc.h> -# define alloca _alloca -# else -# if HAVE_ALLOCA_H -# include <alloca.h> -# else -# ifdef _AIX - #pragma alloca -# else -# ifdef __hpux /* This section must match that of bison generated files. */ -# ifdef __cplusplus -extern "C" void *alloca (unsigned int); -# else /* not __cplusplus */ -void *alloca (); -# endif /* not __cplusplus */ -# else /* not __hpux */ -# ifndef alloca -char *alloca (); -# endif -# endif /* __hpux */ -# endif -# endif -# endif -#endif +#include <alloca.h>