Skip to content

Commit 96b733e

Browse files
author
John Wellbelove
committed
Sync with 20.39.5
1 parent 97d1ba9 commit 96b733e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5071
-1202
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Embedded Template Library ETL",
3-
"version": "20.39.4",
3+
"version": "20.39.5",
44
"authors": {
55
"name": "John Wellbelove",
66
"email": "[email protected]"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Embedded Template Library ETL
2-
version=20.39.4
2+
version=20.39.5
33
author= John Wellbelove <[email protected]>
44
maintainer=John Wellbelove <[email protected]>
55
license=MIT

src/etl/algorithm.h

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,16 +1449,20 @@ namespace etl
14491449
TCompare compare)
14501450
{
14511451
TIterator minimum = begin;
1452-
++begin;
14531452

1454-
while (begin != end)
1453+
if (begin != end)
14551454
{
1456-
if (compare(*begin, *minimum))
1455+
++begin;
1456+
1457+
while (begin != end)
14571458
{
1458-
minimum = begin;
1459-
}
1459+
if (compare(*begin, *minimum))
1460+
{
1461+
minimum = begin;
1462+
}
14601463

1461-
++begin;
1464+
++begin;
1465+
}
14621466
}
14631467

14641468
return minimum;
@@ -1493,16 +1497,20 @@ namespace etl
14931497
TCompare compare)
14941498
{
14951499
TIterator maximum = begin;
1496-
++begin;
14971500

1498-
while (begin != end)
1501+
if (begin != end)
14991502
{
1500-
if (!compare(*begin, *maximum))
1503+
++begin;
1504+
1505+
while (begin != end)
15011506
{
1502-
maximum = begin;
1503-
}
1507+
if (!compare(*begin, *maximum))
1508+
{
1509+
maximum = begin;
1510+
}
15041511

1505-
++begin;
1512+
++begin;
1513+
}
15061514
}
15071515

15081516
return maximum;
@@ -1538,21 +1546,25 @@ namespace etl
15381546
{
15391547
TIterator minimum = begin;
15401548
TIterator maximum = begin;
1541-
++begin;
15421549

1543-
while (begin != end)
1550+
if (begin != end)
15441551
{
1545-
if (compare(*begin, *minimum))
1546-
{
1547-
minimum = begin;
1548-
}
1552+
++begin;
15491553

1550-
if (compare(*maximum, *begin))
1554+
while (begin != end)
15511555
{
1552-
maximum = begin;
1553-
}
1556+
if (compare(*begin, *minimum))
1557+
{
1558+
minimum = begin;
1559+
}
15541560

1555-
++begin;
1561+
if (compare(*maximum, *begin))
1562+
{
1563+
maximum = begin;
1564+
}
1565+
1566+
++begin;
1567+
}
15561568
}
15571569

15581570
return ETL_OR_STD::pair<TIterator, TIterator>(minimum, maximum);

src/etl/array_view.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,19 @@ namespace etl
239239
//*************************************************************************
240240
template <typename TIterator>
241241
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_)
242-
: mbegin(etl::addressof(*begin_)),
243-
mend(etl::addressof(*begin_) + etl::distance(begin_, end_))
242+
: mbegin(etl::to_address(begin_)),
243+
mend(etl::to_address(begin_) + etl::distance(begin_, end_))
244244
{
245245
}
246246

247247
//*************************************************************************
248-
/// Construct from C array
248+
/// Construct from iterator and size
249249
//*************************************************************************
250250
template <typename TIterator,
251251
typename TSize>
252252
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_)
253-
: mbegin(etl::addressof(*begin_)),
254-
mend(etl::addressof(*begin_) + size_)
253+
: mbegin(etl::to_address(begin_)),
254+
mend(etl::to_address(begin_) + size_)
255255
{
256256
}
257257

@@ -458,8 +458,8 @@ namespace etl
458458
template <typename TIterator>
459459
void assign(const TIterator begin_, const TIterator end_)
460460
{
461-
mbegin = etl::addressof(*begin_);
462-
mend = etl::addressof(*begin_) + etl::distance(begin_, end_);
461+
mbegin = etl::to_address(begin_);
462+
mend = etl::to_address(begin_) + etl::distance(begin_, end_);
463463
}
464464

465465
//*************************************************************************
@@ -469,8 +469,8 @@ namespace etl
469469
typename TSize>
470470
void assign(const TIterator begin_, const TSize size_)
471471
{
472-
mbegin = etl::addressof(*begin_);
473-
mend = etl::addressof(*begin_) + size_;
472+
mbegin = etl::to_address(begin_);
473+
mend = etl::to_address(begin_) + size_;
474474
}
475475

476476
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)

src/etl/atomic/atomic_gcc_sync.h

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,30 @@ namespace etl
8383
// Only integral and pointer types are supported.
8484
//***************************************************************************
8585

86-
enum memory_order
86+
typedef enum memory_order
8787
{
8888
memory_order_relaxed = __ATOMIC_RELAXED,
8989
memory_order_consume = __ATOMIC_CONSUME,
9090
memory_order_acquire = __ATOMIC_ACQUIRE,
9191
memory_order_release = __ATOMIC_RELEASE,
9292
memory_order_acq_rel = __ATOMIC_ACQ_REL,
9393
memory_order_seq_cst = __ATOMIC_SEQ_CST
94+
} memory_order;
95+
96+
template <bool Is_Always_Lock_Free>
97+
struct atomic_traits
98+
{
99+
static ETL_CONSTANT bool is_always_lock_free = Is_Always_Lock_Free;
94100
};
95101

102+
template <bool Is_Always_Lock_Free>
103+
ETL_CONSTANT bool atomic_traits<Is_Always_Lock_Free>::is_always_lock_free;
104+
96105
//***************************************************************************
97106
/// For all types except bool, pointers and types that are always lock free.
98107
//***************************************************************************
99108
template <typename T, bool integral_type = etl::is_integral<T>::value>
100-
class atomic
109+
class atomic : public atomic_traits<integral_type>
101110
{
102111
public:
103112

@@ -389,7 +398,7 @@ namespace etl
389398
/// Specialisation for pointers
390399
//***************************************************************************
391400
template <typename T>
392-
class atomic<T*, false>
401+
class atomic<T*, false> : public atomic_traits<true>
393402
{
394403
public:
395404

@@ -631,7 +640,7 @@ namespace etl
631640
/// Specialisation for bool
632641
//***************************************************************************
633642
template <>
634-
class atomic<bool, true>
643+
class atomic<bool, true> : public atomic_traits<true>
635644
{
636645
public:
637646

@@ -794,7 +803,7 @@ namespace etl
794803
/// Uses a mutex to control access.
795804
//***************************************************************************
796805
template <typename T>
797-
class atomic<T, false>
806+
class atomic<T, false> : public atomic_traits<false>
798807
{
799808
public:
800809

@@ -1030,11 +1039,20 @@ namespace etl
10301039
memory_order_seq_cst
10311040
} memory_order;
10321041

1042+
template <bool Is_Always_Lock_Free>
1043+
struct atomic_traits
1044+
{
1045+
static ETL_CONSTANT bool is_always_lock_free = Is_Always_Lock_Free;
1046+
};
1047+
1048+
template <bool Is_Always_Lock_Free>
1049+
ETL_CONSTANT bool atomic_traits<Is_Always_Lock_Free>::is_always_lock_free;
1050+
10331051
//***************************************************************************
10341052
/// For all types except bool and pointers
10351053
//***************************************************************************
10361054
template <typename T, bool integral_type = etl::is_integral<T>::value>
1037-
class atomic
1055+
class atomic : public atomic_traits<integral_type>
10381056
{
10391057
public:
10401058

@@ -1440,7 +1458,7 @@ namespace etl
14401458
/// Specialisation for pointers
14411459
//***************************************************************************
14421460
template <typename T>
1443-
class atomic<T*, false>
1461+
class atomic<T*, false> : public atomic_traits<true>
14441462
{
14451463
public:
14461464

@@ -1750,7 +1768,7 @@ namespace etl
17501768
/// Specialisation for bool
17511769
//***************************************************************************
17521770
template <>
1753-
class atomic<bool, true>
1771+
class atomic<bool, true> : public atomic_traits<true>
17541772
{
17551773
public:
17561774

@@ -1973,7 +1991,7 @@ namespace etl
19731991
/// Uses a mutex to control access.
19741992
//***************************************************************************
19751993
template <typename T>
1976-
class atomic<T, false>
1994+
class atomic<T, false> : public atomic_traits<false>
19771995
{
19781996
public:
19791997

@@ -2234,3 +2252,4 @@ namespace etl
22342252
}
22352253

22362254
#endif
2255+

0 commit comments

Comments
 (0)