Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SITL fixs for alpine linux #11871

Merged
merged 3 commits into from Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Tools/ardupilotwaf/boards.py
Expand Up @@ -360,6 +360,7 @@ def configure_env(self, cfg, env):
]

cfg.check_librt(env)
cfg.check_feenableexcept()

env.LINKFLAGS += ['-pthread',]
env.AP_LIBRARIES += [
Expand Down
16 changes: 16 additions & 0 deletions Tools/ardupilotwaf/cxx_checks.py
Expand Up @@ -169,6 +169,22 @@ def check_librt(cfg, env):

return ret

@conf
def check_feenableexcept(cfg):

cfg.check(
compiler='cxx',
fragment='''
#include <fenv.h>

int main() {
return feenableexcept(FE_OVERFLOW | FE_DIVBYZERO);
}''',
msg="Checking for feenableexcept",
define_name="HAVE_FEENABLEEXCEPT",
mandatory=False,
)

@conf
def check_package(cfg, env, libname):
'''use pkg-config to look for an installed library that has a LIBNAME.pc file'''
Expand Down
26 changes: 26 additions & 0 deletions libraries/AP_Common/missing/fenv.h
Expand Up @@ -2,6 +2,7 @@

#include_next <fenv.h>

#ifndef HAVE_FEENABLEEXCEPT
#if defined(__APPLE__) && defined(__MACH__)

// Public domain polyfill for feenableexcept on OS X
Expand Down Expand Up @@ -45,4 +46,29 @@ inline int fedisableexcept(unsigned int excepts)
return fesetenv(&fenv) ? -1 : old_excepts;
}

#else
inline int feenableexcept(unsigned int excepts)
{
#pragma STDC FENV_ACCESS ON
fexcept_t flags;
/* Save current exception flags. */
fegetexceptflag(&flags, FE_ALL_EXCEPT);

feclearexcept(FE_ALL_EXCEPT); /* clear all fp exception conditions */
return fesetexceptflag(&flags, excepts) != 0 ? -1 : flags; /* set new flags */

}

inline int fedisableexcept(unsigned int excepts)
{
#pragma STDC FENV_ACCESS ON
fexcept_t flags;
/* Save current exception flags. */
fegetexceptflag(&flags, FE_ALL_EXCEPT);

feclearexcept(FE_ALL_EXCEPT); /* clear all fp exception conditions */
return fesetexceptflag(&flags, ~excepts) != 0 ? -1 : flags; /* set new flags */
}

#endif
#endif
1 change: 1 addition & 0 deletions libraries/AP_HAL_SITL/UART_utils.cpp
Expand Up @@ -26,6 +26,7 @@
#ifdef USE_TERMIOS
#include <termios.h>
#else
#include <asm/ioctls.h>
#include <asm/termbits.h>
#endif

Expand Down