diff options
author | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2018-02-22 09:34:08 +0000 |
---|---|---|
committer | Mikhail Maltsev <mikhail.maltsev@arm.com> | 2018-02-22 09:34:08 +0000 |
commit | 61ccaf6ddd923e80358b96d59e78f9475a1ed065 (patch) | |
tree | dc27b8edd2651b75b3aa466db5cef220383ae28e | |
parent | 26e943106b5cc6bc08d7c14068ff3526cf9faf9b (diff) | |
download | bcm5719-llvm-61ccaf6ddd923e80358b96d59e78f9475a1ed065.tar.gz bcm5719-llvm-61ccaf6ddd923e80358b96d59e78f9475a1ed065.zip |
[libcxx] Do not include the C math.h header before __config
Summary:
Certain C libraries require configuration macros defined in __config
to provide the correct functionality for libc++. This patch ensures
that the C header math.h is always included after the __config
header. It also adds a Windows-specific #if guard for the case when
the C math.h file is included the second time, as suggested by
Marshall in https://reviews.llvm.org/rL323490.
Fixes PR36382.
Reviewers: mclow.lists, EricWF
Reviewed By: mclow.lists
Subscribers: cfe-commits, pcc, christof, rogfer01
Differential Revision: https://reviews.llvm.org/D43579
llvm-svn: 325760
-rw-r--r-- | libcxx/include/math.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/libcxx/include/math.h b/libcxx/include/math.h index 1476772351c..cd055caef72 100644 --- a/libcxx/include/math.h +++ b/libcxx/include/math.h @@ -8,16 +8,6 @@ // //===----------------------------------------------------------------------===// -// This include lives outside the header guard in order to support an MSVC -// extension which allows users to do: -// -// #define _USE_MATH_DEFINES -// #include <math.h> -// -// and receive the definitions of mathematical constants, even if <math.h> -// has previously been included. -#include_next <math.h> - #ifndef _LIBCPP_MATH_H #define _LIBCPP_MATH_H @@ -308,6 +298,8 @@ long double truncl(long double x); #pragma GCC system_header #endif +#include_next <math.h> + #ifdef __cplusplus // We support including .h headers inside 'extern "C"' contexts, so switch @@ -1494,4 +1486,18 @@ trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);} #endif // __cplusplus +#else // _LIBCPP_MATH_H + +// This include lives outside the header guard in order to support an MSVC +// extension which allows users to do: +// +// #define _USE_MATH_DEFINES +// #include <math.h> +// +// and receive the definitions of mathematical constants, even if <math.h> +// has previously been included. +#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES) +#include_next <math.h> +#endif + #endif // _LIBCPP_MATH_H |