summaryrefslogtreecommitdiffabout
authorBruno Haible <bruno@clisp.org>2020-08-07 00:12:09 (GMT)
committer Bruno Haible <bruno@clisp.org>2020-08-07 00:12:09 (GMT)
commit564afbf88812844f83589d091bff88af55556de6 (patch) (side-by-side diff)
treeecf93311fd3e6f63ea19734c31549ef27cee781c
parentfef32067411958cf5b7300de0de92ab179bee149 (diff)
downloadgnulib-master.tar.gz
gnulib-master.tar.bz2
Use __builtin_assume with clang.HEADmaster
* lib/verify.h (_GL_HAS_BUILTIN_ASSUME): New macro. (assume): Use __builtin_assume when available.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ChangeLog6
-rw-r--r--lib/verify.h11
2 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d78accc..19aff68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1 +1,7 @@
+2020-08-06 Bruno Haible <bruno@clisp.org>
+
+ Use __builtin_assume with clang.
+ * lib/verify.h (_GL_HAS_BUILTIN_ASSUME): New macro.
+ (assume): Use __builtin_assume when available.
+
2020-08-06 Paul Eggert <eggert@cs.ucla.edu>
diff --git a/lib/verify.h b/lib/verify.h
index f109761..58172f3 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -235,2 +235,9 @@ template <int w>
+#if defined __has_builtin
+/* <https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions> */
+# define _GL_HAS_BUILTIN_ASSUME __has_builtin (__builtin_assume)
+#else
+# define _GL_HAS_BUILTIN_ASSUME 0
+#endif
+
#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
@@ -296,3 +303,5 @@ template <int w>
-#if _GL_HAS_BUILTIN_UNREACHABLE
+#if _GL_HAS_BUILTIN_ASSUME
+# define assume(R) __builtin_assume (R)
+#elif _GL_HAS_BUILTIN_UNREACHABLE
# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())

Return to:

Send suggestions and report system problems to the System administrator.