From 3ddf66206aff3a2b3ca4079d87819667d42cd440 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 4 Jan 2002 20:56:28 +0000 Subject: [PATCH] Don't generate FPEs for Linux for now, until PPE model loading is fixed. Developers can uncomment lines to get FPEs for debugging. --- src/Main/main.cxx | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index a777195c1..9584e8c95 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -27,6 +27,7 @@ #if defined(__linux__) && defined(__i386__) # include +# include #endif #include @@ -1770,20 +1771,39 @@ int mainLoop( int argc, char **argv ) { // $$$ end - added VS Renganathan, 15 Oct 2K // - added Venky , 12 Nov 2K +#if defined(__linux__) && defined(__i386__) + +static void handleFPE (int); + +static void +initFPE () +{ + fpu_control_t fpe_flags = 0; + _FPU_GETCW(fpe_flags); +// fpe_flags &= ~_FPU_MASK_IM; // invalid operation +// fpe_flags &= ~_FPU_MASK_DM; // denormalized operand +// fpe_flags &= ~_FPU_MASK_ZM; // zero-divide +// fpe_flags &= ~_FPU_MASK_OM; // overflow +// fpe_flags &= ~_FPU_MASK_UM; // underflow +// fpe_flags &= ~_FPU_MASK_PM; // precision (inexact result) + _FPU_SETCW(fpe_flags); + signal(SIGFPE, handleFPE); +} + +static void +handleFPE (int num) +{ + initFPE(); + SG_LOG(SG_GENERAL, SG_ALERT, "Floating point interrupt (SIGFPE)"); +} +#endif + // Main entry point; catch any exceptions that have made it this far. int main ( int argc, char **argv ) { // Enable floating-point exceptions for Linux/x86 #if defined(__linux__) && defined(__i386__) - fpu_control_t fpe_flags; - _FPU_GETCW(fpe_flags); -// fpe_flags &= ~_FPU_MASK_IM; // invalid operation -// fpe_flags &= ~_FPU_MASK_DM; // denormalized operand - fpe_flags &= ~_FPU_MASK_ZM; // zero-divide -// fpe_flags &= ~_FPU_MASK_OM; // overflow -// fpe_flags &= ~_FPU_MASK_UM; // underflow -// fpe_flags &= ~_FPU_MASK_PM; // precision (inexact result) - _FPU_SETCW(fpe_flags); + initFPE(); #endif // Enable floating-point exceptions for Windows -- 2.39.5