]> https://gitweb.dealii.org/ - dealii.git/commitdiff
config.h: for consistency move DEAL_II_ASSUME macro to config.h.in
authorMatthias Maier <tamiko@43-1.org>
Fri, 19 Jan 2024 17:15:04 +0000 (11:15 -0600)
committerMatthias Maier <tamiko@43-1.org>
Fri, 19 Jan 2024 17:21:08 +0000 (11:21 -0600)
include/deal.II/base/config.h.in
include/deal.II/base/exceptions.h

index 9ca48428da0fda7bd6fb4701492fb49b533c35c1..8dbd40e313e36804f4a91fe6eff7bf345222f085 100644 (file)
 #cmakedefine DEAL_II_HAVE_CXX20
 #cmakedefine DEAL_II_HAVE_CXX23
 
+#cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS
+#cmakedefine DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
+#cmakedefine DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS
+#cmakedefine DEAL_II_CXX14_CONSTEXPR_BUG
+
+// The following three are defined for backwards compatibility with older
+// deal.II versions:
+#define DEAL_II_WITH_CXX11
+#define DEAL_II_WITH_CXX14
+#define DEAL_II_WITH_CXX17
+
 /**
  * If we have C++20 available, we can have concepts and requires
  * clauses. We want to avoid using too many `#ifdef` statements, so
 #  define DEAL_II_CXX20_REQUIRES(condition)
 #endif
 
-#cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS
-#cmakedefine DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
-#cmakedefine DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS
-#cmakedefine DEAL_II_CXX14_CONSTEXPR_BUG
+/**
+ * Provide support for the C++23 [[assume]] attribute. To mimic the
+ * attribute for older standards we rely on compiler intrinsics when
+ * available.
+ */
+#if defined(__clang__)
+#  define DEAL_II_ASSUME(expr) __builtin_assume(static_cast<bool>(expr))
+#elif defined(__GNUC__) && !defined(__ICC) && __GNUC__ >= 13
+#  define DEAL_II_ASSUME(expr)                                         \
+    do                                                                 \
+      {                                                                \
+        _Pragma("GCC diagnostic push")                                 \
+          _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") \
+            [[assume(expr)]];                                          \
+        _Pragma("GCC diagnostic pop")                                  \
+      }                                                                \
+    while (false)
+#elif defined(_MSC_VER) || defined(__ICC)
+#  define DEAL_II_ASSUME(expr) __assume(expr);
+#else
+/* no way with GCC to express this without evaluating 'expr' */
+#  define DEAL_II_ASSUME(expr) \
+    do                         \
+      {                        \
+      }                        \
+    while (false)
+#endif
 
 /**
  * Macro indicating that the current feature will be removed in a future
 #cmakedefine DEAL_II_FALLTHROUGH @DEAL_II_FALLTHROUGH@
 #cmakedefine DEAL_II_CONSTEXPR @DEAL_II_CONSTEXPR@
 
-// The following three are defined for backwards compatibility with older deal.II versions:
-#define DEAL_II_WITH_CXX11
-#define DEAL_II_WITH_CXX14
-#define DEAL_II_WITH_CXX17
-
 
 /***********************************************************************
  * System features:
index 2453809e5307cc7704ed43b42f8083c9e7e2306e..a82b4eeacd9a4f4d0ccbec55ab096b287c9b6cd0 100644 (file)
@@ -1519,38 +1519,6 @@ namespace deal_II_exceptions
 } /*namespace deal_II_exceptions*/
 
 
-#if defined(__clang__)
-#  define DEAL_II_ASSUME(expr) __builtin_assume(static_cast<bool>(expr))
-#elif defined(__GNUC__) && !defined(__ICC)
-#  if __GNUC__ >= 13
-#    define DEAL_II_ASSUME(expr)                                         \
-      do                                                                 \
-        {                                                                \
-          _Pragma("GCC diagnostic push")                                 \
-            _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") \
-              [[assume(expr)]];                                          \
-          _Pragma("GCC diagnostic pop")                                  \
-        }                                                                \
-      while (false)
-#  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,

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.