Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a DEAL_II_ASSUME macro. #16393

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 26 additions & 10 deletions include/deal.II/base/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,30 @@ namespace deal_II_exceptions



#if defined(__clang__)
# define DEAL_II_ASSUME(expr) __builtin_assume(expr)
#elif defined(__GNUC__) && !defined(__ICC)
# if __GNUC__ >= 13
# define DEAL_II_ASSUME(expr) __attribute__((__assume__(expr)))
# else
/* no way with GCC to express this without evaluating 'expr' */
# define DEAL_II_ASSUME(expr) \
do \
{ \
} \
while (false)
# endif
#elif defined(_MSC_VER) || defined(__ICC)
# define DEAL_II_ASSUME(expr) __assume(expr)
#else
# define DEAL_II_ASSUME(expr) \
do \
{ \
} \
while (false)
#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,
Expand Down Expand Up @@ -1638,11 +1662,7 @@ namespace deal_II_exceptions
# endif /*ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/
# endif /*KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST*/
#else /*ifdef DEBUG*/
# define Assert(cond, exc) \
do \
{ \
} \
while (false)
# define Assert(cond, exc) DEAL_II_ASSUME(cond)
#endif /*ifdef DEBUG*/


Expand Down Expand Up @@ -1694,11 +1714,7 @@ namespace deal_II_exceptions
while (false)
# endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
#else
# define AssertNothrow(cond, exc) \
do \
{ \
} \
while (false)
# define AssertNothrow(cond, exc) DEAL_II_ASSUME(cond)
#endif

/**
Expand Down