Nico Rieck:  Currently _MSC_VER and _WIN32 are used to guard code which is
MSVC-specific, MSVCRT-specific, or Windows-specific. Because Clang can
also define _MSC_VER, and MSVCRT is not necessarily the only C runtime,
these macros should not be used interchangeably.

This patch divides all Windows-related bits into the aforementioned
categories. Two new macros are introduced:

- _LIBCPP_MSVC: Defined when compiling with MSVC. Detected using
  _MSC_VER, excluding Clang.
- _LIBCPP_MSVCRT: Defined when using the Microsoft CRT. This is the default
   when _WIN32 is defined.

This leaves _WIN32 for code using the Windows API.

This also corrects the spelling of _LIBCP_HAS_IS_BASE_OF to _LIBCPP_HAS_IS_BASE_OF.

Nico, please prepare a patch for CREDITS.TXT, thanks.

llvm-svn: 187593
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 0be8f64c44d2fe87fdf8feda175dc39d38a83906
diff --git a/include/cmath b/include/cmath
index bd60344..3e545ce 100644
--- a/include/cmath
+++ b/include/cmath
@@ -301,7 +301,7 @@
 #include <math.h>
 #include <type_traits>
 
-#ifdef _MSC_VER
+#ifdef _LIBCPP_MSVCRT
 #include "support/win32/math_win32.h"
 #endif
 
@@ -673,7 +673,7 @@
 using ::acos;
 using ::acosf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       acos(float __x) _NOEXCEPT       {return acosf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) _NOEXCEPT {return acosl(__x);}
 #endif
@@ -688,7 +688,7 @@
 using ::asin;
 using ::asinf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       asin(float __x) _NOEXCEPT       {return asinf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) _NOEXCEPT {return asinl(__x);}
 #endif
@@ -703,7 +703,7 @@
 using ::atan;
 using ::atanf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       atan(float __x) _NOEXCEPT       {return atanf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) _NOEXCEPT {return atanl(__x);}
 #endif
@@ -718,7 +718,7 @@
 using ::atan2;
 using ::atan2f;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       atan2(float __y, float __x) _NOEXCEPT             {return atan2f(__y, __x);}
 inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) _NOEXCEPT {return atan2l(__y, __x);}
 #endif
@@ -744,7 +744,7 @@
 using ::ceil;
 using ::ceilf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       ceil(float __x) _NOEXCEPT       {return ceilf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) _NOEXCEPT {return ceill(__x);}
 #endif
@@ -759,7 +759,7 @@
 using ::cos;
 using ::cosf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       cos(float __x) _NOEXCEPT       {return cosf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) _NOEXCEPT {return cosl(__x);}
 #endif
@@ -774,7 +774,7 @@
 using ::cosh;
 using ::coshf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       cosh(float __x) _NOEXCEPT       {return coshf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) _NOEXCEPT {return coshl(__x);}
 #endif
@@ -792,7 +792,7 @@
 
 #ifndef __sun__
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       exp(float __x) _NOEXCEPT       {return expf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) _NOEXCEPT {return expl(__x);}
 #endif
@@ -808,7 +808,7 @@
 using ::fabs;
 using ::fabsf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       fabs(float __x) _NOEXCEPT       {return fabsf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) _NOEXCEPT {return fabsl(__x);}
 #endif
@@ -823,7 +823,7 @@
 using ::floor;
 using ::floorf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       floor(float __x) _NOEXCEPT       {return floorf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) _NOEXCEPT {return floorl(__x);}
 #endif
@@ -840,7 +840,7 @@
 using ::fmodf;
 #ifndef __sun__
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       fmod(float __x, float __y) _NOEXCEPT             {return fmodf(__x, __y);}
 inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) _NOEXCEPT {return fmodl(__x, __y);}
 #endif
@@ -867,7 +867,7 @@
 using ::frexp;
 using ::frexpf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       frexp(float __x, int* __e) _NOEXCEPT       {return frexpf(__x, __e);}
 inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) _NOEXCEPT {return frexpl(__x, __e);}
 #endif
@@ -882,7 +882,7 @@
 using ::ldexp;
 using ::ldexpf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       ldexp(float __x, int __e) _NOEXCEPT       {return ldexpf(__x, __e);}
 inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) _NOEXCEPT {return ldexpl(__x, __e);}
 #endif
@@ -899,7 +899,7 @@
 using ::logf;
 #ifndef __sun__
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       log(float __x) _NOEXCEPT       {return logf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) _NOEXCEPT {return logl(__x);}
 #endif
@@ -915,7 +915,7 @@
 using ::log10;
 using ::log10f;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       log10(float __x) _NOEXCEPT       {return log10f(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) _NOEXCEPT {return log10l(__x);}
 #endif
@@ -930,7 +930,7 @@
 using ::modf;
 using ::modff;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       modf(float __x, float* __y) _NOEXCEPT             {return modff(__x, __y);}
 inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) _NOEXCEPT {return modfl(__x, __y);}
 #endif
@@ -943,7 +943,7 @@
 
 #ifndef __sun__
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       pow(float __x, float __y) _NOEXCEPT             {return powf(__x, __y);}
 inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) _NOEXCEPT {return powl(__x, __y);}
 #endif
@@ -970,7 +970,7 @@
 using ::sin;
 using ::sinf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       sin(float __x) _NOEXCEPT       {return sinf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) _NOEXCEPT {return sinl(__x);}
 #endif
@@ -985,7 +985,7 @@
 using ::sinh;
 using ::sinhf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       sinh(float __x) _NOEXCEPT       {return sinhf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) _NOEXCEPT {return sinhl(__x);}
 #endif
@@ -1002,7 +1002,7 @@
 using ::sqrtf;
 
 
-#if !(defined(_MSC_VER) || defined(__sun__))
+#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float       sqrt(float __x) _NOEXCEPT       {return sqrtf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) _NOEXCEPT {return sqrtl(__x);}
 #endif
@@ -1018,7 +1018,7 @@
 using ::tanf;
 #ifndef __sun__
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       tan(float __x) _NOEXCEPT       {return tanf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) _NOEXCEPT {return tanl(__x);}
 #endif
@@ -1033,7 +1033,7 @@
 using ::tanh;
 using ::tanhf;
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 inline _LIBCPP_INLINE_VISIBILITY float       tanh(float __x) _NOEXCEPT       {return tanhf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) _NOEXCEPT {return tanhl(__x);}
 #endif
@@ -1045,7 +1045,7 @@
 
 // acosh
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 using ::acosh;
 using ::acoshf;
 
@@ -1060,7 +1060,7 @@
 
 // asinh
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 using ::asinh;
 using ::asinhf;
 
@@ -1075,7 +1075,7 @@
 
 // atanh
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 using ::atanh;
 using ::atanhf;
 
@@ -1090,7 +1090,7 @@
 
 // cbrt
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 using ::cbrt;
 using ::cbrtf;
 
@@ -1127,7 +1127,7 @@
     return copysign((__result_type)__x, (__result_type)__y);
 }
 
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 
 // erf
 
@@ -1426,13 +1426,18 @@
 typename enable_if<is_integral<_A1>::value, long>::type
 lround(_A1 __x) _NOEXCEPT {return lround((double)__x);}
 
-// nan
-#endif // _MSC_VER
+#endif // _LIBCPP_MSVCRT
 #endif // __sun__
+
+// nan
+
+#ifndef _LIBCPP_MSVCRT
 using ::nan;
 using ::nanf;
+#endif // _LIBCPP_MSVCRT
+
 #ifndef __sun__
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 
 // nearbyint
 
@@ -1610,7 +1615,7 @@
 typename enable_if<is_integral<_A1>::value, double>::type
 trunc(_A1 __x) _NOEXCEPT {return trunc((double)__x);}
 
-#endif // !_MSC_VER
+#endif // !_LIBCPP_MSVCRT
 
 using ::acosl;
 using ::asinl;
@@ -1633,15 +1638,15 @@
 using ::sinhl;
 using ::sqrtl;
 using ::tanl;
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 using ::tanhl;
 using ::acoshl;
 using ::asinhl;
 using ::atanhl;
 using ::cbrtl;
-#endif  // !_MSC_VER
+#endif  // !_LIBCPP_MSVCRT
 using ::copysignl;
-#ifndef _MSC_VER
+#ifndef _LIBCPP_MSVCRT
 using ::erfl;
 using ::erfcl;
 using ::exp2l;
@@ -1672,7 +1677,7 @@
 using ::scalbnl;
 using ::tgammal;
 using ::truncl;
-#endif // !_MSC_VER
+#endif // !_LIBCPP_MSVCRT
 
 #else 
 using ::lgamma;