61 static void ieee0(
bool enableTrap);
98 #define RNAN 0xffc00000
99 #define DNAN0 0xfff80000
104 #define RNAN 0xffc00000
105 #define DNAN0 0xfff80000
107 #endif // _PA_RISC1_1
110 # define RNAN 0xff800001
112 # define DNAN0 0xfff00000
116 # define DNAN1 0xfff00000
121 static unsigned Long rnan = RNAN, dnan0 = DNAN0, dnan1 = DNAN1;
147 static void ieee0(
bool enableTrap)
150 enableTrap ==
false, std::logic_error,
151 "Error, don't know how to turn off trap for MSpc!"
154 _control87(EM_DENORMAL | EM_UNDERFLOW | EM_INEXACT, MCW_EM);
159 signal(SIGFPE, SIG_DFL);
175 #include "/usr/include/sigfpe.h"
176 #include "/usr/include/sys/fpu.h"
178 static void ieeeuserhand(
unsigned std::exception[5],
int val[2])
181 fprintf(stderr,
"ieee0() aborting because of ");
182 if(std::exception[0]==_OVERFL) fprintf(stderr,
"overflow\n");
183 else if(std::exception[0]==_UNDERFL) fprintf(stderr,
"underflow\n");
184 else if(std::exception[0]==_DIVZERO) fprintf(stderr,
"divide by 0\n");
185 else if(std::exception[0]==_INVALID) fprintf(stderr,
"invalid operation\n");
186 else fprintf(stderr,
"\tunknown reason\n");
191 static void ieeeuserhand2(
unsigned int **j)
193 fprintf(stderr,
"ieee0() aborting because of confusion\n");
197 static void ieee0(
bool enableTrap)
200 enableTrap ==
false, std::logic_error,
201 "Error, don't know how to turn off trap for MIPS!"
205 sigfpe_[i].count = 1000;
206 sigfpe_[i].trace = 1;
207 sigfpe_[i].repls = _USER_DETERMINED;
209 sigfpe_[1].repls = _ZERO;
211 _EN_UNDERFL|_EN_OVERFL|_EN_DIVZERO|_EN_INVALID,
212 ieeeuserhand,_ABORT_ON_ERROR,ieeeuserhand2);
225 #include "fpu_control.h"
228 # ifndef USE_setfpucw
229 # define __setfpucw(x) __fpu_control = (x)
234 # undef Can_use__setfpucw
235 # define Can_use__setfpucw
238 static void ieee0(
bool enableTrap)
242 enableTrap ==
false, std::logic_error,
243 "Error, don't know how to turn off trap for LINUX!"
246 #if (defined(__mc68000__) || defined(__mc68020__) || defined(mc68020) || defined (__mc68k__))
252 #ifdef Can_use__setfpucw
253 __setfpucw(_FPU_IEEE + _FPU_DOUBLE + _FPU_MASK_OPERR + _FPU_MASK_DZ + _FPU_MASK_SNAN + _FPU_MASK_OVFL);
255 __fpu_control = _FPU_IEEE + _FPU_DOUBLE + _FPU_MASK_OPERR + _FPU_MASK_DZ + _FPU_MASK_SNAN + _FPU_MASK_OVFL;
256 _FPU_SETCW(__fpu_control);
259 #elif (defined(__powerpc__)||defined(_ARCH_PPC)||defined(_ARCH_PWR))
262 #ifdef Can_use__setfpucw
269 __setfpucw(_FPU_DEFAULT + _FPU_MASK_IM+_FPU_MASK_OM+_FPU_MASK_UM);
273 __fpu_control = _FPU_DEFAULT +_FPU_MASK_OM+_FPU_MASK_IM+_FPU_MASK_UM;
274 _FPU_SETCW(__fpu_control);
281 # ifndef _FPU_EXTENDED
282 # define _FPU_EXTENDED 0
286 # define _FPU_DOUBLE 0
289 #ifdef Can_use__setfpucw
290 __setfpucw(_FPU_IEEE - _FPU_EXTENDED + _FPU_DOUBLE - _FPU_MASK_IM - _FPU_MASK_ZM - _FPU_MASK_OM);
292 __fpu_control = _FPU_IEEE - _FPU_EXTENDED + _FPU_DOUBLE - _FPU_MASK_IM - _FPU_MASK_ZM - _FPU_MASK_OM;
293 _FPU_SETCW(__fpu_control);
299 true, std::logic_error,
300 "Error, don't know how to trap floating-point errors on this Linux system!"
322 #include <machine/fpu.h>
324 static void ieee0(
bool enableTrap)
327 enableTrap ==
false, std::logic_error,
328 "Error, don't know how to turn off trap for Alpha!"
330 ieee_set_fp_control(IEEE_TRAP_ENABLE_INV);
347 #define _INCLUDE_HPUX_SOURCE
353 # define fpsetmask fesettrapenable
354 # define FP_X_INV FE_INVALID
357 static void ieee0(
bool enableTrap)
360 enableTrap ==
false, std::logic_error,
361 "Error, don't know how to turn off trap for HPUX!"
379 static void ieee0(
bool enableTrap)
382 enableTrap ==
false, std::logic_error,
383 "Error, don't know how to turn off trap for AIX!"
385 fp_enable(TRP_INVALID);
386 fp_trap(FP_TRAP_SYNC);
402 static void ieee0(
bool enableTrap)
405 enableTrap ==
false, std::logic_error,
406 "Error, don't know how to turn off trap for SUN!"
421 static void ieee0(
bool enableTrap)
424 true, std::logic_error,
425 "Error, Don't know how to implement floating-point traps on this platform!"
431 #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.