[commit: ghc] master: refactor test for __builtin_unreachable into Rts.h macro RTS_UNREACHABLE (3551e62)
git at git.haskell.org
git at git.haskell.org
Mon Aug 15 20:26:24 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/3551e622ab3a833589a069b473a4dfb3f171e5b8/ghc
>---------------------------------------------------------------
commit 3551e622ab3a833589a069b473a4dfb3f171e5b8
Author: Karel Gardas <karel.gardas at centrum.cz>
Date: Mon Aug 15 22:26:04 2016 +0200
refactor test for __builtin_unreachable into Rts.h macro RTS_UNREACHABLE
Summary:
This patch refactors GNU C version test (for 4.5 and more modern)
due to usage of __builtin_unreachable done in the CNF.c code directly
into the new RTS_UNREACHABLE macro placed into Rts.h
Reviewers: bgamari, austin, simonmar, erikd
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2457
>---------------------------------------------------------------
3551e622ab3a833589a069b473a4dfb3f171e5b8
includes/Rts.h | 7 +++++++
rts/sm/CNF.c | 5 +----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/includes/Rts.h b/includes/Rts.h
index 3d4538f..be81b0d 100644
--- a/includes/Rts.h
+++ b/includes/Rts.h
@@ -61,6 +61,13 @@ extern "C" {
#define RTS_UNLIKELY(p) p
#endif
+/* __builtin_unreachable is supported since GNU C 4.5 */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define RTS_UNREACHABLE __builtin_unreachable()
+#else
+#define RTS_UNREACHABLE abort()
+#endif
+
/* Fix for mingw stat problem (done here so it's early enough) */
#ifdef mingw32_HOST_OS
#define __MSVCRT__ 1
diff --git a/rts/sm/CNF.c b/rts/sm/CNF.c
index 0594a6e..f8e706a 100644
--- a/rts/sm/CNF.c
+++ b/rts/sm/CNF.c
@@ -164,11 +164,8 @@ compactAllocateBlockInternal(Capability *cap,
default:
#ifdef DEBUG
ASSERT(!"code should not be reached");
-#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
- /* __builtin_unreachable is supported since GNU C 4.5 */
- __builtin_unreachable();
#else
- abort();
+ RTS_UNREACHABLE;
#endif
}
RELEASE_SM_LOCK;
More information about the ghc-commits
mailing list