From f4c2b1ba2b70c628c616e5a7ad8f604bc27ff876 Mon Sep 17 00:00:00 2001 From: David Wells Date: Thu, 29 May 2025 10:30:51 -0400 Subject: [PATCH] Add DEAL_II_BUILTIN_EXPECT(). This makes it easier to portably use this function. --- include/deal.II/base/exception_macros.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 -- 2.39.5