From: Paul Eggert Date: Mon, 17 May 2004 05:41:42 +0000 (+0000) Subject: alloca cleanup: always include . X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e576318cdb5628381e4082c3f4a29c1e97f27a8;p=pspp alloca cleanup: always include . --- diff --git a/ChangeLog b/ChangeLog index bed45c6613..0890404c47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-05-16 Paul Eggert + + * modules/getdate: Depend on alloca. + * modules/setenv: Likewise. + 2004-05-04 Derek Price * modules/argp: Remove dependency on alloca. diff --git a/lib/ChangeLog b/lib/ChangeLog index 37f2703b67..15e3e1efdb 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,16 @@ +2004-05-16 Paul Eggert + Derek Price + + * alloca.c: Include , to get our interface. + * alloca_.h: Use __alloca on AIX, so that we don't have to + include first. Use C89 prototype for alloca; this + requires including for size_t. Use extern "C" if C++. + Use #elif for simplicity, since we can assume C89 now. + Don't try to source the system alloca.h since it will not be found + and to prevent recursively including its replacement. + * fnmatch.c: Include instead of opencoding. + * lib/regex.c: Likewise. + 2004-05-16 Derek Price Paul Eggert @@ -5,11 +18,11 @@ arguments, and meaning of delim2 (now uses EOF, not 0, to indicate no delimiter). - * lib/getline.c: Don't include stddef.h or stdio.h, since our + * getline.c: Don't include stddef.h or stdio.h, since our interface does that. (getline): Always use getdelim, so that we don't have two copies of this code. - * lib/getndelim2.c: Include , , + * getndelim2.c: Include , , if available. (PTRDIFF_MAX, SIZE_MAX, SSIZE_MAX): Define if not defined. (GETNDELIM2_MAXIMUM): New macro. @@ -17,15 +30,15 @@ instead of the old practice of delim2==0. All callers changed. Return -1 on overflow, instead of returning junk. Do not set *linesize unless allocation succeeds. - * lib/getndelim2.h: Do not include stddef.h; no longer needed, now + * getndelim2.h: Do not include stddef.h; no longer needed, now that we include sys/types.h. - * lib/getnline.h: Likewise. - * lib/getndelim2.h (GETNLINE_NO_LIMIT): New macro. + * getnline.h: Likewise. + * getndelim2.h (GETNLINE_NO_LIMIT): New macro. (getndelim2): Reorder arguments. - * lib/getnline.c (getnline, getndelim): + * getnline.c (getnline, getndelim): Don't discard the NMAX argument. (getnline): Invoke getndelim, to avoid code duplication. - * lib/getnline.h (GETNLINE_NO_LIMIT): New macro, used instead + * getnline.h (GETNLINE_NO_LIMIT): New macro, used instead of (size_t) -1 by callers of the getnline family. 2004-05-13 Paul Eggert diff --git a/lib/alloca.c b/lib/alloca.c index a580078696..d1d54475bb 100644 --- a/lib/alloca.c +++ b/lib/alloca.c @@ -25,6 +25,8 @@ # include #endif +#include + #include #include diff --git a/lib/alloca_.h b/lib/alloca_.h index 8ed34fdc6d..8a91698c54 100644 --- a/lib/alloca_.h +++ b/lib/alloca_.h @@ -1,5 +1,7 @@ /* Memory allocation on the stack. - Copyright (C) 1995, 1999, 2001-2003 Free Software Foundation, Inc. + + Copyright (C) 1995, 1999, 2001, 2002, 2003, 2004 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 @@ -23,8 +25,8 @@ #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. +/* alloca (N) returns a pointer to N bytes of memory + allocated on the stack, 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 @@ -34,35 +36,19 @@ request, the program just crashes. */ -# ifdef __GNUC__ -# ifndef alloca -# define alloca __builtin_alloca -# endif -# else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# if HAVE_ALLOCA_H -# include -# 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 +#ifdef __GNUC__ +# define alloca __builtin_alloca +#elif defined _AIX +# define alloca __alloca +#elif defined _MSC_VER +# include +# define alloca _alloca +#else +# include +# ifdef __cplusplus +extern "C" # endif +void *alloca (size_t); +#endif #endif /* _ALLOCA_H */ diff --git a/lib/fnmatch.c b/lib/fnmatch.c index d0cd8cdd79..b9b0598340 100644 --- a/lib/fnmatch.c +++ b/lib/fnmatch.c @@ -24,29 +24,13 @@ # define _GNU_SOURCE 1 #endif -#ifdef __GNUC__ -# define alloca __builtin_alloca -# define HAVE_ALLOCA 1 -#else -# if defined HAVE_ALLOCA_H || defined _LIBC -# include -# else -# ifdef _AIX - # pragma alloca -# else -# ifndef alloca -char *alloca (); -# endif -# endif -# endif -#endif - #if ! defined __builtin_expect && __GNUC__ < 3 # define __builtin_expect(expr, expected) (expr) #endif #include +#include #include #include #include diff --git a/lib/regex.c b/lib/regex.c index ac70b90dd3..32c1519115 100644 --- a/lib/regex.c +++ b/lib/regex.c @@ -4,7 +4,7 @@ internationalization features.) Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003 Free Software Foundation, Inc. + 2002, 2003, 2004 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 @@ -275,13 +275,7 @@ init_syntax_once (void) # ifndef alloca /* Make alloca work the best possible way. */ -# ifdef __GNUC__ -# define alloca __builtin_alloca -# else /* not __GNUC__ */ -# if HAVE_ALLOCA_H -# include -# endif /* HAVE_ALLOCA_H */ -# endif /* not __GNUC__ */ +# include # endif /* not alloca */ diff --git a/m4/ChangeLog b/m4/ChangeLog index 47612ddf97..756df038b3 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,8 +1,16 @@ +2004-05-16 Paul Eggert + + * alloca.m4 (gl_FUNC_ALLOCA): Define HAVE_ALLOCA_H always, + for backward compatibility with older code. We need our own + alloca.h if _AIX is defined. Define HAVE_ALLOCA if we discover + it under some other name, and our alloca.h will define it. + 2004-05-13 Paul Eggert - * gettime.m4 (gl_GETTIME): Require gl_TIMESPEC. Check for gettimeofday. - * settime.m4 (gl_SETTIME): Require gl_TIMESPEC. Check for settimeofday, - stime. + * gettime.m4 (gl_GETTIME): Require gl_TIMESPEC. + Check for gettimeofday. + * settime.m4 (gl_SETTIME): Require gl_TIMESPEC. + Check for settimeofday, stime. 2004-04-20 Paul Eggert diff --git a/m4/alloca.m4 b/m4/alloca.m4 index 793cf0ac0e..6fcb205e94 100644 --- a/m4/alloca.m4 +++ b/m4/alloca.m4 @@ -1,5 +1,5 @@ -# alloca.m4 serial 3 -dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. +# alloca.m4 serial 4 +dnl Copyright (C) 2002, 2003, 2004 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 @@ -18,15 +18,25 @@ AC_DEFUN([gl_FUNC_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 + if test $ac_cv_working_alloca_h = yes; then + AC_EGREP_CPP([Need own alloca], [ +#if defined __GNUC__ || defined _AIX || defined _MSC_VER + Need own alloca #endif - ], - ALLOCA_H=alloca.h, - ALLOCA_H=) + ], + [AC_DEFINE(HAVE_ALLOCA, 1, + [Define to 1 if you have `alloca' after including , + a header that may be supplied by this distribution.]) + ALLOCA_H=alloca.h], + [ALLOCA_H=]) + else + ALLOCA_H=alloca.h + fi AC_SUBST([ALLOCA_H]) + + AC_DEFINE(HAVE_ALLOCA_H, 1, + [Define HAVE_ALLOCA_H for backward compatibility with older code + that includes only if HAVE_ALLOCA_H is defined.]) ]) # Prerequisites of lib/alloca.c. diff --git a/modules/getdate b/modules/getdate index 3a04045782..c93959ed12 100644 --- a/modules/getdate +++ b/modules/getdate @@ -13,6 +13,7 @@ timespec stdbool gettime mktime +alloca unlocked-io configure.ac: diff --git a/modules/setenv b/modules/setenv index 5f95ae6f12..eaab550dff 100644 --- a/modules/setenv +++ b/modules/setenv @@ -10,6 +10,7 @@ m4/setenv.m4 Depends-on: allocsa +alloca configure.ac: gt_FUNC_SETENV