Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 10b064ffe902d5af31bb49bd8e4f03c545f8d462 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ladislav Michl <ladis@linux-mips.org> |
| 3 | Date: Tue, 13 Nov 2012 11:19:47 +0100 |
| 4 | Subject: [PATCH] Support building with older compilers. |
| 5 | |
| 6 | Add a check for __builtin_unreachable. |
| 7 | |
| 8 | Upstream-Status: Pending |
| 9 | --- |
| 10 | configure.ac | 11 +++++++++++ |
| 11 | include/libunwind_i.h | 6 ++++++ |
| 12 | src/arm/Gresume.c | 2 +- |
| 13 | src/sh/Gresume.c | 2 +- |
| 14 | 4 files changed, 19 insertions(+), 2 deletions(-) |
| 15 | |
| 16 | --- a/configure.ac |
| 17 | +++ b/configure.ac |
| 18 | @@ -285,6 +285,17 @@ if test x$have__builtin___clear_cache = |
| 19 | fi |
| 20 | AC_MSG_RESULT([$have__builtin___clear_cache]) |
| 21 | |
| 22 | +AC_MSG_CHECKING([for __builtin_unreachable]) |
| 23 | +AC_LINK_IFELSE( |
| 24 | + [AC_LANG_PROGRAM([[]], [[__builtin_unreachable()]])], |
| 25 | + [have__builtin_unreachable=yes], |
| 26 | + [have__builtin_unreachable=no]) |
| 27 | +if test x$have__builtin_unreachable = xyes; then |
| 28 | + AC_DEFINE([HAVE__BUILTIN_UNREACHABLE], [1], |
| 29 | + [Defined if __builtin_unreachable() is available]) |
| 30 | +fi |
| 31 | +AC_MSG_RESULT([$have__builtin_unreachable]) |
| 32 | + |
| 33 | AC_MSG_CHECKING([for __sync atomics]) |
| 34 | AC_LINK_IFELSE( |
| 35 | [AC_LANG_PROGRAM([[]], [[ |
| 36 | --- a/include/libunwind_i.h |
| 37 | +++ b/include/libunwind_i.h |
| 38 | @@ -72,6 +72,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE |
| 39 | # endif |
| 40 | #endif |
| 41 | |
| 42 | +#if defined(HAVE__BUILTIN_UNREACHABLE) |
| 43 | +# define unreachable() __builtin_unreachable() |
| 44 | +#else |
| 45 | +# define unreachable() do { } while (1) |
| 46 | +#endif |
| 47 | + |
| 48 | #ifdef DEBUG |
| 49 | # define UNW_DEBUG 1 |
| 50 | #else |
| 51 | --- a/src/arm/Gresume.c |
| 52 | +++ b/src/arm/Gresume.c |
| 53 | @@ -96,7 +96,7 @@ arm_local_resume (unw_addr_space_t as, u |
| 54 | : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc) |
| 55 | ); |
| 56 | } |
| 57 | - __builtin_unreachable(); |
| 58 | + unreachable(); |
| 59 | #else |
| 60 | printf ("%s: implement me\n", __FUNCTION__); |
| 61 | #endif |
| 62 | --- a/src/sh/Gresume.c |
| 63 | +++ b/src/sh/Gresume.c |
| 64 | @@ -109,7 +109,7 @@ sh_local_resume (unw_addr_space_t as, un |
| 65 | "r" (c->sigcontext_pc) |
| 66 | ); |
| 67 | } |
| 68 | - __builtin_unreachable(); |
| 69 | + unreachable(); |
| 70 | #endif |
| 71 | return -UNW_EINVAL; |
| 72 | } |