Skip to content

Commit ce9b774

Browse files
XiaoP76MarshMilo100Zach Van Campjwellbelove
authored
Fixed compilation errors in algorithm.h in C++03 and compiler warning… (#1080)
* Add Zephyr build system module.yml (#1074) The Zephyr build system requires that modules have a `module.yml` file to specify where the module cmake and kconfig files are located. These can also be explicitly set as "external" meaning that they do not exist within the module tree, itself. These build file can still be specified elsewhere via cmake variables, explained more in-depth here: https://docs.zephyrproject.org/latest/develop/modules.html#modules-module-ext-root This change makes it such that ETL can be included more easily in zephyr projects running on embedded systems. A similar change can be observed in the public nanopb repository, where the repo only requires its own `zephyr/module.yml` file to be found by the zephyr build system, but the kconfig and cmake additions can exist outside of the library repository. * Add full West support for ETL (#1075) This will allow ETL to be included via west in a zephyr build without any additional wrappers or external kconfigs. Signed-off-by: Zach Van Camp <[email protected]> Co-authored-by: Zach Van Camp <[email protected]> * Fixed compilation errors in algorithm.h in C++03 and compiler warnings in gcc older than 4.6 --------- Signed-off-by: Zach Van Camp <[email protected]> Co-authored-by: Zach Van Camp <[email protected]> Co-authored-by: Zach Van Camp <[email protected]> Co-authored-by: John Wellbelove <[email protected]>
1 parent 270cb33 commit ce9b774

13 files changed

+45
-33
lines changed

include/etl/algorithm.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -953,12 +953,12 @@ namespace etl
953953

954954
while ((value_index > top_index) && compare(first[parent], value))
955955
{
956-
first[value_index] = etl::move(first[parent]);
956+
first[value_index] = ETL_MOVE(first[parent]);
957957
value_index = parent;
958958
parent = (value_index - 1) / 2;
959959
}
960960

961-
first[value_index] = etl::move(value);
961+
first[value_index] = ETL_MOVE(value);
962962
}
963963

964964
// Adjust Heap Helper
@@ -975,18 +975,18 @@ namespace etl
975975
--child2nd;
976976
}
977977

978-
first[value_index] = etl::move(first[child2nd]);
978+
first[value_index] = ETL_MOVE(first[child2nd]);
979979
value_index = child2nd;
980980
child2nd = 2 * (child2nd + 1);
981981
}
982982

983983
if (child2nd == length)
984984
{
985-
first[value_index] = etl::move(first[child2nd - 1]);
985+
first[value_index] = ETL_MOVE(first[child2nd - 1]);
986986
value_index = child2nd - 1;
987987
}
988988

989-
push_heap(first, value_index, top_index, etl::move(value), compare);
989+
push_heap(first, value_index, top_index, ETL_MOVE(value), compare);
990990
}
991991

992992
// Is Heap Helper
@@ -1019,10 +1019,10 @@ namespace etl
10191019
typedef typename etl::iterator_traits<TIterator>::value_type value_t;
10201020
typedef typename etl::iterator_traits<TIterator>::difference_type distance_t;
10211021

1022-
value_t value = etl::move(last[-1]);
1023-
last[-1] = etl::move(first[0]);
1022+
value_t value = ETL_MOVE(last[-1]);
1023+
last[-1] = ETL_MOVE(first[0]);
10241024

1025-
private_heap::adjust_heap(first, distance_t(0), distance_t(last - first - 1), etl::move(value), compare);
1025+
private_heap::adjust_heap(first, distance_t(0), distance_t(last - first - 1), ETL_MOVE(value), compare);
10261026
}
10271027

10281028
// Pop Heap
@@ -1041,7 +1041,7 @@ namespace etl
10411041
typedef typename etl::iterator_traits<TIterator>::difference_type difference_t;
10421042
typedef typename etl::iterator_traits<TIterator>::value_type value_t;
10431043

1044-
private_heap::push_heap(first, difference_t(last - first - 1), difference_t(0), value_t(etl::move(*(last - 1))), compare);
1044+
private_heap::push_heap(first, difference_t(last - first - 1), difference_t(0), value_t(ETL_MOVE(*(last - 1))), compare);
10451045
}
10461046

10471047
// Push Heap
@@ -1069,7 +1069,7 @@ namespace etl
10691069

10701070
while (true)
10711071
{
1072-
private_heap::adjust_heap(first, parent, length, etl::move(*(first + parent)), compare);
1072+
private_heap::adjust_heap(first, parent, length, ETL_MOVE(*(first + parent)), compare);
10731073

10741074
if (parent == 0)
10751075
{
@@ -1206,7 +1206,7 @@ namespace etl
12061206

12071207
for (int i = 0; i < gcd_nm; i++)
12081208
{
1209-
value_type temp = etl::move(*(first + i));
1209+
value_type temp = ETL_MOVE(*(first + i));
12101210
int j = i;
12111211

12121212
while (true)
@@ -1223,11 +1223,11 @@ namespace etl
12231223
break;
12241224
}
12251225

1226-
*(first + j) = etl::move(*(first + k));
1226+
*(first + j) = ETL_MOVE(*(first + k));
12271227
j = k;
12281228
}
12291229

1230-
*(first + j) = etl::move(temp);
1230+
*(first + j) = ETL_MOVE(temp);
12311231
}
12321232

12331233
return result;
@@ -1348,13 +1348,13 @@ namespace etl
13481348
typedef typename etl::iterator_traits<TIterator>::value_type value_type;
13491349

13501350
// Save the first item.
1351-
value_type temp(etl::move(*first));
1351+
value_type temp(ETL_MOVE(*first));
13521352

13531353
// Move the rest.
13541354
TIterator result = etl::move(etl::next(first), last, first);
13551355

13561356
// Restore the first item in its rotated position.
1357-
*result = etl::move(temp);
1357+
*result = ETL_MOVE(temp);
13581358

13591359
// The new position of the first item.
13601360
return result;
@@ -1370,13 +1370,13 @@ namespace etl
13701370

13711371
// Save the last item.
13721372
TIterator previous = etl::prev(last);
1373-
value_type temp(etl::move(*previous));
1373+
value_type temp(ETL_MOVE(*previous));
13741374

13751375
// Move the rest.
13761376
TIterator result = etl::move_backward(first, previous, last);
13771377

13781378
// Restore the last item in its rotated position.
1379-
*first = etl::move(temp);
1379+
*first = ETL_MOVE(temp);
13801380

13811381
// The new position of the first item.
13821382
return result;
@@ -2151,7 +2151,7 @@ namespace etl
21512151
{
21522152
while (first != last)
21532153
{
2154-
sum = etl::move(sum) + *first;
2154+
sum = ETL_MOVE(sum) + *first;
21552155
++first;
21562156
}
21572157

@@ -2168,7 +2168,7 @@ namespace etl
21682168
{
21692169
while (first != last)
21702170
{
2171-
sum = operation(etl::move(sum), *first);
2171+
sum = operation(ETL_MOVE(sum), *first);
21722172
++first;
21732173
}
21742174

@@ -2225,7 +2225,7 @@ namespace etl
22252225
{
22262226
if (!(*itr == value))
22272227
{
2228-
*first++ = etl::move(*itr);
2228+
*first++ = ETL_MOVE(*itr);
22292229
}
22302230
}
22312231
}
@@ -2251,7 +2251,7 @@ namespace etl
22512251
{
22522252
if (!predicate(*itr))
22532253
{
2254-
*first++ = etl::move(*itr);
2254+
*first++ = ETL_MOVE(*itr);
22552255
}
22562256
}
22572257
}

include/etl/private/diagnostic_array_bounds_push.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic push
3839
#pragma GCC diagnostic ignored "-Warray-bounds"
3940
#endif

include/etl/private/diagnostic_deprecated_push.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic push
3839
#pragma GCC diagnostic ignored "-Wdeprecated"
3940
#endif

include/etl/private/diagnostic_float_equal_push.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic push
3839
#pragma GCC diagnostic ignored "-Wfloat-equal"
3940
#endif

include/etl/private/diagnostic_null_dereference_push.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic push
3839
#pragma GCC diagnostic ignored "-Wnull-dereference"
3940
#endif

include/etl/private/diagnostic_pessimizing_move_push.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic push
3839
#pragma GCC diagnostic ignored "-Wpessimizing-move"
3940
#endif

include/etl/private/diagnostic_pop.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic pop
3839
#endif
3940

include/etl/private/diagnostic_self_assign_overloaded_push.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic push
3839
#endif
3940

include/etl/private/diagnostic_uninitialized_push.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic push
3839
#pragma GCC diagnostic ignored "-Wuninitialized"
3940
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

include/etl/private/diagnostic_unused_function_push.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SOFTWARE.
3333
* This file is intended to evaluated multiple times by design.
3434
*/
3535

36-
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__)
36+
#if defined(__GNUC__) && !defined(__clang__) && !defined(__llvm__) && \
37+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
3738
#pragma GCC diagnostic push
3839
#pragma GCC diagnostic ignored "-Wunused-function"
3940
#endif

0 commit comments

Comments
 (0)