mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-05 15:33:57 -04:00
AP_Common: missing/fenv: fix coding style
This commit is contained in:
parent
484db9ff82
commit
c728b6c164
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include_next <fenv.h>
|
#include_next <fenv.h>
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
@ -6,37 +7,42 @@
|
|||||||
// Public domain polyfill for feenableexcept on OS X
|
// Public domain polyfill for feenableexcept on OS X
|
||||||
// http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c
|
// http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c
|
||||||
|
|
||||||
inline int
|
inline int feenableexcept(unsigned int excepts)
|
||||||
feenableexcept (unsigned int excepts)
|
|
||||||
{
|
{
|
||||||
static fenv_t fenv;
|
static fenv_t fenv;
|
||||||
unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
|
unsigned int new_excepts = excepts & FE_ALL_EXCEPT;
|
||||||
old_excepts; // previous masks
|
// previous masks
|
||||||
|
unsigned int old_excepts;
|
||||||
|
|
||||||
if ( fegetenv (&fenv) ) return -1;
|
if (fegetenv(&fenv)) {
|
||||||
old_excepts = fenv.__control & FE_ALL_EXCEPT;
|
return -1;
|
||||||
|
}
|
||||||
|
old_excepts = fenv.__control & FE_ALL_EXCEPT;
|
||||||
|
|
||||||
// unmask
|
// unmask
|
||||||
fenv.__control &= ~new_excepts;
|
fenv.__control &= ~new_excepts;
|
||||||
fenv.__mxcsr &= ~(new_excepts << 7);
|
fenv.__mxcsr &= ~(new_excepts << 7);
|
||||||
|
|
||||||
return ( fesetenv (&fenv) ? -1 : old_excepts );
|
return fesetenv(&fenv) ? -1 : old_excepts;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int fedisableexcept(unsigned int excepts)
|
||||||
fedisableexcept (unsigned int excepts)
|
|
||||||
{
|
{
|
||||||
static fenv_t fenv;
|
static fenv_t fenv;
|
||||||
unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
|
unsigned int new_excepts = excepts & FE_ALL_EXCEPT;
|
||||||
old_excepts; // all previous masks
|
// all previous masks
|
||||||
|
unsigned int old_excepts;
|
||||||
|
|
||||||
if ( fegetenv (&fenv) ) return -1;
|
if (fegetenv(&fenv)) {
|
||||||
old_excepts = fenv.__control & FE_ALL_EXCEPT;
|
return -1;
|
||||||
|
}
|
||||||
|
old_excepts = fenv.__control & FE_ALL_EXCEPT;
|
||||||
|
|
||||||
// mask
|
// mask
|
||||||
fenv.__control |= new_excepts;
|
fenv.__control |= new_excepts;
|
||||||
fenv.__mxcsr |= new_excepts << 7;
|
fenv.__mxcsr |= new_excepts << 7;
|
||||||
|
|
||||||
return ( fesetenv (&fenv) ? -1 : old_excepts );
|
return fesetenv(&fenv) ? -1 : old_excepts;
|
||||||
}
|
}
|
||||||
#endif // APPLE
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user