Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
  • Loading branch information
jwellbelove committed Jul 24, 2022
2 parents eb3ae1e + e4cf390 commit c8a3f07
Show file tree
Hide file tree
Showing 35 changed files with 1,735 additions and 323 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ test/build-etl_initializer_list-GCC-Debug
test/etl_initializer_list/etl_initializer_list.vcxproj.filters
test/etl_initializer_list/build-make
test/vs-build
test/etl_error_handler/build-log_errors-GCC-Debug
test/etl_error_handler/build-exceptions_and_log_errors-GCC-Debug
test/etl_error_handler/build-exceptions-GCC-Debug
test/etl_error_handler/exceptions_and_log_errors/.vs
test/etl_error_handler/exceptions/build-make
test/etl_error_handler/log_errors/build-make
test/etl_error_handler/log_errors_and_exceptions/build-make
test/etl_error_handler/log_errors_and_exceptions/.vs
test/etl_error_handler/exceptions/build-make
test/etl_error_handler/log_errors/build-make
test/etl_error_handler/log_errors_and_exceptions/.vs
Expand Down
2 changes: 1 addition & 1 deletion arduino/library-arduino.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Embedded Template Library - Arduino",
"version": "20.31.2",
"version": "20.31.3",
"authors": {
"name": "John Wellbelove",
"email": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion arduino/library-arduino.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Embedded Template Library - Arduino
version=20.31.2
version=20.31.3
author= John Wellbelove <[email protected]>
maintainer=John Wellbelove <[email protected]>
license=MIT
Expand Down
57 changes: 31 additions & 26 deletions include/etl/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace etl
//*************************************************************************
size_type size() const
{
return (in >= out) ? in - out : BUFFER_SIZE - (out - in);
return (in >= out) ? in - out : buffer_size - (out - in);
}

//*************************************************************************
Expand All @@ -98,7 +98,7 @@ namespace etl
size_t i = in;

++i;
if (i == BUFFER_SIZE) ETL_UNLIKELY
if (i == buffer_size) ETL_UNLIKELY
{
i = 0U;
}
Expand All @@ -115,20 +115,20 @@ namespace etl
//*************************************************************************
size_type max_size() const
{
return BUFFER_SIZE - 1U;
return buffer_size - 1U;
}

//*************************************************************************
size_type capacity() const
{
return BUFFER_SIZE - 1U;
return buffer_size - 1U;
}

protected:

//*************************************************************************
circular_buffer_base(size_type BUFFER_SIZE_)
: BUFFER_SIZE(BUFFER_SIZE_)
circular_buffer_base(size_type buffer_size_)
: buffer_size(buffer_size_)
, in(0U)
, out(0U)
{
Expand All @@ -138,7 +138,7 @@ namespace etl
void increment_in()
{
++in;
if (in == BUFFER_SIZE) ETL_UNLIKELY
if (in == buffer_size) ETL_UNLIKELY
{
in = 0U;
}
Expand All @@ -148,13 +148,13 @@ namespace etl
void increment_out()
{
++out;
if (out == BUFFER_SIZE) ETL_UNLIKELY
if (out == buffer_size) ETL_UNLIKELY
{
out = 0U;
}
}

const size_type BUFFER_SIZE;
size_type buffer_size;
size_type in; ///< Index to the next write.
size_type out; ///< Index to the next read.
ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging.
Expand Down Expand Up @@ -230,7 +230,7 @@ namespace etl
//*************************************************************************
pointer operator ->() const
{
return picb->pbuffer[current];
return &picb->pbuffer[current];
}

//*************************************************************************
Expand All @@ -241,7 +241,7 @@ namespace etl
++current;

// Did we reach the end of the buffer?
if (current == picb->BUFFER_SIZE)
if (current == picb->buffer_size)
{
current = 0U;
}
Expand Down Expand Up @@ -269,7 +269,7 @@ namespace etl
// Are we at the end of the buffer?
if (current == 0U)
{
current = picb->BUFFER_SIZE - 1;
current = picb->buffer_size - 1;
}
else
{
Expand All @@ -296,8 +296,8 @@ namespace etl
//*************************************************************************
iterator& operator +=(int n)
{
current += size_type(picb->BUFFER_SIZE + n);
current %= picb->BUFFER_SIZE;
current += size_type(picb->buffer_size + n);
current %= picb->buffer_size;

return (*this);
}
Expand Down Expand Up @@ -407,7 +407,7 @@ namespace etl
{
if (index < firstIndex)
{
return picb->BUFFER_SIZE + current - firstIndex;
return picb->buffer_size + current - firstIndex;
}
else
{
Expand Down Expand Up @@ -501,7 +501,7 @@ namespace etl
//*************************************************************************
const_pointer operator ->() const
{
return picb->pbuffer[current];
return &(picb->pbuffer[current]);
}

//*************************************************************************
Expand All @@ -512,7 +512,7 @@ namespace etl
++current;

// Did we reach the end of the buffer?
if (current == picb->BUFFER_SIZE)
if (current == picb->buffer_size)
{
current = 0U;
}
Expand Down Expand Up @@ -540,7 +540,7 @@ namespace etl
// Are we at the end of the buffer?
if (current == 0U)
{
current = picb->BUFFER_SIZE - 1;
current = picb->buffer_size - 1;
}
else
{
Expand All @@ -567,8 +567,8 @@ namespace etl
//*************************************************************************
const_iterator& operator +=(int n)
{
current += size_type(picb->BUFFER_SIZE + n);
current %= picb->BUFFER_SIZE;
current += size_type(picb->buffer_size + n);
current %= picb->buffer_size;

return (*this);
}
Expand Down Expand Up @@ -820,7 +820,7 @@ namespace etl
{
ETL_ASSERT(!empty(), ETL_ERROR(circular_buffer_empty));

return pbuffer[in == 0U ? BUFFER_SIZE - 1 : in - 1U];
return pbuffer[in == 0U ? buffer_size - 1 : in - 1U];
}

//*************************************************************************
Expand All @@ -831,15 +831,15 @@ namespace etl
{
ETL_ASSERT(!empty(), ETL_ERROR(circular_buffer_empty));

return pbuffer[in == 0U ? BUFFER_SIZE - 1 : in - 1U];
return pbuffer[in == 0U ? buffer_size - 1 : in - 1U];
}

//*************************************************************************
/// Get a reference to the item.
//*************************************************************************
reference operator [](size_t index)
{
return pbuffer[(out + index) % BUFFER_SIZE];
return pbuffer[(out + index) % buffer_size];
}

//*************************************************************************
Expand All @@ -848,7 +848,7 @@ namespace etl
//*************************************************************************
const_reference operator [](size_t index) const
{
return pbuffer[(out + index) % BUFFER_SIZE];
return pbuffer[(out + index) % buffer_size];
}

//*************************************************************************
Expand Down Expand Up @@ -1025,7 +1025,7 @@ namespace etl
{
const difference_type index = other.get_index();
const difference_type reference_index = other.container().out;
const size_t buffer_size = other.container().BUFFER_SIZE;
const size_t buffer_size = other.container().buffer_size;

if (index < reference_index)
{
Expand Down Expand Up @@ -1294,13 +1294,18 @@ namespace etl
//*************************************************************************
/// Swap with another circular buffer
//*************************************************************************
void swap(circular_buffer_ext& other)
void swap(circular_buffer_ext& other) ETL_NOEXCEPT
{
using ETL_OR_STD::swap; // Allow ADL

swap(this->in, other.in);
swap(this->out, other.out);
swap(this->pbuffer, other.pbuffer);
swap(this->buffer_size, other.buffer_size);

#if defined(ETL_DEBUG_COUNT)
this->etl_debug_count.swap(other.etl_debug_count);
#endif
}

//*************************************************************************
Expand Down
Loading

0 comments on commit c8a3f07

Please sign in to comment.