diff options
Diffstat (limited to 'libcxx/include/support/win32')
-rw-r--r-- | libcxx/include/support/win32/locale_win32.h | 6 | ||||
-rw-r--r-- | libcxx/include/support/win32/math_win32.h | 113 | ||||
-rw-r--r-- | libcxx/include/support/win32/support.h | 11 |
3 files changed, 123 insertions, 7 deletions
diff --git a/libcxx/include/support/win32/locale_win32.h b/libcxx/include/support/win32/locale_win32.h index 8b7267c1d33..e035420fb58 100644 --- a/libcxx/include/support/win32/locale_win32.h +++ b/libcxx/include/support/win32/locale_win32.h @@ -107,4 +107,10 @@ inline int iswblank_l( wint_t c, locale_t /*loc*/ ) 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 diff --git a/libcxx/include/support/win32/math_win32.h b/libcxx/include/support/win32/math_win32.h new file mode 100644 index 00000000000..80eabc1353d --- /dev/null +++ b/libcxx/include/support/win32/math_win32.h @@ -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 diff --git a/libcxx/include/support/win32/support.h b/libcxx/include/support/win32/support.h index dcc45fc3956..6ffd3d25890 100644 --- a/libcxx/include/support/win32/support.h +++ b/libcxx/include/support/win32/support.h @@ -34,10 +34,7 @@ size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src, #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 @@ _LIBCPP_ALWAYS_INLINE double strtod( const char *nptr, char **endptr ) { 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 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzll( unsigned long long x ) _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 |