summaryrefslogtreecommitdiff
path: root/lib/verify.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-10-03 00:06:52 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-10-03 00:06:52 -0700
commit0a858ebfc57a072ae8ab65f509d8a4901a2ec073 (patch)
treedd81bcdf11f3d3efa32ffe00f7cdc90d3c1144d9 /lib/verify.h
parentb52f569dcfc5c2e1b764c89d27ea8699a44228e6 (diff)
downloademacs-0a858ebfc57a072ae8ab65f509d8a4901a2ec073.tar.gz
Merge from gnulib.
* src/conf_post.h (__has_builtin, assume): Remove; gnulib now does these. * src/lisp.h: Include <verify.h>, for 'assume'. This also incorpoprates: 2013-10-02 verify: new macro 'assume' 2013-09-26 dup2, dup3: work around another cygwin crasher 2013-09-26 getdtablesize: work around cygwin issue
Diffstat (limited to 'lib/verify.h')
-rw-r--r--lib/verify.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/verify.h b/lib/verify.h
index d42d0750ee1..bf40b028c92 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -250,6 +250,30 @@ template <int w>
#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
+/* Assume that R always holds. This lets the compiler optimize
+ accordingly. R should not have side-effects; it may or may not be
+ evaluated. Behavior is undefined if R is false. */
+
+#if (__has_builtin (__builtin_unreachable) \
+ || 4 < __GNUC__ + (5 <= __GNUC_MINOR__))
+# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
+#elif 1200 <= _MSC_VER
+# define assume(R) __assume (R)
+#elif (defined lint \
+ && (__has_builtin (__builtin_trap) \
+ || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))))
+ /* Doing it this way helps various packages when configured with
+ --enable-gcc-warnings, which compiles with -Dlint. It's nicer
+ when 'assume' silences warnings even with older GCCs. */
+# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
+#else
+# define assume(R) ((void) (0 && (R)))
+#endif
+
/* @assert.h omit end@ */
#endif