|
Packit |
06dd63 |
/* Memory allocation on the stack.
|
|
Packit |
06dd63 |
|
|
Packit |
06dd63 |
Copyright (C) 1995, 1999, 2001-2004, 2006-2019 Free Software Foundation,
|
|
Packit |
06dd63 |
Inc.
|
|
Packit |
06dd63 |
|
|
Packit |
06dd63 |
This program is free software; you can redistribute it and/or modify it
|
|
Packit |
06dd63 |
under the terms of the GNU Lesser General Public License as published
|
|
Packit |
06dd63 |
by the Free Software Foundation; either version 2.1, or (at your option)
|
|
Packit |
06dd63 |
any later version.
|
|
Packit |
06dd63 |
|
|
Packit |
06dd63 |
This program is distributed in the hope that it will be useful,
|
|
Packit |
06dd63 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
06dd63 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
06dd63 |
Lesser General Public License for more details.
|
|
Packit |
06dd63 |
|
|
Packit |
06dd63 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
06dd63 |
License along with this program; if not, see
|
|
Packit |
06dd63 |
<https://www.gnu.org/licenses/>.
|
|
Packit |
06dd63 |
*/
|
|
Packit |
06dd63 |
|
|
Packit |
06dd63 |
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
|
|
Packit |
06dd63 |
means there is a real alloca function. */
|
|
Packit |
06dd63 |
#ifndef _GL_ALLOCA_H
|
|
Packit |
06dd63 |
#define _GL_ALLOCA_H
|
|
Packit |
06dd63 |
|
|
Packit |
06dd63 |
/* alloca (N) returns a pointer to N bytes of memory
|
|
Packit |
06dd63 |
allocated on the stack, which will last until the function returns.
|
|
Packit |
06dd63 |
Use of alloca should be avoided:
|
|
Packit |
06dd63 |
- inside arguments of function calls - undefined behaviour,
|
|
Packit |
06dd63 |
- in inline functions - the allocation may actually last until the
|
|
Packit |
06dd63 |
calling function returns,
|
|
Packit |
06dd63 |
- for huge N (say, N >= 65536) - you never know how large (or small)
|
|
Packit |
06dd63 |
the stack is, and when the stack cannot fulfill the memory allocation
|
|
Packit |
06dd63 |
request, the program just crashes.
|
|
Packit |
06dd63 |
*/
|
|
Packit |
06dd63 |
|
|
Packit |
06dd63 |
#ifndef alloca
|
|
Packit |
06dd63 |
# ifdef __GNUC__
|
|
Packit |
06dd63 |
/* Some version of mingw have an <alloca.h> that causes trouble when
|
|
Packit |
06dd63 |
included after 'alloca' gets defined as a macro. As a workaround, include
|
|
Packit |
06dd63 |
this <alloca.h> first and define 'alloca' as a macro afterwards. */
|
|
Packit |
06dd63 |
# if (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
|
|
Packit |
06dd63 |
# include_next <alloca.h>
|
|
Packit |
06dd63 |
# endif
|
|
Packit |
06dd63 |
# define alloca __builtin_alloca
|
|
Packit |
06dd63 |
# elif defined _AIX
|
|
Packit |
06dd63 |
# define alloca __alloca
|
|
Packit |
06dd63 |
# elif defined _MSC_VER
|
|
Packit |
06dd63 |
# include <malloc.h>
|
|
Packit |
06dd63 |
# define alloca _alloca
|
|
Packit |
06dd63 |
# elif defined __DECC && defined __VMS
|
|
Packit |
06dd63 |
# define alloca __ALLOCA
|
|
Packit |
06dd63 |
# elif defined __TANDEM && defined _TNS_E_TARGET
|
|
Packit |
06dd63 |
# ifdef __cplusplus
|
|
Packit |
06dd63 |
extern "C"
|
|
Packit |
06dd63 |
# endif
|
|
Packit |
06dd63 |
void *_alloca (unsigned short);
|
|
Packit |
06dd63 |
# pragma intrinsic (_alloca)
|
|
Packit |
06dd63 |
# define alloca _alloca
|
|
Packit |
06dd63 |
# elif defined __MVS__
|
|
Packit |
06dd63 |
# include <stdlib.h>
|
|
Packit |
06dd63 |
# else
|
|
Packit |
06dd63 |
# include <stddef.h>
|
|
Packit |
06dd63 |
# ifdef __cplusplus
|
|
Packit |
06dd63 |
extern "C"
|
|
Packit |
06dd63 |
# endif
|
|
Packit |
06dd63 |
void *alloca (size_t);
|
|
Packit |
06dd63 |
# endif
|
|
Packit |
06dd63 |
#endif
|
|
Packit |
06dd63 |
|
|
Packit |
06dd63 |
#endif /* _GL_ALLOCA_H */
|