diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference index fa381bb43cb2..46213332c3e8 100644 --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -218,9 +218,9 @@ __find_bool_false(__bit_iterator<_C, false> __first, typename _C::size_type __n) template inline _LIBCPP_INLINE_VISIBILITY __bit_iterator<_C, false> -find(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value) +find(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value_) { - if (static_cast(__value)) + if (static_cast(__value_)) return __find_bool_true(__first, static_cast(__last - __first)); return __find_bool_false(__first, static_cast(__last - __first)); } @@ -292,9 +292,9 @@ __count_bool_false(__bit_iterator<_C, false> __first, typename _C::size_type __n template inline _LIBCPP_INLINE_VISIBILITY typename __bit_iterator<_C, false>::difference_type -count(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value) +count(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value_) { - if (static_cast(__value)) + if (static_cast(__value_)) return __count_bool_true(__first, static_cast(__last - __first)); return __count_bool_false(__first, static_cast(__last - __first)); } @@ -364,11 +364,11 @@ __fill_n_true(__bit_iterator<_C, false> __first, typename _C::size_type __n) template _LIBCPP_INLINE_VISIBILITY inline void -fill_n(__bit_iterator<_C, false> __first, typename _C::size_type __n, bool __value) +fill_n(__bit_iterator<_C, false> __first, typename _C::size_type __n, bool __value_) { if (__n > 0) { - if (__value) + if (__value_) __fill_n_true(__first, __n); else __fill_n_false(__first, __n); @@ -380,9 +380,9 @@ fill_n(__bit_iterator<_C, false> __first, typename _C::size_type __n, bool __val template inline _LIBCPP_INLINE_VISIBILITY void -fill(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, bool __value) +fill(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, bool __value_) { - _VSTD::fill_n(__first, static_cast(__last - __first), __value); + _VSTD::fill_n(__first, static_cast(__last - __first), __value_); } // copy diff --git a/libcxx/include/__config b/libcxx/include/__config index fe3917242ce0..3bd22a51ee65 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -321,6 +321,8 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #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 #define _LIBCPP_HAS_NO_UNICODE_CHARS diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 3a47b8d6c38c..e662632b043c 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -764,10 +764,10 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) template inline _LIBCPP_INLINE_VISIBILITY _InputIterator -find(_InputIterator __first, _InputIterator __last, const _Tp& __value) +find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { for (; __first != __last; ++__first) - if (*__first == __value) + if (*__first == __value_) break; return __first; } @@ -1004,11 +1004,11 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last) template inline _LIBCPP_INLINE_VISIBILITY typename iterator_traits<_InputIterator>::difference_type -count(_InputIterator __first, _InputIterator __last, const _Tp& __value) +count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { typename iterator_traits<_InputIterator>::difference_type __r(0); for (; __first != __last; ++__first) - if (*__first == __value) + if (*__first == __value_) ++__r; return __r; } @@ -1312,22 +1312,22 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, template _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last, - _Size __count, const _Tp& __value, _BinaryPredicate __pred, forward_iterator_tag) + _Size __count, const _Tp& __value_, _BinaryPredicate __pred, forward_iterator_tag) { if (__count <= 0) return __first; while (true) { - // Find first element in sequence that matchs __value, with a mininum of loop checks + // Find first element in sequence that matchs __value_, with a mininum of loop checks while (true) { - if (__first == __last) // return __last if no element matches __value + if (__first == __last) // return __last if no element matches __value_ return __last; - if (__pred(*__first, __value)) + if (__pred(*__first, __value_)) break; ++__first; } - // *__first matches __value, now match elements after here + // *__first matches __value_, now match elements after here _ForwardIterator __m = __first; _Size __c(0); while (true) @@ -1336,7 +1336,7 @@ __search_n(_ForwardIterator __first, _ForwardIterator __last, return __first; if (++__m == __last) // Otherwise if source exhaused, pattern not found return __last; - if (!__pred(*__m, __value)) // if there is a mismatch, restart with a new __first + if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first { __first = __m; ++__first; @@ -1349,7 +1349,7 @@ __search_n(_ForwardIterator __first, _ForwardIterator __last, template _RandomAccessIterator __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Size __count, const _Tp& __value, _BinaryPredicate __pred, random_access_iterator_tag) + _Size __count, const _Tp& __value_, _BinaryPredicate __pred, random_access_iterator_tag) { if (__count <= 0) return __first; @@ -1359,16 +1359,16 @@ __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last, const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here while (true) { - // Find first element in sequence that matchs __value, with a mininum of loop checks + // Find first element in sequence that matchs __value_, with a mininum of loop checks while (true) { - if (__first == __s) // return __last if no element matches __value + if (__first == __s) // return __last if no element matches __value_ return __last; - if (__pred(*__first, __value)) + if (__pred(*__first, __value_)) break; ++__first; } - // *__first matches __value, now match elements after here + // *__first matches __value_, now match elements after here _RandomAccessIterator __m = __first; _Size __c(0); while (true) @@ -1376,7 +1376,7 @@ __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last, if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern) return __first; ++__m; // no need to check range on __m because __s guarantees we have enough source - if (!__pred(*__m, __value)) // if there is a mismatch, restart with a new __first + if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first { __first = __m; ++__first; @@ -1390,19 +1390,19 @@ template ::type> - (__first, __last, __count, __value, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); + (__first, __last, __count, __value_, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator -search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) +search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) { typedef typename iterator_traits<_ForwardIterator>::value_type __v; - return _VSTD::search_n(__first, __last, __count, __value, __equal_to<__v, _Tp>()); + return _VSTD::search_n(__first, __last, __count, __value_, __equal_to<__v, _Tp>()); } // copy @@ -1744,29 +1744,29 @@ replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator _ template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator -__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value, false_type) +__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_, false_type) { for (; __n > 0; ++__first, --__n) - *__first = __value; + *__first = __value_; return __first; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator -__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value, true_type) +__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_, true_type) { if (__n > 0) - _VSTD::memset(__first, (unsigned char)__value, (size_t)(__n)); + _VSTD::memset(__first, (unsigned char)__value_, (size_t)(__n)); return __first + __n; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator -fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) +fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) { - return _VSTD::__fill_n(__first, __n, __value, integral_constant::value && is_trivially_copy_assignable<_Tp>::value && sizeof(_Tp) == 1>()); @@ -1777,26 +1777,26 @@ fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) template inline _LIBCPP_INLINE_VISIBILITY void -__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag) +__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag) { for (; __first != __last; ++__first) - *__first = __value; + *__first = __value_; } template inline _LIBCPP_INLINE_VISIBILITY void -__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag) +__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag) { - _VSTD::fill_n(__first, __last - __first, __value); + _VSTD::fill_n(__first, __last - __first, __value_); } template inline _LIBCPP_INLINE_VISIBILITY void -fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) +fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { - _VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category()); + _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category()); } // generate @@ -1826,15 +1826,15 @@ generate_n(_OutputIterator __first, _Size __n, _Generator __gen) template _ForwardIterator -remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) +remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { - __first = _VSTD::find(__first, __last, __value); + __first = _VSTD::find(__first, __last, __value_); if (__first != __last) { _ForwardIterator __i = __first; while (++__i != __last) { - if (!(*__i == __value)) + if (!(*__i == __value_)) { *__first = _VSTD::move(*__i); ++__first; @@ -1872,11 +1872,11 @@ remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator -remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value) +remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_) { for (; __first != __last; ++__first) { - if (!(*__first == __value)) + if (!(*__first == __value_)) { *__result = *__first; ++__result; @@ -3683,6 +3683,10 @@ sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last, _Compare __comp) _VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp); } +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4231) +#endif // _MSC_VER extern template void __sort<__less&, char*>(char*, char*, __less&); extern template void __sort<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&); extern template void __sort<__less&, signed char*>(signed char*, signed char*, __less&); @@ -3716,12 +3720,15 @@ extern template bool __insertion_sort_incomplete<__less&, double*>(doubl extern template bool __insertion_sort_incomplete<__less&, long double*>(long double*, long double*, __less&); extern template unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, long double*, __less&); +#ifdef _MSC_VER +#pragma warning( pop ) +#endif _MSC_VER // lower_bound template _ForwardIterator -__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) +__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; difference_type __len = _VSTD::distance(__first, __last); @@ -3730,7 +3737,7 @@ __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va difference_type __l2 = __len / 2; _ForwardIterator __m = __first; _VSTD::advance(__m, __l2); - if (__comp(*__m, __value)) + if (__comp(*__m, __value_)) { __first = ++__m; __len -= __l2 + 1; @@ -3744,24 +3751,24 @@ __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator -lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) +lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { #ifdef _LIBCPP_DEBUG2 typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); - return __lower_bound<_Comp_ref>(__first, __last, __value, __c); + return __lower_bound<_Comp_ref>(__first, __last, __value_, __c); #else // _LIBCPP_DEBUG2 typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; - return __lower_bound<_Comp_ref>(__first, __last, __value, __comp); + return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp); #endif // _LIBCPP_DEBUG2 } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator -lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) +lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { - return _VSTD::lower_bound(__first, __last, __value, + return _VSTD::lower_bound(__first, __last, __value_, __less::value_type, _Tp>()); } @@ -3769,7 +3776,7 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu template _ForwardIterator -__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) +__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; difference_type __len = _VSTD::distance(__first, __last); @@ -3778,7 +3785,7 @@ __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va difference_type __l2 = __len / 2; _ForwardIterator __m = __first; _VSTD::advance(__m, __l2); - if (__comp(__value, *__m)) + if (__comp(__value_, *__m)) __len = __l2; else { @@ -3792,24 +3799,24 @@ __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator -upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) +upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { #ifdef _LIBCPP_DEBUG2 typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); - return __upper_bound<_Comp_ref>(__first, __last, __value, __c); + return __upper_bound<_Comp_ref>(__first, __last, __value_, __c); #else // _LIBCPP_DEBUG2 typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; - return __upper_bound<_Comp_ref>(__first, __last, __value, __comp); + return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp); #endif // _LIBCPP_DEBUG2 } template inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator -upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) +upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { - return _VSTD::upper_bound(__first, __last, __value, + return _VSTD::upper_bound(__first, __last, __value_, __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>()); } @@ -3817,7 +3824,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu template pair<_ForwardIterator, _ForwardIterator> -__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) +__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; difference_type __len = _VSTD::distance(__first, __last); @@ -3826,12 +3833,12 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va difference_type __l2 = __len / 2; _ForwardIterator __m = __first; _VSTD::advance(__m, __l2); - if (__comp(*__m, __value)) + if (__comp(*__m, __value_)) { __first = ++__m; __len -= __l2 + 1; } - else if (__comp(__value, *__m)) + else if (__comp(__value_, *__m)) { __last = __m; __len = __l2; @@ -3841,8 +3848,8 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va _ForwardIterator __mp1 = __m; return pair<_ForwardIterator, _ForwardIterator> ( - __lower_bound<_Compare>(__first, __m, __value, __comp), - __upper_bound<_Compare>(++__mp1, __last, __value, __comp) + __lower_bound<_Compare>(__first, __m, __value_, __comp), + __upper_bound<_Compare>(++__mp1, __last, __value_, __comp) ); } } @@ -3852,24 +3859,24 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va template inline _LIBCPP_INLINE_VISIBILITY pair<_ForwardIterator, _ForwardIterator> -equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) +equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { #ifdef _LIBCPP_DEBUG2 typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); - return __equal_range<_Comp_ref>(__first, __last, __value, __c); + return __equal_range<_Comp_ref>(__first, __last, __value_, __c); #else // _LIBCPP_DEBUG2 typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; - return __equal_range<_Comp_ref>(__first, __last, __value, __comp); + return __equal_range<_Comp_ref>(__first, __last, __value_, __comp); #endif // _LIBCPP_DEBUG2 } template inline _LIBCPP_INLINE_VISIBILITY pair<_ForwardIterator, _ForwardIterator> -equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) +equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { - return _VSTD::equal_range(__first, __last, __value, + return _VSTD::equal_range(__first, __last, __value_, __less::value_type, _Tp>()); } @@ -3878,33 +3885,33 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu template inline _LIBCPP_INLINE_VISIBILITY bool -__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) +__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { - __first = __lower_bound<_Compare>(__first, __last, __value, __comp); - return __first != __last && !__comp(__value, *__first); + __first = __lower_bound<_Compare>(__first, __last, __value_, __comp); + return __first != __last && !__comp(__value_, *__first); } template inline _LIBCPP_INLINE_VISIBILITY bool -binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) +binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { #ifdef _LIBCPP_DEBUG2 typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); - return __binary_search<_Comp_ref>(__first, __last, __value, __c); + return __binary_search<_Comp_ref>(__first, __last, __value_, __c); #else // _LIBCPP_DEBUG2 typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; - return __binary_search<_Comp_ref>(__first, __last, __value, __comp); + return __binary_search<_Comp_ref>(__first, __last, __value_, __comp); #endif // _LIBCPP_DEBUG2 } template inline _LIBCPP_INLINE_VISIBILITY bool -binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) +binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { - return _VSTD::binary_search(__first, __last, __value, + return _VSTD::binary_search(__first, __last, __value_, __less::value_type, _Tp>()); } diff --git a/libcxx/include/cctype b/libcxx/include/cctype index 5ef32a48b5fe..e33244e7daa2 100644 --- a/libcxx/include/cctype +++ b/libcxx/include/cctype @@ -37,6 +37,9 @@ int toupper(int c); #include <__config> #include +#if defined(_MSC_VER) +#include "support/win32/support.h" +#endif // _MSC_VER #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/libcxx/include/cstdio b/libcxx/include/cstdio index aa891742ea1e..2a6ec762deae 100644 --- a/libcxx/include/cstdio +++ b/libcxx/include/cstdio @@ -126,13 +126,15 @@ using ::scanf; using ::snprintf; using ::sprintf; using ::sscanf; +#ifndef _MSC_VER using ::vfprintf; using ::vfscanf; -using ::vprintf; using ::vscanf; +using ::vsscanf; +#endif // _MSC_VER +using ::vprintf; using ::vsnprintf; using ::vsprintf; -using ::vsscanf; using ::fgetc; using ::fgets; using ::fputc; diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib index e8726cf6fce7..01b13a8dc041 100644 --- a/libcxx/include/cstdlib +++ b/libcxx/include/cstdlib @@ -81,6 +81,9 @@ size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n); #include <__config> #include +#ifdef _MSC_VER +#include "support/win32/support.h" +#endif // _MSC_VER #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -129,11 +132,13 @@ using ::wctomb; using ::mbstowcs; using ::wcstombs; +#ifndef _MSC_VER // MSVC already has the correct prototype in #ifdef __cplusplus inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) {return labs(__x);} inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) {return llabs(__x);} inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) {return ldiv(__x, __y);} inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) {return lldiv(__x, __y);} +#endif // _MSC_VER _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/cstring b/libcxx/include/cstring index 1a230559bd24..dd49d802d5e0 100644 --- a/libcxx/include/cstring +++ b/libcxx/include/cstring @@ -93,7 +93,8 @@ using ::strspn; using ::strstr; -#ifndef __GLIBC__ // GNU libc and its derivates already have the correct prototype in #ifdef __cplusplus +// MSVC, GNU libc and its derivates already have the correct prototype in #ifdef __cplusplus +#if !defined(__GLIBC__) && !defined(_MSC_VER) inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);} inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);} inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);} diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar index 6fe485229f63..8e788fc764e1 100644 --- a/libcxx/include/cwchar +++ b/libcxx/include/cwchar @@ -124,13 +124,15 @@ using ::FILE; using ::fwprintf; using ::fwscanf; using ::swprintf; -using ::swscanf; using ::vfwprintf; -using ::vfwscanf; using ::vswprintf; -using ::vswscanf; using ::vwprintf; +#ifndef _MSC_VER +using ::swscanf; +using ::vfwscanf; +using ::vswscanf; using ::vwscanf; +#endif // _MSC_VER using ::wprintf; using ::wscanf; using ::fgetwc; @@ -144,8 +146,10 @@ using ::putwc; using ::putwchar; using ::ungetwc; using ::wcstod; +#ifndef _MSC_VER using ::wcstof; using ::wcstold; +#endif // _MSC_VER using ::wcstol; using ::wcstoll; using ::wcstoul; diff --git a/libcxx/include/iterator b/libcxx/include/iterator index d62743856b04..13c2c341e238 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -626,11 +626,11 @@ public: typedef _Container container_type; _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(&__x) {} - _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value) - {container->push_back(__value); return *this;} + _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_) + {container->push_back(__value_); return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value) - {container->push_back(_VSTD::move(__value)); return *this;} + _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_) + {container->push_back(_VSTD::move(__value_)); return *this;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++() {return *this;} @@ -659,11 +659,11 @@ public: typedef _Container container_type; _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(&__x) {} - _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value) - {container->push_front(__value); return *this;} + _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_) + {container->push_front(__value_); return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value) - {container->push_front(_VSTD::move(__value)); return *this;} + _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_) + {container->push_front(_VSTD::move(__value_)); return *this;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++() {return *this;} @@ -694,11 +694,11 @@ public: _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i) : container(&__x), iter(__i) {} - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value) - {iter = container->insert(iter, __value); ++iter; return *this;} + _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_) + {iter = container->insert(iter, __value_); ++iter; return *this;} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value) - {iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;} + _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_) + {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY insert_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++() {return *this;} @@ -769,9 +769,9 @@ public: : __out_stream_(&__s), __delim_(0) {} _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) : __out_stream_(&__s), __delim_(__delimiter) {} - _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value) + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_) { - *__out_stream_ << __value; + *__out_stream_ << __value_; if (__delim_) *__out_stream_ << __delim_; return *this; diff --git a/libcxx/include/limits b/libcxx/include/limits index 5f31c4fdfecf..14b49b1385b3 100644 --- a/libcxx/include/limits +++ b/libcxx/include/limits @@ -109,6 +109,10 @@ template<> class numeric_limits; #include <__config> #include +#if defined(_MSC_VER) +#include "support/win32/limits_win32.h" +#endif // _MSC_VER + _LIBCPP_BEGIN_NAMESPACE_STD enum float_round_style diff --git a/libcxx/include/numeric b/libcxx/include/numeric index 4ca62e8eb649..c201a5f57cbb 100644 --- a/libcxx/include/numeric +++ b/libcxx/include/numeric @@ -186,10 +186,10 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat template inline _LIBCPP_INLINE_VISIBILITY void -iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) +iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_) { - for (; __first != __last; ++__first, ++__value) - *__first = __value; + for (; __first != __last; ++__first, ++__value_) + *__first = __value_; } _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/string b/libcxx/include/string index 4e29e8ae166e..5f5a347c6340 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1023,7 +1023,14 @@ __basic_string_common<__b>::__throw_out_of_range() const #endif } +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4231 ) +#endif // _MSC_VER extern template class __basic_string_common; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif // _MSC_VER template class _LIBCPP_VISIBLE basic_string diff --git a/libcxx/include/support/win32/limits_win32.h b/libcxx/include/support/win32/limits_win32.h index 91cdcf156af3..671631df2f9c 100644 --- a/libcxx/include/support/win32/limits_win32.h +++ b/libcxx/include/support/win32/limits_win32.h @@ -15,6 +15,11 @@ #error "This header is MSVC specific, Clang and GCC should not include it" #else +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include // ymath.h works correctly + #include // limit constants #define __FLT_MANT_DIG__ FLT_MANT_DIG @@ -57,16 +62,17 @@ #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L // __builtin replacements/workarounds +#include // HUGE_VAL #include // internal MSVC header providing the needed functionality -#define __builtin_huge_val() HUGE_VAL -#define __builtin_huge_valf() _FInf -#define __builtin_huge_vall() _LInf -#define __builtin_nan() _Nan -#define __builtin_nanf() _FNan -#define __builtin_nanl() _LNan -#define __builtin_nans() _Snan -#define __builtin_nansf() _FSnan -#define __builtin_nansl() _LSnan +#define __builtin_huge_val() HUGE_VAL +#define __builtin_huge_valf() _FInf._Float +#define __builtin_huge_vall() _LInf._Long_double +#define __builtin_nan(__dummy) _Nan._Double +#define __builtin_nanf(__dummy) _FNan._Float +#define __builtin_nanl(__dummmy) _LNan._Long_double +#define __builtin_nans(__dummy) _Snan._Double +#define __builtin_nansf(__dummy) _FSnan._Float +#define __builtin_nansl(__dummy) _LSnan._Long_double #endif // _MSC_VER diff --git a/libcxx/include/support/win32/support.h b/libcxx/include/support/win32/support.h index 8ce947a16a31..dcc45fc39561 100644 --- a/libcxx/include/support/win32/support.h +++ b/libcxx/include/support/win32/support.h @@ -15,17 +15,81 @@ Functions and constants used in libc++ that are missing from the Windows C library. */ +#include <__config> #include // mbstate_t #include // _snwprintf #define swprintf _snwprintf #define vswprintf _vsnwprintf +#define vfscnaf fscanf -int vasprintf( char **sptr, const char *__restrict__ fmt , va_list ap ); -int asprintf(char **sptr, const char *__restrict__ fmt, ...); +int vasprintf( char **sptr, const char *__restrict fmt , va_list ap ); +int asprintf( char **sptr, const char *__restrict fmt, ...); +//int vfscanf( FILE *__restrict stream, const char *__restrict format, +// va_list arg); -size_t mbsnrtowcs( wchar_t *__restrict__ dst, const char **__restrict__ src, - size_t nmc, size_t len, mbstate_t *__restrict__ ps ); -size_t wcsnrtombs( char *__restrict__ dst, const wchar_t **__restrict__ src, - size_t nwc, size_t len, mbstate_t *__restrict__ ps ); +size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src, + size_t nmc, size_t len, mbstate_t *__restrict ps ); +size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src, + size_t nwc, size_t len, mbstate_t *__restrict ps ); + +#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 +#define atoll _atoi64 +#define strtoll _strtoi64 +#define strtoull _strtoui64 +#define wcstoll _wcstoi64 +#define wcstoull _wcstoui64 +_LIBCPP_ALWAYS_INLINE float strtof( const char *nptr, char **endptr ) +{ return _Stof(nptr, endptr, 0); } +_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 + +#include +#define __builtin_popcount __popcnt +#define __builtin_popcountl __popcnt +#define __builtin_popcountll(__i) static_cast(__popcnt64(__i)) + +_LIBCPP_ALWAYS_INLINE int __builtin_ctz( unsigned int x ) +{ + DWORD r = 0; + _BitScanReverse(&r, x); + return static_cast(r); +} +// sizeof(long) == sizeof(int) on Windows +_LIBCPP_ALWAYS_INLINE int __builtin_ctzl( unsigned long x ) +{ return __builtin_ctz( static_cast(x) ); } +_LIBCPP_ALWAYS_INLINE int __builtin_ctzll( unsigned long long x ) +{ + DWORD r = 0; + _BitScanReverse64(&r, x); + return static_cast(r); +} +_LIBCPP_ALWAYS_INLINE int __builtin_clz( unsigned int x ) +{ + DWORD r = 0; + _BitScanForward(&r, x); + return static_cast(r); +} +// sizeof(long) == sizeof(int) on Windows +_LIBCPP_ALWAYS_INLINE int __builtin_clzl( unsigned long x ) +{ return __builtin_clz( static_cast(x) ); } +_LIBCPP_ALWAYS_INLINE int __builtin_clzll( unsigned long long x ) +{ + DWORD r = 0; + _BitScanForward64(&r, x); + return static_cast(r); +} + +#endif #endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H \ No newline at end of file diff --git a/libcxx/include/vector b/libcxx/include/vector index 5f47180c4f40..7f7e3d361b90 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -307,7 +307,14 @@ __vector_base_common<__b>::__throw_out_of_range() const #endif } +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4231 ) +#endif // _MSC_VER extern template class __vector_base_common; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif // _MSC_VER template class __vector_base diff --git a/libcxx/src/support/win32/support.cpp b/libcxx/src/support/win32/support.cpp index b3ef50a79901..9e85077a7ada 100644 --- a/libcxx/src/support/win32/support.cpp +++ b/libcxx/src/support/win32/support.cpp @@ -15,7 +15,7 @@ #include // vsprintf, vsnprintf #include // strcpy, wcsncpy -int asprintf(char **sptr, const char *__restrict__ fmt, ...) +int asprintf(char **sptr, const char *__restrict fmt, ...) { va_list ap; va_start(ap, fmt); @@ -23,7 +23,7 @@ int asprintf(char **sptr, const char *__restrict__ fmt, ...) va_end(ap); return result; } -int vasprintf( char **sptr, const char *__restrict__ fmt, va_list ap ) +int vasprintf( char **sptr, const char *__restrict fmt, va_list ap ) { *sptr = NULL; int count = vsnprintf( *sptr, 0, fmt, ap ); @@ -38,8 +38,8 @@ int vasprintf( char **sptr, const char *__restrict__ fmt, va_list ap ) // FIXME: use wcrtomb and avoid copy // use mbsrtowcs which is available, first copy first nwc elements of src -size_t mbsnrtowcs( wchar_t *__restrict__ dst, const char **__restrict__ src, - size_t nmc, size_t len, mbstate_t *__restrict__ ps ) +size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src, + size_t nmc, size_t len, mbstate_t *__restrict ps ) { char* local_src = new char[nmc+1]; char* nmcsrc = local_src; @@ -54,8 +54,8 @@ size_t mbsnrtowcs( wchar_t *__restrict__ dst, const char **__restrict__ src, } // FIXME: use wcrtomb and avoid copy // use wcsrtombs which is available, first copy first nwc elements of src -size_t wcsnrtombs( char *__restrict__ dst, const wchar_t **__restrict__ src, - size_t nwc, size_t len, mbstate_t *__restrict__ ps ) +size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src, + size_t nwc, size_t len, mbstate_t *__restrict ps ) { wchar_t* local_src = new wchar_t[nwc]; wchar_t* nwcsrc = local_src;