2 //===--------------------------- __debug ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_DEBUG_H
12 #define _LIBCPP_DEBUG_H
14 #if _LIBCPP_DEBUG_LEVEL >= 1
19 # ifndef _LIBCPP_ASSERT
20 # define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort()))
25 #if _LIBCPP_DEBUG_LEVEL >= 2
27 _LIBCPP_BEGIN_NAMESPACE_STD
29 struct _LIBCPP_TYPE_VIS __c_node;
31 struct _LIBCPP_TYPE_VIS __i_node
37 __i_node(const __i_node&) = delete;
38 __i_node& operator=(const __i_node&) = delete;
39 _LIBCPP_INLINE_VISIBILITY
40 __i_node(void* __i, __i_node* __next, __c_node* __c)
41 : __i_(__i), __next_(__next), __c_(__c) {}
45 struct _LIBCPP_TYPE_VIS __c_node
53 __c_node(const __c_node&) = delete;
54 __c_node& operator=(const __c_node&) = delete;
55 _LIBCPP_INLINE_VISIBILITY
56 __c_node(void* __c, __c_node* __next)
57 : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {}
60 virtual bool __dereferenceable(const void*) const = 0;
61 virtual bool __decrementable(const void*) const = 0;
62 virtual bool __addable(const void*, ptrdiff_t) const = 0;
63 virtual bool __subscriptable(const void*, ptrdiff_t) const = 0;
65 void __add(__i_node* __i);
66 _LIBCPP_HIDDEN void __remove(__i_node* __i);
69 template <class _Cont>
73 _C_node(void* __c, __c_node* __n)
74 : __c_node(__c, __n) {}
76 virtual bool __dereferenceable(const void*) const;
77 virtual bool __decrementable(const void*) const;
78 virtual bool __addable(const void*, ptrdiff_t) const;
79 virtual bool __subscriptable(const void*, ptrdiff_t) const;
82 template <class _Cont>
84 _C_node<_Cont>::__dereferenceable(const void* __i) const
86 typedef typename _Cont::const_iterator iterator;
87 const iterator* __j = static_cast<const iterator*>(__i);
88 _Cont* _Cp = static_cast<_Cont*>(__c_);
89 return _Cp->__dereferenceable(__j);
92 template <class _Cont>
94 _C_node<_Cont>::__decrementable(const void* __i) const
96 typedef typename _Cont::const_iterator iterator;
97 const iterator* __j = static_cast<const iterator*>(__i);
98 _Cont* _Cp = static_cast<_Cont*>(__c_);
99 return _Cp->__decrementable(__j);
102 template <class _Cont>
104 _C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const
106 typedef typename _Cont::const_iterator iterator;
107 const iterator* __j = static_cast<const iterator*>(__i);
108 _Cont* _Cp = static_cast<_Cont*>(__c_);
109 return _Cp->__addable(__j, __n);
112 template <class _Cont>
114 _C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const
116 typedef typename _Cont::const_iterator iterator;
117 const iterator* __j = static_cast<const iterator*>(__i);
118 _Cont* _Cp = static_cast<_Cont*>(__c_);
119 return _Cp->__subscriptable(__j, __n);
122 class _LIBCPP_TYPE_VIS __libcpp_db
133 __libcpp_db(const __libcpp_db&) = delete;
134 __libcpp_db& operator=(const __libcpp_db&) = delete;
137 class __db_c_iterator;
138 class __db_c_const_iterator;
139 class __db_i_iterator;
140 class __db_i_const_iterator;
142 __db_c_const_iterator __c_end() const;
143 __db_i_const_iterator __i_end() const;
145 template <class _Cont>
146 _LIBCPP_INLINE_VISIBILITY
147 void __insert_c(_Cont* __c)
149 __c_node* __n = __insert_c(static_cast<void*>(__c));
150 ::new(__n) _C_node<_Cont>(__n->__c_, __n->__next_);
153 void __insert_i(void* __i);
154 __c_node* __insert_c(void* __c);
155 void __erase_c(void* __c);
157 void __insert_ic(void* __i, const void* __c);
158 void __iterator_copy(void* __i, const void* __i0);
159 void __erase_i(void* __i);
161 void* __find_c_from_i(void* __i) const;
162 void __invalidate_all(void* __c);
163 __c_node* __find_c_and_lock(void* __c) const;
164 __c_node* __find_c(void* __c) const;
167 void swap(void* __c1, void* __c2);
170 bool __dereferenceable(const void* __i) const;
171 bool __decrementable(const void* __i) const;
172 bool __addable(const void* __i, ptrdiff_t __n) const;
173 bool __subscriptable(const void* __i, ptrdiff_t __n) const;
174 bool __comparable(const void* __i, const void* __j) const;
177 __i_node* __insert_iterator(void* __i);
179 __i_node* __find_iterator(const void* __i) const;
181 friend _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
184 _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
185 _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
188 _LIBCPP_END_NAMESPACE_STD
192 #endif // _LIBCPP_DEBUG_H