186d7f5d3SJohn Marino /* Memory allocation on the stack. 286d7f5d3SJohn Marino 386d7f5d3SJohn Marino Copyright (C) 1995, 1999, 2001, 2002, 2003, 2004 Free Software 486d7f5d3SJohn Marino Foundation, Inc. 586d7f5d3SJohn Marino 686d7f5d3SJohn Marino This program is free software; you can redistribute it and/or modify it 786d7f5d3SJohn Marino under the terms of the GNU General Public License as published 886d7f5d3SJohn Marino by the Free Software Foundation; either version 2, or (at your option) 986d7f5d3SJohn Marino any later version. 1086d7f5d3SJohn Marino 1186d7f5d3SJohn Marino This program is distributed in the hope that it will be useful, 1286d7f5d3SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 1386d7f5d3SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1486d7f5d3SJohn Marino General Public License for more details. 1586d7f5d3SJohn Marino 1686d7f5d3SJohn Marino You should have received a copy of the GNU General Public 1786d7f5d3SJohn Marino License along with this program; if not, write to the Free Software 1886d7f5d3SJohn Marino Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 1986d7f5d3SJohn Marino USA. */ 2086d7f5d3SJohn Marino 2186d7f5d3SJohn Marino /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H 2286d7f5d3SJohn Marino means there is a real alloca function. */ 2386d7f5d3SJohn Marino #ifndef _GNULIB_ALLOCA_H 2486d7f5d3SJohn Marino # define _GNULIB_ALLOCA_H 2586d7f5d3SJohn Marino 2686d7f5d3SJohn Marino /* alloca (N) returns a pointer to N bytes of memory 2786d7f5d3SJohn Marino allocated on the stack, which will last until the function returns. 2886d7f5d3SJohn Marino Use of alloca should be avoided: 2986d7f5d3SJohn Marino - inside arguments of function calls - undefined behaviour, 3086d7f5d3SJohn Marino - in inline functions - the allocation may actually last until the 3186d7f5d3SJohn Marino calling function returns, 3286d7f5d3SJohn Marino - for huge N (say, N >= 65536) - you never know how large (or small) 3386d7f5d3SJohn Marino the stack is, and when the stack cannot fulfill the memory allocation 3486d7f5d3SJohn Marino request, the program just crashes. 3586d7f5d3SJohn Marino */ 3686d7f5d3SJohn Marino 3786d7f5d3SJohn Marino #undef alloca 3886d7f5d3SJohn Marino #ifdef __GNUC__ 3986d7f5d3SJohn Marino # define alloca __builtin_alloca 4086d7f5d3SJohn Marino #elif defined _AIX 4186d7f5d3SJohn Marino # define alloca __alloca 4286d7f5d3SJohn Marino #elif defined _MSC_VER 4386d7f5d3SJohn Marino # include <malloc.h> 4486d7f5d3SJohn Marino # define alloca _alloca 4586d7f5d3SJohn Marino #else 4686d7f5d3SJohn Marino # include <stddef.h> 4786d7f5d3SJohn Marino # ifdef __cplusplus 4886d7f5d3SJohn Marino extern "C" 4986d7f5d3SJohn Marino # endif 5086d7f5d3SJohn Marino void *alloca (size_t); 5186d7f5d3SJohn Marino #endif 5286d7f5d3SJohn Marino 5386d7f5d3SJohn Marino #endif /* _GNULIB_ALLOCA_H */ 54