diff --git a/doc/macro_reference.qbk b/doc/macro_reference.qbk index eacbf8e7..7f84ef44 100644 --- a/doc/macro_reference.qbk +++ b/doc/macro_reference.qbk @@ -71,6 +71,11 @@ The Platform does not provide `` and ``. [[`BOOST_NO_CWCTYPE`][Platform][ The Platform does not provide `` and ``. ]] +[[`BOOST_NO_FENV_H`][Platform, Standard library][ +The C standard library doesn't provide ``. [@../../../../boost/detail/fenv.hpp +``] should be included instead of `` for maximum +portability on platforms which do provide ``. +]] [[`BOOST_NO_DEPENDENT_NESTED_DERIVATIONS`][Compiler][ The compiler fails to compile a nested class that has a dependent base class: `` @@ -399,11 +404,6 @@ The platform has the POSIX API `sched_yield`. [[`BOOST_HAS_SGI_TYPE_TRAITS`][Compiler, Standard library][ The compiler has native support for SGI style type traits. ]] -[[`BOOST_HAS_FENV_H`][Platform, Standard library][ -The platform has a ``. [@../../../../boost/detail/fenv.hpp -``] should be included instead of `` for maximum -portability. -]] [[`BOOST_HAS_STDINT_H`][Platform][ The platform has a `` ]] diff --git a/include/boost/config/compiler/visualc.hpp b/include/boost/config/compiler/visualc.hpp index 15b58b38..38789367 100644 --- a/include/boost/config/compiler/visualc.hpp +++ b/include/boost/config/compiler/visualc.hpp @@ -37,6 +37,9 @@ // #endif +/// Visual Studio has no fenv.h +#define BOOST_NO_FENV_H + #if (_MSC_VER <= 1300) // 1300 == VC++ 7.0 # if !defined(_MSC_EXTENSIONS) && !defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) // VC7 bug with /Za diff --git a/include/boost/config/platform/cygwin.hpp b/include/boost/config/platform/cygwin.hpp index 8e1bcb01..b7ef572f 100644 --- a/include/boost/config/platform/cygwin.hpp +++ b/include/boost/config/platform/cygwin.hpp @@ -39,6 +39,9 @@ #define BOOST_HAS_STDINT_H #endif +/// Cygwin has no fenv.h +#define BOOST_NO_FENV_H + // boilerplate code: #include diff --git a/include/boost/config/platform/win32.hpp b/include/boost/config/platform/win32.hpp index 690f464a..72c3dceb 100644 --- a/include/boost/config/platform/win32.hpp +++ b/include/boost/config/platform/win32.hpp @@ -31,7 +31,6 @@ # define BOOST_SYMBOL_IMPORT __declspec(dllimport) #endif - #if defined(__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 2) || ((__MINGW32_MAJOR_VERSION == 2) && (__MINGW32_MINOR_VERSION >= 0))) # define BOOST_HAS_STDINT_H # define __STDC_LIMIT_MACROS diff --git a/include/boost/config/stdlib/libstdcpp3.hpp b/include/boost/config/stdlib/libstdcpp3.hpp index f99d7d35..c048b896 100644 --- a/include/boost/config/stdlib/libstdcpp3.hpp +++ b/include/boost/config/stdlib/libstdcpp3.hpp @@ -56,11 +56,6 @@ # define BOOST_HAS_THREADS #endif -#if !defined(CYGWIN) -# include -# define BOOST_HAS_FENV_H -#endif - #if !defined(_GLIBCPP_USE_LONG_LONG) \ && !defined(_GLIBCXX_USE_LONG_LONG)\ && defined(BOOST_HAS_LONG_LONG) @@ -69,6 +64,16 @@ # undef BOOST_HAS_LONG_LONG #endif +// Apple doesn't seem to reliably defined a *unix* macro +#if !defined(CYGWIN) && ( defined(__unix__) \ + || defined(__unix) \ + || defined(unix) \ + || defined(__APPLE__) \ + || defined(__APPLE) \ + || defined(APPLE)) +# include +#endif + #if defined(__GLIBCXX__) || (defined(__GLIBCPP__) && __GLIBCPP__>=20020514) // GCC >= 3.1.0 # define BOOST_STD_EXTENSION_NAMESPACE __gnu_cxx # define BOOST_HAS_SLIST diff --git a/include/boost/config/stdlib/sgi.hpp b/include/boost/config/stdlib/sgi.hpp index 088e0471..5731fe5e 100644 --- a/include/boost/config/stdlib/sgi.hpp +++ b/include/boost/config/stdlib/sgi.hpp @@ -40,11 +40,14 @@ # define BOOST_NO_STRINGSTREAM #endif -#if !defined(CYGWIN) && (defined(unix) || defined(__unix) || defined(__unix__)) +// Apple doesn't seem to reliably defined a *unix* macro +#if !defined(CYGWIN) && ( defined(__unix__) \ + || defined(__unix) \ + || defined(unix) \ + || defined(__APPLE__) \ + || defined(__APPLE) \ + || defined(APPLE)) # include -# if defined(_POSIX_VERSION) || defined(_XOPEN_VERSION) -# define BOOST_HAS_FENV_H -# endif #endif diff --git a/include/boost/config/stdlib/stlport.hpp b/include/boost/config/stdlib/stlport.hpp index 098da44e..85176a4d 100644 --- a/include/boost/config/stdlib/stlport.hpp +++ b/include/boost/config/stdlib/stlport.hpp @@ -16,11 +16,14 @@ # endif #endif -#if !defined(CYGWIN) && (defined(unix) || defined(__unix) || defined(__unix__)) +// Apple doesn't seem to reliably defined a *unix* macro +#if !defined(CYGWIN) && ( defined(__unix__) \ + || defined(__unix) \ + || defined(unix) \ + || defined(__APPLE__) \ + || defined(__APPLE) \ + || defined(APPLE)) # include -# if defined(_POSIX_VERSION) || defined(_XOPEN_VERSION) -# define BOOST_HAS_FENV_H -# endif #endif // diff --git a/include/boost/config/stdlib/vacpp.hpp b/include/boost/config/stdlib/vacpp.hpp index 904e0681..3fcf6e05 100644 --- a/include/boost/config/stdlib/vacpp.hpp +++ b/include/boost/config/stdlib/vacpp.hpp @@ -12,11 +12,14 @@ #define BOOST_HAS_MACRO_USE_FACET #define BOOST_NO_STD_MESSAGES -#if !defined(CYGWIN) && (defined(unix) || defined(__unix) || defined(__unix__)) +// Apple doesn't seem to reliably defined a *unix* macro +#if !defined(CYGWIN) && ( defined(__unix__) \ + || defined(__unix) \ + || defined(unix) \ + || defined(__APPLE__) \ + || defined(__APPLE) \ + || defined(APPLE)) # include -# if defined(_POSIX_VERSION) || defined(_XOPEN_VERSION) -# define BOOST_HAS_FENV_H -# endif #endif // C++0x headers not yet implemented diff --git a/test/boost_no_fenv_h.ipp b/test/boost_no_fenv_h.ipp new file mode 100644 index 00000000..97ed5124 --- /dev/null +++ b/test/boost_no_fenv_h.ipp @@ -0,0 +1,78 @@ +// (C) Copyright John Maddock 2001. +// (C) Copyright Bryce Lelbach 2010. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for most recent version. + +// MACRO: BOOST_NO_FENV_H +// TITLE: fenv.h +// DESCRIPTION: There is no POSIX available. If is +// available, should be included +// instead of directly including . + +#include + +namespace boost_no_fenv_h { + +int test() +{ + /// POSIX required typedefs + typedef ::fenv_t has_fenv_t; + typedef ::fexcept_t has_fexcept_t; + + /// POSIX required macros + #if !defined(FE_DIVBYZERO) + #error platform does not define FE_DIVBYZERO + #endif + + #if !defined(FE_INEXACT) + #error platform does not define FE_INEXACT + #endif + + #if !defined(FE_INVALID) + #error platform does not define FE_INVALID + #endif + + #if !defined(FE_OVERFLOW) + #error platform does not define FE_OVERFLOW + #endif + + #if !defined(FE_UNDERFLOW) + #error platform does not define FE_UNDERFLOW + #endif + + #if !defined(FE_DOWNWARD) + #error platform does not define FE_DOWNWARD + #endif + + #if !defined(FE_TONEAREST) + #error platform does not define FE_TONEAREST + #endif + + #if !defined(FE_UPWARD) + #error platform does not define FE_UPWARD + #endif + + #if !defined(FE_DFL_ENV) + #error platform does not define FE_DFL_ENV + #endif + + int (*has_feclearexcept)(int) = ::feclearexcept; + int (*has_fegetenv)(fenv_t*) = ::fegetenv; + int (*has_fegetexcept)(fexcept_t*, int) = ::fegetexcept; + int (*has_fegetround)(void) = ::fegetround; + int (*has_feholdexcept)(fenv_t*) = ::feholdexcept; + int (*has_feraiseexcept)(int) = ::feraiseexcept; + int (*has_fesetenv)(const fenv_t*) = ::fesetenv; + int (*has_fesetexceptflag)(const fexcept_t*, int) = ::fesetexceptflag; + int (*has_fesetround)(int) = ::fesetround; + int (*has_fetestexcept)(int) = ::fetestexcept; + int (*has_feupdateenv)(const fenv_t*) = ::feupdateenv; + + return 0; +} + +} + diff --git a/test/no_fenv_h_fail.cpp b/test/no_fenv_h_fail.cpp new file mode 100644 index 00000000..9b2f4103 --- /dev/null +++ b/test/no_fenv_h_fail.cpp @@ -0,0 +1,33 @@ +// Copyright Bryce Lelbach 2010. +// Copyright John Maddock 2002-4. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for the most recent version. + +// Test file for macro BOOST_NO_FENV_H +// This file should not compile, if it does then +// BOOST_NO_FENV_H should not be defined. +// See file boost_no_fenv_h.ipp for details + +// Must not have BOOST_ASSERT_CONFIG set; it defeats +// the objective of this file: +#ifdef BOOST_ASSERT_CONFIG +# undef BOOST_ASSERT_CONFIG +#endif + +#include +#include "test.hpp" + +#ifdef BOOST_NO_FENV_H +#include "boost_no_fenv_h.ipp" +#else +#error "this file should not compile" +#endif + +int main( int, char *[] ) +{ + return boost_no_fenv_h::test(); +} + diff --git a/test/no_fenv_h_pass.cpp b/test/no_fenv_h_pass.cpp new file mode 100644 index 00000000..573d6244 --- /dev/null +++ b/test/no_fenv_h_pass.cpp @@ -0,0 +1,33 @@ +// Copyright Bryce Lelbach 2010. +// Copyright John Maddock 2002-4. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for the most recent version. + +// Test file for macro BOOST_NO_FENV_H +// This file should compile, if it does not then +// BOOST_NO_FENV_H should be defined. +// See file boost_no_fenv_h.ipp for details + +// Must not have BOOST_ASSERT_CONFIG set; it defeats +// the objective of this file: +#ifdef BOOST_ASSERT_CONFIG +# undef BOOST_ASSERT_CONFIG +#endif + +#include +#include "test.hpp" + +#ifndef BOOST_NO_FENV_H +#include "boost_no_fenv_h.ipp" +#else +namespace boost_no_fenv_h = empty_boost; +#endif + +int main( int, char *[] ) +{ + return boost_no_fenv_h::test(); +} +