OSDN Git Service

move extend_alloca macro to alloca.h
authorPeter S. Mazinger <ps.m@gmx.net>
Fri, 16 Oct 2009 23:14:16 +0000 (01:14 +0200)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Thu, 19 Nov 2009 21:37:08 +0000 (22:37 +0100)
guard it by _LIBC. __MAX_ALLOCA_CUTOFF is not needed on target either

Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
include/alloca.h
include/libc-internal.h

index b4fc317..2565b48 100644 (file)
@@ -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
 
index 33956d8..8809bc0 100644 (file)
@@ -67,36 +67,6 @@ extern const char *__uclibc_progname attribute_hidden;
 
 # endif /* IS_IN_libc */
 
-/* #include <alloca.h> */
-#include <bits/stackinfo.h>
-#if defined(_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
-# warning unknown stack
-# define extend_alloca(buf, len, newlen) \
-  alloca (((len) = (newlen)))
-#endif
-
 #endif /* __ASSEMBLER__ */
 
 #endif /* _LIBC_INTERNAL_H */