summaryrefslogtreecommitdiffstats
path: root/sys/sys/cdefs.h
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2015-05-14 15:49:48 +0000
committerpfg <pfg@FreeBSD.org>2015-05-14 15:49:48 +0000
commitf7984cfbeee89ab50566d7d09e6d0238505f0a83 (patch)
tree2911157c89ddf65d9209ac5640b0e5ba973d3c58 /sys/sys/cdefs.h
parent1288a9c61937a95d6586948da68c17b9b867bee3 (diff)
downloadFreeBSD-src-f7984cfbeee89ab50566d7d09e6d0238505f0a83.zip
FreeBSD-src-f7984cfbeee89ab50566d7d09e6d0238505f0a83.tar.gz
Add new __unreachable() builtin
This is one of the few post gcc4.2 builtins that has been implemented by clang: __builtin_unreachable is used to indicate that a specific point in the program cannot be reached, even if the compiler might otherwise think it can. This is useful to improve optimization and eliminates certain warnings. Hinted by: NetBSD Differential Revision: https://reviews.freebsd.org/D2536
Diffstat (limited to 'sys/sys/cdefs.h')
-rw-r--r--sys/sys/cdefs.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index a7286ab..73734cb 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -388,6 +388,12 @@
#define __alloc_size(x)
#endif
+#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
+#define __unreachable() __builtin_unreachable()
+#else
+#define __unreachable() do {} while (/*CONSTCOND*/0)
+#endif
+
#if __has_attribute(alloc_align) || __GNUC_PREREQ__(4, 9)
#define __alloc_align(x) __attribute__((__alloc_align__(x)))
#else
OpenPOWER on IntegriCloud