Back to index

glibc  2.9
alloca.h
Go to the documentation of this file.
00001 #ifndef _ALLOCA_H
00002 
00003 #include <stdlib/alloca.h>
00004 #include <stackinfo.h>
00005 
00006 #undef __alloca
00007 
00008 /* Now define the internal interfaces.  */
00009 extern void *__alloca (size_t __size);
00010 
00011 #ifdef __GNUC__
00012 # define __alloca(size)     __builtin_alloca (size)
00013 #endif /* GCC.  */
00014 
00015 extern int __libc_use_alloca (size_t size) __attribute__ ((const));
00016 extern int __libc_alloca_cutoff (size_t size) __attribute__ ((const));
00017 
00018 #define __MAX_ALLOCA_CUTOFF 65536
00019 
00020 #include <allocalim.h>
00021 
00022 #if _STACK_GROWS_DOWN
00023 # define extend_alloca(buf, len, newlen) \
00024   (__typeof (buf)) ({ size_t __newlen = (newlen);                           \
00025                     char *__newbuf = __alloca (__newlen);                   \
00026                     if (__newbuf + __newlen == (char *) buf)                \
00027                      len += __newlen;                                \
00028                     else                                             \
00029                      len = __newlen;                                        \
00030                     __newbuf; })
00031 #elif _STACK_GROWS_UP
00032 # define extend_alloca(buf, len, newlen) \
00033   (__typeof (buf)) ({ size_t __newlen = (newlen);                           \
00034                     char *__newbuf = __alloca (__newlen);                   \
00035                     char *__buf = (buf);                             \
00036                     if (__buf + __newlen == __newbuf)                       \
00037                      {                                               \
00038                        len += __newlen;                              \
00039                        __newbuf = __buf;                             \
00040                      }                                               \
00041                     else                                             \
00042                      len = __newlen;                                        \
00043                     __newbuf; })
00044 #else
00045 # define extend_alloca(buf, len, newlen) \
00046   __alloca (((len) = (newlen)))
00047 #endif
00048 
00049 #endif