.
[glibc/history.git] / include / alloca.h
blob563d7868bdc89adc04a2f9ac43ae59b96698f28e
1 #ifndef _ALLOCA_H
3 #include <stdlib/alloca.h>
4 #include <stackinfo.h>
6 #undef __alloca
8 /* Now define the internal interfaces. */
9 extern void *__alloca (size_t __size);
11 #ifdef __GNUC__
12 # define __alloca(size) __builtin_alloca (size)
13 #endif /* GCC. */
15 extern int __libc_use_alloca (size_t size) __attribute__ ((const));
16 extern int __libc_alloca_cutoff (size_t size) __attribute__ ((const));
18 #define __MAX_ALLOCA_CUTOFF 65536
20 #include <allocalim.h>
22 #if _STACK_GROWS_DOWN
23 # define extend_alloca(buf, len, newlen) \
24 (__typeof (buf)) ({ size_t __newlen = (newlen); \
25 char *__newbuf = __alloca (__newlen); \
26 if (__newbuf + __newlen == (char *) buf) \
27 len += __newlen; \
28 else \
29 len = __newlen; \
30 __newbuf; })
31 #elif _STACK_GROWS_UP
32 # define extend_alloca(buf, len, newlen) \
33 (__typeof (buf)) ({ size_t __newlen = (newlen); \
34 char *__newbuf = __alloca (__newlen); \
35 char *__buf = (buf); \
36 if (__buf + __newlen == __newbuf) \
37 { \
38 len += __newlen; \
39 __newbuf = __buf; \
40 } \
41 else \
42 len = __newlen; \
43 __newbuf; })
44 #else
45 # define extend_alloca(buf, len, newlen) \
46 __alloca (((len) = (newlen)))
47 #endif
49 #endif