blob: 57318b9d31c4845368c390be9d305984b0f9210c [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001/* memalloc.h -- consolidate code for including alloca.h or malloc.h and
2 defining alloca. */
3
4/* Copyright (C) 1993 Free Software Foundation, Inc.
5
6 This file is part of GNU Bash, the Bourne Again SHell.
7
Jari Aalto31859422009-01-12 13:36:28 +00008 Bash is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
Jari Aalto726f6381996-08-26 18:22:31 +000012
Jari Aalto31859422009-01-12 13:36:28 +000013 Bash is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
Jari Aalto726f6381996-08-26 18:22:31 +000017
Jari Aalto31859422009-01-12 13:36:28 +000018 You should have received a copy of the GNU General Public License
19 along with Bash. If not, see <http://www.gnu.org/licenses/>.
20*/
Jari Aalto726f6381996-08-26 18:22:31 +000021
Jari Aaltoccc6cda1996-12-23 17:02:34 +000022#if !defined (_MEMALLOC_H_)
23# define _MEMALLOC_H_
Jari Aalto726f6381996-08-26 18:22:31 +000024
25#if defined (sparc) && defined (sun) && !defined (HAVE_ALLOCA_H)
26# define HAVE_ALLOCA_H
27#endif
28
29#if defined (__GNUC__) && !defined (HAVE_ALLOCA)
30# define HAVE_ALLOCA
31#endif
32
Jari Aaltof73dda02001-11-13 17:56:06 +000033#if defined (HAVE_ALLOCA_H) && !defined (HAVE_ALLOCA) && !defined (C_ALLOCA)
Jari Aalto726f6381996-08-26 18:22:31 +000034# define HAVE_ALLOCA
35#endif /* HAVE_ALLOCA_H && !HAVE_ALLOCA */
36
Jari Aaltob72432f1999-02-19 17:11:39 +000037#if defined (__GNUC__) && !defined (C_ALLOCA)
Jari Aalto726f6381996-08-26 18:22:31 +000038# undef alloca
39# define alloca __builtin_alloca
Jari Aaltob72432f1999-02-19 17:11:39 +000040#else /* !__GNUC__ || C_ALLOCA */
41# if defined (HAVE_ALLOCA_H) && !defined (C_ALLOCA)
Jari Aalto726f6381996-08-26 18:22:31 +000042# if defined (IBMESA)
43# include <malloc.h>
44# else /* !IBMESA */
45# include <alloca.h>
46# endif /* !IBMESA */
Jari Aaltob72432f1999-02-19 17:11:39 +000047# else /* !HAVE_ALLOCA_H || C_ALLOCA */
Jari Aaltod166f041997-06-05 14:59:13 +000048# if defined (__hpux) && defined (__STDC__) && !defined (alloca)
Jari Aaltoccc6cda1996-12-23 17:02:34 +000049extern void *alloca ();
50# else
51# if !defined (alloca)
Jari Aaltof73dda02001-11-13 17:56:06 +000052# if defined (__STDC__)
53extern void *alloca (size_t);
54# else
Jari Aalto726f6381996-08-26 18:22:31 +000055extern char *alloca ();
Jari Aaltof73dda02001-11-13 17:56:06 +000056# endif /* !__STDC__ */
Jari Aaltoccc6cda1996-12-23 17:02:34 +000057# endif /* !alloca */
Jari Aaltod166f041997-06-05 14:59:13 +000058# endif /* !__hpux || !__STDC__ && !alloca */
Jari Aaltob72432f1999-02-19 17:11:39 +000059# endif /* !HAVE_ALLOCA_H || C_ALLOCA */
60#endif /* !__GNUC__ || C_ALLOCA */
Jari Aalto726f6381996-08-26 18:22:31 +000061
Jari Aaltoccc6cda1996-12-23 17:02:34 +000062#endif /* _MEMALLOC_H_ */