Skip to content

Commit

Permalink
Sync to 20.27.2
Browse files Browse the repository at this point in the history
  • Loading branch information
John Wellbelove committed Apr 9, 2022
1 parent 1ce9246 commit 1837320
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 41 deletions.
20 changes: 19 additions & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Embedded Template Library - Arduino",
"version": "20.27.1",
"version": "20.27.2",
"authors": {
"name": "John Wellbelove",
"email": "[email protected]"
Expand All @@ -16,6 +16,24 @@
"build": {
"includeDir": "include"
},
"export": {
"include": [
"include",
"examples",
"LICENSE",
"README.md"
],
"exclude": [
"include/etl/experimental",
"include/etl/deprecated",
"**/__vm",
"**/.vs",
"**/*.filters",
"**/*.log",
"**/*.tmp"
]
},
"platforms": "*",
"frameworks": "*"
}

2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Embedded Template Library - Arduino
version=20.27.1
version=20.27.2
author= John Wellbelove <[email protected]>
maintainer=John Wellbelove <[email protected]>
license=MIT
Expand Down
5 changes: 3 additions & 2 deletions src/etl/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ namespace etl
typename etl::enable_if<etl::is_pointer<TIterator>::value, void>::type
reverse(TIterator b, TIterator e)
{
typedef typename etl::iterator_traits<TIterator>::value_type value_type;

if (b != e)
{
while (b < --e)
Expand Down Expand Up @@ -1217,6 +1215,7 @@ namespace etl
TCompare compare)
{
TIterator minimum = begin;
++begin;

while (begin != end)
{
Expand Down Expand Up @@ -1260,6 +1259,7 @@ namespace etl
TCompare compare)
{
TIterator maximum = begin;
++begin;

while (begin != end)
{
Expand Down Expand Up @@ -1304,6 +1304,7 @@ namespace etl
{
TIterator minimum = begin;
TIterator maximum = begin;
++begin;

while (begin != end)
{
Expand Down
2 changes: 1 addition & 1 deletion src/etl/char_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SOFTWARE.
//*****************************************************************************

// Define the large character types if necessary.
#if (ETL_NO_LARGE_CHAR_SUPPORT)
#if ETL_NO_LARGE_CHAR_SUPPORT
#if ETL_USING_8BIT_TYPES
typedef int8_t char8_t;
#endif
Expand Down
42 changes: 36 additions & 6 deletions src/etl/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ namespace etl
//*************************************************************************
bool full() const
{
return (in + 1U) % BUFFER_SIZE == out;
size_t i = in;

++i;
if (i == BUFFER_SIZE) ETL_UNLIKELY
{
i = 0U;
}

return i == out;
}

//*************************************************************************
Expand Down Expand Up @@ -126,6 +134,26 @@ namespace etl
{
}

//*************************************************************************
void increment_in()
{
++in;
if (in == BUFFER_SIZE) ETL_UNLIKELY
{
in = 0U;
}
}

//*************************************************************************
void increment_out()
{
++out;
if (out == BUFFER_SIZE) ETL_UNLIKELY
{
out = 0U;
}
}

const size_type BUFFER_SIZE;
size_type in; ///< Index to the next write.
size_type out; ///< Index to the next read.
Expand Down Expand Up @@ -835,14 +863,14 @@ namespace etl
void push(const_reference item)
{
::new (&pbuffer[in]) T(item);
in = (in + 1U) % BUFFER_SIZE;
increment_in();

// Did we catch up with the 'out' index?
if (in == out)
{
// Forget about the oldest one.
pbuffer[out].~T();
out = (out + 1U) % BUFFER_SIZE;
this->increment_out();
}
else
{
Expand All @@ -859,14 +887,14 @@ namespace etl
void push(rvalue_reference item)
{
::new (&pbuffer[in]) T(etl::move(item));
in = (in + 1U) % BUFFER_SIZE;
increment_in();

// Did we catch up with the 'out' index?
if (in == out)
{
// Forget about the oldest item.
pbuffer[out].~T();
out = (out + 1U) % BUFFER_SIZE;
increment_out();
}
else
{
Expand Down Expand Up @@ -895,7 +923,7 @@ namespace etl
{
ETL_ASSERT(!empty(), ETL_ERROR(circular_buffer_empty));
pbuffer[out].~T();
out = (out + 1U) % BUFFER_SIZE;
increment_out();
ETL_DECREMENT_DEBUG_COUNT
}

Expand Down Expand Up @@ -1013,6 +1041,8 @@ namespace etl
}
}



pointer pbuffer;

private:
Expand Down
4 changes: 2 additions & 2 deletions src/etl/cyclic_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace etl
//*************************************************************************
cyclic_value& operator ++()
{
if (value >= LAST)
if (value >= LAST) ETL_UNLIKELY
{
value = FIRST;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ namespace etl
//*************************************************************************
cyclic_value& operator --()
{
if (value <= FIRST)
if (value <= FIRST) ETL_UNLIKELY
{
value = LAST;
}
Expand Down
26 changes: 7 additions & 19 deletions src/etl/nth_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,16 @@ SOFTWARE.
namespace etl
{
#if ETL_USING_CPP11
//***************************************************************************
// nth_type
//***************************************************************************
namespace private_nth_type
template <size_t N, typename T1, typename... TRest>
struct nth_type
{
template <size_t N, typename T1, typename... TRest>
struct nth_type_helper
{
using type = typename nth_type_helper<N - 1U, TRest...>::type;
};

template <size_t N, typename T1>
struct nth_type_helper<N, T1>
{
using type = T1;
};
}
using type = typename nth_type<N - 1U, TRest...>::type;
};

template <size_t N, typename... TTypes>
struct nth_type
template <typename T1, typename... TRest>
struct nth_type<0U, T1, TRest...>
{
using type = typename private_nth_type::nth_type_helper<N, TTypes...>::type;
using type = T1;
};

template <size_t N, typename... TTypes>
Expand Down
2 changes: 1 addition & 1 deletion src/etl/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ namespace etl
static ETL_CONSTANT bool has_mutable_array_view = (ETL_HAS_MUTABLE_ARRAY_VIEW == 1);
static ETL_CONSTANT bool has_ideque_repair = (ETL_HAS_IDEQUE_REPAIR == 1);
static ETL_CONSTANT bool is_debug_build = (ETL_IS_DEBUG_BUILD == 1);
static ETL_CONSTANT int cplusplus = __cplusplus;
static ETL_CONSTANT long cplusplus = __cplusplus;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/etl/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ namespace etl
//*************************************************************************
void add_in()
{
if (++in == CAPACITY)
if (++in == CAPACITY) ETL_UNLIKELY
{
in = 0;
}
Expand All @@ -201,7 +201,7 @@ namespace etl
//*************************************************************************
void del_out()
{
if (++out == CAPACITY)
if (++out == CAPACITY) ETL_UNLIKELY
{
out = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/etl/queue_lockable.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ namespace etl
{
++index;

if (index == maximum)
if (index == maximum) ETL_UNLIKELY
{
index = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/etl/queue_mpmc_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace etl
{
++index;

if (index == maximum)
if (index == maximum) ETL_UNLIKELY
{
index = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/etl/queue_spsc_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace etl
{
++index;

if (index == maximum)
if (index == maximum) ETL_UNLIKELY
{
index = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/etl/queue_spsc_isr.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ namespace etl
{
++index;

if (index == maximum)
if (index == maximum) ETL_UNLIKELY
{
index = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/etl/queue_spsc_locked.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace etl
{
++index;

if (index == maximum)
if (index == maximum) ETL_UNLIKELY
{
index = 0;
}
Expand Down
25 changes: 24 additions & 1 deletion src/etl/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ SOFTWARE.
#ifndef ETL_VERSION_INCLUDED
#define ETL_VERSION_INCLUDED

#include "platform.h"
#include "macros.h"

///\defgroup version version
Expand All @@ -39,12 +40,34 @@ SOFTWARE.

#define ETL_VERSION_MAJOR 20
#define ETL_VERSION_MINOR 27
#define ETL_VERSION_PATCH 1
#define ETL_VERSION_PATCH 2


#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_U32 ETL_STRINGIFY(ETL_VERSION_MAJOR) U"." ETL_STRINGIFY(ETL_VERSION_MINOR) U"." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_VALUE ((ETL_VERSION_MAJOR * 10000) + (ETL_VERSION_MINOR * 100) + ETL_VERSION_PATCH)

namespace etl
{
namespace traits
{
static ETL_CONSTANT long version = ETL_VERSION_VALUE;
static ETL_CONSTANT long version_major = ETL_VERSION_MAJOR;
static ETL_CONSTANT long version_minor = ETL_VERSION_MINOR;
static ETL_CONSTANT long version_patch = ETL_VERSION_PATCH;
#if ETL_USING_CPP11
static constexpr const char* version_string = ETL_VERSION;
static constexpr const wchar_t* version_wstring = ETL_VERSION_W;
static constexpr const char16_t* version_u16string = ETL_VERSION_U16;
static constexpr const char32_t* version_u32string = ETL_VERSION_U32;
#else
static const char* version_string = ETL_VERSION;
static const wchar_t* version_wstring = ETL_VERSION_W;
#endif
}
}

#endif

0 comments on commit 1837320

Please sign in to comment.