[PATCH] cmath: account for MSVCRT 12.0 changes
Saleem Abdulrasool
abdulras at fb.com
Wed Feb 4 14:33:36 PST 2015
Hi mclow.lists,
MSVCRT 12.0 introduces better compatibility for C99. This includes a number of
math routines that were previously undefined. Use the crtversion.h header to
detect the version of MSVCRT being targeted and avoid re-declaring the
variables.
Since copysign has been introduced in MSVCRT, importing the definition via using
makes it difficult to provide overloads (due to minor differences between
`throw ()` and `noexcept`. Avoid defining the overloads on newer MSVCRT
targets.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D7418
Files:
include/cmath
include/support/win32/math_win32.h
Index: include/cmath
===================================================================
--- include/cmath
+++ include/cmath
@@ -1109,8 +1109,16 @@
using ::copysign;
using ::copysignf;
-inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return copysignf(__lcpp_x, __lcpp_y);}
-inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return copysignl(__lcpp_x, __lcpp_y);}
+#if !defined(_VC_CRT_MAJOR_VERSION) || (_VC_CRT_MAJOR_VERSION < 12)
+inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
+ float __lcpp_y) _NOEXCEPT {
+ return copysignf(__lcpp_x, __lcpp_y);
+}
+inline _LIBCPP_INLINE_VISIBILITY long double
+copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
+ return copysignl(__lcpp_x, __lcpp_y);
+}
+#endif
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
Index: include/support/win32/math_win32.h
===================================================================
--- include/support/win32/math_win32.h
+++ include/support/win32/math_win32.h
@@ -17,7 +17,9 @@
#include <math.h>
#include <float.h> // _FPCLASS_PN etc.
+#include <crtversion.h>
+#if ((_VC_CRT_MAJOR_VERSION-0) < 12)
// Necessary?
typedef float float_t;
typedef double double_t;
@@ -109,7 +111,7 @@
{
return _fpclass(num);
}
-
+#endif
#endif // _LIBCPP_MSVCRT
#endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7418.19349.patch
Type: text/x-patch
Size: 1509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150204/28e3fa83/attachment.bin>
More information about the cfe-commits
mailing list