summaryrefslogtreecommitdiff
path: root/include/alloca.h
diff options
context:
space:
mode:
authorAustin Foxley <austinf@cetoncorp.com>2009-11-22 11:46:31 -0800
committerAustin Foxley <austinf@cetoncorp.com>2009-11-22 11:51:37 -0800
commitf757db2d319ccc5f7034165046fb2bb58901afb1 (patch)
tree7dc465febb3a802d3f0e8856fcda856b13b04c0a /include/alloca.h
parent76c0c0ed99f74b8a5965be6e1c6a0c0e7a72513c (diff)
parentb71274eebd68b7c68ab95c856f8075bdf4524cd7 (diff)
Merge remote branch 'origin/master' into nptl_merge
Conflicts: Rules.mak libc/misc/sysvipc/msgq.c test/Rules.mak Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'include/alloca.h')
-rw-r--r--include/alloca.h33
1 files changed, 32 insertions, 1 deletions
diff --git a/include/alloca.h b/include/alloca.h
index b4fc31738..2565b4835 100644
--- a/include/alloca.h
+++ b/include/alloca.h
@@ -36,7 +36,38 @@ extern void *alloca (size_t __size) __THROW;
# define alloca(size) __builtin_alloca (size)
#endif /* GCC. */
-#define __MAX_ALLOCA_CUTOFF 65536
+#ifdef _LIBC
+# define __MAX_ALLOCA_CUTOFF 65536
+
+# include <bits/stackinfo.h>
+# ifdef _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 defined _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
+# error unknown stack
+# define extend_alloca(buf, len, newlen) \
+ alloca (((len) = (newlen)))
+# endif
+#endif
__END_DECLS