[cfe-commits] [libcxx] r143105 - in /libcxx/trunk/include: __config cmath cstdlib support/win32/locale_win32.h support/win32/math_win32.h support/win32/support.h

Howard Hinnant hhinnant at apple.com
Thu Oct 27 09:24:42 PDT 2011


Author: hhinnant
Date: Thu Oct 27 11:24:42 2011
New Revision: 143105

URL: http://llvm.org/viewvc/llvm-project?rev=143105&view=rev
Log:
Windows port work by Ruben Van Boxem

Added:
    libcxx/trunk/include/support/win32/math_win32.h
Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/include/cmath
    libcxx/trunk/include/cstdlib
    libcxx/trunk/include/support/win32/locale_win32.h
    libcxx/trunk/include/support/win32/support.h

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=143105&r1=143104&r2=143105&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Oct 27 11:24:42 2011
@@ -321,7 +321,6 @@
 
 #elif defined(_MSC_VER)
 
-#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #define _LIBCPP_HAS_NO_CONSTEXPR

Modified: libcxx/trunk/include/cmath
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=143105&r1=143104&r2=143105&view=diff
==============================================================================
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Thu Oct 27 11:24:42 2011
@@ -301,6 +301,10 @@
 #include <math.h>
 #include <type_traits>
 
+#ifdef _MSC_VER
+#include "support/win32/math_win32.h"
+#endif
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
@@ -654,8 +658,10 @@
 using ::acos;
 using ::acosf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       acos(float __x)       {return acosf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) {return acosl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -667,8 +673,10 @@
 using ::asin;
 using ::asinf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       asin(float __x)       {return asinf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) {return asinl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -680,8 +688,10 @@
 using ::atan;
 using ::atanf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       atan(float __x)       {return atanf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) {return atanl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -693,8 +703,10 @@
 using ::atan2;
 using ::atan2f;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       atan2(float __y, float __x)             {return atan2f(__y, __x);}
 inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) {return atan2l(__y, __x);}
+#endif
 
 template <class _A1, class _A2>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -717,8 +729,10 @@
 using ::ceil;
 using ::ceilf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       ceil(float __x)       {return ceilf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) {return ceill(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -730,8 +744,10 @@
 using ::cos;
 using ::cosf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       cos(float __x)       {return cosf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) {return cosl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
@@ -743,8 +759,10 @@
 using ::cosh;
 using ::coshf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       cosh(float __x)       {return coshf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) {return coshl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -756,8 +774,10 @@
 using ::exp;
 using ::expf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       exp(float __x)       {return expf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) {return expl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -769,8 +789,10 @@
 using ::fabs;
 using ::fabsf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       fabs(float __x)       {return fabsf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) {return fabsl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -782,8 +804,10 @@
 using ::floor;
 using ::floorf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       floor(float __x)       {return floorf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) {return floorl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -795,8 +819,10 @@
 using ::fmod;
 using ::fmodf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       fmod(float __x, float __y)             {return fmodf(__x, __y);}
 inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) {return fmodl(__x, __y);}
+#endif
 
 template <class _A1, class _A2>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -819,8 +845,10 @@
 using ::frexp;
 using ::frexpf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       frexp(float __x, int* __e)       {return frexpf(__x, __e);}
 inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) {return frexpl(__x, __e);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -832,8 +860,10 @@
 using ::ldexp;
 using ::ldexpf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       ldexp(float __x, int __e)       {return ldexpf(__x, __e);}
 inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) {return ldexpl(__x, __e);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -845,8 +875,10 @@
 using ::log;
 using ::logf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       log(float __x)       {return logf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) {return logl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -858,8 +890,10 @@
 using ::log10;
 using ::log10f;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       log10(float __x)       {return log10f(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) {return log10l(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -871,16 +905,20 @@
 using ::modf;
 using ::modff;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       modf(float __x, float* __y)             {return modff(__x, __y);}
 inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) {return modfl(__x, __y);}
+#endif
 
 // pow
 
 using ::pow;
 using ::powf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       pow(float __x, float __y)             {return powf(__x, __y);}
 inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) {return powl(__x, __y);}
+#endif
 
 template <class _A1, class _A2>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -903,8 +941,10 @@
 using ::sin;
 using ::sinf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       sin(float __x)       {return sinf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) {return sinl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -916,8 +956,10 @@
 using ::sinh;
 using ::sinhf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       sinh(float __x)       {return sinhf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) {return sinhl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -929,8 +971,10 @@
 using ::sqrt;
 using ::sqrtf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       sqrt(float __x)       {return sqrtf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) {return sqrtl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -942,8 +986,10 @@
 using ::tan;
 using ::tanf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       tan(float __x)       {return tanf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) {return tanl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -955,8 +1001,10 @@
 using ::tanh;
 using ::tanhf;
 
+#ifndef _MSC_VER
 inline _LIBCPP_INLINE_VISIBILITY float       tanh(float __x)       {return tanhf(__x);}
 inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) {return tanhl(__x);}
+#endif
 
 template <class _A1>
 inline _LIBCPP_INLINE_VISIBILITY
@@ -965,6 +1013,7 @@
 
 // acosh
 
+#ifndef _MSC_VER
 using ::acosh;
 using ::acoshf;
 
@@ -975,9 +1024,11 @@
 inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if<is_integral<_A1>::value, double>::type
 acosh(_A1 __x) {return acosh((double)__x);}
+#endif
 
 // asinh
 
+#ifndef _MSC_VER
 using ::asinh;
 using ::asinhf;
 
@@ -988,9 +1039,11 @@
 inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if<is_integral<_A1>::value, double>::type
 asinh(_A1 __x) {return asinh((double)__x);}
+#endif
 
 // atanh
 
+#ifndef _MSC_VER
 using ::atanh;
 using ::atanhf;
 
@@ -1001,9 +1054,11 @@
 inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if<is_integral<_A1>::value, double>::type
 atanh(_A1 __x) {return atanh((double)__x);}
+#endif
 
 // cbrt
 
+#ifndef _MSC_VER
 using ::cbrt;
 using ::cbrtf;
 
@@ -1014,6 +1069,7 @@
 inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if<is_integral<_A1>::value, double>::type
 cbrt(_A1 __x) {return cbrt((double)__x);}
+#endif
 
 // copysign
 
@@ -1039,6 +1095,8 @@
     return copysign((__result_type)__x, (__result_type)__y);
 }
 
+#ifndef _MSC_VER
+
 // erf
 
 using ::erf;
@@ -1513,6 +1571,8 @@
 typename enable_if<is_integral<_A1>::value, double>::type
 trunc(_A1 __x) {return trunc((double)__x);}
 
+#endif // !_MSC_VER
+
 using ::acosl;
 using ::asinl;
 using ::atanl;
@@ -1534,12 +1594,15 @@
 using ::sinhl;
 using ::sqrtl;
 using ::tanl;
+#ifndef _MSC_VER
 using ::tanhl;
 using ::acoshl;
 using ::asinhl;
 using ::atanhl;
 using ::cbrtl;
+#endif !_MSC_VER
 using ::copysignl;
+#ifndef _MSC_VER
 using ::erfl;
 using ::erfcl;
 using ::exp2l;
@@ -1570,6 +1633,7 @@
 using ::scalbnl;
 using ::tgammal;
 using ::truncl;
+#endif // !_MSC_VER
 
 _LIBCPP_END_NAMESPACE_STD
 

Modified: libcxx/trunk/include/cstdlib
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdlib?rev=143105&r1=143104&r2=143105&view=diff
==============================================================================
--- libcxx/trunk/include/cstdlib (original)
+++ libcxx/trunk/include/cstdlib Thu Oct 27 11:24:42 2011
@@ -82,7 +82,7 @@
 #include <__config>
 #include <stdlib.h>
 #ifdef _MSC_VER
-#include "support/win32/support.h"
+#include "support/win32/locale_win32.h"
 #endif // _MSC_VER
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

Modified: libcxx/trunk/include/support/win32/locale_win32.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/locale_win32.h?rev=143105&r1=143104&r2=143105&view=diff
==============================================================================
--- libcxx/trunk/include/support/win32/locale_win32.h (original)
+++ libcxx/trunk/include/support/win32/locale_win32.h Thu Oct 27 11:24:42 2011
@@ -107,4 +107,10 @@
     return ( c == L' ' || c == L'\t' );
 }
 
+#ifdef _MSC_VER
+inline int isblank( int c, locale_t /*loc*/ )
+{ return ( c == ' ' || c == '\t' ); }
+inline int iswblank( wint_t c, locale_t /*loc*/ )
+{ return ( c == L' ' || c == L'\t' ); }
+#endif // _MSC_VER
 #endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H

Added: libcxx/trunk/include/support/win32/math_win32.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/math_win32.h?rev=143105&view=auto
==============================================================================
--- libcxx/trunk/include/support/win32/math_win32.h (added)
+++ libcxx/trunk/include/support/win32/math_win32.h Thu Oct 27 11:24:42 2011
@@ -0,0 +1,113 @@
+// -*- C++ -*-
+//===---------------------- support/win32/math_win32.h --------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
+
+#if !defined(_MSC_VER)
+#error "This header is MSVC specific, Clang and GCC should not include it"
+#else
+
+#include <math.h>
+
+typedef float float_t;
+typedef double double_t;
+
+_LIBCPP_ALWAYS_INLINE bool isfinite( double num )
+{
+    return _finite(num) != 0;
+}
+_LIBCPP_ALWAYS_INLINE bool isinf( double num )
+{
+    return !isfinite(num) && !_isnan(num);
+}
+_LIBCPP_ALWAYS_INLINE bool isnan( double num )
+{
+    return _isnan(num) != 0;
+}
+_LIBCPP_ALWAYS_INLINE bool isnormal( double num )
+{
+    int class_ = _fpclass(num);
+    return class_ == _FPCLASS_NN || class_ == _FPCLASS_PN;
+}
+
+_LIBCPP_ALWAYS_INLINE bool isgreater( double x, double y )
+{
+    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x > y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool isgreaterequal( double x, double y )
+{
+    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x >= y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool isless( double x, double y )
+{
+    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x < y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool islessequal( double x, double y )
+{
+    if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x <= y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool islessgreater( double x, double y )
+{
+    if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x < y || x > y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool isunordered( double x, double y )
+{
+    return isnan(x) || isnan(y);
+}
+_LIBCPP_ALWAYS_INLINE bool signbit( double num )
+{
+    switch(_fpclass(num))
+    {
+        case _FPCLASS_SNAN:
+        case _FPCLASS_QNAN:
+        case _FPCLASS_NINF:
+        case _FPCLASS_NN:
+        case _FPCLASS_ND:
+        case _FPCLASS_NZ:
+            return true;
+        case _FPCLASS_PZ:
+        case _FPCLASS_PD:
+        case _FPCLASS_PN:
+        case _FPCLASS_PINF:
+            return false;
+    }
+    return false;
+}
+_LIBCPP_ALWAYS_INLINE float copysignf( float x, float y )
+{
+    return (signbit (x) != signbit (y) ? - x : x);
+}
+_LIBCPP_ALWAYS_INLINE double copysign( double x, double y )
+{
+    return ::_copysign(x,y);
+}
+_LIBCPP_ALWAYS_INLINE double copysignl( long double x, long double y )
+{
+    return ::_copysignl(x,y);
+}
+_LIBCPP_ALWAYS_INLINE int fpclassify( double num )
+{
+    return _fpclass(num);
+}
+
+#endif // _MSC_VER
+
+#endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
\ No newline at end of file

Modified: libcxx/trunk/include/support/win32/support.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/support.h?rev=143105&r1=143104&r2=143105&view=diff
==============================================================================
--- libcxx/trunk/include/support/win32/support.h (original)
+++ libcxx/trunk/include/support/win32/support.h Thu Oct 27 11:24:42 2011
@@ -34,10 +34,7 @@
 				   
 #if defined(_MSC_VER)
 #define snprintf _snprintf
-inline int isblank( int c, locale_t /*loc*/ )
-{ return ( c == ' ' || c == '\t' ); }
-inline int iswblank( wint_t c, locale_t /*loc*/ )
-{ return ( c == L' ' || c == L'\t' ); }
+
 #include <xlocinfo.h>
 #define atoll _atoi64
 #define strtoll _strtoi64
@@ -50,10 +47,10 @@
 { return _Stod(nptr, endptr, 0); }
 _LIBCPP_ALWAYS_INLINE long double strtold( const char *nptr, char **endptr )
 { return _Stold(nptr, endptr, 0); }
-_LIBCPP_ALWAYS_INLINE float wcstof( const wchar_t *nptr, char** endptr )
 
 #define _Exit _exit
 
+#ifndef __clang__ // MSVC-based Clang also defines _MSC_VER
 #include <intrin.h>
 #define __builtin_popcount __popcnt
 #define __builtin_popcountl __popcnt
@@ -89,7 +86,7 @@
 	_BitScanForward64(&r, x);
 	return static_cast<int>(r);
 }
-
-#endif
+#endif // !__clang__
+#endif // _MSC_VER
 
 #endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H
\ No newline at end of file





More information about the cfe-commits mailing list