[libc++] Tolerate presence of __deallocate macro
Summary: On Windows the identifier `__deallocate` is defined as a macro by one of the Windows system headers. Previously libc++ worked around this by `#undef __deallocate` and generating a warning. However this causes the WIN32 version of `__threading_support` to always generate a warning on Windows. This is not OK. This patch renames all usages of `__deallocate` internally as to not conflict with the macro. Reviewers: mclow.lists, majnemer, rnk, rsmith, smeenai, compnerd Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28426 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291332 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <__undef_min_max>
|
#include <__undef_min_max>
|
||||||
#include <__undef___deallocate>
|
|
||||||
|
|
||||||
#include <__debug>
|
#include <__debug>
|
||||||
|
|
||||||
@@ -1321,7 +1320,7 @@ private:
|
|||||||
void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
|
void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
|
||||||
#endif // _LIBCPP_CXX03_LANG
|
#endif // _LIBCPP_CXX03_LANG
|
||||||
|
|
||||||
void __deallocate(__next_pointer __np) _NOEXCEPT;
|
void __deallocate_node(__next_pointer __np) _NOEXCEPT;
|
||||||
__next_pointer __detach() _NOEXCEPT;
|
__next_pointer __detach() _NOEXCEPT;
|
||||||
|
|
||||||
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
|
template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
|
||||||
@@ -1454,7 +1453,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
|
|||||||
"Predicate must be copy-constructible.");
|
"Predicate must be copy-constructible.");
|
||||||
static_assert((is_copy_constructible<hasher>::value),
|
static_assert((is_copy_constructible<hasher>::value),
|
||||||
"Hasher must be copy-constructible.");
|
"Hasher must be copy-constructible.");
|
||||||
__deallocate(__p1_.first().__next_);
|
__deallocate_node(__p1_.first().__next_);
|
||||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
__get_db()->__erase_c(this);
|
__get_db()->__erase_c(this);
|
||||||
#endif
|
#endif
|
||||||
@@ -1492,7 +1491,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u)
|
|||||||
|
|
||||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||||
void
|
void
|
||||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__next_pointer __np)
|
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
|
||||||
_NOEXCEPT
|
_NOEXCEPT
|
||||||
{
|
{
|
||||||
__node_allocator& __na = __node_alloc();
|
__node_allocator& __na = __node_alloc();
|
||||||
@@ -1599,11 +1598,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
__deallocate(__cache);
|
__deallocate_node(__cache);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||||
__deallocate(__cache);
|
__deallocate_node(__cache);
|
||||||
}
|
}
|
||||||
const_iterator __i = __u.begin();
|
const_iterator __i = __u.begin();
|
||||||
while (__u.size() != 0)
|
while (__u.size() != 0)
|
||||||
@@ -1661,11 +1660,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
__deallocate(__cache);
|
__deallocate_node(__cache);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||||
__deallocate(__cache);
|
__deallocate_node(__cache);
|
||||||
}
|
}
|
||||||
for (; __first != __last; ++__first)
|
for (; __first != __last; ++__first)
|
||||||
__insert_unique(*__first);
|
__insert_unique(*__first);
|
||||||
@@ -1701,11 +1700,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
__deallocate(__cache);
|
__deallocate_node(__cache);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||||
__deallocate(__cache);
|
__deallocate_node(__cache);
|
||||||
}
|
}
|
||||||
for (; __first != __last; ++__first)
|
for (; __first != __last; ++__first)
|
||||||
__insert_multi(_NodeTypes::__get_value(*__first));
|
__insert_multi(_NodeTypes::__get_value(*__first));
|
||||||
@@ -1765,7 +1764,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT
|
|||||||
{
|
{
|
||||||
if (size() > 0)
|
if (size() > 0)
|
||||||
{
|
{
|
||||||
__deallocate(__p1_.first().__next_);
|
__deallocate_node(__p1_.first().__next_);
|
||||||
__p1_.first().__next_ = nullptr;
|
__p1_.first().__next_ = nullptr;
|
||||||
size_type __bc = bucket_count();
|
size_type __bc = bucket_count();
|
||||||
for (size_type __i = 0; __i < __bc; ++__i)
|
for (size_type __i = 0; __i < __bc; ++__i)
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <__undef___deallocate>
|
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||||
#pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
@@ -64,7 +62,7 @@ public:
|
|||||||
if (__p == (pointer)&buf_)
|
if (__p == (pointer)&buf_)
|
||||||
__allocated_ = false;
|
__allocated_ = false;
|
||||||
else
|
else
|
||||||
_VSTD::__deallocate(__p);
|
_VSTD::__libcpp_deallocate(__p);
|
||||||
}
|
}
|
||||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
|
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifdef __deallocate
|
|
||||||
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
|
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
|
||||||
_LIBCPP_WARNING("macro __deallocate is incompatible with C++. #undefining __deallocate")
|
|
||||||
#else
|
|
||||||
#warning: macro __deallocate is incompatible with C++. #undefining __deallocate
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#undef __deallocate
|
|
||||||
#endif
|
|
||||||
@@ -11,9 +11,6 @@
|
|||||||
#ifndef _LIBCPP_DYNARRAY
|
#ifndef _LIBCPP_DYNARRAY
|
||||||
#define _LIBCPP_DYNARRAY
|
#define _LIBCPP_DYNARRAY
|
||||||
|
|
||||||
#include <__config>
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
dynarray synopsis
|
dynarray synopsis
|
||||||
|
|
||||||
@@ -96,6 +93,8 @@ public:
|
|||||||
}} // std::experimental
|
}} // std::experimental
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#include <__config>
|
||||||
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
|
||||||
#include <__functional_base>
|
#include <__functional_base>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@@ -104,8 +103,6 @@ public:
|
|||||||
#include <new>
|
#include <new>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <__undef___deallocate>
|
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||||
#pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
@@ -143,9 +140,9 @@ private:
|
|||||||
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
|
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept
|
static inline _LIBCPP_INLINE_VISIBILITY void __deallocate_value( value_type* __ptr ) noexcept
|
||||||
{
|
{
|
||||||
_VSTD::__deallocate (static_cast<void *> (__ptr));
|
_VSTD::__libcpp_deallocate (static_cast<void *> (__ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -265,7 +262,7 @@ dynarray<_Tp>::~dynarray()
|
|||||||
value_type *__data = data () + __size_;
|
value_type *__data = data () + __size_;
|
||||||
for ( size_t i = 0; i < __size_; ++i )
|
for ( size_t i = 0; i < __size_; ++i )
|
||||||
(--__data)->value_type::~value_type();
|
(--__data)->value_type::~value_type();
|
||||||
__deallocate ( __base_ );
|
__deallocate_value( __base_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
|
|||||||
@@ -644,7 +644,6 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <__undef_min_max>
|
#include <__undef_min_max>
|
||||||
#include <__undef___deallocate>
|
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||||
#pragma GCC system_header
|
#pragma GCC system_header
|
||||||
@@ -1772,7 +1771,7 @@ public:
|
|||||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||||
}
|
}
|
||||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||||
{_VSTD::__deallocate((void*)__p);}
|
{_VSTD::__libcpp_deallocate((void*)__p);}
|
||||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||||
{return size_type(~0) / sizeof(_Tp);}
|
{return size_type(~0) / sizeof(_Tp);}
|
||||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||||
@@ -1868,7 +1867,7 @@ public:
|
|||||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||||
}
|
}
|
||||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||||
{_VSTD::__deallocate((void*)__p);}
|
{_VSTD::__libcpp_deallocate((void*)__p);}
|
||||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||||
{return size_type(~0) / sizeof(_Tp);}
|
{return size_type(~0) / sizeof(_Tp);}
|
||||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||||
|
|||||||
@@ -485,7 +485,6 @@ module std [system] {
|
|||||||
module __tree { header "__tree" export * }
|
module __tree { header "__tree" export * }
|
||||||
module __tuple { header "__tuple" export * }
|
module __tuple { header "__tuple" export * }
|
||||||
module __undef_min_max { header "__undef_min_max" export * }
|
module __undef_min_max { header "__undef_min_max" export * }
|
||||||
module __undef___deallocate { header "__undef___deallocate" export * }
|
|
||||||
|
|
||||||
module experimental {
|
module experimental {
|
||||||
requires cplusplus11
|
requires cplusplus11
|
||||||
|
|||||||
@@ -92,8 +92,6 @@ void operator delete[](void* ptr, void*) noexcept;
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <__undef___deallocate>
|
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||||
#pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
@@ -217,7 +215,7 @@ inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline _LIBCPP_INLINE_VISIBILITY void __deallocate(void *__ptr) {
|
inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void *__ptr) {
|
||||||
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
|
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
|
||||||
::operator delete(__ptr);
|
::operator delete(__ptr);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -348,7 +348,6 @@ template <class T> unspecified2 end(const valarray<T>& v);
|
|||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <__undef_min_max>
|
#include <__undef_min_max>
|
||||||
#include <__undef___deallocate>
|
|
||||||
|
|
||||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||||
#pragma GCC system_header
|
#pragma GCC system_header
|
||||||
@@ -3697,7 +3696,7 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
|
|||||||
{
|
{
|
||||||
while (__end_ != __begin_)
|
while (__end_ != __begin_)
|
||||||
(--__end_)->~value_type();
|
(--__end_)->~value_type();
|
||||||
_VSTD::__deallocate(__begin_);
|
_VSTD::__libcpp_deallocate(__begin_);
|
||||||
__begin_ = __end_ = nullptr;
|
__begin_ = __end_ = nullptr;
|
||||||
}
|
}
|
||||||
if (__n)
|
if (__n)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ protected:
|
|||||||
{ return __allocate(__size); }
|
{ return __allocate(__size); }
|
||||||
|
|
||||||
virtual void do_deallocate(void * __p, size_t, size_t)
|
virtual void do_deallocate(void * __p, size_t, size_t)
|
||||||
{ __deallocate(__p); }
|
{ _VSTD::__libcpp_deallocate(__p); }
|
||||||
|
|
||||||
virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
|
virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
|
||||||
{ return &__other == this; }
|
{ return &__other == this; }
|
||||||
|
|||||||
Reference in New Issue
Block a user