#ifdef __linux
-#include <fpu_control.h>
-void __attribute__ ((constructor))
- trapfpe () {
- fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM |
- _FPU_MASK_OM);
- _FPU_SETCW(cw);
+#define _GNU_SOURCE 1
+#include <fenv.h>
+static void __attribute__ ((constructor)) trapfpe(void)
+{
+ /* Enable some exceptions. At startup all exceptions are masked. */
+ feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
}
+#else
+void trapfpe () {}
#endif