Chris@16: /*============================================================================= Chris@16: Copyright (c) 2010 Bryce Lelbach Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: =============================================================================*/ Chris@16: Chris@16: #include Chris@16: Chris@16: #if defined(BOOST_NO_FENV_H) Chris@16: #error This platform does not have a floating point environment Chris@16: #endif Chris@16: Chris@16: #if !defined(BOOST_DETAIL_FENV_HPP) Chris@16: #define BOOST_DETAIL_FENV_HPP Chris@16: Chris@101: /* If we're using clang + glibc, we have to get hacky. Chris@16: * See http://llvm.org/bugs/show_bug.cgi?id=6907 */ Chris@16: #if defined(__clang__) && (__clang_major__ < 3) && \ Chris@16: defined(__GNU_LIBRARY__) && /* up to version 5 */ \ Chris@16: defined(__GLIBC__) && /* version 6 + */ \ Chris@16: !defined(_FENV_H) Chris@16: #define _FENV_H Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: extern "C" { Chris@16: extern int fegetexceptflag (fexcept_t*, int) __THROW; Chris@16: extern int fesetexceptflag (__const fexcept_t*, int) __THROW; Chris@16: extern int feclearexcept (int) __THROW; Chris@16: extern int feraiseexcept (int) __THROW; Chris@16: extern int fetestexcept (int) __THROW; Chris@16: extern int fegetround (void) __THROW; Chris@16: extern int fesetround (int) __THROW; Chris@16: extern int fegetenv (fenv_t*) __THROW; Chris@16: extern int fesetenv (__const fenv_t*) __THROW; Chris@16: extern int feupdateenv (__const fenv_t*) __THROW; Chris@16: extern int feholdexcept (fenv_t*) __THROW; Chris@16: Chris@16: #ifdef __USE_GNU Chris@16: extern int feenableexcept (int) __THROW; Chris@16: extern int fedisableexcept (int) __THROW; Chris@16: extern int fegetexcept (void) __THROW; Chris@16: #endif Chris@16: } Chris@16: Chris@16: namespace std { namespace tr1 { Chris@16: using ::fenv_t; Chris@16: using ::fexcept_t; Chris@16: using ::fegetexceptflag; Chris@16: using ::fesetexceptflag; Chris@16: using ::feclearexcept; Chris@16: using ::feraiseexcept; Chris@16: using ::fetestexcept; Chris@16: using ::fegetround; Chris@16: using ::fesetround; Chris@16: using ::fegetenv; Chris@16: using ::fesetenv; Chris@16: using ::feupdateenv; Chris@16: using ::feholdexcept; Chris@16: } } Chris@16: Chris@101: #elif defined(__MINGW32__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 Chris@101: Chris@101: // MinGW (32-bit) has a bug in mingw32/bits/c++config.h, it does not define _GLIBCXX_HAVE_FENV_H, Chris@101: // which prevents the C fenv.h header contents to be included in the C++ wrapper header fenv.h. This is at least Chris@101: // the case with gcc 4.8.1 packages tested so far, up to 4.8.1-4. Note that there is no issue with Chris@101: // MinGW-w64. Chris@101: // To work around the bug we avoid including the C++ wrapper header and include the C header directly Chris@101: // and import all relevant symbols into std:: ourselves. Chris@101: Chris@101: #include <../include/fenv.h> Chris@101: Chris@101: namespace std { Chris@101: using ::fenv_t; Chris@101: using ::fexcept_t; Chris@101: using ::fegetexceptflag; Chris@101: using ::fesetexceptflag; Chris@101: using ::feclearexcept; Chris@101: using ::feraiseexcept; Chris@101: using ::fetestexcept; Chris@101: using ::fegetround; Chris@101: using ::fesetround; Chris@101: using ::fegetenv; Chris@101: using ::fesetenv; Chris@101: using ::feupdateenv; Chris@101: using ::feholdexcept; Chris@101: } Chris@101: Chris@16: #else /* if we're not using GNU's C stdlib, fenv.h should work with clang */ Chris@101: Chris@16: #if defined(__SUNPRO_CC) /* lol suncc */ Chris@16: #include Chris@16: #endif Chris@101: Chris@16: #include Chris@16: Chris@16: #endif Chris@16: Chris@16: #endif /* BOOST_DETAIL_FENV_HPP */