2 // from: http://www.fortran-2000.com/ArnaudRecipes/CompilerTricks.html
5 // Starting with glibc 2.2, the following C99-style (but glibc specific)
8 // #define _GNU_SOURCE 1
10 // static void __attribute__ ((constructor)) trapfpe(void)
12 // /* Enable some exceptions. At startup all exceptions are masked. */
13 // feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
18 // Previous versions of glibc require the following code.
21 #include <fpu_control.h>
22 static void __attribute__ ((constructor)) trapfpe(void)
25 _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM);
27 /* On x86, this expands to: */
28 /* unsigned int cw = 0x037f & ~(0x01 | 0x04 | 0x08); */
29 /* __asm__ ("fldcw %0" : : "m" (*&cw)); */