#endif
}
+int gmx_fedisableexcept()
+{
+#if HAVE_FEDISABLEEXCEPT
+ return fedisableexcept(c_FPexceptions);
+#elif (defined(__i386__) || defined(__x86_64__)) && defined(__APPLE__)
+ static fenv_t fenv;
+ unsigned int new_excepts = c_FPexceptions & FE_ALL_EXCEPT;
+ if (fegetenv (&fenv) )
+ {
+ return -1;
+ }
+
+ // mask
+ fenv.__control |= new_excepts;
+ fenv.__mxcsr |= new_excepts << 7;
+
+ return fesetenv(&fenv);
+#else
+ return -1;
+#endif
+}
+
real max_cutoff(real cutoff1, real cutoff2)
{
if (cutoff1 == 0 || cutoff2 == 0)
*/
int gmx_feenableexcept();
+/*! \brief Disable floating-point exceptions if supported on OS
+ *
+ * Disables division-by-zero, invalid value, and overflow.
+ *
+ * \returns 0 if successful in disabling exceptions, anything else in case of failure/unsupported OS.
+ */
+int gmx_fedisableexcept();
+
/*! \brief Return cut-off to use
*
* Takes the max of two cut-offs. However a cut-off of 0
fplog = nullptr;
}
+ /* Reset FPEs (important for unit tests) by disabling them. Assumes no
+ * exceptions were enabled before function was called. */
+#if !defined NDEBUG && !(defined __clang__ && defined __OPTIMIZE__)
+ if (!EI_TPI(inputrec->eI) &&
+ inputrec->cutoff_scheme == ecutsVERLET)
+ {
+ gmx_fedisableexcept();
+ }
+#endif
+
rc = (int)gmx_get_stop_condition();
#if GMX_THREAD_MPI