]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add DEAL_II_BUILTIN_EXPECT().
authorDavid Wells <drwells@email.unc.edu>
Thu, 29 May 2025 14:30:51 +0000 (10:30 -0400)
committerDavid Wells <drwells@email.unc.edu>
Thu, 29 May 2025 15:14:56 +0000 (11:14 -0400)
This makes it easier to portably use this function.

include/deal.II/base/exception_macros.h

index 3aa130c6dae48a9aea2f0e8cb058a8e355b7ab79..530bbcb107308259f51f8e2ff58f8586df9327ec 100644 (file)
  * to have `#include <deal.II/base/exceptions.h>`.
  */
 
+/**
+ * Wrapper macro around __builtin_expect(). Only used in the assertion macros
+ * (Assert(), AssertNothrow(), and AssertThrow()).
+ */
+#ifdef DEAL_II_HAVE_BUILTIN_EXPECT
+#  define DEAL_II_BUILTIN_EXPECT(a, b) __builtin_expect((a), (b))
+#else
+#  define DEAL_II_BUILTIN_EXPECT(a, b) (a)
+#endif
+
+
 /**
  * A macro that serves as the main routine in the exception mechanism for debug
  * mode error checking. It asserts that a certain condition is fulfilled,
 #  define AssertIDA(code) Assert(code >= 0, ExcIDAError(code))
 #endif
 
-
 #endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.