From 0db43b64890cbce12d269ad0d689f3d48796e9e5 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 4 May 2014 21:22:18 +0400 Subject: [PATCH] Partially removed all references to STL's algorithm. is not included anywhere, though still used in several places which still alows the code to compile as is being pulled in from some other standard headers. --- libuavcan/include/uavcan/data_type.hpp | 1 - libuavcan/include/uavcan/driver/can.hpp | 1 - libuavcan/include/uavcan/dynamic_memory.hpp | 13 +++++++++---- libuavcan/include/uavcan/marshal/array.hpp | 1 - .../uavcan/node/global_data_type_registry.hpp | 1 - libuavcan/include/uavcan/time.hpp | 1 - libuavcan/include/uavcan/transport/frame.hpp | 1 - .../include/uavcan/transport/transfer_buffer.hpp | 1 - .../include/uavcan/transport/transfer_listener.hpp | 1 - libuavcan/src/marshal/uc_float_spec.cpp | 2 +- libuavcan/src/protocol/uc_node_status_monitor.cpp | 1 - libuavcan/src/transport/uc_can_io.cpp | 1 - libuavcan/src/transport/uc_transfer_receiver.cpp | 1 - 13 files changed, 10 insertions(+), 16 deletions(-) diff --git a/libuavcan/include/uavcan/data_type.hpp b/libuavcan/include/uavcan/data_type.hpp index 700bd8806f..0e437e0669 100644 --- a/libuavcan/include/uavcan/data_type.hpp +++ b/libuavcan/include/uavcan/data_type.hpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include diff --git a/libuavcan/include/uavcan/driver/can.hpp b/libuavcan/include/uavcan/driver/can.hpp index ce339b8306..9ab7ed517d 100644 --- a/libuavcan/include/uavcan/driver/can.hpp +++ b/libuavcan/include/uavcan/driver/can.hpp @@ -6,7 +6,6 @@ #pragma once #include -#include #include #include #include diff --git a/libuavcan/include/uavcan/dynamic_memory.hpp b/libuavcan/include/uavcan/dynamic_memory.hpp index 2009edaa45..63ddc1c7d2 100644 --- a/libuavcan/include/uavcan/dynamic_memory.hpp +++ b/libuavcan/include/uavcan/dynamic_memory.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -38,11 +37,17 @@ class UAVCAN_EXPORT PoolManager : public IPoolAllocator, Noncopyable { IPoolAllocator* pools_[MaxPools]; - static bool sortComparePoolAllocators(const IPoolAllocator* a, const IPoolAllocator* b) + static int qsortComparePoolAllocators(const void* raw_a, const void* raw_b) { + const IPoolAllocator* const a = *static_cast(raw_a); + const IPoolAllocator* const b = *static_cast(raw_b); const std::size_t a_size = a ? a->getBlockSize() : std::numeric_limits::max(); const std::size_t b_size = b ? b->getBlockSize() : std::numeric_limits::max(); - return a_size < b_size; + if (a_size != b_size) + { + return (a_size > b_size) ? 1 : -1; + } + return 0; } public: @@ -144,7 +149,7 @@ bool PoolManager::addPool(IPoolAllocator* pool) } } // We need to keep the pools in order, so that smallest blocks go first - std::sort(pools_, pools_ + MaxPools, &PoolManager::sortComparePoolAllocators); + std::qsort(pools_, MaxPools, sizeof(IPoolAllocator*), &PoolManager::qsortComparePoolAllocators); return retval; } diff --git a/libuavcan/include/uavcan/marshal/array.hpp b/libuavcan/include/uavcan/marshal/array.hpp index 399759de36..b9178cc59e 100644 --- a/libuavcan/include/uavcan/marshal/array.hpp +++ b/libuavcan/include/uavcan/marshal/array.hpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include diff --git a/libuavcan/include/uavcan/node/global_data_type_registry.hpp b/libuavcan/include/uavcan/node/global_data_type_registry.hpp index d18785690b..5e4e4d90f4 100644 --- a/libuavcan/include/uavcan/node/global_data_type_registry.hpp +++ b/libuavcan/include/uavcan/node/global_data_type_registry.hpp @@ -5,7 +5,6 @@ #pragma once #include -#include #include #include #include diff --git a/libuavcan/include/uavcan/time.hpp b/libuavcan/include/uavcan/time.hpp index 12c409a69c..4de173ce85 100644 --- a/libuavcan/include/uavcan/time.hpp +++ b/libuavcan/include/uavcan/time.hpp @@ -4,7 +4,6 @@ #pragma once -#include #include #include #include diff --git a/libuavcan/include/uavcan/transport/frame.hpp b/libuavcan/include/uavcan/transport/frame.hpp index bd569766d1..026502fcf1 100644 --- a/libuavcan/include/uavcan/transport/frame.hpp +++ b/libuavcan/include/uavcan/transport/frame.hpp @@ -5,7 +5,6 @@ #pragma once #include -#include #include #include #include diff --git a/libuavcan/include/uavcan/transport/transfer_buffer.hpp b/libuavcan/include/uavcan/transport/transfer_buffer.hpp index 033b9eb72e..4835d67350 100644 --- a/libuavcan/include/uavcan/transport/transfer_buffer.hpp +++ b/libuavcan/include/uavcan/transport/transfer_buffer.hpp @@ -4,7 +4,6 @@ #pragma once -#include #include #include #include diff --git a/libuavcan/include/uavcan/transport/transfer_listener.hpp b/libuavcan/include/uavcan/transport/transfer_listener.hpp index 783b52792d..78e5b00deb 100644 --- a/libuavcan/include/uavcan/transport/transfer_listener.hpp +++ b/libuavcan/include/uavcan/transport/transfer_listener.hpp @@ -5,7 +5,6 @@ #pragma once #include -#include #include #include #include diff --git a/libuavcan/src/marshal/uc_float_spec.cpp b/libuavcan/src/marshal/uc_float_spec.cpp index be51793d7a..8aad065401 100644 --- a/libuavcan/src/marshal/uc_float_spec.cpp +++ b/libuavcan/src/marshal/uc_float_spec.cpp @@ -82,7 +82,7 @@ uint16_t IEEE754Converter::nativeNonIeeeToHalf(float value) hbits |= ((exp + 14) << 10); } const int32_t ival = static_cast(value); - hbits |= static_cast(std::abs(ival) & 0x3FFU); + hbits |= static_cast(((ival < 0) ? (-ival) : ival) & 0x3FFU); float diff = std::abs(value - static_cast(ival)); hbits += diff >= 0.5F; return hbits; diff --git a/libuavcan/src/protocol/uc_node_status_monitor.cpp b/libuavcan/src/protocol/uc_node_status_monitor.cpp index 67505ebcd4..bcffce097e 100644 --- a/libuavcan/src/protocol/uc_node_status_monitor.cpp +++ b/libuavcan/src/protocol/uc_node_status_monitor.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include diff --git a/libuavcan/src/transport/uc_can_io.cpp b/libuavcan/src/transport/uc_can_io.cpp index 7a60934d81..4df84247d2 100644 --- a/libuavcan/src/transport/uc_can_io.cpp +++ b/libuavcan/src/transport/uc_can_io.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/libuavcan/src/transport/uc_transfer_receiver.cpp b/libuavcan/src/transport/uc_transfer_receiver.cpp index f5db8217ea..25ada2ba06 100644 --- a/libuavcan/src/transport/uc_transfer_receiver.cpp +++ b/libuavcan/src/transport/uc_transfer_receiver.cpp @@ -7,7 +7,6 @@ #include #include #include -#include namespace uavcan {