Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'copy_on_write' into caller_for_all_threads

  • Loading branch information...
commit 57c90f2045888a97673387ab473f38837e91c3c2 2 parents 2e95d94 + 00b2e69
@FooBarWidget authored
Showing with 41 additions and 2 deletions.
  1. +36 −1 configure.in
  2. +5 −1 rubysig.h
View
37 configure.in
@@ -154,7 +154,8 @@ if test $frame_address = yes; then
fi
AC_ARG_ENABLE(mbari-api,
[ --enable-mbari-api enable API changes from the MBARI patches. ],
- [mbari_api=$enableval])
+ [mbari_api=$enableval],
+ [mbari_api=yes])
if test "$mbari_api" = yes; then
AC_DEFINE(MBARI_API)
fi
@@ -620,6 +621,40 @@ powerpc-darwin*)
;;
*)
AC_FUNC_ALLOCA
+ if test $ac_cv_func_alloca_works = yes; then
+ # On Apple uses llvm-gcc since Xcode 4. llvm-gcc has this nice bug
+ # where __builtin_alloca(0) would return non-NULL with -O0, but NULL
+ # with -O2...
+ AC_CACHE_CHECK(whether alloca(0) returns the stack pointer, rb_cv_alloca_0_returns_stack_pointer,
+ [AC_TRY_RUN([
+#ifdef HAVE_ALLOCA_H_
+# include <alloca.h>
+#endif
+#include <stdlib.h>
+int
+main()
+{
+ /* It's important that we assign the result of alloca to a variable!
+ * If we put it in the if-statement then the compiler's -O2 optimizations
+ * will optimize it away to "if (true)", thereby bypassing our
+ * llvm-gcc bug detection! Let's put 'volatile' in there too,
+ * just in case.
+ */
+ volatile void *addr = alloca(0);
+ if (addr != NULL) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+],
+ rb_cv_alloca_0_returns_stack_pointer=yes,
+ rb_cv_alloca_0_returns_stack_pointer=no,
+ rb_cv_alloca_0_returns_stack_pointer=no)])
+ if test $rb_cv_alloca_0_returns_stack_pointer = yes; then
+ AC_DEFINE(ALLOCA_0_RETURNS_STACK_POINTER, 1)
+ fi
+ fi
;;
esac
AC_FUNC_MEMCMP
View
6 rubysig.h
@@ -234,7 +234,11 @@ __defspfn("mov %0, sp": "=r"(sp))
# warning No assembly version of __sp() defined for this CPU.
# endif
# else
-# define __sp() ((VALUE *)__builtin_alloca(0))
+# if ALLOCA_0_RETURNS_STACK_POINTER
+# define __sp() ((VALUE *)__builtin_alloca(0))
+# else
+# define __sp() ((VALUE *)__builtin_alloca(sizeof(void *)))
+# endif /* ALLOCA_0_RETURNS_STACK_POINTER */
# endif
#else // not GNUC
Please sign in to comment.
Something went wrong with that request. Please try again.