Merge branch 'feature/debug_count' into development

This commit is contained in:
John Wellbelove 2018-04-24 14:16:35 +01:00
commit 5d6e01c8bb
25 changed files with 293 additions and 275 deletions

View File

@ -39,6 +39,15 @@ SOFTWARE.
///\defgroup debug_count debug count
///\ingroup utilities
#if defined(ETL_DEBUG_COUNT)
#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count
#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count
#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count
#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n)
#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n)
#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear()
namespace etl
{
//***************************************************************************
@ -51,8 +60,7 @@ namespace etl
class debug_count
{
public:
#if defined(ETL_DEBUG)
inline debug_count()
: count(0)
{
@ -113,46 +121,16 @@ namespace etl
private:
int32_t count;
#else
inline debug_count()
{
}
inline ~debug_count()
{
}
inline debug_count& operator ++()
{
return *this;
}
inline debug_count& operator --()
{
return *this;
}
inline debug_count& operator +=(int32_t /*n*/)
{
return *this;
}
inline debug_count& operator -=(int32_t /*n*/)
{
return *this;
}
inline operator int32_t()
{
return 0;
}
inline void clear()
{
}
#endif
};
#else
#define ETL_DECLARE_DEBUG_COUNT
#define ETL_INCREMENT_DEBUG_COUNT
#define ETL_DECREMENT_DEBUG_COUNT
#define ETL_ADD_DEBUG_COUNT(n)
#define ETL_SUBTRACT_DEBUG_COUNT(n)
#define ETL_RESET_DEBUG_COUNT
#endif // ETL_DEBUG_COUNT
}
#endif

View File

@ -211,10 +211,10 @@ namespace etl
{
}
size_type current_size; ///< The current number of elements in the deque.
const size_type CAPACITY; ///< The maximum number of elements in the deque.
const size_type BUFFER_SIZE; ///< The number of elements in the buffer.
etl::debug_count construct_count; ///< Internal debugging.
size_type current_size; ///< The current number of elements in the deque.
const size_type CAPACITY; ///< The maximum number of elements in the deque.
const size_type BUFFER_SIZE; ///< The number of elements in the buffer.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
//***************************************************************************
@ -935,7 +935,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -943,7 +943,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1000,7 +1000,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -1008,7 +1008,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1065,7 +1065,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -1073,7 +1073,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1130,7 +1130,7 @@ namespace etl
--_begin;
p = etl::addressof(*_begin);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
position = _begin;
}
else if (insert_position == end())
@ -1138,7 +1138,7 @@ namespace etl
p = etl::addressof(*_end);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
position = _end - 1;
}
else
@ -1538,7 +1538,7 @@ namespace etl
::new (&(*_end)) T(value1);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -1555,7 +1555,7 @@ namespace etl
::new (&(*_end)) T(value1, value2);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -1572,7 +1572,7 @@ namespace etl
::new (&(*_end)) T(value1, value2, value3);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -1589,7 +1589,7 @@ namespace etl
::new (&(*_end)) T(value1, value2, value3, value4);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -1645,7 +1645,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value1);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -1662,7 +1662,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value1, value2);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -1679,7 +1679,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value1, value2, value3);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -1696,7 +1696,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value1, value2, value3, value4);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -1811,7 +1811,7 @@ namespace etl
if ETL_IF_CONSTEXPR(etl::is_trivially_destructible<T>::value)
{
current_size = 0;
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
}
else
{
@ -1850,7 +1850,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T();
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -1882,7 +1882,7 @@ namespace etl
::new (&(*item++)) T(*from);
++from;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
} while (n-- != 0);
}
@ -1894,7 +1894,7 @@ namespace etl
::new (&(*_end)) T();
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -1905,7 +1905,7 @@ namespace etl
--_begin;
::new (&(*_begin)) T(value);
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -1916,7 +1916,7 @@ namespace etl
::new (&(*_end)) T(value);
++_end;
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -1926,7 +1926,7 @@ namespace etl
{
(*_begin).~T();
--current_size;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
++_begin;
}
@ -1938,7 +1938,7 @@ namespace etl
--_end;
(*_end).~T();
--current_size;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -234,7 +234,7 @@ namespace etl
{
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type();
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
std::pair<iterator, bool> result = refmap_t::insert_at(i_element, *pvalue);
i_element->second = result.first->second;
@ -306,7 +306,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
@ -367,7 +367,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (i_element->first != key)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -399,7 +399,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (i_element->first != key)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -431,7 +431,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (i_element->first != key)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -463,7 +463,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (i_element->first != key)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -495,7 +495,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (i_element->first != key)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
}
else
@ -525,7 +525,7 @@ namespace etl
i_element->~value_type();
storage.release(etl::addressof(*i_element));
refmap_t::erase(i_element);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
return 1;
}
}
@ -539,7 +539,7 @@ namespace etl
i_element->~value_type();
storage.release(etl::addressof(*i_element));
refmap_t::erase(i_element);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -558,7 +558,7 @@ namespace etl
itr->~value_type();
storage.release(etl::addressof(*itr));
++itr;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
refmap_t::erase(first, last);
@ -585,7 +585,7 @@ namespace etl
}
}
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
refmap_t::clear();
}
@ -765,7 +765,7 @@ namespace etl
storage_t& storage;
/// Internal debugging.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -260,7 +260,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refmap_t::insert_at(i_element, *pvalue);
return result;
@ -313,7 +313,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value);
iterator i_element = lower_bound(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -331,7 +331,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1);
iterator i_element = lower_bound(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -349,7 +349,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2);
iterator i_element = lower_bound(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -367,7 +367,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3);
iterator i_element = lower_bound(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -385,7 +385,7 @@ namespace etl
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4);
iterator i_element = lower_bound(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return refmap_t::insert_at(i_element, *pvalue);
}
@ -420,7 +420,7 @@ namespace etl
i_element->~value_type();
storage.release(etl::addressof(*i_element));
refmap_t::erase(i_element);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -439,7 +439,7 @@ namespace etl
itr->~value_type();
storage.release(etl::addressof(*itr));
++itr;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
refmap_t::erase(first, last);
@ -466,7 +466,7 @@ namespace etl
}
}
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
refmap_t::clear();
}
@ -646,7 +646,7 @@ namespace etl
storage_t& storage;
/// Internal debugging.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -236,7 +236,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
return result;
@ -292,7 +292,7 @@ namespace etl
iterator i_element = lower_bound(*pvalue);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
@ -310,7 +310,7 @@ namespace etl
iterator i_element = lower_bound(*pvalue);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
@ -328,7 +328,7 @@ namespace etl
iterator i_element = lower_bound(*pvalue);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
@ -346,7 +346,7 @@ namespace etl
iterator i_element = lower_bound(*pvalue);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
}
@ -380,7 +380,7 @@ namespace etl
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
refset_t::erase(i_element);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -399,7 +399,7 @@ namespace etl
etl::destroy_at(etl::addressof(*itr));
storage.release(etl::addressof(*itr));
++itr;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
refset_t::erase(first, last);
@ -426,7 +426,7 @@ namespace etl
}
}
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
refset_t::clear();
}
@ -606,7 +606,7 @@ namespace etl
storage_t& storage;
/// Internal debugging.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -239,7 +239,7 @@ namespace etl
value_type* pvalue = storage.allocate<value_type>();
::new (pvalue) value_type(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
@ -300,7 +300,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (*i_element != *pvalue)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -333,7 +333,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (*i_element != *pvalue)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -366,7 +366,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (*i_element != *pvalue)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -399,7 +399,7 @@ namespace etl
// Doesn't already exist?
if ((i_element == end() || (*i_element != *pvalue)))
{
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
result = refset_t::insert_at(i_element, *pvalue);
}
else
@ -431,7 +431,7 @@ namespace etl
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
refset_t::erase(i_element);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
return 1;
}
}
@ -445,7 +445,7 @@ namespace etl
etl::destroy_at(etl::addressof(*i_element));
storage.release(etl::addressof(*i_element));
refset_t::erase(i_element);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -464,7 +464,7 @@ namespace etl
etl::destroy_at(etl::addressof(*itr));
storage.release(etl::addressof(*itr));
++itr;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
refset_t::erase(first, last);
@ -488,11 +488,11 @@ namespace etl
etl::destroy_at(etl::addressof(*itr));
storage.release(etl::addressof(*itr));
++itr;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
}
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
refset_t::clear();
}
@ -672,7 +672,7 @@ namespace etl
storage_t& storage;
/// Internal debugging.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -275,10 +275,10 @@ namespace etl
left->next = right;
}
node_t start_node; ///< The node that acts as the forward_list start.
etl::ipool* p_node_pool; ///< The pool of data nodes used in the list.
const size_type MAX_SIZE; ///< The maximum size of the forward_list.
etl::debug_count construct_count; ///< Internal debugging.
node_t start_node; ///< The node that acts as the forward_list start.
etl::ipool* p_node_pool; ///< The pool of data nodes used in the list.
const size_type MAX_SIZE; ///< The maximum size of the forward_list.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
//***************************************************************************
@ -658,7 +658,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
}
@ -673,7 +673,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
}
@ -688,7 +688,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
}
@ -703,7 +703,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(start_node, *p_data_node);
}
@ -793,7 +793,7 @@ namespace etl
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*position.p_node, *p_data_node);
return iterator(*p_data_node);
@ -809,7 +809,7 @@ namespace etl
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*position.p_node, *p_data_node);
return iterator(*p_data_node);
@ -825,7 +825,7 @@ namespace etl
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*position.p_node, *p_data_node);
return iterator(*p_data_node);
@ -841,7 +841,7 @@ namespace etl
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node_after(*position.p_node, *p_data_node);
return iterator(*p_data_node);
@ -1247,7 +1247,7 @@ namespace etl
if ETL_IF_CONSTEXPR(etl::is_trivially_destructible<T>::value)
{
p_node_pool->release_all();
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
}
else
{
@ -1326,7 +1326,7 @@ namespace etl
{
data_node_t* p_node = p_node_pool->allocate<data_node_t>();
::new (&(p_node->value)) T(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return *p_node;
}
@ -1338,7 +1338,7 @@ namespace etl
{
node.value.~T();
p_node_pool->release(&node);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
// Disable copy construction.

View File

@ -317,10 +317,10 @@ namespace etl
{
}
etl::ipool* p_node_pool; ///< The pool of data nodes used in the list.
node_t terminal_node; ///< The node that acts as the list start and end.
const size_type MAX_SIZE; ///< The maximum size of the list.
etl::debug_count construct_count; ///< Internal debugging.
etl::ipool* p_node_pool; ///< The pool of data nodes used in the list.
node_t terminal_node; ///< The node that acts as the list start and end.
const size_type MAX_SIZE; ///< The maximum size of the list.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
//***************************************************************************
@ -789,7 +789,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
}
@ -804,7 +804,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
}
@ -819,7 +819,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
}
@ -834,7 +834,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(get_head(), *p_data_node);
}
@ -880,7 +880,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
}
@ -895,7 +895,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
}
@ -910,7 +910,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
}
@ -925,7 +925,7 @@ namespace etl
#endif
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(terminal_node, *p_data_node);
}
@ -964,7 +964,7 @@ namespace etl
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*position.p_node, *p_data_node);
return iterator(*p_data_node);
@ -980,7 +980,7 @@ namespace etl
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*position.p_node, *p_data_node);
return iterator(*p_data_node);
@ -996,7 +996,7 @@ namespace etl
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*position.p_node, *p_data_node);
return iterator(*p_data_node);
@ -1012,7 +1012,7 @@ namespace etl
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
insert_node(*position.p_node, *p_data_node);
return iterator(*p_data_node);
@ -1456,7 +1456,7 @@ namespace etl
if ETL_IF_CONSTEXPR(etl::is_trivially_destructible<T>::value)
{
p_node_pool->release_all();
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
}
else
{
@ -1549,7 +1549,7 @@ namespace etl
{
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
::new (&(p_data_node->value)) T(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return *p_data_node;
}
@ -1561,7 +1561,7 @@ namespace etl
{
node.value.~T();
p_node_pool->release(&node);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
// Disable copy construction.

View File

@ -453,7 +453,7 @@ namespace etl
size_type current_size; ///< The number of the used nodes.
const size_type CAPACITY; ///< The maximum size of the map.
Node* root_node; ///< The node that acts as the map root.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
};
//***************************************************************************
@ -1263,7 +1263,7 @@ namespace etl
{
Data_Node& node = *p_node_pool->allocate<Data_Node>();
::new (&node.value) const value_type(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1274,7 +1274,7 @@ namespace etl
{
node.value.~value_type();
p_node_pool->release(&node);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -0,0 +1,46 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2018 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_MEMORY_MODEL_INCLUDED
#define ETL_MEMORY_MODEL_INCLUDED
#include "user_type.h"
namespace etl
{
ETL_DECLARE_USER_TYPE(memory_model, int)
ETL_USER_TYPE(MM_SMALL, 0)
ETL_USER_TYPE(MM_MEDIUM, 1)
ETL_USER_TYPE(MM_LARGE, 2)
ETL_END_USER_TYPE(memory_model)
}
#endif

View File

@ -609,7 +609,7 @@ namespace etl
size_type current_size; ///< The number of the used nodes.
const size_type CAPACITY; ///< The maximum size of the map.
Node* root_node; ///< The node that acts as the multimap root.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
};
//***************************************************************************
@ -1356,7 +1356,7 @@ namespace etl
{
Data_Node& node = *p_node_pool->allocate<Data_Node>();
::new (&node.value) const value_type(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1367,7 +1367,7 @@ namespace etl
{
node.value.~value_type();
p_node_pool->release(&node);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -609,7 +609,7 @@ namespace etl
size_type current_size; ///< The number of the used nodes.
const size_type CAPACITY; ///< The maximum size of the set.
Node* root_node; ///< The node that acts as the multiset root.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
};
//***************************************************************************
@ -1337,7 +1337,7 @@ namespace etl
{
Data_Node& node = *p_node_pool->allocate<Data_Node>();
::new ((void*)&node.value) value_type(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1348,7 +1348,7 @@ namespace etl
{
node.value.~value_type();
p_node_pool->release(&node);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -161,8 +161,8 @@ namespace etl
{
}
const size_type CAPACITY; ///<The maximum number of elements in the vector.
etl::debug_count construct_count; ///< Internal debugging.
const size_type CAPACITY; ///<The maximum number of elements in the vector.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
};
}

View File

@ -190,7 +190,7 @@ namespace etl
}
++current_size;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -203,7 +203,7 @@ namespace etl
out = 0;
}
--current_size;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -214,14 +214,14 @@ namespace etl
in = 0;
out = 0;
current_size = 0;
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
}
size_type in; ///< Where to input new data.
size_type out; ///< Where to get the oldest data.
size_type current_size; ///< The number of items in the queue.
const size_type CAPACITY; ///< The maximum number of items in the queue.
etl::debug_count construct_count; ///< For internal debugging purposes.
size_type in; ///< Where to input new data.
size_type out; ///< Where to get the oldest data.
size_type current_size; ///< The number of items in the queue.
const size_type CAPACITY; ///< The maximum number of items in the queue.
ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes.
};

View File

@ -447,7 +447,7 @@ namespace etl
size_type current_size; ///< The number of the used nodes.
const size_type CAPACITY; ///< The maximum size of the set.
Node* root_node; ///< The node that acts as the set root.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
};
@ -1186,7 +1186,7 @@ namespace etl
{
Data_Node& node = *p_node_pool->allocate<Data_Node>();
::new ((void*)&node.value) value_type(value);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
return node;
}
@ -1197,7 +1197,7 @@ namespace etl
{
node.value.~value_type();
p_node_pool->release(&node);
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************

View File

@ -178,7 +178,7 @@ namespace etl
void add_in()
{
top_index = current_size++;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -188,7 +188,7 @@ namespace etl
{
--top_index;
--current_size;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -198,13 +198,13 @@ namespace etl
{
top_index = 0;
current_size = 0;
construct_count.clear();
ETL_RESET_DEBUG_COUNT;
}
size_type top_index; ///< The index of the top of the stack.
size_type current_size; ///< The number of items in the stack.
const size_type CAPACITY; ///< The maximum number of items in the stack.
etl::debug_count construct_count; ///< For internal debugging purposes.
size_type top_index; ///< The index of the top of the stack.
size_type current_size; ///< The number of items in the stack.
const size_type CAPACITY; ///< The maximum number of items in the stack.
ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes.
};
//***************************************************************************

View File

@ -658,7 +658,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key_value_pair) value_type(key, T());
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
pbucket->insert_after(pbucket->before_begin(), node);
@ -788,7 +788,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key_value_pair) value_type(key_value_pair);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
// Just add the pointer to the bucket;
bucket.insert_after(bucket.before_begin(), node);
@ -822,7 +822,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key_value_pair) value_type(key_value_pair);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
// Add the node to the end of the bucket;
bucket.insert_after(inode_previous, node);
@ -892,7 +892,7 @@ namespace etl
icurrent->key_value_pair.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
n = 1;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
return n;
@ -921,7 +921,7 @@ namespace etl
bucket.erase_after(iprevious); // Unlink from the bucket.
icurrent->key_value_pair.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
return inext;
}
@ -956,7 +956,7 @@ namespace etl
local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket.
icurrent->key_value_pair.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
icurrent = inext;
@ -1224,7 +1224,7 @@ namespace etl
{
// Destroy the value contents.
it->key_value_pair.~value_type();
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
++it;
}
@ -1282,7 +1282,7 @@ namespace etl
key_equal key_equal_function;
/// For library debugging purposes only.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -677,7 +677,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key_value_pair) value_type(key_value_pair);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
// Just add the pointer to the bucket;
bucket.insert_after(bucket.before_begin(), node);
@ -707,7 +707,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key_value_pair) value_type(key_value_pair);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
// Add the node to the end of the bucket;
bucket.insert_after(inode_previous, node);
@ -770,7 +770,7 @@ namespace etl
pnodepool->release(&*icurrent); // Release it back to the pool.
++n;
icurrent = iprevious;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
else
{
@ -806,7 +806,7 @@ namespace etl
bucket.erase_after(iprevious); // Unlink from the bucket.
icurrent->key_value_pair.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
return inext;
}
@ -841,7 +841,7 @@ namespace etl
local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket.
icurrent->key_value_pair.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
icurrent = inext;
@ -1136,7 +1136,7 @@ namespace etl
// Destroy the value contents.
it->key_value_pair.~value_type();
++it;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
// Now it's safe to clear the bucket.
@ -1192,7 +1192,7 @@ namespace etl
key_equal key_equal_function;
/// For library debugging purposes only.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -669,7 +669,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key) value_type(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
// Just add the pointer to the bucket;
bucket.insert_after(bucket.before_begin(), node);
@ -700,7 +700,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key) value_type(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
// Add the node to the end of the bucket;
bucket.insert_after(inode_previous, node);
@ -764,7 +764,7 @@ namespace etl
pnodepool->release(&*icurrent); // Release it back to the pool.
++n;
icurrent = iprevious;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
else
{
@ -800,7 +800,7 @@ namespace etl
bucket.erase_after(iprevious); // Unlink from the bucket.
icurrent->key.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
return inext;
}
@ -835,7 +835,7 @@ namespace etl
local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket.
icurrent->key.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
icurrent = inext;
@ -1130,7 +1130,7 @@ namespace etl
// Destroy the value contents.
it->key.~value_type();
++it;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
// Now it's safe to clear the bucket.
@ -1186,7 +1186,7 @@ namespace etl
key_equal key_equal_function;
/// For library debugging purposes only.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -670,7 +670,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key) value_type(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
// Just add the pointer to the bucket;
bucket.insert_after(bucket.before_begin(), node);
@ -704,7 +704,7 @@ namespace etl
// Get a new node.
node_t& node = *pnodepool->allocate<node_t>();
::new (&node.key) value_type(key);
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
// Add the node to the end of the bucket;
bucket.insert_after(inode_previous, node);
@ -774,7 +774,7 @@ namespace etl
icurrent->key.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
n = 1;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
return n;
@ -803,7 +803,7 @@ namespace etl
bucket.erase_after(iprevious); // Unlink from the bucket.
icurrent->key.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
return inext;
}
@ -838,7 +838,7 @@ namespace etl
local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket.
icurrent->key.~value_type(); // Destroy the value.
pnodepool->release(&*icurrent); // Release it back to the pool.
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
icurrent = inext;
@ -1107,7 +1107,7 @@ namespace etl
// Destroy the value contents.
it->key.~value_type();
++it;
--construct_count;
ETL_DECREMENT_DEBUG_COUNT;
}
// Now it's safe to clear the bucket.
@ -1163,7 +1163,7 @@ namespace etl
key_equal key_equal_function;
/// For library debugging purposes only.
etl::debug_count construct_count;
ETL_DECLARE_DEBUG_COUNT;
//*************************************************************************
/// Destructor.

View File

@ -5,7 +5,7 @@ The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
https://www.etlcpp.com
Copyright(c) 2014 jwellbelove
@ -233,16 +233,12 @@ namespace etl
if (current_size < new_size)
{
etl::uninitialized_fill_n(p_end, delta, value);
#if defined(ETL_DEBUG)
construct_count += delta;
#endif
ETL_ADD_DEBUG_COUNT(delta);
}
else
{
etl::destroy_n(p_end - delta, delta);
#if defined(ETL_DEBUG)
construct_count -= delta;
#endif
ETL_SUBTRACT_DEBUG_COUNT(delta);
}
p_end = p_buffer + new_size;
@ -372,11 +368,8 @@ namespace etl
initialise();
#if defined(ETL_DEBUG)
p_end = etl::uninitialized_copy(first, last, p_buffer, construct_count);
#else
p_end = etl::uninitialized_copy(first, last, p_buffer);
#endif
ETL_ADD_DEBUG_COUNT(uint32_t(std::distance(first, last)));
}
//*********************************************************************
@ -391,11 +384,8 @@ namespace etl
initialise();
#if defined(ETL_DEBUG)
p_end = etl::uninitialized_fill_n(p_buffer, n, value, construct_count);
#else
p_end = etl::uninitialized_fill_n(p_buffer, n, value);
#endif
ETL_ADD_DEBUG_COUNT(uint32_t(n));
}
//*************************************************************************
@ -445,7 +435,7 @@ namespace etl
#endif
::new (p_end) T(value1);
++p_end;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -461,7 +451,7 @@ namespace etl
#endif
::new (p_end) T(value1, value2);
++p_end;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -477,7 +467,7 @@ namespace etl
#endif
::new (p_end) T(value1, value2, value3);
++p_end;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*********************************************************************
@ -493,7 +483,7 @@ namespace etl
#endif
::new (p_end) T(value1, value2, value3, value4);
++p_end;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
//*************************************************************************
@ -545,7 +535,7 @@ namespace etl
if (position == end())
{
p = p_end++;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
else
{
@ -573,7 +563,7 @@ namespace etl
if (position == end())
{
p = p_end++;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
else
{
@ -601,7 +591,7 @@ namespace etl
if (position == end())
{
p = p_end++;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
else
{
@ -629,7 +619,7 @@ namespace etl
if (position == end())
{
p = p_end++;
++construct_count;
ETL_INCREMENT_DEBUG_COUNT;
}
else
{
@ -680,31 +670,19 @@ namespace etl
size_t copy_new_n = construct_old_n;
size_t construct_new_n = insert_n - copy_new_n;
#if defined(ETL_DEBUG)
// Construct old.
etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old, construct_count);
// Copy old.
etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end);
// Construct new.
etl::uninitialized_fill_n(p_end, construct_new_n, value, construct_count);
// Copy new.
std::fill_n(p_buffer + insert_begin, copy_new_n, value);
#else
// Construct old.
etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old);
ETL_ADD_DEBUG_COUNT(construct_old_n);
// Copy old.
etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end);
// Construct new.
etl::uninitialized_fill_n(p_end, construct_new_n, value);
ETL_ADD_DEBUG_COUNT(construct_new_n);
// Copy new.
std::fill_n(p_buffer + insert_begin, copy_new_n, value);
#endif
p_end += n;
}
@ -749,31 +727,19 @@ namespace etl
size_t copy_new_n = construct_old_n;
size_t construct_new_n = insert_n - copy_new_n;
#if defined(ETL_DEBUG)
// Construct old.
etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old, construct_count);
// Copy old.
etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end);
// Construct new.
etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end, construct_count);
// Copy new.
etl::copy_n(first, copy_new_n, p_buffer + insert_begin);
#else
// Construct old.
etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old);
ETL_ADD_DEBUG_COUNT(construct_old_n);
// Copy old.
etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end);
// Construct new.
etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end);
ETL_ADD_DEBUG_COUNT(construct_new_n);
// Copy new.
etl::copy_n(first, copy_new_n, p_buffer + insert_begin);
#endif
p_end += count;
}
@ -811,11 +777,8 @@ namespace etl
size_t n_delete = std::distance(first, last);
// Destroy the elements left over at the end.
#if defined(ETL_DEBUG)
etl::destroy(p_end - n_delete, p_end, construct_count);
#else
etl::destroy(p_end - n_delete, p_end);
#endif
ETL_SUBTRACT_DEBUG_COUNT(n_delete);
p_end -= n_delete;
}
@ -895,11 +858,8 @@ namespace etl
//*********************************************************************
void initialise()
{
#if defined(ETL_DEBUG)
etl::destroy(p_buffer, p_end, construct_count);
#else
etl::destroy(p_buffer, p_end);
#endif
ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end)));
p_end = p_buffer;
}
@ -924,11 +884,9 @@ namespace etl
//*********************************************************************
inline void create_back()
{
#if defined(ETL_DEBUG)
etl::create_value_at(p_end, construct_count);
#else
etl::create_value_at(p_end);
#endif
ETL_INCREMENT_DEBUG_COUNT;
++p_end;
}
@ -937,11 +895,9 @@ namespace etl
//*********************************************************************
inline void create_back(parameter_t value)
{
#if defined(ETL_DEBUG)
etl::create_copy_at(p_end, value, construct_count);
#else
etl::create_copy_at(p_end, value);
#endif
ETL_INCREMENT_DEBUG_COUNT;
++p_end;
}
@ -952,11 +908,8 @@ namespace etl
{
--p_end;
#if defined(ETL_DEBUG)
etl::destroy_at(p_end, construct_count);
#else
etl::destroy_at(p_end);
#endif
ETL_DECREMENT_DEBUG_COUNT;
}
// Disable copy construction.

View File

@ -38,6 +38,7 @@ SOFTWARE.
#define ETL_IVECTOR_REPAIR_ENABLE
#define ETL_IDEQUE_REPAIR_ENABLE
#define ETL_IN_UNIT_TEST
#define ETL_DEBUG_COUNT
#define ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK
#define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK

View File

@ -45,6 +45,42 @@ SOFTWARE.
namespace
{
struct Data
{
Data(int a_, int b_ = 2, int c_ = 3, int d_ = 4)
: a(a_),
b(b_),
c(c_),
d(d_)
{
}
Data()
: a(0),
b(0),
c(0),
d(0)
{
}
int a;
int b;
int c;
int d;
};
bool operator ==(const Data& lhs, const Data& rhs)
{
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d);
}
std::ostream& operator <<(std::ostream& os, const Data& data)
{
os << data.a << " " << data.b << " " << data.c << " " << data.d;
return os;
}
SUITE(test_queue_mpmc_mutex)
{
//*************************************************************************
@ -371,7 +407,7 @@ namespace
std::thread t2(push_thread2);
std::thread t3(pop_thread1);
std::thread t4(pop_thread2);
start.store(true);
// Join the threads with the main thread

View File

@ -337,6 +337,7 @@
<ClInclude Include="..\..\include\etl\fsm.h" />
<ClInclude Include="..\..\include\etl\fsm_generator.h" />
<ClInclude Include="..\..\include\etl\largest_generator.h" />
<ClInclude Include="..\..\include\etl\memory_model.h" />
<ClInclude Include="..\..\include\etl\message.h" />
<ClInclude Include="..\..\include\etl\message_bus.h" />
<ClInclude Include="..\..\include\etl\message_timer.h" />

View File

@ -627,6 +627,9 @@
<ClInclude Include="..\..\include\etl\type_select_generator.h">
<Filter>ETL\Utilities\Generators</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\memory_model.h">
<Filter>ETL\Utilities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp">