From 1c0323adbc390c40453c4ad02150e26b55e0dbf5 Mon Sep 17 00:00:00 2001 From: knu Date: Fri, 9 Nov 2012 03:34:08 +0000 Subject: Fix build when gcc is used and the platform's libc lacks alloca(). * include/ruby/ruby.h (alloca), eval_intern.h (alloca), gc.c (alloca): Make alloca() globally available by moving the ultimate ifdef's to ruby/ruby.h. Gcc hides its builtin alloca() when compiling with -ansi, and linking thus fails on platforms that lack their own alloca() implementation in libc, which include OpenBSD and some ports of NetBSD. We use alloca() everywhere including from within third party C extentions, so alloca() must be made globally available. [Bug #7307] * addr2line.c (alloca): Replace the alloca() part with the ultimate ifdef's. [Bug #7307] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/ruby.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'include/ruby/ruby.h') diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index e8f0d15380..d432f4b1f7 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -73,13 +73,26 @@ extern "C" { #pragma GCC visibility push(default) #endif -#if defined(HAVE_ALLOCA_H) -#include +/* Make alloca work the best possible way. */ +#ifdef __GNUC__ +# ifndef atarist +# ifndef alloca +# define alloca __builtin_alloca +# endif +# endif /* atarist */ #else +# ifdef HAVE_ALLOCA_H +# include +# else # ifdef _AIX #pragma alloca -# endif -#endif +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +void *alloca(); +# endif +# endif /* AIX */ +# endif /* HAVE_ALLOCA_H */ +#endif /* __GNUC__ */ #if defined HAVE_UINTPTR_T && 0 typedef uintptr_t VALUE; -- cgit v1.2.3