HAL_SITL: avoid floating point exceptions on i386

fixes issue #2147
This commit is contained in:
Andrew Tridgell 2015-04-27 13:08:50 +10:00
parent 4e86a6cd0e
commit 028248d1f5
1 changed files with 7 additions and 2 deletions

View File

@ -232,10 +232,15 @@ void SITLScheduler::system_initialized() {
panic( panic(
PSTR("PANIC: scheduler system initialized called more than once")); 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) { if (_sitlState->_sitl == NULL || _sitlState->_sitl->float_exception) {
feenableexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO); feenableexcept(exceptions);
} else { } else {
feclearexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO); feclearexcept(exceptions);
} }
_initialized = true; _initialized = true;
} }