From 310764dcb491266a982d039907f721005b1650a2 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 1 May 2012 12:14:25 +1000 Subject: [PATCH] Add enable/disable floating point exceptions --- debug.cpp | 14 ++++++++++++++ debug.hpp | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/debug.cpp b/debug.cpp index 03e26d62..dce2f5e6 100644 --- a/debug.cpp +++ b/debug.cpp @@ -70,3 +70,17 @@ void unusual (void) { panic ("Unusual code path found."); } + + +#include + +void +enable_fpe (void) { + feenableexcept (FE_DIVBYZERO | FE_INVALID); +} + + +void +disable_fpe (void) { + feenableexcept (0); +} diff --git a/debug.hpp b/debug.hpp index 15dfd855..b88ebc47 100644 --- a/debug.hpp +++ b/debug.hpp @@ -154,4 +154,8 @@ void unusual (void); void breakpoint (void); + +void enable_fpe (void); +void disable_fpe (void); + #endif // __DEBUG_HPP