28 static void ieee0(
bool enableTrap);
65 #define RNAN 0xffc00000
66 #define DNAN0 0xfff80000
71 #define RNAN 0xffc00000
72 #define DNAN0 0xfff80000
77 # define RNAN 0xff800001
79 # define DNAN0 0xfff00000
83 # define DNAN1 0xfff00000
88 static unsigned Long rnan = RNAN, dnan0 = DNAN0, dnan1 = DNAN1;
114 static void ieee0(
bool enableTrap)
117 enableTrap ==
false, std::logic_error,
118 "Error, don't know how to turn off trap for MSpc!"
121 _control87(EM_DENORMAL | EM_UNDERFLOW | EM_INEXACT, MCW_EM);
126 signal(SIGFPE, SIG_DFL);
142 #include "/usr/include/sigfpe.h"
143 #include "/usr/include/sys/fpu.h"
145 static void ieeeuserhand(
unsigned std::exception[5],
int val[2])
148 fprintf(stderr,
"ieee0() aborting because of ");
149 if(std::exception[0]==_OVERFL) fprintf(stderr,
"overflow\n");
150 else if(std::exception[0]==_UNDERFL) fprintf(stderr,
"underflow\n");
151 else if(std::exception[0]==_DIVZERO) fprintf(stderr,
"divide by 0\n");
152 else if(std::exception[0]==_INVALID) fprintf(stderr,
"invalid operation\n");
153 else fprintf(stderr,
"\tunknown reason\n");
158 static void ieeeuserhand2(
unsigned int **j)
160 fprintf(stderr,
"ieee0() aborting because of confusion\n");
164 static void ieee0(
bool enableTrap)
167 enableTrap ==
false, std::logic_error,
168 "Error, don't know how to turn off trap for MIPS!"
172 sigfpe_[i].count = 1000;
173 sigfpe_[i].trace = 1;
174 sigfpe_[i].repls = _USER_DETERMINED;
176 sigfpe_[1].repls = _ZERO;
178 _EN_UNDERFL|_EN_OVERFL|_EN_DIVZERO|_EN_INVALID,
179 ieeeuserhand,_ABORT_ON_ERROR,ieeeuserhand2);
192 #include "fpu_control.h"
195 # ifndef USE_setfpucw
196 # define __setfpucw(x) __fpu_control = (x)
201 # undef Can_use__setfpucw
202 # define Can_use__setfpucw
205 static void ieee0(
bool enableTrap)
209 enableTrap ==
false, std::logic_error,
210 "Error, don't know how to turn off trap for LINUX!"
213 #if (defined(__mc68000__) || defined(__mc68020__) || defined(mc68020) || defined (__mc68k__))
219 #ifdef Can_use__setfpucw
220 __setfpucw(_FPU_IEEE + _FPU_DOUBLE + _FPU_MASK_OPERR + _FPU_MASK_DZ + _FPU_MASK_SNAN + _FPU_MASK_OVFL);
222 __fpu_control = _FPU_IEEE + _FPU_DOUBLE + _FPU_MASK_OPERR + _FPU_MASK_DZ + _FPU_MASK_SNAN + _FPU_MASK_OVFL;
223 _FPU_SETCW(__fpu_control);
226 #elif (defined(__powerpc__)||defined(_ARCH_PPC)||defined(_ARCH_PWR))
229 #ifdef Can_use__setfpucw
236 __setfpucw(_FPU_DEFAULT + _FPU_MASK_IM+_FPU_MASK_OM+_FPU_MASK_UM);
240 __fpu_control = _FPU_DEFAULT +_FPU_MASK_OM+_FPU_MASK_IM+_FPU_MASK_UM;
241 _FPU_SETCW(__fpu_control);
248 # ifndef _FPU_EXTENDED
249 # define _FPU_EXTENDED 0
253 # define _FPU_DOUBLE 0
256 #ifdef Can_use__setfpucw
257 __setfpucw(_FPU_IEEE - _FPU_EXTENDED + _FPU_DOUBLE - _FPU_MASK_IM - _FPU_MASK_ZM - _FPU_MASK_OM);
259 __fpu_control = _FPU_IEEE - _FPU_EXTENDED + _FPU_DOUBLE - _FPU_MASK_IM - _FPU_MASK_ZM - _FPU_MASK_OM;
260 _FPU_SETCW(__fpu_control);
266 true, std::logic_error,
267 "Error, don't know how to trap floating-point errors on this Linux system!"
289 #include <machine/fpu.h>
291 static void ieee0(
bool enableTrap)
294 enableTrap ==
false, std::logic_error,
295 "Error, don't know how to turn off trap for Alpha!"
297 ieee_set_fp_control(IEEE_TRAP_ENABLE_INV);
314 #define _INCLUDE_HPUX_SOURCE
320 # define fpsetmask fesettrapenable
321 # define FP_X_INV FE_INVALID
324 static void ieee0(
bool enableTrap)
327 enableTrap ==
false, std::logic_error,
328 "Error, don't know how to turn off trap for HPUX!"
346 static void ieee0(
bool enableTrap)
349 enableTrap ==
false, std::logic_error,
350 "Error, don't know how to turn off trap for AIX!"
352 fp_enable(TRP_INVALID);
353 fp_trap(FP_TRAP_SYNC);
369 static void ieee0(
bool enableTrap)
372 enableTrap ==
false, std::logic_error,
373 "Error, don't know how to turn off trap for SUN!"
388 static void ieee0(
bool enableTrap)
391 true, std::logic_error,
392 "Error, Don't know how to implement floating-point traps on this platform!"
398 #endif // 0 // Disabled!
void doFloatingPointTrap(bool enableTrap)
Turn on or off a floating point trap.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.