diff --git a/ChangeLog b/ChangeLog index 8640355354..658cd99327 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri Nov 9 12:07:06 2012 Akinori MUSHA + + * 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] + Fri Nov 9 09:30:00 2012 Zachary Scott * io.c (IO#new): diff --git a/addr2line.c b/addr2line.c index 9528a8fa43..e102abba4f 100644 --- a/addr2line.c +++ b/addr2line.c @@ -32,9 +32,26 @@ #include #include -#if defined(HAVE_ALLOCA_H) -#include -#endif +/* 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 +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +void *alloca(); +# endif +# endif /* AIX */ +# endif /* HAVE_ALLOCA_H */ +#endif /* __GNUC__ */ #ifdef HAVE_DL_ITERATE_PHDR # ifndef _GNU_SOURCE diff --git a/eval_intern.h b/eval_intern.h index fb852cbca5..421900b147 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -31,27 +31,6 @@ #include #endif -/* 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 -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -void *alloca(); -# endif -# endif /* AIX */ -# endif /* HAVE_ALLOCA_H */ -#endif /* __GNUC__ */ - #ifndef HAVE_STRING_H char *strrchr(const char *, const char); #endif diff --git a/gc.c b/gc.c index f5411282c8..b930621065 100644 --- a/gc.c +++ b/gc.c @@ -65,27 +65,6 @@ #define rb_setjmp(env) RUBY_SETJMP(env) #define rb_jmp_buf rb_jmpbuf_t -/* 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 -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -void *alloca (); -# endif -# endif /* AIX */ -# endif /* HAVE_ALLOCA_H */ -#endif /* __GNUC__ */ - #ifndef GC_MALLOC_LIMIT #define GC_MALLOC_LIMIT 8000000 #endif 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;