From d573446841743e709c3da79b28051ab4fc18d3fd Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 24 Feb 2012 06:49:09 +0000 Subject: [PATCH] * configure.in (__builtin_unreachable): check for clang. [ruby-core:42849] * include/ruby/ruby.h (UNREACHABLE): fallback definition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ configure.in | 10 ++++++++++ include/ruby/ruby.h | 3 +++ 3 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index d5a24f1de5..9e9fc5180d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 24 15:49:07 2012 Nobuyoshi Nakada + + * configure.in (__builtin_unreachable): check for clang. + [ruby-core:42849] + + * include/ruby/ruby.h (UNREACHABLE): fallback definition. + Fri Feb 24 13:54:33 2012 Aaron Patterson * ext/psych/parser.c: prevent a memory leak by protecting calls to diff --git a/configure.in b/configure.in index 18ed6b53db..8f9e7d0810 100644 --- a/configure.in +++ b/configure.in @@ -908,6 +908,16 @@ if test "$GCC" = yes; then if test "$rb_cv_gcc_atomic_builtins" = yes; then AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS) fi + + AC_CACHE_CHECK(for __builtin_unreachable, rb_cv_func___builtin_unreachable, + [AC_TRY_LINK([@%:@include ], + [exit(0); __builtin_unreachable();], + [rb_cv_func___builtin_unreachable=yes], + [rb_cv_func___builtin_unreachable=no]) + ]) + if test "$rb_cv_func___builtin_unreachable" = yes; then + AC_DEFINE_UNQUOTED(UNREACHABLE, [__builtin_unreachable()]) + fi fi AC_CACHE_CHECK(for exported function attribute, rb_cv_func_exported, [ diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 75f0d71965..898d2e251d 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -36,6 +36,9 @@ extern "C" { #ifndef NOINLINE # define NOINLINE(x) x #endif +#ifndef UNREACHABLE +# define UNREACHABLE /* unreachable */ +#endif #ifdef __GNUC__ #define PRINTF_ARGS(decl, string_index, first_to_check) \