From: David Wells Date: Thu, 29 May 2025 14:30:51 +0000 (-0400) Subject: Add DEAL_II_BUILTIN_EXPECT(). X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4c2b1ba2b70c628c616e5a7ad8f604bc27ff876;p=dealii.git Add DEAL_II_BUILTIN_EXPECT(). This makes it easier to portably use this function. --- diff --git a/include/deal.II/base/exception_macros.h b/include/deal.II/base/exception_macros.h index 3aa130c6da..530bbcb107 100644 --- a/include/deal.II/base/exception_macros.h +++ b/include/deal.II/base/exception_macros.h @@ -479,6 +479,17 @@ * to have `#include `. */ +/** + * 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, @@ -1152,5 +1163,4 @@ # define AssertIDA(code) Assert(code >= 0, ExcIDAError(code)) #endif - #endif