diff --git a/configure.ac b/configure.ac index cffe19b1..7d549aac 100644 --- a/configure.ac +++ b/configure.ac @@ -285,6 +285,17 @@ if test x$have__builtin___clear_cache = xyes; then fi AC_MSG_RESULT([$have__builtin___clear_cache]) +AC_MSG_CHECKING([for __builtin_unreachable]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[]], [[__builtin_unreachable()]])], + [have__builtin_unreachable=yes], + [have__builtin_unreachable=no]) +if test x$have__builtin_unreachable = xyes; then + AC_DEFINE([HAVE__BUILTIN_UNREACHABLE], [1], + [Defined if __builtin_unreachable() is available]) +fi +AC_MSG_RESULT([$have__builtin_unreachable]) + AC_MSG_CHECKING([for __sync atomics]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[ diff --git a/include/libunwind_i.h b/include/libunwind_i.h index 23f615e0..966a3e36 100644 --- a/include/libunwind_i.h +++ b/include/libunwind_i.h @@ -72,6 +72,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ # endif #endif +#if defined(HAVE__BUILTIN_UNREACHABLE) +# define unreachable() __builtin_unreachable() +#else +# define unreachable() do { } while (1) +#endif + #ifdef DEBUG # define UNW_DEBUG 1 #else diff --git a/src/arm/Gresume.c b/src/arm/Gresume.c index 4100d873..2e5e9fdd 100644 --- a/src/arm/Gresume.c +++ b/src/arm/Gresume.c @@ -96,7 +96,7 @@ arm_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc) ); } - __builtin_unreachable(); + unreachable(); #else printf ("%s: implement me\n", __FUNCTION__); #endif diff --git a/src/sh/Gresume.c b/src/sh/Gresume.c index 6a76fe12..536670ff 100644 --- a/src/sh/Gresume.c +++ b/src/sh/Gresume.c @@ -109,7 +109,7 @@ sh_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) "r" (c->sigcontext_pc) ); } - __builtin_unreachable(); + unreachable(); #endif return -UNW_EINVAL; }