13 #include <xmmintrin.h> 
   21 static constexpr 
int LFpe = LogArea::Fpe::id;
 
   23 #if !defined _GNU_SOURCE && defined __SSE__ && !defined __clang__ 
   25   static_assert(FE_INVALID == 0x01,
 
   26                 "incorrect assumption that FE_INVALID == 0x01");
 
   27   static_assert(FE_DIVBYZERO == 0x04,
 
   28                 "incorrect assumption that FE_DIVBYZERO == 0x04");
 
   29   static_assert(FE_OVERFLOW == 0x08,
 
   30                 "incorrect assumption that FE_OVERFLOW == 0x08");
 
   31   static_assert(FE_UNDERFLOW == 0x10,
 
   32                 "incorrect assumption that FE_UNDERFLOW == 0x10");
 
   33   static_assert(FE_INEXACT == 0x20,
 
   34                 "incorrect assumption that FE_INEXACT == 0x20");
 
   37   femask &= FE_ALL_EXCEPT;
 
   42   asm volatile(
"fstcw %0" : 
"=m"(fpucw));
 
   48   asm volatile(
"fldcw %0" ::
"m"(fpucw));
 
   56   _mm_setcsr(_mm_getcsr() & ~femask);
 
   65     logg[
LFpe].warn(
"Failed to setup traps on ", mask);
 
   73       logg[
LFpe].warn(
"Failed to setup trap on pole error.");
 
   78       logg[
LFpe].warn(
"Failed to setup trap on domain error.");
 
   84       logg[
LFpe].warn(
"Failed to setup trap on overflow.");
 
   96 #if (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 199309L) || \ 
   97     (defined _XOPEN_SOURCE && _XOPEN_SOURCE) ||                \ 
   98     (defined _POSIX_SOURCE && _POSIX_SOURCE) 
  102 #pragma GCC diagnostic ignored "-Wmissing-field-initializers" 
  103   struct sigaction action = {};
 
  104   action.sa_flags = SA_SIGINFO;
 
  105   action.sa_sigaction = [](
int signal, siginfo_t *info, 
void *) {
 
  106     if (signal == SIGFPE) {
 
  107       const char *msg = 
nullptr;
 
  108       switch (info->si_code) {
 
  110           msg = 
"Division by Zero (NaN)";
 
  113           msg = 
"Underflow (result was subnormal with a loss of precision)";
 
  116           msg = 
"Overflow (result was too large to be representable)";
 
  119           msg = 
"Invalid (domain error occurred)";
 
  123               "Inexact Result (rounding was necessary to store the result of " 
  124               "an earlier floating-point operation)";
 
  131                        "Floating point trap was raised: ", msg);
 
  134                        " received in the FPE signal handler. Aborting.");
 
  138   sigaction(SIGFPE, &action, 
nullptr);
 
void reenable_traps(int mask)
Reenables the given traps.
 
#define SMASH_SOURCE_LOCATION
Hackery that is required to output the location in the source code where the log statement occurs.
 
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
 
bool enable_float_traps(int)
Fallback that fails to set the trap.
 
static constexpr int LFpe
 
void setup_default_float_traps()
Setup the floating-point traps used throughout SMASH.