From 028248d1f5c575411fde41883d737cfc92ed9d66 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Apr 2015 13:08:50 +1000 Subject: [PATCH] HAL_SITL: avoid floating point exceptions on i386 fixes issue #2147 --- libraries/AP_HAL_AVR_SITL/Scheduler.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/AP_HAL_AVR_SITL/Scheduler.cpp b/libraries/AP_HAL_AVR_SITL/Scheduler.cpp index 21bee7d9dc..70d1257cfc 100644 --- a/libraries/AP_HAL_AVR_SITL/Scheduler.cpp +++ b/libraries/AP_HAL_AVR_SITL/Scheduler.cpp @@ -232,10 +232,15 @@ void SITLScheduler::system_initialized() { panic( PSTR("PANIC: scheduler system initialized called more than once")); } + int exceptions = FE_OVERFLOW | FE_DIVBYZERO; +#ifndef __i386__ + // i386 with gcc doesn't work with FE_INVALID + exceptions |= FE_INVALID; +#endif if (_sitlState->_sitl == NULL || _sitlState->_sitl->float_exception) { - feenableexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO); + feenableexcept(exceptions); } else { - feclearexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO); + feclearexcept(exceptions); } _initialized = true; }