diff options
Diffstat (limited to 'include/alloca.h')
| -rw-r--r-- | include/alloca.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/include/alloca.h b/include/alloca.h index b4fc31738..b3a1e4a6a 100644 --- a/include/alloca.h +++ b/include/alloca.h @@ -12,9 +12,8 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #ifndef _ALLOCA_H #define _ALLOCA_H 1 @@ -36,7 +35,40 @@ 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 + +extern int __libc_alloca_cutoff (size_t size); +#endif __END_DECLS |
