annotate lib/alloca.in.h @ 423:079d43b6967b 3.0-beta2 3.0-beta2

Added missing file
author lost@l-w.ca
date Sun, 19 Sep 2010 01:44:47 -0600
parents 3c2e1f24cc7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
421
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
1 /* Memory allocation on the stack.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
2
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
3 Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
4 Inc.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
5
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
6 This program is free software; you can redistribute it and/or modify it
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
7 under the terms of the GNU General Public License as published
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
8 by the Free Software Foundation; either version 3, or (at your option)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
9 any later version.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
10
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
14 General Public License for more details.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
15
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
16 You should have received a copy of the GNU General Public
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
17 License along with this program; if not, write to the Free Software
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
19 USA. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
20
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
21 /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
22 means there is a real alloca function. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
23 #ifndef _GL_ALLOCA_H
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
24 #define _GL_ALLOCA_H
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
25
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
26 /* alloca (N) returns a pointer to N bytes of memory
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
27 allocated on the stack, which will last until the function returns.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
28 Use of alloca should be avoided:
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
29 - inside arguments of function calls - undefined behaviour,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
30 - in inline functions - the allocation may actually last until the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
31 calling function returns,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
32 - for huge N (say, N >= 65536) - you never know how large (or small)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
33 the stack is, and when the stack cannot fulfill the memory allocation
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
34 request, the program just crashes.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
35 */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
36
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
37 #ifndef alloca
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
38 # ifdef __GNUC__
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
39 # define alloca __builtin_alloca
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
40 # elif defined _AIX
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
41 # define alloca __alloca
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
42 # elif defined _MSC_VER
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
43 # include <malloc.h>
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
44 # define alloca _alloca
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
45 # elif defined __DECC && defined __VMS
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
46 # define alloca __ALLOCA
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
47 # else
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
48 # include <stddef.h>
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
49 # ifdef __cplusplus
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
50 extern "C"
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
51 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
52 void *alloca (size_t);
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
53 # endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
54 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
55
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
56 #endif /* _GL_ALLOCA_H */