diff options
author | Mike Frysinger <vapier@gentoo.org> | 2006-01-05 23:48:49 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2006-01-05 23:48:49 +0000 |
commit | ea35ab7829ae1aaae2b24408a7281ee94ce90478 (patch) | |
tree | 579e3e07a92707fcc93dedfc15a1d1538169eed7 | |
parent | 537d67f25d665032b9b86693f283203be11a2f97 (diff) |
import the extend_alloca() macro from glibc
-rw-r--r-- | include/libc-internal.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/libc-internal.h b/include/libc-internal.h index 2e372267f..6cd4feb53 100644 --- a/include/libc-internal.h +++ b/include/libc-internal.h @@ -322,6 +322,36 @@ extern int __sprintf (char *__restrict __s, #define fopen64 __fopen64 #endif +/* #include <alloca.h> */ +#include <bits/stackinfo.h> +#if _STACK_GROWS_DOWN +# define extend_alloca(buf, len, newlen) \ + (__typeof (buf)) ({ size_t __newlen = (newlen); \ + char *__newbuf = alloca (__newlen); \ + if (__newbuf + __newlen == (char *) buf) \ + len += __newlen; \ + else \ + len = __newlen; \ + __newbuf; }) +#elif _STACK_GROWS_UP +# define extend_alloca(buf, len, newlen) \ + (__typeof (buf)) ({ size_t __newlen = (newlen); \ + char *__newbuf = alloca (__newlen); \ + char *__buf = (buf); \ + if (__buf + __newlen == __newbuf) \ + { \ + len += __newlen; \ + __newbuf = __buf; \ + } \ + else \ + len = __newlen; \ + __newbuf; }) +#else +# warning unknown stack +# define extend_alloca(buf, len, newlen) \ + alloca (((len) = (newlen))) +#endif + /* #include <stdlib.h> */ extern char *__getenv (__const char *__name) attribute_hidden; extern void __exit (int __status) __THROW __attribute__ ((__noreturn__)) attribute_hidden; |