From owner-svn-src-projects@freebsd.org Sun Jan 22 18:06:23 2017 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 899FDCBC40F for ; Sun, 22 Jan 2017 18:06:23 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 642BD807; Sun, 22 Jan 2017 18:06:23 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0MI6MWI052746; Sun, 22 Jan 2017 18:06:22 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0MI6L4u052740; Sun, 22 Jan 2017 18:06:21 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201701221806.v0MI6L4u052740@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 22 Jan 2017 18:06:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r312642 - in projects/clang400-import/contrib/libc++: include src X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jan 2017 18:06:23 -0000 Author: dim Date: Sun Jan 22 18:06:21 2017 New Revision: 312642 URL: https://svnweb.freebsd.org/changeset/base/312642 Log: Merge libc++ release_40 branch r292732. Modified: projects/clang400-import/contrib/libc++/include/__config projects/clang400-import/contrib/libc++/include/array projects/clang400-import/contrib/libc++/include/new projects/clang400-import/contrib/libc++/include/string projects/clang400-import/contrib/libc++/include/typeinfo projects/clang400-import/contrib/libc++/src/new.cpp Directory Properties: projects/clang400-import/contrib/libc++/ (props changed) Modified: projects/clang400-import/contrib/libc++/include/__config ============================================================================== --- projects/clang400-import/contrib/libc++/include/__config Sun Jan 22 18:04:57 2017 (r312641) +++ projects/clang400-import/contrib/libc++/include/__config Sun Jan 22 18:06:21 2017 (r312642) @@ -835,6 +835,18 @@ template struct __static_asse #define _DECLARE_C99_LDBL_MATH 1 #endif +#if defined(__APPLE__) +# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ + defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) +# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIROMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# endif +# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +# if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 +# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +# endif +# endif +#endif // defined(__APPLE__) + #if defined(__APPLE__) || defined(__FreeBSD__) #define _LIBCPP_HAS_DEFAULTRUNELOCALE #endif Modified: projects/clang400-import/contrib/libc++/include/array ============================================================================== --- projects/clang400-import/contrib/libc++/include/array Sun Jan 22 18:04:57 2017 (r312641) +++ projects/clang400-import/contrib/libc++/include/array Sun Jan 22 18:06:21 2017 (r312642) @@ -185,14 +185,17 @@ struct _LIBCPP_TEMPLATE_VIS array _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;} // element access: - _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __elems_[__n];} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference operator[](size_type __n) const {return __elems_[__n];} - reference at(size_type __n); + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator[](size_type __n) {return __elems_[__n];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + const_reference operator[](size_type __n) const {return __elems_[__n];} + + _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n); _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const; - _LIBCPP_INLINE_VISIBILITY reference front() {return __elems_[0];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];} - _LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 @@ -202,6 +205,7 @@ struct _LIBCPP_TEMPLATE_VIS array }; template +_LIBCPP_CONSTEXPR_AFTER_CXX14 typename array<_Tp, _Size>::reference array<_Tp, _Size>::at(size_type __n) { Modified: projects/clang400-import/contrib/libc++/include/new ============================================================================== --- projects/clang400-import/contrib/libc++/include/new Sun Jan 22 18:04:57 2017 (r312641) +++ projects/clang400-import/contrib/libc++/include/new Sun Jan 22 18:06:21 2017 (r312642) @@ -101,8 +101,9 @@ void operator delete[](void* ptr, void* # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION #endif -#if !(defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER > 14 || \ - (defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606)) +#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ + (!(defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER > 14 || \ + (defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606))) # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION #endif @@ -144,7 +145,7 @@ public: #endif // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11) -#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || _LIBCPP_STD_VER > 14 #ifndef _LIBCPP_CXX03_LANG enum class _LIBCPP_ENUM_VIS align_val_t : size_t { }; #else Modified: projects/clang400-import/contrib/libc++/include/string ============================================================================== --- projects/clang400-import/contrib/libc++/include/string Sun Jan 22 18:04:57 2017 (r312641) +++ projects/clang400-import/contrib/libc++/include/string Sun Jan 22 18:06:21 2017 (r312642) @@ -818,6 +818,7 @@ public: operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } basic_string& operator=(const basic_string& __str); + template _LIBCPP_INLINE_VISIBILITY basic_string& operator=(__self_view __sv) {return assign(__sv);} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES Modified: projects/clang400-import/contrib/libc++/include/typeinfo ============================================================================== --- projects/clang400-import/contrib/libc++/include/typeinfo Sun Jan 22 18:04:57 2017 (r312641) +++ projects/clang400-import/contrib/libc++/include/typeinfo Sun Jan 22 18:06:21 2017 (r312642) @@ -95,12 +95,13 @@ protected: uintptr_t __type_name; _LIBCPP_INLINE_VISIBILITY - type_info(const char* __n) : __type_name(reinterpret_cast(__n)) {} + explicit type_info(const char* __n) + : __type_name(reinterpret_cast(__n)) {} #else const char *__type_name; _LIBCPP_INLINE_VISIBILITY - type_info(const char* __n) : __type_name(__n) {} + explicit type_info(const char* __n) : __type_name(__n) {} #endif public: Modified: projects/clang400-import/contrib/libc++/src/new.cpp ============================================================================== --- projects/clang400-import/contrib/libc++/src/new.cpp Sun Jan 22 18:04:57 2017 (r312641) +++ projects/clang400-import/contrib/libc++/src/new.cpp Sun Jan 22 18:06:21 2017 (r312642) @@ -64,38 +64,6 @@ operator new(std::size_t size) _THROW_BA } _LIBCPP_WEAK -void * -operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC -{ - if (size == 0) - size = 1; - if (static_cast(alignment) < sizeof(void*)) - alignment = std::align_val_t(sizeof(void*)); - void* p; -#if defined(_LIBCPP_MSVCRT) - while ((p = _aligned_malloc(size, static_cast(alignment))) == nullptr) -#else - while (::posix_memalign(&p, static_cast(alignment), size) != 0) -#endif - { - // If posix_memalign fails and there is a new_handler, - // call it to try free up memory. - std::new_handler nh = std::get_new_handler(); - if (nh) - nh(); - else { -#ifndef _LIBCPP_NO_EXCEPTIONS - throw std::bad_alloc(); -#else - p = nullptr; // posix_memalign doesn't initialize 'p' on failure - break; -#endif - } - } - return p; -} - -_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -116,14 +84,21 @@ operator new(size_t size, const std::not _LIBCPP_WEAK void* -operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT +operator new[](size_t size) _THROW_BAD_ALLOC +{ + return ::operator new(size); +} + +_LIBCPP_WEAK +void* +operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT { void* p = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS - p = ::operator new(size, alignment); + p = ::operator new[](size); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -134,29 +109,92 @@ operator new(size_t size, std::align_val } _LIBCPP_WEAK -void* -operator new[](size_t size) _THROW_BAD_ALLOC +void +operator delete(void* ptr) _NOEXCEPT { - return ::operator new(size); + if (ptr) + ::free(ptr); } _LIBCPP_WEAK -void* -operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC +void +operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT { - return ::operator new(size, alignment); + ::operator delete(ptr); +} + +_LIBCPP_WEAK +void +operator delete(void* ptr, size_t) _NOEXCEPT +{ + ::operator delete(ptr); +} + +_LIBCPP_WEAK +void +operator delete[] (void* ptr) _NOEXCEPT +{ + ::operator delete(ptr); +} + +_LIBCPP_WEAK +void +operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT +{ + ::operator delete[](ptr); +} + +_LIBCPP_WEAK +void +operator delete[] (void* ptr, size_t) _NOEXCEPT +{ + ::operator delete[](ptr); +} + +#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) + +_LIBCPP_WEAK +void * +operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC +{ + if (size == 0) + size = 1; + if (static_cast(alignment) < sizeof(void*)) + alignment = std::align_val_t(sizeof(void*)); + void* p; +#if defined(_LIBCPP_MSVCRT) + while ((p = _aligned_malloc(size, static_cast(alignment))) == nullptr) +#else + while (::posix_memalign(&p, static_cast(alignment), size) != 0) +#endif + { + // If posix_memalign fails and there is a new_handler, + // call it to try free up memory. + std::new_handler nh = std::get_new_handler(); + if (nh) + nh(); + else { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw std::bad_alloc(); +#else + p = nullptr; // posix_memalign doesn't initialize 'p' on failure + break; +#endif + } + } + return p; } _LIBCPP_WEAK void* -operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT +operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT { void* p = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS - p = ::operator new[](size); + p = ::operator new(size, alignment); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -168,6 +206,13 @@ operator new[](size_t size, const std::n _LIBCPP_WEAK void* +operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC +{ + return ::operator new(size, alignment); +} + +_LIBCPP_WEAK +void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT { void* p = 0; @@ -187,14 +232,6 @@ operator new[](size_t size, std::align_v _LIBCPP_WEAK void -operator delete(void* ptr) _NOEXCEPT -{ - if (ptr) - ::free(ptr); -} - -_LIBCPP_WEAK -void operator delete(void* ptr, std::align_val_t) _NOEXCEPT { if (ptr) @@ -207,13 +244,6 @@ operator delete(void* ptr, std::align_va _LIBCPP_WEAK void -operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT -{ - ::operator delete(ptr); -} - -_LIBCPP_WEAK -void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT { ::operator delete(ptr, alignment); @@ -221,13 +251,6 @@ operator delete(void* ptr, std::align_va _LIBCPP_WEAK void -operator delete(void* ptr, size_t) _NOEXCEPT -{ - ::operator delete(ptr); -} - -_LIBCPP_WEAK -void operator delete(void* ptr, size_t, std::align_val_t alignment) _NOEXCEPT { ::operator delete(ptr, alignment); @@ -235,13 +258,6 @@ operator delete(void* ptr, size_t, std:: _LIBCPP_WEAK void -operator delete[] (void* ptr) _NOEXCEPT -{ - ::operator delete(ptr); -} - -_LIBCPP_WEAK -void operator delete[] (void* ptr, std::align_val_t alignment) _NOEXCEPT { ::operator delete(ptr, alignment); @@ -249,13 +265,6 @@ operator delete[] (void* ptr, std::align _LIBCPP_WEAK void -operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT -{ - ::operator delete[](ptr); -} - -_LIBCPP_WEAK -void operator delete[] (void* ptr, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT { ::operator delete[](ptr, alignment); @@ -263,18 +272,13 @@ operator delete[] (void* ptr, std::align _LIBCPP_WEAK void -operator delete[] (void* ptr, size_t) _NOEXCEPT -{ - ::operator delete[](ptr); -} - -_LIBCPP_WEAK -void operator delete[] (void* ptr, size_t, std::align_val_t alignment) _NOEXCEPT { ::operator delete[](ptr, alignment); } +#endif // !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) + #endif // !__GLIBCXX__ namespace std