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