From 35ac4cb2390a846b1486a80d317922850bdef005 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 29 Jul 2021 17:20:40 +0100 Subject: [PATCH 01/25] Variadic message_packet --- include/etl/message_packet.h | 259 +++++++++++++++++++++++++++++++++-- 1 file changed, 249 insertions(+), 10 deletions(-) diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index 6bbb3e52..fe728495 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -62,6 +62,244 @@ SOFTWARE. namespace etl { +#if ETL_CPP17_SUPPORTED && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03) + //*************************************************************************** + // The definition for all message types. + //*************************************************************************** + template + class message_packet + { + public: + + //******************************************** + message_packet() + : valid(false) + { + } + + //******************************************** + explicit message_packet(const etl::imessage& msg) + : valid(true) + { + add_new_message(msg); + } + + //******************************************** + explicit message_packet(etl::imessage&& msg) + : valid(true) + { + add_new_message(etl::move(msg)); + } + + //********************************************** + message_packet(const message_packet& other) + : valid(other.is_valid()) + { + if (valid) + { + add_new_message(other.get()); + } + } + + //********************************************** + message_packet(message_packet&& other) + : valid(other.is_valid()) + { + if (valid) + { + add_new_message(etl::move(other.get())); + } + } + + //********************************************** + message_packet& operator =(const message_packet& rhs) + { + delete_current_message(); + valid = rhs.is_valid(); + if (valid) + { + add_new_message(rhs.get()); + } + + return *this; + } + + //********************************************** + message_packet& operator =(message_packet&& rhs) + { + delete_current_message(); + valid = rhs.is_valid(); + if (valid) + { + add_new_message(etl::move(rhs.get())); + } + + return *this; + } + + //******************************************** + ~message_packet() + { + delete_current_message(); + } + + //******************************************** + etl::imessage& get() ETL_NOEXCEPT + { + return *static_cast(data); + } + + //******************************************** + const etl::imessage& get() const ETL_NOEXCEPT + { + return *static_cast(data); + } + + //******************************************** + bool is_valid() const + { + return valid; + } + + //********************************************** + static ETL_CONSTEXPR bool accepts(etl::message_id_t id) + { + return (accepts_message(id) || ...); + } + + //********************************************** + static ETL_CONSTEXPR bool accepts(const etl::imessage& msg) + { + return accepts(msg.get_message_id()); + } + + //********************************************** + template + static ETL_CONSTEXPR bool accepts() + { + return (accepts_message() || ...); + } + + //********************************************** + template + static ETL_CONSTEXPR + typename etl::enable_if::value, bool>::type + accepts() + { + return accepts(TMessage::ID); + } + + enum + { + SIZE = etl::largest::size, + ALIGNMENT = etl::largest::alignment + }; + + private: + + //********************************************** + template + static ETL_CONSTEXPR bool accepts_message() + { + return Id1 == Id2; + } + + //********************************************** + template + static ETL_CONSTEXPR bool accepts_message(etl::message_id_t id2) + { + return Id1 == id2; + } + + //******************************************** + void delete_current_message() + { + if (valid) + { + etl::imessage* pmsg = static_cast(data); + +#if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES) + pmsg->~imessage(); +#else + if (!(delete_current_message_type(pmsg->get_message_id()) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } +#endif + } + } + + //******************************************** + void add_new_message(const etl::imessage& msg) + { + if (!(add_new_message_type(msg) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + //******************************************** + void add_new_message(etl::imessage&& msg) + { + if (!(add_new_message_type(etl::move(msg)) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + typename etl::aligned_storage::type data; + bool valid; + + private: + + //******************************************** + template + bool delete_current_message_type(etl::message_id_t Id) + { + if (TMessage::ID == Id) + { + static_cast(data)->~TMessage(); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(const etl::imessage& msg) + { + if (TMessage::ID == msg.get_message_id()) + { + void* p = data; + new (p) TMessage(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(etl::imessage&& msg) + { + if (TMessage::ID == msg.get_message_id()) + { + void* p = data; + new (p) TMessage(static_cast(msg)); + return true; + } + else + { + return false; + } + } + }; +#else //*************************************************************************** // The definition for all 16 message types. //*************************************************************************** @@ -206,7 +444,7 @@ namespace etl enum { - SIZE = etl::largest::size, + Size = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -306,7 +544,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -454,7 +692,7 @@ namespace etl enum { - SIZE = etl::largest::size, + Size = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -551,7 +789,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -699,7 +937,7 @@ namespace etl enum { - SIZE = etl::largest::size, + Size = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -793,7 +1031,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -941,7 +1179,7 @@ namespace etl enum { - SIZE = etl::largest::size, + Size = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -1032,7 +1270,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -1179,7 +1417,7 @@ namespace etl enum { - SIZE = etl::largest::size, + Size = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -1267,7 +1505,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -3638,6 +3876,7 @@ namespace etl typename etl::aligned_storage::type data; bool valid; }; +#endif } #endif From e92f93b57f2566f7b407c70d74297e28b5e5a4c1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 29 Jul 2021 17:20:40 +0100 Subject: [PATCH 02/25] Variadic message_packet --- include/etl/message_packet.h | 265 +++++++++++++++++++++++++++++++++++ test/etl_profile.h | 1 + test/test_message_packet.cpp | 6 - 3 files changed, 266 insertions(+), 6 deletions(-) diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index fe728495..4cd97d7d 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -54,6 +54,7 @@ SOFTWARE. #include "message.h" #include "error_handler.h" #include "static_assert.h" +#include "exception.h" #include "largest.h" #include "alignment.h" #include "utility.h" @@ -218,6 +219,270 @@ namespace etl { etl::imessage* pmsg = static_cast(data); +#if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES) + pmsg->~imessage(); +#else + if (!(delete_current_message_type(pmsg->get_message_id()) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } +#endif + } + } + + //******************************************** + void add_new_message(const etl::imessage& msg) + { + if (!(add_new_message_type(msg) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + //******************************************** + void add_new_message(etl::imessage&& msg) + { + if (!(add_new_message_type(etl::move(msg)) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + typename etl::aligned_storage::type data; + bool valid; + + private: + + //******************************************** + template + bool delete_current_message_type(etl::message_id_t Id) + { + if (TMessage::ID == Id) + { + static_cast(data)->~TMessage(); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(const etl::imessage& msg) + { + if (TMessage::ID == msg.get_message_id()) + { + void* p = data; + new (p) TMessage(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(etl::imessage&& msg) + { + if (TMessage::ID == msg.get_message_id()) + { + void* p = data; + new (p) TMessage(static_cast(msg)); + return true; + } + else + { + return false; + } + } + }; +#else + //*************************************************************************** + /// Exception base for message_packet. + //*************************************************************************** + class message_packet_exception : public etl::exception + { + public: + + message_packet_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// Exception for illegal message type. + //*************************************************************************** + class message_packet_illegal_type : public etl::message_packet_exception + { + public: + + message_packet_illegal_type(string_type file_name_, numeric_type line_number_) + : message_packet_exception(ETL_ERROR_TEXT("message_packet:illegal type", ETL_MESSAGE_PACKET_FILE_ID"A"), file_name_, line_number_) + { + } + }; + +#if ETL_CPP17_SUPPORTED && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03) + //*************************************************************************** + // The definition for all message types. + //*************************************************************************** + template + class message_packet + { + public: + + //******************************************** + message_packet() + : valid(false) + { + } + + //******************************************** + explicit message_packet(const etl::imessage& msg) + : valid(true) + { + add_new_message(msg); + } + + //******************************************** + explicit message_packet(etl::imessage&& msg) + : valid(true) + { + add_new_message(etl::move(msg)); + } + + //********************************************** + message_packet(const message_packet& other) + : valid(other.is_valid()) + { + if (valid) + { + add_new_message(other.get()); + } + } + + //********************************************** + message_packet(message_packet&& other) + : valid(other.is_valid()) + { + if (valid) + { + add_new_message(etl::move(other.get())); + } + } + + //********************************************** + message_packet& operator =(const message_packet& rhs) + { + delete_current_message(); + valid = rhs.is_valid(); + if (valid) + { + add_new_message(rhs.get()); + } + + return *this; + } + + //********************************************** + message_packet& operator =(message_packet&& rhs) + { + delete_current_message(); + valid = rhs.is_valid(); + if (valid) + { + add_new_message(etl::move(rhs.get())); + } + + return *this; + } + + //******************************************** + ~message_packet() + { + delete_current_message(); + } + + //******************************************** + etl::imessage& get() ETL_NOEXCEPT + { + return *static_cast(data); + } + + //******************************************** + const etl::imessage& get() const ETL_NOEXCEPT + { + return *static_cast(data); + } + + //******************************************** + bool is_valid() const + { + return valid; + } + + //********************************************** + static ETL_CONSTEXPR bool accepts(etl::message_id_t id) + { + return (accepts_message(id) || ...); + } + + //********************************************** + static ETL_CONSTEXPR bool accepts(const etl::imessage& msg) + { + return accepts(msg.get_message_id()); + } + + //********************************************** + template + static ETL_CONSTEXPR bool accepts() + { + return (accepts_message() || ...); + } + + //********************************************** + template + static ETL_CONSTEXPR + typename etl::enable_if::value, bool>::type + accepts() + { + return accepts(TMessage::ID); + } + + enum + { + SIZE = etl::largest::size, + ALIGNMENT = etl::largest::alignment + }; + + private: + + //********************************************** + template + static ETL_CONSTEXPR bool accepts_message() + { + return Id1 == Id2; + } + + //********************************************** + template + static ETL_CONSTEXPR bool accepts_message(etl::message_id_t id2) + { + return Id1 == id2; + } + + //******************************************** + void delete_current_message() + { + if (valid) + { + etl::imessage* pmsg = static_cast(data); + #if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES) pmsg->~imessage(); #else diff --git a/test/etl_profile.h b/test/etl_profile.h index f4c983ce..65de9de2 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -94,6 +94,7 @@ SOFTWARE. #define ETL_UNINITIALIZED_BUFFER_FORCE_CPP03 #define ETL_CRC_FORCE_CPP03 #define ETL_MEM_CAST_FORCE_CPP03 + #define ETL_MESSAGE_PACKET_FORCE_CPP03 #endif //#define ETL_OVERLOAD_FORCE_CPP11 diff --git a/test/test_message_packet.cpp b/test/test_message_packet.cpp index ae360ad0..75ac200e 100644 --- a/test/test_message_packet.cpp +++ b/test/test_message_packet.cpp @@ -197,9 +197,6 @@ namespace Packet packet2(message2); Packet packet3(message3); - // The next line should result in a compile error. - //Packet packet4(message4); - CHECK_EQUAL(MESSAGE1, packet1.get().get_message_id()); CHECK_EQUAL(MESSAGE2, packet2.get().get_message_id()); CHECK_EQUAL(MESSAGE3, packet3.get().get_message_id()); @@ -251,9 +248,6 @@ namespace const Packet packet2(message2); const Packet packet3(message3); - // The next line should result in a compile error. - //Packet packet4(message4); - CHECK_EQUAL(MESSAGE1, packet1.get().get_message_id()); CHECK_EQUAL(MESSAGE2, packet2.get().get_message_id()); CHECK_EQUAL(MESSAGE3, packet3.get().get_message_id()); From 8c24b42ccfd13616c15b7d9b0bbcef07ba6e508c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 26 Jul 2021 17:17:22 +0100 Subject: [PATCH 03/25] Type traits refactor --- test/vs2019/etl.vcxproj | 2 +- test/vs2019/etl.vcxproj.filters | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 24cac775..5f65af23 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -7129,4 +7129,4 @@ - \ No newline at end of file + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 1fe51913..d1b3f4b4 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2741,4 +2741,4 @@ Resource Files - \ No newline at end of file + From a0c18c56afc1ca3668d6db15d2b82f148c35acb7 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 1 Aug 2021 19:34:40 +0100 Subject: [PATCH 04/25] Changed std::forward to etl::forward --- include/etl/private/variant_variadic.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/etl/private/variant_variadic.h b/include/etl/private/variant_variadic.h index 38e987a5..06ff1933 100644 --- a/include/etl/private/variant_variadic.h +++ b/include/etl/private/variant_variadic.h @@ -536,7 +536,7 @@ namespace etl { static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - construct_in_place>(data, std::forward(value)); + construct_in_place>(data, etl::forward(value)); } //*************************************************************************** @@ -550,7 +550,7 @@ namespace etl { static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - construct_in_place_args>(data, std::forward(args)...); + construct_in_place_args>(data, etl::forward(args)...); } //*************************************************************************** @@ -564,7 +564,7 @@ namespace etl using type = typename private_variant::parameter_pack:: template type_from_index_t; static_assert(etl::is_one_of ::value, "Unsupported type"); - construct_in_place_args(data, std::forward(args)...); + construct_in_place_args(data, etl::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } @@ -581,7 +581,7 @@ namespace etl { static_assert(etl::is_one_of, TTypes...> ::value, "Unsupported type"); - construct_in_place_args>(data, init, std::forward(args)...); + construct_in_place_args>(data, init, etl::forward(args)...); } //*************************************************************************** @@ -595,7 +595,7 @@ namespace etl using type = typename private_variant::parameter_pack:: template type_from_index_t; static_assert(etl::is_one_of ::value, "Unsupported type"); - construct_in_place_args(data, init, std::forward(args)...); + construct_in_place_args(data, init, etl::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } @@ -675,7 +675,7 @@ namespace etl operation(private_variant::Destroy, data, nullptr); - construct_in_place_args(data, std::forward(args)...); + construct_in_place_args(data, etl::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; From c868acaa9bce4f591723de79bba4788e30d10079 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 1 Aug 2021 19:39:14 +0100 Subject: [PATCH 05/25] Updated versions --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- support/Release notes.txt | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 12592eba..3d86d6ee 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 14 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #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) diff --git a/library.json b/library.json index 990b2d31..e6ec5ef2 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.14.0", + "version": "20.14.1", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 5021b0d1..ec1698a8 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.14.0 +version=20.14.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index 7d295964..f5ac7c02 100644 --- a/meson.build +++ b/meson.build @@ -8,7 +8,7 @@ project('PROJECT_NAME', 'cpp_std=c++17', 'build.cpp_std=c++17', ], meson_version: '>=0.54.0', - version: '20.14.0' + version: '20.14.1' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index 463015c7..f815aadf 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +20.14.1 +Changed std::forward to etl::forward in etl::variant (variadic) + =============================================================================== 20.14.0 Added a vaiadic version of etl::variant. Usable for C++11 and up. From 86d1bd78905005002ffb03362dc6b39d475865fe Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 1 Aug 2021 19:35:59 +0100 Subject: [PATCH 06/25] etl::message_packet update --- include/etl/message.h | 2 +- include/etl/message_packet.h | 327 ++++++----------------------------- include/etl/message_router.h | 104 +++++++++++ 3 files changed, 162 insertions(+), 271 deletions(-) diff --git a/include/etl/message.h b/include/etl/message.h index cae10650..27b634a1 100644 --- a/include/etl/message.h +++ b/include/etl/message.h @@ -91,7 +91,7 @@ namespace etl ID = ID_ }; - ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE + ETL_CONSTEXPR ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE { return ID; } diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index 4cd97d7d..79441d09 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -92,268 +92,13 @@ namespace etl add_new_message(etl::move(msg)); } - //********************************************** - message_packet(const message_packet& other) - : valid(other.is_valid()) - { - if (valid) - { - add_new_message(other.get()); - } - } - - //********************************************** - message_packet(message_packet&& other) - : valid(other.is_valid()) - { - if (valid) - { - add_new_message(etl::move(other.get())); - } - } - - //********************************************** - message_packet& operator =(const message_packet& rhs) - { - delete_current_message(); - valid = rhs.is_valid(); - if (valid) - { - add_new_message(rhs.get()); - } - - return *this; - } - - //********************************************** - message_packet& operator =(message_packet&& rhs) - { - delete_current_message(); - valid = rhs.is_valid(); - if (valid) - { - add_new_message(etl::move(rhs.get())); - } - - return *this; - } - //******************************************** - ~message_packet() - { - delete_current_message(); - } - - //******************************************** - etl::imessage& get() ETL_NOEXCEPT - { - return *static_cast(data); - } - - //******************************************** - const etl::imessage& get() const ETL_NOEXCEPT - { - return *static_cast(data); - } - - //******************************************** - bool is_valid() const - { - return valid; - } - - //********************************************** - static ETL_CONSTEXPR bool accepts(etl::message_id_t id) - { - return (accepts_message(id) || ...); - } - - //********************************************** - static ETL_CONSTEXPR bool accepts(const etl::imessage& msg) - { - return accepts(msg.get_message_id()); - } - - //********************************************** - template - static ETL_CONSTEXPR bool accepts() - { - return (accepts_message() || ...); - } - - //********************************************** - template - static ETL_CONSTEXPR - typename etl::enable_if::value, bool>::type - accepts() - { - return accepts(TMessage::ID); - } - - enum - { - SIZE = etl::largest::size, - ALIGNMENT = etl::largest::alignment - }; - - private: - - //********************************************** - template - static ETL_CONSTEXPR bool accepts_message() - { - return Id1 == Id2; - } - - //********************************************** - template - static ETL_CONSTEXPR bool accepts_message(etl::message_id_t id2) - { - return Id1 == id2; - } - - //******************************************** - void delete_current_message() - { - if (valid) - { - etl::imessage* pmsg = static_cast(data); - -#if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES) - pmsg->~imessage(); -#else - if (!(delete_current_message_type(pmsg->get_message_id()) || ...)) - { - ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); - } -#endif - } - } - - //******************************************** - void add_new_message(const etl::imessage& msg) - { - if (!(add_new_message_type(msg) || ...)) - { - ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); - } - } - - //******************************************** - void add_new_message(etl::imessage&& msg) - { - if (!(add_new_message_type(etl::move(msg)) || ...)) - { - ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); - } - } - - typename etl::aligned_storage::type data; - bool valid; - - private: - - //******************************************** - template - bool delete_current_message_type(etl::message_id_t Id) - { - if (TMessage::ID == Id) - { - static_cast(data)->~TMessage(); - return true; - } - else - { - return false; - } - } - - //******************************************** - template - bool add_new_message_type(const etl::imessage& msg) - { - if (TMessage::ID == msg.get_message_id()) - { - void* p = data; - new (p) TMessage(static_cast(msg)); - return true; - } - else - { - return false; - } - } - - //******************************************** - template - bool add_new_message_type(etl::imessage&& msg) - { - if (TMessage::ID == msg.get_message_id()) - { - void* p = data; - new (p) TMessage(static_cast(msg)); - return true; - } - else - { - return false; - } - } - }; -#else - //*************************************************************************** - /// Exception base for message_packet. - //*************************************************************************** - class message_packet_exception : public etl::exception - { - public: - - message_packet_exception(string_type reason_, string_type file_name_, numeric_type line_number_) - : exception(reason_, file_name_, line_number_) - { - } - }; - - //*************************************************************************** - /// Exception for illegal message type. - //*************************************************************************** - class message_packet_illegal_type : public etl::message_packet_exception - { - public: - - message_packet_illegal_type(string_type file_name_, numeric_type line_number_) - : message_packet_exception(ETL_ERROR_TEXT("message_packet:illegal type", ETL_MESSAGE_PACKET_FILE_ID"A"), file_name_, line_number_) - { - } - }; - -#if ETL_CPP17_SUPPORTED && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03) - //*************************************************************************** - // The definition for all message types. - //*************************************************************************** - template - class message_packet - { - public: - - //******************************************** - message_packet() - : valid(false) - { - } - - //******************************************** - explicit message_packet(const etl::imessage& msg) + template , etl::imessage> && + !etl::is_same_v, etl::message_packet>, int> = 0> + explicit message_packet(TMessage&& msg) : valid(true) { - add_new_message(msg); - } - - //******************************************** - explicit message_packet(etl::imessage&& msg) - : valid(true) - { - add_new_message(etl::move(msg)); + add_new_message(etl::forward(msg)); } //********************************************** @@ -451,7 +196,7 @@ namespace etl typename etl::enable_if::value, bool>::type accepts() { - return accepts(TMessage::ID); + return accepts(); } enum @@ -512,18 +257,28 @@ namespace etl } } + //******************************************** + template , etl::imessage>, int> = 0> + void add_new_message(TMessage&& msg) + { + if (!(add_new_message_type::ID>(etl::forward(msg)) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + typename etl::aligned_storage::type data; bool valid; private: //******************************************** - template + template bool delete_current_message_type(etl::message_id_t Id) { - if (TMessage::ID == Id) + if (TType::ID == Id) { - static_cast(data)->~TMessage(); + static_cast(data)->~TType(); return true; } else @@ -533,13 +288,13 @@ namespace etl } //******************************************** - template + template bool add_new_message_type(const etl::imessage& msg) { - if (TMessage::ID == msg.get_message_id()) + if (TType::ID == msg.get_message_id()) { void* p = data; - new (p) TMessage(static_cast(msg)); + new (p) TType(static_cast(msg)); return true; } else @@ -549,13 +304,45 @@ namespace etl } //******************************************** - template - bool add_new_message_type(etl::imessage&& msg) + template + bool add_new_message_type(const etl::imessage& msg) { - if (TMessage::ID == msg.get_message_id()) + if (TType::ID == Id) { void* p = data; - new (p) TMessage(static_cast(msg)); + new (p) TType(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(etl::imessage&& msg) + { + if (TType::ID == msg.get_message_id()) + { + void* p = data; + new (p) TType(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(etl::imessage&& msg) + { + if (TType::ID == Id) + { + void* p = data; + new (p) TType(static_cast(msg)); return true; } else diff --git a/include/etl/message_router.h b/include/etl/message_router.h index ab6d380b..a2fcf299 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -295,6 +295,109 @@ namespace etl destination.receive(message); } +#if ETL_CPP17_SUPPORTED + //*************************************************************************** + // The definition for all message types. + //*************************************************************************** + template + class message_router : public imessage_router + { + public: + + typedef etl::message_packet message_packet; + + //********************************************** + message_router(etl::message_router_id_t id_) + : imessage_router(id_) + { + ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id)); + } + + //********************************************** + message_router(etl::message_router_id_t id_, etl::imessage_router& successor_) + : imessage_router(id_, successor_) + { + ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id)); + } + + //********************************************** + using etl::imessage_router::receive; + + void receive(const etl::imessage& msg) ETL_OVERRIDE + { + const bool was_handled = (receive_message_type(msg) || ...); + + if (!was_handled) + { + if (has_successor()) + { + get_successor().receive(msg); + } + else + { + static_cast(this)->on_receive_unknown(msg); + } + } + } + + //********************************************** + using imessage_router::accepts; + + bool accepts(etl::message_id_t id) const ETL_OVERRIDE + { + return (accepts_type(id) || ...); + } + + //******************************************** + ETL_DEPRECATED bool is_null_router() const ETL_OVERRIDE + { + return false; + } + + //******************************************** + bool is_producer() const ETL_OVERRIDE + { + return true; + } + + //******************************************** + bool is_consumer() const ETL_OVERRIDE + { + return true; + } + + private: + + //******************************************** + template + bool receive_message_type(const etl::imessage& msg) + { + if (TMessage::ID == msg.get_message_id()) + { + static_cast(this)->on_receive(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool accepts_type(etl::message_id_t id) const + { + if (TMessage::ID == id) + { + return true; + } + else + { + return false; + } + } + }; +#else //*************************************************************************** // The definition for all 16 message types. //*************************************************************************** @@ -1790,6 +1893,7 @@ namespace etl return true; } }; +#endif } #endif From 7a067ba8167cccc60009e9be3cc685ec6ef4ff6d Mon Sep 17 00:00:00 2001 From: Benedek Kupper <57992871+bku-sue@users.noreply.github.com> Date: Tue, 6 Jul 2021 16:42:37 +0200 Subject: [PATCH 07/25] introduce bip buffer spsc atomic (#402) Based on the works of Andrea Lattuada and James Munns: https://blog.systems.ethz.ch/blog/2019/the-design-and-implementation-of-a-lock-free-ring-buffer-with-contiguous-reservations.html Whose design was inspired by Simon Cooke: https://www.codeproject.com/Articles/3479/The-Bip-Buffer-The-Circular-Buffer-with-a-Twist Signed-off-by: Benedek Kupper --- .gitignore | 3 + include/etl/bip_buffer_spsc_atomic.h | 400 +++++++++++++++++++++++++++ test/CMakeLists.txt | 1 + test/codeblocks/ETL.cbp | 2 + test/test_bip_buffer_spsc_atomic.cpp | 356 ++++++++++++++++++++++++ test/vs2019/etl.vcxproj | 2 + test/vs2019/etl.vcxproj.filters | 297 ++++++++++++++++++++ 7 files changed, 1061 insertions(+) create mode 100644 include/etl/bip_buffer_spsc_atomic.h create mode 100644 test/test_bip_buffer_spsc_atomic.cpp diff --git a/.gitignore b/.gitignore index 870ab075..a3f4ac99 100644 --- a/.gitignore +++ b/.gitignore @@ -318,3 +318,6 @@ test/vs2019/DebugNoSTL test/vs2022/Debug LLVM test/vs2019/Debug MSVC - No STL - Built-ins/etl.exe test/vs2019/Debug-LLVM-NoSTL-Builtins/etl.exe +test/vs2019/cmake-build +test/vs2019/Debug MSVC - No STL - Built-ins +test/vs2019/Test1 diff --git a/include/etl/bip_buffer_spsc_atomic.h b/include/etl/bip_buffer_spsc_atomic.h new file mode 100644 index 00000000..517436ac --- /dev/null +++ b/include/etl/bip_buffer_spsc_atomic.h @@ -0,0 +1,400 @@ +///\file + +/** + * @note Based on the works of Andrea Lattuada and James Munns: + * https://blog.systems.ethz.ch/blog/2019/the-design-and-implementation-of-a-lock-free-ring-buffer-with-contiguous-reservations.html + * Whose design was inspired by Simon Cooke: + * https://www.codeproject.com/Articles/3479/The-Bip-Buffer-The-Circular-Buffer-with-a-Twist + */ +#ifndef ETL_BIP_BUFFER_SPSC_ATOMIC_INCLUDED +#define ETL_BIP_BUFFER_SPSC_ATOMIC_INCLUDED + +#include +#include + +#include "platform.h" +#include "alignment.h" +#include "parameter_type.h" +#include "atomic.h" +#include "memory_model.h" +#include "integral_limits.h" +#include "utility.h" +#include "error_handler.h" +#include "span.h" + +#if ETL_HAS_ATOMIC + +namespace etl +{ + class bip_buffer_exception: public exception + { + public: + bip_buffer_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + class bip_buffer_reserve_invalid: public bip_buffer_exception + { + public: + bip_buffer_reserve_invalid(string_type file_name_, numeric_type line_number_) + : bip_buffer_exception("bip_buffer:reserve", file_name_, line_number_) + { + } + }; + + template + class bip_buffer_spsc_atomic_base + { + public: + /// The type used for determining the size of buffer. + typedef typename etl::size_type_lookup::type size_type; + + bool empty() const + { + return size() == 0; + } + + bool full() const + { + return available() == 0; + } + + // returns the total used size, which may be split in two blocks + // so the size will always be smaller after a read commit + size_type size() const + { + size_type write_index = write.load(etl::memory_order_acquire); + size_type read_index = read.load(etl::memory_order_acquire); + + // no wraparound + if (write_index >= read_index) + { + // size is distance between read and write + return write_index - read_index; + } + else + { + size_type last_index = last.load(etl::memory_order_acquire); + + // size is distance between beginning and write, plus read and last + return (write_index - 0) + (last_index - read_index); + } + } + + // returns the largest contiguous(!) available block size + size_type available() const + { + size_type write_index = write.load(etl::memory_order_acquire); + size_type read_index = read.load(etl::memory_order_acquire); + + // no wraparound + if (write_index >= read_index) + { + size_type forward_size = capacity() - write_index; + + // check if there's more space if wrapping around + if (read_index > (forward_size + 1)) + { + return read_index - 1; + } + else + { + return forward_size; + } + } + else // read_index > write_index + { + return read_index - write_index - 1; + } + } + + size_type capacity() const + { + return RESERVED; + } + + size_type max_size() const + { + return RESERVED; + } + + void clear() + { + read.store(0, etl::memory_order_release); + write.store(0, etl::memory_order_release); + last.store(0, etl::memory_order_release); + } + + protected: + bip_buffer_spsc_atomic_base(size_type reserved_) + : read(0), + write(0), + last(0), + RESERVED(reserved_) + { + } + + size_type get_write_reserve(size_type* psize) + { + size_type write_index = write.load(etl::memory_order_relaxed); + size_type read_index = read.load(etl::memory_order_acquire); + + // no wraparound + if (write_index >= read_index) + { + size_type forward_size = capacity() - write_index; + + // we still fit in linearly + if (*psize <= forward_size) + { + return write_index; + } + // there isn't more space even when wrapping around + else if (read_index <= (forward_size + 1)) + { + *psize = forward_size; + return write_index; + } + // better wrap around now + else + { + // check if size fits + // when wrapping, the write index cannot reach read index, + // then we'd not be able to distinguish wrapped situation from linear + if (*psize >= read_index) + { + if (read_index > 0) + { + *psize = read_index - 1; + } + else + { + *psize = 0; + } + } + return 0; + } + } + else // read_index > write_index + { + // doesn't fit + if ((write_index + *psize) >= read_index) + { + *psize = read_index - write_index - 1; + } + return write_index; + } + } + + void apply_write_reserve(size_type windex, size_type wsize) + { + if (wsize > 0) + { + size_type write_index = write.load(etl::memory_order_relaxed); + size_type read_index = read.load(etl::memory_order_acquire); + + // wrapped around already + if (write_index < read_index) + { + ETL_ASSERT_AND_RETURN((windex == write_index) && ((wsize + 1) <= read_index), + ETL_ERROR(bip_buffer_reserve_invalid)); + } + // no wraparound so far, also not wrapping around with this block + else if (windex == write_index) + { + ETL_ASSERT_AND_RETURN(wsize <= (capacity() - write_index), + ETL_ERROR(bip_buffer_reserve_invalid)); + + // move both indexes forward + last.store(windex + wsize, etl::memory_order_release); + } + // wrapping around now + else + { + ETL_ASSERT_AND_RETURN((windex == 0) && ((wsize + 1) <= read_index), + ETL_ERROR(bip_buffer_reserve_invalid)); + } + // always update write index + write.store(windex + wsize, etl::memory_order_release); + } + } + + size_type get_read_reserve(size_type* psize) + { + size_type read_index = read.load(etl::memory_order_relaxed); + size_type write_index = write.load(etl::memory_order_acquire); + + if (read_index > write_index) + { + // writer has wrapped around + + size_type last_index = last.load(etl::memory_order_relaxed); + if (read_index == last_index) + { + // reader reached the end, start read from 0 + read_index = 0; + } + else // (read_index < last_index) + { + // use the remaining buffer at the end + write_index = last_index; + } + } + else + { + // no wraparound, nothing to adjust + } + + // limit to max available size + if ((write_index - read_index) < *psize) + { + *psize = write_index - read_index; + } + return read_index; + } + + void apply_read_reserve(size_type rindex, size_type rsize) + { + if (rsize > 0) + { + size_type rsize_checker = rsize; + ETL_ASSERT_AND_RETURN((rindex == get_read_reserve(&rsize_checker)) && (rsize == rsize_checker), + ETL_ERROR(bip_buffer_reserve_invalid)); + + read.store(rindex + rsize, etl::memory_order_release); + } + } + + private: + etl::atomic read; + etl::atomic write; + etl::atomic last; + const size_type RESERVED; + +#if defined(ETL_POLYMORPHIC_SPSC_BIP_BUFFER_ATOMIC) || defined(ETL_POLYMORPHIC_CONTAINERS) + public: + virtual ~bip_buffer_spsc_atomic_base() + { + } +#else + protected: + ~bip_buffer_spsc_atomic_base() + { + } +#endif + }; + + template + class ibip_buffer_spsc_atomic : public bip_buffer_spsc_atomic_base + { + private: + typedef typename etl::bip_buffer_spsc_atomic_base base_t; + using base_t::get_read_reserve; + using base_t::apply_read_reserve; + using base_t::get_write_reserve; + using base_t::apply_write_reserve; + + public: + typedef T value_type; ///< The type stored in the buffer. + typedef T& reference; ///< A reference to the type used in the buffer. + typedef const T& const_reference; ///< A const reference to the type used in the buffer. +#if ETL_CPP11_SUPPORTED + typedef T&& rvalue_reference;///< An rvalue_reference to the type used in the buffer. +#endif + typedef typename base_t::size_type size_type; ///< The type used for determining the size of the buffer. + + // reserves a memory area for reading up to the max_reserve_size + span read_reserve(size_type max_reserve_size) + { + size_type reserve_size = max_reserve_size; + auto rindex = get_read_reserve(&reserve_size); + return span(p_buffer + rindex, reserve_size); + } + + // commits the previously reserved read memory area + // the reserve can be trimmed at the end before committing + // throws bip_buffer_reserve_invalid + void read_commit(const span &reserve) + { + size_type rindex = etl::distance(p_buffer, reserve.data()); + apply_read_reserve(rindex, reserve.size()); + } + + // reserves a memory area for writing up to the max_reserve_size + span write_reserve(size_type max_reserve_size) + { + size_type reserve_size = max_reserve_size; + auto windex = get_write_reserve(&reserve_size); + return span(p_buffer + windex, reserve_size); + } + + // commits the previously reserved write memory area + // the reserve can be trimmed at the end before committing + // throws bip_buffer_reserve_invalid + void write_commit(const span &reserve) + { + size_type windex = etl::distance(p_buffer, reserve.data()); + apply_write_reserve(windex, reserve.size()); + } + + protected: + ibip_buffer_spsc_atomic(T* p_buffer_, size_type reserved_) + : base_t(reserved_), + p_buffer(p_buffer_) + { + } + + private: + // Disable copy construction and assignment. + ibip_buffer_spsc_atomic(const ibip_buffer_spsc_atomic&) ETL_DELETE; + ibip_buffer_spsc_atomic& operator =(const ibip_buffer_spsc_atomic&) ETL_DELETE; + +#if ETL_CPP11_SUPPORTED + ibip_buffer_spsc_atomic(ibip_buffer_spsc_atomic&&) = delete; + ibip_buffer_spsc_atomic& operator =(ibip_buffer_spsc_atomic&&) = delete; +#endif + + T* const p_buffer; + }; + + //*************************************************************************** + /// A fixed capacity bipartite buffer. + /// This buffer supports concurrent access by one producer and one consumer. + /// \tparam T The type this buffer should support. + /// \tparam SIZE The maximum capacity of the buffer. + /// \tparam MEMORY_MODEL The memory model for the buffer. Determines the type of the internal counter variables. + //*************************************************************************** + template + class bip_buffer_spsc_atomic : public ibip_buffer_spsc_atomic + { + private: + typedef typename etl::ibip_buffer_spsc_atomic base_t; + + public: + typedef typename base_t::size_type size_type; + + private: + static const size_type RESERVED_SIZE = size_type(SIZE); + + public: + ETL_STATIC_ASSERT((SIZE <= (etl::integral_limits::max)), "Size too large for memory model"); + + static const size_type MAX_SIZE = size_type(SIZE); + + bip_buffer_spsc_atomic() + : base_t(reinterpret_cast(&buffer[0]), RESERVED_SIZE) + { + } + + private: + + /// The uninitialised buffer of T used in the bip_buffer_spsc. + typename etl::aligned_storage::value>::type buffer[RESERVED_SIZE]; + }; +} + +#endif /* ETL_HAS_ATOMIC */ + +#endif /* ETL_BIP_BUFFER_SPSC_ATOMIC_INCLUDED */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 74cf97b1..a9780307 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -32,6 +32,7 @@ set(TEST_SOURCE_FILES test_atomic_gcc_sync.cpp test_atomic_std.cpp test_binary.cpp + test_bip_buffer_spsc_atomic.cpp test_bitset.cpp test_bit_stream.cpp test_bloom_filter.cpp diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index a4be44b9..e6572c4b 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -255,6 +255,7 @@ + @@ -514,6 +515,7 @@ + diff --git a/test/test_bip_buffer_spsc_atomic.cpp b/test/test_bip_buffer_spsc_atomic.cpp new file mode 100644 index 00000000..f1891040 --- /dev/null +++ b/test/test_bip_buffer_spsc_atomic.cpp @@ -0,0 +1,356 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include +#include +#include + +#include "etl/bip_buffer_spsc_atomic.h" + +#include "data.h" + +#if ETL_HAS_ATOMIC + +#if defined(ETL_TARGET_OS_WINDOWS) + #include +#endif + +#define REALTIME_TEST 0 + +namespace +{ + SUITE(test_bip_buffer_spsc_atomic) + { + //************************************************************************* + TEST(test_constructor) + { + etl::bip_buffer_spsc_atomic stream; + + CHECK_EQUAL(5U, stream.max_size()); + CHECK_EQUAL(5U, stream.capacity()); + } + + //************************************************************************* + TEST(test_size_write_read) + { + etl::bip_buffer_spsc_atomic stream; + etl::ibip_buffer_spsc_atomic& istream = stream; + + // Verify empty buffer + CHECK_EQUAL(0U, stream.size()); + CHECK(stream.empty()); + CHECK((stream.max_size() / 2U) <= stream.available()); + CHECK(stream.available() <= stream.max_size()); + + auto reader = istream.read_reserve(1U); + CHECK_EQUAL(0U, reader.size()); + + // Write partially + auto writer = istream.write_reserve(1U); + CHECK_EQUAL(1U, writer.size()); + writer[0] = 1; + + CHECK(stream.empty()); + + istream.write_commit(writer); // 1 * * * * + CHECK_EQUAL(1U, stream.size()); + + writer = istream.write_reserve(1U); + CHECK_EQUAL(1U, writer.size()); + writer[0] = 2; + + istream.write_commit(writer); // 1 2 * * * + CHECK_EQUAL(2U, stream.size()); + + // Write to capacity + writer = istream.write_reserve(istream.available()); + CHECK_EQUAL(3U, writer.size()); + writer[0] = 3; + writer[1] = 4; + writer[2] = 5; + + istream.write_commit(writer); // 1 2 3 4 5 + + // Verify full buffer + CHECK_EQUAL(0U, stream.available()); + CHECK(stream.full()); + CHECK((stream.max_size() - 1) <= stream.size()); + CHECK(stream.size() <= stream.max_size()); + + writer = istream.write_reserve(1U); + CHECK_EQUAL(0U, writer.size()); + + // Read partially + reader = istream.read_reserve(1U); + CHECK_EQUAL(1U, reader.size()); + CHECK_EQUAL(1, reader[0]); + CHECK_EQUAL(5U, stream.size()); + + istream.read_commit(reader); // * 2 3 4 5 + CHECK_EQUAL(4U, stream.size()); + + reader = istream.read_reserve(1U); + CHECK_EQUAL(1U, reader.size()); + CHECK_EQUAL(2, reader[0]); + CHECK_EQUAL(4U, stream.size()); + + istream.read_commit(reader); // * * 3 4 5 + CHECK_EQUAL(3U, stream.size()); + + // Write to wraparound area (one element remains reserved) + writer = istream.write_reserve(istream.available()); + CHECK_EQUAL(1U, writer.size()); + CHECK_EQUAL(1U, stream.available()); + writer[0] = 6; + + istream.write_commit(writer); // 6 * 3 4 5 + + // Verify full buffer + CHECK_EQUAL(0U, stream.available()); + CHECK(stream.full()); + CHECK((stream.max_size() - 1) <= stream.size()); + CHECK(stream.size() <= stream.max_size()); + + writer = istream.write_reserve(1U); + CHECK_EQUAL(0U, writer.size()); + + // Read to capacity + reader = istream.read_reserve(istream.size()); + CHECK_EQUAL(3U, reader.size()); + CHECK_EQUAL(3, reader[0]); + CHECK_EQUAL(4, reader[1]); + CHECK_EQUAL(5, reader[2]); + CHECK_EQUAL(4U, stream.size()); + + istream.read_commit(reader); // * 2 * * * + CHECK_EQUAL(1U, stream.size()); + + reader = istream.read_reserve(istream.size()); + CHECK_EQUAL(1U, reader.size()); + CHECK_EQUAL(6, reader[0]); + CHECK_EQUAL(1U, stream.size()); + + istream.read_commit(reader); // * * * * * + + // Verify empty buffer + CHECK_EQUAL(0U, stream.size()); + CHECK(stream.empty()); + CHECK((stream.max_size() / 2U) <= stream.available()); + CHECK(stream.available() <= stream.max_size()); + } + + //************************************************************************* + TEST(test_clear) + { + etl::bip_buffer_spsc_atomic stream; + etl::ibip_buffer_spsc_atomic& istream = stream; + + CHECK(stream.empty()); + + // Write the whole buffer + auto writer = istream.write_reserve(istream.capacity()); + // data is committed without set to valid value (it won't be read anyway) + istream.write_commit(writer); + CHECK(stream.full()); + + istream.clear(); + CHECK(stream.empty()); + + // Repeat to see that clear() resets the internal state completely and correctly + writer = istream.write_reserve(istream.capacity()); + // data is committed without set to valid value (it won't be read anyway) + istream.write_commit(writer); + CHECK(stream.full()); + + istream.clear(); + CHECK(stream.empty()); + } + + //************************************************************************* + TEST(test_partial_commits) + { + etl::bip_buffer_spsc_atomic stream; + etl::ibip_buffer_spsc_atomic& istream = stream; + + // Write reserve available + auto writer_1 = istream.write_reserve(istream.capacity()); + CHECK_EQUAL(5U, stream.available()); + CHECK_EQUAL(5U, writer_1.size()); + + // Write and commit partially + writer_1[0] = 1; + writer_1[1] = 2; + writer_1[2] = 3; + writer_1[3] = 4; + + // Cannot commit subspans with offset + CHECK_THROW(istream.write_commit(writer_1.subspan(1U, 3U)), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.write_commit(writer_1.subspan(2U, 2U)), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.write_commit(writer_1.subspan(3U, 1U)), etl::bip_buffer_reserve_invalid); + + CHECK_NO_THROW(istream.write_commit(writer_1.subspan(0U, 4U))); // 1 2 3 4 * + CHECK_EQUAL(4U, stream.size()); + + // Can only commit once for each reserve (provided they don't cover a valid area) + CHECK_THROW(istream.write_commit(writer_1), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.write_commit(writer_1.subspan(0U, 4U)), etl::bip_buffer_reserve_invalid); + + // Read reserve available + auto reader_1 = istream.read_reserve(istream.capacity()); + CHECK_EQUAL(4U, reader_1.size()); + + // Read and commit partially + CHECK_EQUAL(1, reader_1[0]); + CHECK_EQUAL(2, reader_1[1]); + CHECK_EQUAL(3, reader_1[2]); + + // Cannot commit subspans with offset + CHECK_THROW(istream.read_commit(reader_1.subspan(1U, 2U)), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.read_commit(reader_1.subspan(2U, 1U)), etl::bip_buffer_reserve_invalid); + + CHECK_NO_THROW(istream.read_commit(reader_1.subspan(0U, 3U))); // * * * 4 * + CHECK_EQUAL(1U, stream.size()); + + // Can only commit once for each reserve (provided they don't cover a valid area) + CHECK_THROW(istream.read_commit(reader_1), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.read_commit(reader_1.subspan(0U, 3U)), etl::bip_buffer_reserve_invalid); + + // Write reserve available + auto writer_2 = istream.write_reserve(istream.capacity()); + CHECK_EQUAL(2U, stream.available()); + CHECK_EQUAL(2U, writer_2.size()); + + // Write and commit partially + writer_2[0] = 5; + CHECK_NO_THROW(istream.write_commit(writer_2.subspan(0U, 1U))); // 5 * * 4 * + CHECK_EQUAL(2U, stream.size()); + // Even though the second committed span could have fit at the end, + // the reservation asked for the largest consecutive block, + // which resulted in a wraparound span to be allocated + + // Can only commit once for each reserve (provided they don't cover a valid area) + CHECK_THROW(istream.write_commit(writer_1), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.write_commit(writer_2), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.write_commit(writer_2.subspan(0U, 1U)), etl::bip_buffer_reserve_invalid); + + // Read reserve available + auto reader_2 = istream.read_reserve(istream.capacity()); + CHECK_EQUAL(1U, reader_2.size()); + + // Read and commit + CHECK_EQUAL(4, reader_2[0]); + CHECK_NO_THROW(istream.read_commit(reader_2)); // 5 * * * * + CHECK_EQUAL(1U, stream.size()); + + // Can only commit once for each reserve (provided they don't cover a valid area) + CHECK_THROW(istream.read_commit(reader_1), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.read_commit(reader_2), etl::bip_buffer_reserve_invalid); + + // Read reserve available + auto reader_3 = istream.read_reserve(istream.capacity()); + CHECK_EQUAL(1U, reader_3.size()); + + // Read and commit + CHECK_EQUAL(5, reader_3[0]); + CHECK_NO_THROW(istream.read_commit(reader_3)); // * * * * * + CHECK_EQUAL(0U, stream.size()); + + // Can only commit once for each reserve (provided they don't cover a valid area) + CHECK_THROW(istream.read_commit(reader_1), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.read_commit(reader_2), etl::bip_buffer_reserve_invalid); + CHECK_THROW(istream.read_commit(reader_3), etl::bip_buffer_reserve_invalid); + + CHECK(stream.empty()); + } + + //************************************************************************* +#if REALTIME_TEST && defined(ETL_COMPILER_MICROSOFT) + #if defined(ETL_TARGET_OS_WINDOWS) // Only Windows priority is currently supported + #define FIX_PROCESSOR_AFFINITY1 SetThreadAffinityMask(GetCurrentThread(), 1); + #define FIX_PROCESSOR_AFFINITY2 SetThreadAffinityMask(GetCurrentThread(), 2); + #else + #error No thread priority modifier defined + #endif + + etl::bip_buffer_spsc_atomic stream; + + const size_t LENGTH = 1000000; + + void timer_event() + { + FIX_PROCESSOR_AFFINITY1; + + const size_t write_chunk_size = 7; + size_t tick = 0; + + while (tick < LENGTH) + { + auto writer = stream.write_reserve(std::min(write_chunk_size, LENGTH - tick)); + for (auto& item : writer) + { + item = tick++; + } + stream.write_commit(writer); + } + } + + TEST(bip_buffer_threads) + { + FIX_PROCESSOR_AFFINITY2; + + const size_t read_chunk_size = stream.capacity(); + + std::vector tick_list; + tick_list.reserve(LENGTH); + + std::thread t1(timer_event); + + while (tick_list.size() < LENGTH) + { + reader = stream.read_reserve(read_chunk_size); + tick_list.insert(tick_list.end(), reader.begin(), reader.end()); + stream.read_commit(reader); + } + + // Join the thread with the main thread + t1.join(); + + CHECK_EQUAL(LENGTH, tick_list.size()); + + for (size_t i = 0; i < LENGTH; i++) + { + CHECK_EQUAL(i, tick_list[i]); + } + } +#endif + }; +} + +#endif // ETL_HAS_ATOMIC diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 5f65af23..8a0ac45e 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1489,6 +1489,7 @@ + @@ -6560,6 +6561,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index d1b3f4b4..07cbbfa0 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1125,6 +1125,9 @@ ETL\Utilities + + ETL\Containers + ETL\Private @@ -2561,6 +2564,300 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Sanity Checks + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks From 1789e4937d19e3cd8b0a5373f3755ee116bcd68e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 6 Jul 2021 18:49:27 +0100 Subject: [PATCH 08/25] Changes before merging to development --- include/etl/bip_buffer_spsc_atomic.h | 714 ++++++++++-------- .../bip_buffer_spsc_atomic.h.t.cpp | 29 + test/sanity-check/c++03/CMakeLists.txt | 1 + test/sanity-check/c++11/CMakeLists.txt | 1 + test/sanity-check/c++14/CMakeLists.txt | 1 + test/sanity-check/c++17/CMakeLists.txt | 1 + test/vs2019/etl.vcxproj | 17 + test/vs2019/etl.vcxproj.filters | 3 + 8 files changed, 456 insertions(+), 311 deletions(-) create mode 100644 test/sanity-check/bip_buffer_spsc_atomic.h.t.cpp diff --git a/include/etl/bip_buffer_spsc_atomic.h b/include/etl/bip_buffer_spsc_atomic.h index 517436ac..100fc961 100644 --- a/include/etl/bip_buffer_spsc_atomic.h +++ b/include/etl/bip_buffer_spsc_atomic.h @@ -1,11 +1,40 @@ ///\file +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 Benedek Kupper, John Wellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + /** * @note Based on the works of Andrea Lattuada and James Munns: * https://blog.systems.ethz.ch/blog/2019/the-design-and-implementation-of-a-lock-free-ring-buffer-with-contiguous-reservations.html * Whose design was inspired by Simon Cooke: * https://www.codeproject.com/Articles/3479/The-Bip-Buffer-The-Circular-Buffer-with-a-Twist */ + #ifndef ETL_BIP_BUFFER_SPSC_ATOMIC_INCLUDED #define ETL_BIP_BUFFER_SPSC_ATOMIC_INCLUDED @@ -22,379 +51,442 @@ #include "error_handler.h" #include "span.h" -#if ETL_HAS_ATOMIC +#if ETL_HAS_ATOMIC && ETL_CPP11_SUPPORTED namespace etl { - class bip_buffer_exception: public exception + //*************************************************************************** + /// Base exception for a bip buffer. + //*************************************************************************** + class bip_buffer_exception: public exception + { + public: + + bip_buffer_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) { - public: - bip_buffer_exception(string_type reason_, string_type file_name_, numeric_type line_number_) - : exception(reason_, file_name_, line_number_) - { - } - }; + } + }; - class bip_buffer_reserve_invalid: public bip_buffer_exception + //*************************************************************************** + /// Exception for an invalid reserve. + //*************************************************************************** + class bip_buffer_reserve_invalid: public bip_buffer_exception + { + public: + + bip_buffer_reserve_invalid(string_type file_name_, numeric_type line_number_) + : bip_buffer_exception("bip_buffer:reserve", file_name_, line_number_) { - public: - bip_buffer_reserve_invalid(string_type file_name_, numeric_type line_number_) - : bip_buffer_exception("bip_buffer:reserve", file_name_, line_number_) - { - } - }; + } + }; - template - class bip_buffer_spsc_atomic_base + //*************************************************************************** + /// The common base for a bip_buffer_spsc_atomic_base. + //*************************************************************************** + template + class bip_buffer_spsc_atomic_base + { + public: + + /// The type used for determining the size of buffer. + typedef typename etl::size_type_lookup::type size_type; + + //************************************************************************* + /// Returns true if the buffer is empty. + //************************************************************************* + bool empty() const { - public: - /// The type used for determining the size of buffer. - typedef typename etl::size_type_lookup::type size_type; + return size() == 0; + } - bool empty() const + //************************************************************************* + /// Returns true if the buffer is full. + //************************************************************************* + bool full() const + { + return available() == 0; + } + + //************************************************************************* + /// Returns the total used size, which may be split in two blocks + /// so the size will always be smaller after a read commit. + //************************************************************************* + size_type size() const + { + size_type write_index = write.load(etl::memory_order_acquire); + size_type read_index = read.load(etl::memory_order_acquire); + + // no wraparound + if (write_index >= read_index) + { + // size is distance between read and write + return write_index - read_index; + } + else + { + size_type last_index = last.load(etl::memory_order_acquire); + + // size is distance between beginning and write, plus read and last + return (write_index - 0) + (last_index - read_index); + } + } + + //************************************************************************* + /// Returns the largest contiguous available block size. + //************************************************************************* + size_type available() const + { + size_type write_index = write.load(etl::memory_order_acquire); + size_type read_index = read.load(etl::memory_order_acquire); + + // no wraparound + if (write_index >= read_index) + { + size_type forward_size = capacity() - write_index; + + // check if there's more space if wrapping around + if (read_index > (forward_size + 1)) { - return size() == 0; + return read_index - 1; } - - bool full() const + else { - return available() == 0; + return forward_size; } + } + else // read_index > write_index + { + return read_index - write_index - 1; + } + } - // returns the total used size, which may be split in two blocks - // so the size will always be smaller after a read commit - size_type size() const + //************************************************************************* + /// Returns the maximum capacity of the buffer. + //************************************************************************* + size_type capacity() const + { + return RESERVED; + } + + //************************************************************************* + /// Returns the maximum size of the buffer. + //************************************************************************* + size_type max_size() const + { + return RESERVED; + } + + //************************************************************************* + /// Clears the buffer. + //************************************************************************* + void clear() + { + read.store(0, etl::memory_order_release); + write.store(0, etl::memory_order_release); + last.store(0, etl::memory_order_release); + } + + protected: + + //************************************************************************* + /// Construccts the buffer. + //************************************************************************* + bip_buffer_spsc_atomic_base(size_type reserved_) + : read(0) + , write(0) + , last(0) + , RESERVED(reserved_) + { + } + + //************************************************************************* + size_type get_write_reserve(size_type* psize) + { + size_type write_index = write.load(etl::memory_order_relaxed); + size_type read_index = read.load(etl::memory_order_acquire); + + // No wraparound + if (write_index >= read_index) + { + size_type forward_size = capacity() - write_index; + + // We still fit in linearly + if (*psize <= forward_size) { - size_type write_index = write.load(etl::memory_order_acquire); - size_type read_index = read.load(etl::memory_order_acquire); - - // no wraparound - if (write_index >= read_index) + return write_index; + } + // There isn't more space even when wrapping around + else if (read_index <= (forward_size + 1)) + { + *psize = forward_size; + return write_index; + } + // Better wrap around now + else + { + // Check if size fits. + // When wrapping, the write index cannot reach read index, + // then we'd not be able to distinguish wrapped situation from linear. + if (*psize >= read_index) + { + if (read_index > 0) { - // size is distance between read and write - return write_index - read_index; + *psize = read_index - 1; } else { - size_type last_index = last.load(etl::memory_order_acquire); - - // size is distance between beginning and write, plus read and last - return (write_index - 0) + (last_index - read_index); + *psize = 0; } - } + } - // returns the largest contiguous(!) available block size - size_type available() const + return 0; + } + } + else // read_index > write_index + { + // Doesn't fit + if ((write_index + *psize) >= read_index) { - size_type write_index = write.load(etl::memory_order_acquire); - size_type read_index = read.load(etl::memory_order_acquire); - - // no wraparound - if (write_index >= read_index) - { - size_type forward_size = capacity() - write_index; - - // check if there's more space if wrapping around - if (read_index > (forward_size + 1)) - { - return read_index - 1; - } - else - { - return forward_size; - } - } - else // read_index > write_index - { - return read_index - write_index - 1; - } + *psize = read_index - write_index - 1; } - size_type capacity() const + return write_index; + } + } + + //************************************************************************* + void apply_write_reserve(size_type windex, size_type wsize) + { + if (wsize > 0) + { + size_type write_index = write.load(etl::memory_order_relaxed); + size_type read_index = read.load(etl::memory_order_acquire); + + // Wrapped around already + if (write_index < read_index) { - return RESERVED; + ETL_ASSERT_AND_RETURN((windex == write_index) && ((wsize + 1) <= read_index), ETL_ERROR(bip_buffer_reserve_invalid)); } - - size_type max_size() const + // No wraparound so far, also not wrapping around with this block + else if (windex == write_index) { - return RESERVED; - } + ETL_ASSERT_AND_RETURN(wsize <= (capacity() - write_index), ETL_ERROR(bip_buffer_reserve_invalid)); - void clear() + // Move both indexes forward + last.store(windex + wsize, etl::memory_order_release); + } + // Wrapping around now + else { - read.store(0, etl::memory_order_release); - write.store(0, etl::memory_order_release); - last.store(0, etl::memory_order_release); + ETL_ASSERT_AND_RETURN((windex == 0) && ((wsize + 1) <= read_index), ETL_ERROR(bip_buffer_reserve_invalid)); } + + // Always update write index + write.store(windex + wsize, etl::memory_order_release); + } + } - protected: - bip_buffer_spsc_atomic_base(size_type reserved_) - : read(0), - write(0), - last(0), - RESERVED(reserved_) + //************************************************************************* + size_type get_read_reserve(size_type* psize) + { + size_type read_index = read.load(etl::memory_order_relaxed); + size_type write_index = write.load(etl::memory_order_acquire); + + if (read_index > write_index) + { + // Writer has wrapped around + size_type last_index = last.load(etl::memory_order_relaxed); + + if (read_index == last_index) { + // Reader reached the end, start read from 0 + read_index = 0; } - - size_type get_write_reserve(size_type* psize) + else // (read_index < last_index) { - size_type write_index = write.load(etl::memory_order_relaxed); - size_type read_index = read.load(etl::memory_order_acquire); - - // no wraparound - if (write_index >= read_index) - { - size_type forward_size = capacity() - write_index; - - // we still fit in linearly - if (*psize <= forward_size) - { - return write_index; - } - // there isn't more space even when wrapping around - else if (read_index <= (forward_size + 1)) - { - *psize = forward_size; - return write_index; - } - // better wrap around now - else - { - // check if size fits - // when wrapping, the write index cannot reach read index, - // then we'd not be able to distinguish wrapped situation from linear - if (*psize >= read_index) - { - if (read_index > 0) - { - *psize = read_index - 1; - } - else - { - *psize = 0; - } - } - return 0; - } - } - else // read_index > write_index - { - // doesn't fit - if ((write_index + *psize) >= read_index) - { - *psize = read_index - write_index - 1; - } - return write_index; - } + // Use the remaining buffer at the end + write_index = last_index; } + } + else + { + // No wraparound, nothing to adjust + } - void apply_write_reserve(size_type windex, size_type wsize) - { - if (wsize > 0) - { - size_type write_index = write.load(etl::memory_order_relaxed); - size_type read_index = read.load(etl::memory_order_acquire); + // Limit to max available size + if ((write_index - read_index) < *psize) + { + *psize = write_index - read_index; + } - // wrapped around already - if (write_index < read_index) - { - ETL_ASSERT_AND_RETURN((windex == write_index) && ((wsize + 1) <= read_index), - ETL_ERROR(bip_buffer_reserve_invalid)); - } - // no wraparound so far, also not wrapping around with this block - else if (windex == write_index) - { - ETL_ASSERT_AND_RETURN(wsize <= (capacity() - write_index), - ETL_ERROR(bip_buffer_reserve_invalid)); + return read_index; + } - // move both indexes forward - last.store(windex + wsize, etl::memory_order_release); - } - // wrapping around now - else - { - ETL_ASSERT_AND_RETURN((windex == 0) && ((wsize + 1) <= read_index), - ETL_ERROR(bip_buffer_reserve_invalid)); - } - // always update write index - write.store(windex + wsize, etl::memory_order_release); - } - } + //************************************************************************* + void apply_read_reserve(size_type rindex, size_type rsize) + { + if (rsize > 0) + { + size_type rsize_checker = rsize; + ETL_ASSERT_AND_RETURN((rindex == get_read_reserve(&rsize_checker)) && (rsize == rsize_checker), ETL_ERROR(bip_buffer_reserve_invalid)); - size_type get_read_reserve(size_type* psize) - { - size_type read_index = read.load(etl::memory_order_relaxed); - size_type write_index = write.load(etl::memory_order_acquire); + read.store(rindex + rsize, etl::memory_order_release); + } + } - if (read_index > write_index) - { - // writer has wrapped around + private: - size_type last_index = last.load(etl::memory_order_relaxed); - if (read_index == last_index) - { - // reader reached the end, start read from 0 - read_index = 0; - } - else // (read_index < last_index) - { - // use the remaining buffer at the end - write_index = last_index; - } - } - else - { - // no wraparound, nothing to adjust - } - - // limit to max available size - if ((write_index - read_index) < *psize) - { - *psize = write_index - read_index; - } - return read_index; - } - - void apply_read_reserve(size_type rindex, size_type rsize) - { - if (rsize > 0) - { - size_type rsize_checker = rsize; - ETL_ASSERT_AND_RETURN((rindex == get_read_reserve(&rsize_checker)) && (rsize == rsize_checker), - ETL_ERROR(bip_buffer_reserve_invalid)); - - read.store(rindex + rsize, etl::memory_order_release); - } - } - - private: - etl::atomic read; - etl::atomic write; - etl::atomic last; - const size_type RESERVED; + etl::atomic read; + etl::atomic write; + etl::atomic last; + const size_type RESERVED; #if defined(ETL_POLYMORPHIC_SPSC_BIP_BUFFER_ATOMIC) || defined(ETL_POLYMORPHIC_CONTAINERS) - public: - virtual ~bip_buffer_spsc_atomic_base() - { - } + public: + virtual ~bip_buffer_spsc_atomic_base() + { + } #else - protected: - ~bip_buffer_spsc_atomic_base() - { - } -#endif - }; + protected: - template - class ibip_buffer_spsc_atomic : public bip_buffer_spsc_atomic_base + ~bip_buffer_spsc_atomic_base() { - private: - typedef typename etl::bip_buffer_spsc_atomic_base base_t; - using base_t::get_read_reserve; - using base_t::apply_read_reserve; - using base_t::get_write_reserve; - using base_t::apply_write_reserve; - - public: - typedef T value_type; ///< The type stored in the buffer. - typedef T& reference; ///< A reference to the type used in the buffer. - typedef const T& const_reference; ///< A const reference to the type used in the buffer. -#if ETL_CPP11_SUPPORTED - typedef T&& rvalue_reference;///< An rvalue_reference to the type used in the buffer. + } #endif - typedef typename base_t::size_type size_type; ///< The type used for determining the size of the buffer. + }; - // reserves a memory area for reading up to the max_reserve_size - span read_reserve(size_type max_reserve_size) - { - size_type reserve_size = max_reserve_size; - auto rindex = get_read_reserve(&reserve_size); - return span(p_buffer + rindex, reserve_size); - } + //*************************************************************************** + /// A fixed capacity bipartite buffer. + //*************************************************************************** + template + class ibip_buffer_spsc_atomic : public bip_buffer_spsc_atomic_base + { + private: + + typedef typename etl::bip_buffer_spsc_atomic_base base_t; + using base_t::get_read_reserve; + using base_t::apply_read_reserve; + using base_t::get_write_reserve; + using base_t::apply_write_reserve; - // commits the previously reserved read memory area - // the reserve can be trimmed at the end before committing - // throws bip_buffer_reserve_invalid - void read_commit(const span &reserve) - { - size_type rindex = etl::distance(p_buffer, reserve.data()); - apply_read_reserve(rindex, reserve.size()); - } + public: + + typedef T value_type; ///< The type stored in the buffer. + typedef T& reference; ///< A reference to the type used in the buffer. + typedef const T& const_reference; ///< A const reference to the type used in the buffer. +#if ETL_CPP11_SUPPORTED + typedef T&& rvalue_reference;///< An rvalue_reference to the type used in the buffer. +#endif + typedef typename base_t::size_type size_type; ///< The type used for determining the size of the buffer. - // reserves a memory area for writing up to the max_reserve_size - span write_reserve(size_type max_reserve_size) - { - size_type reserve_size = max_reserve_size; - auto windex = get_write_reserve(&reserve_size); - return span(p_buffer + windex, reserve_size); - } + //************************************************************************* + // Reserves a memory area for reading up to the max_reserve_size + //************************************************************************* + span read_reserve(size_type max_reserve_size) + { + size_type reserve_size = max_reserve_size; + auto rindex = get_read_reserve(&reserve_size); + + return span(p_buffer + rindex, reserve_size); + } - // commits the previously reserved write memory area - // the reserve can be trimmed at the end before committing - // throws bip_buffer_reserve_invalid - void write_commit(const span &reserve) - { - size_type windex = etl::distance(p_buffer, reserve.data()); - apply_write_reserve(windex, reserve.size()); - } + //************************************************************************* + // Commits the previously reserved read memory area + // the reserve can be trimmed at the end before committing. + // Throws bip_buffer_reserve_invalid + //************************************************************************* + void read_commit(const span &reserve) + { + size_type rindex = etl::distance(p_buffer, reserve.data()); + apply_read_reserve(rindex, reserve.size()); + } - protected: - ibip_buffer_spsc_atomic(T* p_buffer_, size_type reserved_) - : base_t(reserved_), - p_buffer(p_buffer_) - { - } + //************************************************************************* + // Reserves a memory area for writing up to the max_reserve_size + //************************************************************************* + span write_reserve(size_type max_reserve_size) + { + size_type reserve_size = max_reserve_size; + auto windex = get_write_reserve(&reserve_size); + + return span(p_buffer + windex, reserve_size); + } - private: - // Disable copy construction and assignment. - ibip_buffer_spsc_atomic(const ibip_buffer_spsc_atomic&) ETL_DELETE; - ibip_buffer_spsc_atomic& operator =(const ibip_buffer_spsc_atomic&) ETL_DELETE; + //************************************************************************* + // Commits the previously reserved write memory area + // the reserve can be trimmed at the end before committing. + // Throws bip_buffer_reserve_invalid + //************************************************************************* + void write_commit(const span &reserve) + { + size_type windex = etl::distance(p_buffer, reserve.data()); + apply_write_reserve(windex, reserve.size()); + } + + protected: + + //************************************************************************* + ibip_buffer_spsc_atomic(T* p_buffer_, size_type reserved_) + : base_t(reserved_) + , p_buffer(p_buffer_) + { + } + + private: + + // Disable copy construction and assignment. + ibip_buffer_spsc_atomic(const ibip_buffer_spsc_atomic&) ETL_DELETE; + ibip_buffer_spsc_atomic& operator =(const ibip_buffer_spsc_atomic&) ETL_DELETE; #if ETL_CPP11_SUPPORTED - ibip_buffer_spsc_atomic(ibip_buffer_spsc_atomic&&) = delete; - ibip_buffer_spsc_atomic& operator =(ibip_buffer_spsc_atomic&&) = delete; + ibip_buffer_spsc_atomic(ibip_buffer_spsc_atomic&&) = delete; + ibip_buffer_spsc_atomic& operator =(ibip_buffer_spsc_atomic&&) = delete; #endif - T* const p_buffer; - }; + const T* p_buffer; + }; - //*************************************************************************** - /// A fixed capacity bipartite buffer. - /// This buffer supports concurrent access by one producer and one consumer. - /// \tparam T The type this buffer should support. - /// \tparam SIZE The maximum capacity of the buffer. - /// \tparam MEMORY_MODEL The memory model for the buffer. Determines the type of the internal counter variables. - //*************************************************************************** - template - class bip_buffer_spsc_atomic : public ibip_buffer_spsc_atomic + //*************************************************************************** + /// A fixed capacity bipartite buffer. + /// This buffer supports concurrent access by one producer and one consumer. + /// \tparam T The type this buffer should support. + /// \tparam SIZE The maximum capacity of the buffer. + /// \tparam MEMORY_MODEL The memory model for the buffer. Determines the type of the internal counter variables. + //*************************************************************************** + template + class bip_buffer_spsc_atomic : public ibip_buffer_spsc_atomic + { + private: + + typedef typename etl::ibip_buffer_spsc_atomic base_t; + + public: + + typedef typename base_t::size_type size_type; + + private: + + static ETL_CONSTANT size_type RESERVED_SIZE = size_type(SIZE); + + public: + + ETL_STATIC_ASSERT((SIZE <= (etl::integral_limits::max)), "Size too large for memory model"); + + static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); + + bip_buffer_spsc_atomic() + : base_t(reinterpret_cast(&buffer[0]), RESERVED_SIZE) { - private: - typedef typename etl::ibip_buffer_spsc_atomic base_t; + } - public: - typedef typename base_t::size_type size_type; + private: - private: - static const size_type RESERVED_SIZE = size_type(SIZE); - - public: - ETL_STATIC_ASSERT((SIZE <= (etl::integral_limits::max)), "Size too large for memory model"); - - static const size_type MAX_SIZE = size_type(SIZE); - - bip_buffer_spsc_atomic() - : base_t(reinterpret_cast(&buffer[0]), RESERVED_SIZE) - { - } - - private: - - /// The uninitialised buffer of T used in the bip_buffer_spsc. - typename etl::aligned_storage::value>::type buffer[RESERVED_SIZE]; - }; + /// The uninitialised buffer of T used in the bip_buffer_spsc. + etl::uninitialized_buffer_of buffer; + }; } -#endif /* ETL_HAS_ATOMIC */ +#endif /* ETL_HAS_ATOMIC && ETL_CPP11_SUPPORTED */ #endif /* ETL_BIP_BUFFER_SPSC_ATOMIC_INCLUDED */ diff --git a/test/sanity-check/bip_buffer_spsc_atomic.h.t.cpp b/test/sanity-check/bip_buffer_spsc_atomic.h.t.cpp new file mode 100644 index 00000000..d3c54920 --- /dev/null +++ b/test/sanity-check/bip_buffer_spsc_atomic.h.t.cpp @@ -0,0 +1,29 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 John Wellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include diff --git a/test/sanity-check/c++03/CMakeLists.txt b/test/sanity-check/c++03/CMakeLists.txt index 5347a376..ff78e74f 100644 --- a/test/sanity-check/c++03/CMakeLists.txt +++ b/test/sanity-check/c++03/CMakeLists.txt @@ -33,6 +33,7 @@ target_sources(t98 PRIVATE etl_profile.h ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp ../binary.h.t.cpp + ../bip_buffer_spsc_atomic.h.t.cpp ../bitset.h.t.cpp ../bit_stream.h.t.cpp ../bloom_filter.h.t.cpp diff --git a/test/sanity-check/c++11/CMakeLists.txt b/test/sanity-check/c++11/CMakeLists.txt index 087c9085..aa401782 100644 --- a/test/sanity-check/c++11/CMakeLists.txt +++ b/test/sanity-check/c++11/CMakeLists.txt @@ -33,6 +33,7 @@ target_sources(t11 PRIVATE etl_profile.h ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp ../binary.h.t.cpp + ../bip_buffer_spsc_atomic.h.t.cpp ../bitset.h.t.cpp ../bit_stream.h.t.cpp ../bloom_filter.h.t.cpp diff --git a/test/sanity-check/c++14/CMakeLists.txt b/test/sanity-check/c++14/CMakeLists.txt index fd9a2e2e..40996189 100644 --- a/test/sanity-check/c++14/CMakeLists.txt +++ b/test/sanity-check/c++14/CMakeLists.txt @@ -33,6 +33,7 @@ target_sources(t14 PRIVATE etl_profile.h ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp ../binary.h.t.cpp + ../bip_buffer_spsc_atomic.h.t.cpp ../bitset.h.t.cpp ../bit_stream.h.t.cpp ../bloom_filter.h.t.cpp diff --git a/test/sanity-check/c++17/CMakeLists.txt b/test/sanity-check/c++17/CMakeLists.txt index 63d76bd3..81cdbb4a 100644 --- a/test/sanity-check/c++17/CMakeLists.txt +++ b/test/sanity-check/c++17/CMakeLists.txt @@ -33,6 +33,7 @@ target_sources(t17 PRIVATE etl_profile.h ../basic_string.h.t.cpp ../basic_string_stream.h.t.cpp ../binary.h.t.cpp + ../bip_buffer_spsc_atomic.h.t.cpp ../bitset.h.t.cpp ../bit_stream.h.t.cpp ../bloom_filter.h.t.cpp diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 8a0ac45e..c010d82a 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -2029,6 +2029,23 @@ true true + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true true diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 07cbbfa0..3cb7534e 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2894,6 +2894,9 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + From 3363da4f91ad8045afd423e6fcd62c8b06b22b1a Mon Sep 17 00:00:00 2001 From: Benedek Kupper <57992871+bku-sue@users.noreply.github.com> Date: Fri, 16 Jul 2021 12:42:35 +0200 Subject: [PATCH 09/25] Feature/bip buffer spsc atomic (#402 follow-up) (#404) * bip_buffer_spsc_atomic: fix compiler failure The previous commit changed the pointer being const (cannot change where the pointer is pointing after construction) to the referred data to be const (the buffer itself is not writeable), which causes compiler issue with the tests. Signed-off-by: Benedek Kupper * bip_buffer_spsc_atomic: whitespace cleanup for consistency Signed-off-by: Benedek Kupper * bip_buffer_spsc_atomic: clear() destroys the unread data Signed-off-by: Benedek Kupper * bip_buffer_spsc_atomic: add destructor Signed-off-by: Benedek Kupper --- include/etl/bip_buffer_spsc_atomic.h | 60 +++++++++++++++++++++------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/include/etl/bip_buffer_spsc_atomic.h b/include/etl/bip_buffer_spsc_atomic.h index 100fc961..4b2427aa 100644 --- a/include/etl/bip_buffer_spsc_atomic.h +++ b/include/etl/bip_buffer_spsc_atomic.h @@ -45,6 +45,7 @@ SOFTWARE. #include "alignment.h" #include "parameter_type.h" #include "atomic.h" +#include "memory.h" #include "memory_model.h" #include "integral_limits.h" #include "utility.h" @@ -177,18 +178,8 @@ namespace etl return RESERVED; } - //************************************************************************* - /// Clears the buffer. - //************************************************************************* - void clear() - { - read.store(0, etl::memory_order_release); - write.store(0, etl::memory_order_release); - last.store(0, etl::memory_order_release); - } - protected: - + //************************************************************************* /// Construccts the buffer. //************************************************************************* @@ -200,6 +191,14 @@ namespace etl { } + //************************************************************************* + void reset() + { + read.store(0, etl::memory_order_release); + write.store(0, etl::memory_order_release); + last.store(0, etl::memory_order_release); + } + //************************************************************************* size_type get_write_reserve(size_type* psize) { @@ -344,6 +343,7 @@ namespace etl #if defined(ETL_POLYMORPHIC_SPSC_BIP_BUFFER_ATOMIC) || defined(ETL_POLYMORPHIC_CONTAINERS) public: + virtual ~bip_buffer_spsc_atomic_base() { } @@ -363,15 +363,16 @@ namespace etl class ibip_buffer_spsc_atomic : public bip_buffer_spsc_atomic_base { private: - + typedef typename etl::bip_buffer_spsc_atomic_base base_t; + using base_t::reset; using base_t::get_read_reserve; using base_t::apply_read_reserve; using base_t::get_write_reserve; using base_t::apply_write_reserve; public: - + typedef T value_type; ///< The type stored in the buffer. typedef T& reference; ///< A reference to the type used in the buffer. typedef const T& const_reference; ///< A const reference to the type used in the buffer. @@ -380,6 +381,8 @@ namespace etl #endif typedef typename base_t::size_type size_type; ///< The type used for determining the size of the buffer. + using base_t::max_size; + //************************************************************************* // Reserves a memory area for reading up to the max_reserve_size //************************************************************************* @@ -424,6 +427,24 @@ namespace etl apply_write_reserve(windex, reserve.size()); } + //************************************************************************* + /// Clears the buffer, destructing any elements that haven't been read. + //************************************************************************* + void clear() + { + // the buffer might be split into two contiguous blocks + for (auto reader = read_reserve(max_size()); reader.size() > 0; reader = read_reserve(max_size())) + { + destroy(reader.begin(), reader.end()); + read_commit(reader); + } + // now the buffer is already empty + // resetting the buffer here is beneficial to have + // the whole buffer available for a single block, + // but it requires synchronization between the writer and reader threads + reset(); + } + protected: //************************************************************************* @@ -444,7 +465,7 @@ namespace etl ibip_buffer_spsc_atomic& operator =(ibip_buffer_spsc_atomic&&) = delete; #endif - const T* p_buffer; + T* const p_buffer; }; //*************************************************************************** @@ -475,11 +496,22 @@ namespace etl static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); + //************************************************************************* + /// Default constructor. + //************************************************************************* bip_buffer_spsc_atomic() : base_t(reinterpret_cast(&buffer[0]), RESERVED_SIZE) { } + //************************************************************************* + /// Destructor. + //************************************************************************* + ~bip_buffer_spsc_atomic() + { + base_t::clear(); + } + private: /// The uninitialised buffer of T used in the bip_buffer_spsc. From b5c282699d6593406d08f3bb13fc4d2d6c0981e3 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 26 Jul 2021 17:17:22 +0100 Subject: [PATCH 10/25] Type traits refactor --- test/vs2019/etl.vcxproj | 2 +- test/vs2019/etl.vcxproj.filters | 399 ++++++++------------------------ 2 files changed, 102 insertions(+), 299 deletions(-) diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index c010d82a..3aa5ff29 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -6306,7 +6306,7 @@ true true - + true true true diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 3cb7534e..f9fa5ce1 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2054,6 +2054,106 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -2564,300 +2664,6 @@ Source Files\Sanity Checks - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\Sanity Checks - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - Source Files\Sanity Checks @@ -2867,7 +2673,7 @@ Source Files\Sanity Checks - + Source Files\Sanity Checks @@ -2894,9 +2700,6 @@ Source Files\Sanity Checks - - Source Files\Sanity Checks - From 53ad78768fd3c552842190cce79a9ad40bba66bd Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 29 Jul 2021 14:15:49 +0100 Subject: [PATCH 11/25] Changed variant files names --- test/vs2019/etl.vcxproj | 2 +- test/vs2019/etl.vcxproj.filters | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 3aa5ff29..c010d82a 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -6306,7 +6306,7 @@ true true - + true true true diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index f9fa5ce1..6187d860 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2673,7 +2673,7 @@ Source Files\Sanity Checks - + Source Files\Sanity Checks From 8181cec7675c19324baab97942439174cb10237d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 4 Aug 2021 10:27:22 +0100 Subject: [PATCH 12/25] Updated version numbers --- include/etl/version.h | 4 ++-- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- support/Release notes.txt | 5 +++++ 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 3d86d6ee..581d4f6b 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,8 +38,8 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 14 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_MINOR 15 +#define ETL_VERSION_PATCH 0 #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) diff --git a/library.json b/library.json index e6ec5ef2..98bbae72 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.14.1", + "version": "20.15.0", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index ec1698a8..d09ea365 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.14.1 +version=20.15.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index f5ac7c02..96086037 100644 --- a/meson.build +++ b/meson.build @@ -8,7 +8,7 @@ project('PROJECT_NAME', 'cpp_std=c++17', 'build.cpp_std=c++17', ], meson_version: '>=0.54.0', - version: '20.14.1' + version: '20.15.0' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index f815aadf..bd97feba 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +20.15.0 +Added a Bipartite buffer, by Benedek Kupper. +etl::bip_buffer_spsc_atomic + =============================================================================== 20.14.1 Changed std::forward to etl::forward in etl::variant (variadic) From 79ffe63b1c05d2d4a43c00fa17193979890c2eee Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 4 Aug 2021 18:47:42 +0100 Subject: [PATCH 13/25] Refactoring of type traits for GCC compatibility --- .github/workflows/clang.yml | 10 +- .github/workflows/gcc.yml | 6 +- .github/workflows/vs2019.yml | 6 +- include/etl/type_traits.h | 118 ++++- test/CMakeLists.txt | 10 + test/runsanitychecks.sh | 258 +++++----- test/runtests.sh | 78 +-- test/sanity-check/c++03/CMakeLists.txt | 10 + test/sanity-check/c++11/CMakeLists.txt | 10 + test/sanity-check/c++14/CMakeLists.txt | 10 + test/sanity-check/c++17/CMakeLists.txt | 10 + test/test_type_traits.cpp | 4 + test/test_vector_non_trivial.cpp | 3 +- test/vs2019/etl.sln | 24 +- test/vs2019/etl.vcxproj | 669 ++++++++++++++++++++++++- test/vs2019/etl.vcxproj.filters | 8 +- 16 files changed, 1007 insertions(+), 227 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index ea07e377..71e06811 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -1,7 +1,7 @@ name: clang on: push: - branches: [ master ] + branches: [ master, development ] pull_request: branches: [ master ] @@ -22,7 +22,7 @@ jobs: sudo apt-get install -y "clang-9" "lldb-9" "lld-9" "clang-format-9" export CC=clang-9 export CXX=clang++-9 - cmake -D BUILD_TESTS=ON ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF ./ clang --version make @@ -41,7 +41,7 @@ jobs: - name: Build run: | - cmake -DBUILD_TESTS=ON -DNO_STL=ON ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF ./ gcc --version make @@ -62,7 +62,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -D BUILD_TESTS=ON ./ + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF ./ clang --version make @@ -83,7 +83,7 @@ jobs: run: | export CC=clang export CXX=clang++ - cmake -D BUILD_TESTS=ON -DNO_STL=ON ./ + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF ./ clang --version make diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index 5e1ea8f1..0870442b 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -1,7 +1,7 @@ name: gcc on: push: - branches: [ master ] + branches: [ master, development ] pull_request: branches: [ master ] @@ -18,7 +18,7 @@ jobs: - name: Build run: | - cmake -DBUILD_TESTS=ON ./ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF ./ gcc --version make @@ -37,7 +37,7 @@ jobs: - name: Build run: | - cmake -DBUILD_TESTS=ON -DNO_STL=ON ./ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF ./ gcc --version make diff --git a/.github/workflows/vs2019.yml b/.github/workflows/vs2019.yml index 8eedf4aa..11ee107f 100644 --- a/.github/workflows/vs2019.yml +++ b/.github/workflows/vs2019.yml @@ -1,7 +1,7 @@ name: vs2019 on: push: - branches: [ master] + branches: [ master, development ] pull_request: branches: [ master ] @@ -21,7 +21,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 16 2019" -DBUILD_TESTS=ON ./ + cmake -G "Visual Studio 16 2019" -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF ./ MSBuild.exe -version MSBuild.exe etl.sln @@ -43,7 +43,7 @@ jobs: - name: Build run: | - cmake -G "Visual Studio 16 2019" -DBUILD_TESTS=ON -DNO_STL=ON ./ + cmake -G "Visual Studio 16 2019" -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF ./ MSBuild.exe -version MSBuild.exe etl.sln diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 82bf041d..a9fad8cf 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -1559,7 +1559,7 @@ namespace etl struct is_trivially_constructible; #endif - //*************************************************************************** + //********************************************* // is_trivially_copy_constructible #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template @@ -1579,7 +1579,7 @@ namespace etl struct is_trivially_copy_constructible; #endif - //*************************************************************************** + //********************************************* // is_trivially_destructible #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template @@ -1599,7 +1599,7 @@ namespace etl struct is_trivially_destructible; #endif - //*************************************************************************** + //********************************************* // is_trivially_copy_assignable #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template @@ -1619,7 +1619,7 @@ namespace etl struct is_trivially_copy_assignable; #endif - //*************************************************************************** + //********************************************* // is_trivially_copyable #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template @@ -1644,27 +1644,45 @@ namespace etl //********************************************* // Use the compiler's builtins. //********************************************* - + //********************************************* // is_assignable template - struct is_assignable : public etl::bool_constant<__is_assignable(T1, T2)> + struct is_assignable { + static ETL_CONSTANT bool value = __is_assignable(T1, T2); }; -#if ETL_CPP11_SUPPORTED + #if ETL_CPP11_SUPPORTED //********************************************* // is_constructible template - struct is_constructible : public etl::bool_constant<__is_constructible(T, TArgs...)> + struct is_constructible { + static ETL_CONSTANT bool value = __is_constructible(T, TArgs...); }; -#endif + #else + //********************************************* + // is_constructible + template + struct is_constructible + { + static ETL_CONSTANT bool value = __is_constructible(T, TArgs); + }; + + //********************************************* + // is_constructible + template + struct is_constructible + { + static ETL_CONSTANT bool value = __is_constructible(T); + }; + #endif //********************************************* // is_copy_constructible template - struct is_copy_constructible : public etl::is_constructible> + struct is_copy_constructible : public etl::is_constructible::type> { }; @@ -1675,39 +1693,85 @@ namespace etl { }; +#if ETL_CPP11_SUPPORTED + //********************************************* + // is_trivially_constructible + template + struct is_trivially_constructible + { + #if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_constructor(T); + #else + static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs...); + #endif + }; +#else + //********************************************* + // is_trivially_constructible + template + struct is_trivially_constructible + { +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_constructor(T); +#else + static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs); +#endif + }; + //********************************************* // is_trivially_constructible template - struct is_trivially_constructible : public etl::bool_constant<__is_trivially_constructible(T)> + struct is_trivially_constructible { +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_constructor(T); +#else + static ETL_CONSTANT bool value = __is_trivially_constructible(T); +#endif }; +#endif - //*************************************************************************** + //********************************************* // is_trivially_copy_constructible template - struct is_trivially_copy_constructible : public etl::bool_constant<__is_trivially_copyable(T)> + struct is_trivially_copy_constructible : public is_trivially_constructible::type> { }; - //*************************************************************************** + //********************************************* // is_trivially_destructible template - struct is_trivially_destructible : public etl::bool_constant<__is_trivially_destructible(T)> + struct is_trivially_destructible { + #if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_destructor(T); + #else + static ETL_CONSTANT bool value = __is_trivially_destructible(T); + #endif }; - //*************************************************************************** + //********************************************* // is_trivially_copy_assignable template - struct is_trivially_copy_assignable : public etl::bool_constant<__is_trivially_copyable(T)> + struct is_trivially_copy_assignable { + #if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_copy(T); + #else + static ETL_CONSTANT bool value = __is_trivially_copyable(T); + #endif }; - //*************************************************************************** + //********************************************* // is_trivially_copyable template - struct is_trivially_copyable : public etl::bool_constant<__is_trivially_copyable(T)> + struct is_trivially_copyable { + #if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_copy(T); + #else + static ETL_CONSTANT bool value = __is_trivially_copyable(T); + #endif }; #elif defined(ETL_USER_DEFINED_TYPE_TRAITS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) @@ -1791,7 +1855,7 @@ namespace etl template struct is_trivially_constructible; - //*************************************************************************** + //********************************************* // is_trivially_copy_constructible template ::value || etl::is_pointer::value> struct is_trivially_copy_constructible; @@ -1804,7 +1868,7 @@ namespace etl template struct is_trivially_copy_constructible; - //*************************************************************************** + //********************************************* // is_trivially_destructible template ::value || etl::is_pointer::value> struct is_trivially_destructible; @@ -1817,7 +1881,7 @@ namespace etl template struct is_trivially_destructible; - //*************************************************************************** + //********************************************* // is_trivially_copy_assignable template ::value || etl::is_pointer::value> struct is_trivially_copy_assignable; @@ -1830,7 +1894,7 @@ namespace etl template struct is_trivially_copy_assignable; - //*************************************************************************** + //********************************************* // is_trivially_copyable template ::value || etl::is_pointer::value> struct is_trivially_copyable; @@ -1887,28 +1951,28 @@ namespace etl { }; - //*************************************************************************** + //********************************************* // is_trivially_copy_constructible template struct is_trivially_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - //*************************************************************************** + //********************************************* // is_trivially_destructible template struct is_trivially_destructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - //*************************************************************************** + //********************************************* // is_trivially_copy_assignable template struct is_trivially_copy_assignable : public etl::bool_constant::value || etl::is_pointer::value> { }; - //*************************************************************************** + //********************************************* // is_trivially_copyable template struct is_trivially_copyable : public etl::bool_constant::value || etl::is_pointer::value> diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a9780307..022d6608 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,6 +12,16 @@ else() message(STATUS "Compiling for STL") endif() +if (ETL_USE_TYPE_TRAITS_BUILTINS) + message(STATUS "Compiling for built-in type traits") + add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS) +endif() + +if (ETL_USER_DEFINED_TYPE_TRAITS) + message(STATUS "Compiling for user defined type traits") + add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS) +endif() + if(NOT UnitTest++_FOUND) # Add unittest-cpp as an ExternalProject include(cmake/unit-test_external_project.cmake) diff --git a/test/runsanitychecks.sh b/test/runsanitychecks.sh index 42f7adbb..a0de3ff3 100755 --- a/test/runsanitychecks.sh +++ b/test/runsanitychecks.sh @@ -13,45 +13,45 @@ echo "-----------------------------------------------" echo " C++03" echo "-----------------------------------------------" -echo "GCC - STL"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "GCC - STL"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "GCC - No STL"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL - Builtins"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "GCC - No STL - Builtins"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL - User defined traits"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +##{ echo ""; echo "GCC - No STL - User defined traits"; } | tee -a ../log.txt +#g++ --version | head --lines=1 | tee -a ../log.txt +#CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +#cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - STL"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - STL"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - No STL"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL - Builtins"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - No STL - Builtins"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL - User defined traits"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +##{ echo ""; echo "Clang - No STL - User defined traits"; } | tee -a ../log.txt +#clang++ --version | head --lines=1 | tee -a ../log.txt +#CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +#cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ############################################################################### cd ../c++11 || exit 1 @@ -61,45 +61,45 @@ echo "-----------------------------------------------" echo " C++11" echo "-----------------------------------------------" -echo "GCC - STL"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "GCC - STL"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "GCC - No STL"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL - Builtins"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "GCC - No STL - Builtins"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL - User defined traits"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +##{ echo ""; echo "GCC - No STL - User defined traits"; } | tee -a ../log.txt +#g++ --version | head --lines=1 | tee -a ../log.txt +#CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +#cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - STL"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - STL"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - No STL"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL - Builtins"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - No STL - Builtins"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL - User defined traits"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +##{ echo ""; echo "Clang - No STL - User defined traits"; } | tee -a ../log.txt +#clang++ --version | head --lines=1 | tee -a ../log.txt +#CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +#cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ############################################################################### cd ../c++14 || exit 1 @@ -109,45 +109,45 @@ echo "-----------------------------------------------" echo " C++14" echo "-----------------------------------------------" -echo "GCC - STL"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "GCC - STL"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "GCC - No STL"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL - Builtins"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "GCC - No STL - Builtins"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL - User defined traits"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +##{ echo ""; echo "GCC - No STL - User defined traits"; } | tee -a ../log.txt +#g++ --version | head --lines=1 | tee -a ../log.txt +#CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +#cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - STL"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - STL"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - No STL"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL - Builtins"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - No STL - Builtins"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL - User defined traits"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +##{ echo ""; echo "Clang - No STL - User defined traits"; } | tee -a ../log.txt +#clang++ --version | head --lines=1 | tee -a ../log.txt +#CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +#cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ############################################################################### cd ../c++17 || exit 1 @@ -157,47 +157,47 @@ echo "-----------------------------------------------" echo " C++17 " echo "-----------------------------------------------" -echo "GCC - STL"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "GCC - STL"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "GCC - No STL"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL - Builtins"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "GCC - No STL - Builtins"; } | tee -a ../log.txt +g++ --version | head --lines=1 | tee -a ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "GCC - No STL - User defined traits"; } >> ../log.txt -g++ --version | head --lines=1 >> ../log.txt -CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt +##{ echo ""; echo "GCC - No STL - User defined traits"; } | tee -a ../log.txt +#g++ --version | head --lines=1 | tee -a ../log.txt +#CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +#cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - STL"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - STL"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - No STL"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL - Builtins"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +{ echo ""; echo "Clang - No STL - Builtins"; } | tee -a ../log.txt +clang++ --version | head --lines=1 | tee -a ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt -{ echo ""; echo "Clang - No STL - User defined traits"; } >> ../log.txt -clang++ --version | head --lines=1 >> ../log.txt -CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt +##{ echo ""; echo "Clang - No STL - User defined traits"; } | tee -a ../log.txt +#clang++ --version | head --lines=1 | tee -a ../log.txt +#CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +#cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt { echo "" echo "-----------------------------------------------" echo " Completed" -echo "-----------------------------------------------"; } >> ../log.txt +echo "-----------------------------------------------"; } | tee -a ../log.txt diff --git a/test/runtests.sh b/test/runtests.sh index 51feeff5..9bbb9c4f 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -4,54 +4,54 @@ cd build || exit 1 echo "ETL Tests" > log.txt echo "" -echo "-----------------------------------------------" >> log.txt -echo " GCC" >> log.txt -echo "-----------------------------------------------" >> log.txt -gcc --version | grep gcc >> log.txt -CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=OFF .. -make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "-----------------------------------------------" | tee -a log.txt +echo " GCC" | tee -a log.txt +echo "-----------------------------------------------" | tee -a log.txt +gcc --version | grep gcc | tee -a log.txt +CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> log.txt -echo " GCC - No STL" >> log.txt -echo "-----------------------------------------------" >> log.txt -gcc --version | grep gcc >> log.txt -CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON .. -make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "-----------------------------------------------" | tee -a log.txt +echo " GCC - No STL" | tee -a log.txt +echo "-----------------------------------------------" | tee -a log.txt +gcc --version | grep gcc | tee -a log.txt +CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> log.txt -echo " GCC - No STL - Builtins" >> log.txt -echo "-----------------------------------------------" >> log.txt -gcc --version | grep gcc >> log.txt -CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "-----------------------------------------------" | tee -a log.txt +echo " GCC - No STL - Builtins" | tee -a log.txt +echo "-----------------------------------------------" | tee -a log.txt +gcc --version | grep gcc | tee -a log.txt +CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> log.txt -echo " Clang" >> log.txt -echo "-----------------------------------------------" >> log.txt -clang --version | grep clang >> log.txt -CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=OFF .. -make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "-----------------------------------------------" | tee -a log.txt +echo " Clang" | tee -a log.txt +echo "-----------------------------------------------" | tee -a log.txt +clang --version | grep clang | tee -a log.txt +CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> log.txt -echo " Clang - No STL" >> log.txt -echo "-----------------------------------------------" >> log.txt -clang --version | grep clang >> log.txt -CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON .. -make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "-----------------------------------------------" | tee -a log.txt +echo " Clang - No STL" | tee -a log.txt +echo "-----------------------------------------------" | tee -a log.txt +clang --version | grep clang | tee -a log.txt +CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> log.txt -echo " Clang - No STL - Builtins" >> log.txt -echo "-----------------------------------------------" >> log.txt -clang --version | grep clang >> log.txt -CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. -make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +echo "-----------------------------------------------" | tee -a log.txt +echo " Clang - No STL - Builtins" | tee -a log.txt +echo "-----------------------------------------------" | tee -a log.txt +clang --version | grep clang | tee -a log.txt +CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. +make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt ./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> log.txt -echo " Tests Completed" >> log.txt -echo "-----------------------------------------------" >> log.txt +echo "-----------------------------------------------" | tee -a log.txt +echo " Tests Completed" | tee -a log.txt +echo "-----------------------------------------------" | tee -a log.txt diff --git a/test/sanity-check/c++03/CMakeLists.txt b/test/sanity-check/c++03/CMakeLists.txt index ff78e74f..eaea3524 100644 --- a/test/sanity-check/c++03/CMakeLists.txt +++ b/test/sanity-check/c++03/CMakeLists.txt @@ -12,6 +12,16 @@ else() message(STATUS "Compiling for STL") endif() +if (ETL_USE_TYPE_TRAITS_BUILTINS) + message(STATUS "Compiling for built-in type traits") + add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS) +endif() + +if (ETL_USER_DEFINED_TYPE_TRAITS) + message(STATUS "Compiling for user defined type traits") + add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS) +endif() + add_library(t98 OBJECT) target_compile_definitions(t98 PRIVATE __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS __STDC_FORMAT_MACROS) target_include_directories(t98 PRIVATE "") diff --git a/test/sanity-check/c++11/CMakeLists.txt b/test/sanity-check/c++11/CMakeLists.txt index aa401782..c9c2d2a3 100644 --- a/test/sanity-check/c++11/CMakeLists.txt +++ b/test/sanity-check/c++11/CMakeLists.txt @@ -12,6 +12,16 @@ else() message(STATUS "Compiling for STL") endif() +if (ETL_USE_TYPE_TRAITS_BUILTINS) + message(STATUS "Compiling for built-in type traits") + add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS) +endif() + +if (ETL_USER_DEFINED_TYPE_TRAITS) + message(STATUS "Compiling for user defined type traits") + add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS) +endif() + add_library(t11 OBJECT) target_compile_definitions(t11 PRIVATE __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS __STDC_FORMAT_MACROS) target_include_directories(t11 PRIVATE "") diff --git a/test/sanity-check/c++14/CMakeLists.txt b/test/sanity-check/c++14/CMakeLists.txt index 40996189..4b3a512b 100644 --- a/test/sanity-check/c++14/CMakeLists.txt +++ b/test/sanity-check/c++14/CMakeLists.txt @@ -12,6 +12,16 @@ else() message(STATUS "Compiling for STL") endif() +if (ETL_USE_TYPE_TRAITS_BUILTINS) + message(STATUS "Compiling for built-in type traits") + add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS) +endif() + +if (ETL_USER_DEFINED_TYPE_TRAITS) + message(STATUS "Compiling for user defined type traits") + add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS) +endif() + add_library(t14 OBJECT) target_compile_definitions(t14 PRIVATE __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS __STDC_FORMAT_MACROS) target_include_directories(t14 PRIVATE "") diff --git a/test/sanity-check/c++17/CMakeLists.txt b/test/sanity-check/c++17/CMakeLists.txt index 81cdbb4a..4b1b89c8 100644 --- a/test/sanity-check/c++17/CMakeLists.txt +++ b/test/sanity-check/c++17/CMakeLists.txt @@ -12,6 +12,16 @@ else() message(STATUS "Compiling for STL") endif() +if (ETL_USE_TYPE_TRAITS_BUILTINS) + message(STATUS "Compiling for built-in type traits") + add_definitions(-DETL_USE_TYPE_TRAITS_BUILTINS) +endif() + +if (ETL_USER_DEFINED_TYPE_TRAITS) + message(STATUS "Compiling for user defined type traits") + add_definitions(-DETL_USER_DEFINED_TYPE_TRAITS) +endif() + add_library(t17 OBJECT) target_compile_definitions(t17 PRIVATE __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS __STDC_FORMAT_MACROS) target_include_directories(t17 PRIVATE "") diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index b3f8b938..234acce5 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -1068,20 +1068,24 @@ namespace //************************************************************************* TEST(test_is_trivially_copy_assignable) { +#if (!(defined(ETL_COMPILER_GCC) && defined(ETL_USE_TYPE_TRAITS_BUILTINS))) #if ETL_USING_STL || defined(ETL_USE_TYPE_TRAITS_BUILTINS) || defined(ETL_USER_DEFINED_TYPE_TRAITS) CHECK((etl::is_trivially_copy_assignable_v) == (std::is_trivially_copy_assignable_v)); CHECK((etl::is_trivially_copy_assignable_v) == (std::is_trivially_copy_assignable_v)); CHECK((etl::is_trivially_copy_assignable_v) == (std::is_trivially_copy_assignable_v)); +#endif #endif } //************************************************************************* TEST(test_is_trivially_copyable) { +#if (!(defined(ETL_COMPILER_GCC) && defined(ETL_USE_TYPE_TRAITS_BUILTINS))) #if ETL_USING_STL || defined(ETL_USE_TYPE_TRAITS_BUILTINS) || defined(ETL_USER_DEFINED_TYPE_TRAITS) CHECK((etl::is_trivially_copyable_v) == (std::is_trivially_copyable_v)); CHECK((etl::is_trivially_copyable_v) == (std::is_trivially_copyable_v)); CHECK((etl::is_trivially_copyable_v) == (std::is_trivially_copyable_v)); +#endif #endif } } diff --git a/test/test_vector_non_trivial.cpp b/test/test_vector_non_trivial.cpp index d7723df0..39a71c04 100644 --- a/test/test_vector_non_trivial.cpp +++ b/test/test_vector_non_trivial.cpp @@ -730,6 +730,7 @@ namespace CHECK_EQUAL(1, data[3]); } +#if (!(defined(ETL_COMPILER_GCC) && defined(ETL_USE_TYPE_TRAITS_BUILTINS))) //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_unique_ptr) { @@ -754,8 +755,8 @@ namespace CHECK_EQUAL(4, *data[0]); CHECK_EQUAL(3, *data[1]); CHECK_EQUAL(2, *data[2]); - } +#endif //************************************************************************* // To test the CPP03 versions then ETL_TEST_VECTOR_CPP11 must be set to 0 in vector.h diff --git a/test/vs2019/etl.sln b/test/vs2019/etl.sln index 7e198816..de7c4e23 100644 --- a/test/vs2019/etl.sln +++ b/test/vs2019/etl.sln @@ -7,12 +7,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "etl", "etl.vcxproj", "{C21D EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug LLVM - No STL - Built-ins|Win32 = Debug LLVM - No STL - Built-ins|Win32 + Debug LLVM - No STL - Built-ins|x64 = Debug LLVM - No STL - Built-ins|x64 Debug LLVM - No STL|Win32 = Debug LLVM - No STL|Win32 Debug LLVM - No STL|x64 = Debug LLVM - No STL|x64 Debug LLVM|Win32 = Debug LLVM|Win32 Debug LLVM|x64 = Debug LLVM|x64 - Debug MSVC - No STL - Builtins|Win32 = Debug MSVC - No STL - Builtins|Win32 - Debug MSVC - No STL - Builtins|x64 = Debug MSVC - No STL - Builtins|x64 + Debug MSVC - No STL - Built-ins|Win32 = Debug MSVC - No STL - Built-ins|Win32 + Debug MSVC - No STL - Built-ins|x64 = Debug MSVC - No STL - Built-ins|x64 Debug MSVC - No STL - Force No Advanced|Win32 = Debug MSVC - No STL - Force No Advanced|Win32 Debug MSVC - No STL - Force No Advanced|x64 = Debug MSVC - No STL - Force No Advanced|x64 Debug MSVC - No STL|Win32 = Debug MSVC - No STL|Win32 @@ -29,8 +31,6 @@ Global Debug MSVC No Checks|x64 = Debug MSVC No Checks|x64 Debug MSVC|Win32 = Debug MSVC|Win32 Debug MSVC|x64 = Debug MSVC|x64 - Debug LLVM - No STL - Builtins|Win32 = Debug LLVM - No STL - Builtins|Win32 - Debug LLVM - No STL - Builtins|x64 = Debug LLVM - No STL - Builtins|x64 LLVM New|Win32 = LLVM New|Win32 LLVM New|x64 = LLVM New|x64 MSVCDebugAppveyor|Win32 = MSVCDebugAppveyor|Win32 @@ -41,6 +41,10 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Built-ins|Win32.ActiveCfg = Test2|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Built-ins|Win32.Build.0 = Test2|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Built-ins|x64.ActiveCfg = Test2|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Built-ins|x64.Build.0 = Test2|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|Win32.ActiveCfg = DebugLLVMNoSTL|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|Win32.Build.0 = DebugLLVMNoSTL|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|x64.ActiveCfg = DebugLLVMNoSTL|x64 @@ -49,10 +53,10 @@ Global {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|Win32.Build.0 = Debug LLVM|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|x64.ActiveCfg = Debug LLVM|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|x64.Build.0 = Debug LLVM|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Builtins|Win32.ActiveCfg = Debug|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Builtins|Win32.Build.0 = Debug|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Builtins|x64.ActiveCfg = Debug-MSVC-No-STL-Builtins|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Builtins|x64.Build.0 = Debug-MSVC-No-STL-Builtins|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Built-ins|Win32.ActiveCfg = Test1|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Built-ins|Win32.Build.0 = Test1|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Built-ins|x64.ActiveCfg = Test1|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Built-ins|x64.Build.0 = Test1|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|Win32.ActiveCfg = DebugNoSTLForceNoAdvanced|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|Win32.Build.0 = DebugNoSTLForceNoAdvanced|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|x64.ActiveCfg = DebugNoSTLForceNoAdvanced|x64 @@ -85,10 +89,6 @@ Global {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|Win32.Build.0 = Debug|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|x64.ActiveCfg = Debug|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|x64.Build.0 = Debug|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Builtins|Win32.ActiveCfg = Debug-LLVM-NoSTL-Builtins|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Builtins|Win32.Build.0 = Debug-LLVM-NoSTL-Builtins|Win32 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Builtins|x64.ActiveCfg = Debug-LLVM-NoSTL-Builtins|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Builtins|x64.Build.0 = Debug-LLVM-NoSTL-Builtins|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.LLVM New|Win32.ActiveCfg = LLVM New|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.LLVM New|Win32.Build.0 = LLVM New|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.LLVM New|x64.ActiveCfg = LLVM New|x64 diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index c010d82a..62ce00da 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -145,6 +145,22 @@ Release x64 + + Test1 + Win32 + + + Test1 + x64 + + + Test2 + Win32 + + + Test2 + x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB} @@ -198,6 +214,13 @@ Unicode false + + Application + true + v142 + Unicode + false + Application true @@ -229,6 +252,12 @@ ClangCL Unicode + + Application + true + ClangCL + Unicode + Application true @@ -289,6 +318,12 @@ v142 Unicode + + Application + true + v142 + Unicode + Application true @@ -319,6 +354,12 @@ v142 Unicode + + Application + true + v142 + Unicode + Application true @@ -399,6 +440,9 @@ + + + @@ -414,6 +458,9 @@ + + + @@ -444,6 +491,9 @@ + + + @@ -459,6 +509,9 @@ + + + @@ -522,6 +575,11 @@ true \$(IntDir) + + true + true + \$(IntDir) + true true @@ -547,6 +605,11 @@ true \$(IntDir) + + false + true + \$(IntDir) + false true @@ -590,6 +653,10 @@ true true + + true + true + true true @@ -610,6 +677,10 @@ true true + + true + true + true true @@ -796,6 +867,28 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING;ETL_NO_STL;ETL_USE_TYPE_TRAITS_BUILTINS;%(PreprocessorDefinitions) + ./;../../../unittest-cpp/;../../include;../../test + + + true + stdcpp17 + ProgramDatabase + + + Console + true + + + $(OutDir)\etl.exe + + @@ -908,6 +1001,30 @@ "$(OutDir)etl.exe" + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_USE_TYPE_TRAITS_BUILTINS;__clang__;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + false + ProgramDatabase + -Wno-self-assign /Zc:__cplusplus %(AdditionalOptions) + + + Console + false + + + "$(OutDir)etl.exe" + + @@ -1151,6 +1268,27 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -1256,6 +1394,27 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -1818,10 +1977,12 @@ true true true + true true true true true + true true true true @@ -1838,10 +1999,12 @@ true true true + true true true true true + true true true true @@ -1858,10 +2021,12 @@ true true true + true true true true true + true true true true @@ -1878,10 +2043,12 @@ true true true + true true true true true + true true true true @@ -1898,10 +2065,12 @@ true true true + true true true true true + true true true true @@ -1918,10 +2087,12 @@ true true true + true true true true true + true true true true @@ -1938,10 +2109,12 @@ true true true + true true true true true + true true true true @@ -1958,10 +2131,12 @@ true true true + true true true true true + true true true true @@ -1978,10 +2153,12 @@ true true true + true true true true true + true true true true @@ -1998,10 +2175,12 @@ true true true + true true true true true + true true true true @@ -2018,10 +2197,12 @@ true true true + true true true true true + true true true true @@ -2032,6 +2213,7 @@ true true + true true true true @@ -2041,6 +2223,7 @@ true true true + true true true true @@ -2055,10 +2238,12 @@ true true true + true true true true true + true true true true @@ -2075,10 +2260,12 @@ true true true + true true true true true + true true true true @@ -2095,10 +2282,12 @@ true true true + true true true true true + true true true true @@ -2115,10 +2304,12 @@ true true true + true true true true true + true true true true @@ -2135,10 +2326,12 @@ true true true + true true true true true + true true true true @@ -2155,10 +2348,12 @@ true true true + true true true true true + true true true true @@ -2175,10 +2370,12 @@ true true true + true true true true true + true true true true @@ -2195,10 +2392,12 @@ true true true + true true true true true + true true true true @@ -2215,10 +2414,12 @@ true true true + true true true true true + true true true true @@ -2235,10 +2436,12 @@ true true true + true true true true true + true true true true @@ -2255,10 +2458,12 @@ true true true + true true true true true + true true true true @@ -2275,10 +2480,12 @@ true true true + true true true true true + true true true true @@ -2295,10 +2502,12 @@ true true true + true true true true true + true true true true @@ -2315,10 +2524,12 @@ true true true + true true true true true + true true true true @@ -2335,10 +2546,12 @@ true true true + true true true true true + true true true true @@ -2355,10 +2568,12 @@ true true true + true true true true true + true true true true @@ -2375,10 +2590,12 @@ true true true + true true true true true + true true true true @@ -2395,10 +2612,12 @@ true true true + true true true true true + true true true true @@ -2415,10 +2634,12 @@ true true true + true true true true true + true true true true @@ -2435,10 +2656,12 @@ true true true + true true true true true + true true true true @@ -2455,10 +2678,12 @@ true true true + true true true true true + true true true true @@ -2475,10 +2700,12 @@ true true true + true true true true true + true true true true @@ -2495,10 +2722,12 @@ true true true + true true true true true + true true true true @@ -2515,10 +2744,12 @@ true true true + true true true true true + true true true true @@ -2535,10 +2766,12 @@ true true true + true true true true true + true true true true @@ -2555,10 +2788,12 @@ true true true + true true true true true + true true true true @@ -2575,10 +2810,12 @@ true true true + true true true true true + true true true true @@ -2595,10 +2832,12 @@ true true true + true true true true true + true true true true @@ -2615,10 +2854,12 @@ true true true + true true true true true + true true true true @@ -2635,10 +2876,12 @@ true true true + true true true true true + true true true true @@ -2655,10 +2898,12 @@ true true true + true true true true true + true true true true @@ -2675,10 +2920,12 @@ true true true + true true true true true + true true true true @@ -2695,10 +2942,12 @@ true true true + true true true true true + true true true true @@ -2715,10 +2964,12 @@ true true true + true true true true true + true true true true @@ -2735,10 +2986,12 @@ true true true + true true true true true + true true true true @@ -2755,10 +3008,12 @@ true true true + true true true true true + true true true true @@ -2775,10 +3030,12 @@ true true true + true true true true true + true true true true @@ -2795,10 +3052,12 @@ true true true + true true true true true + true true true true @@ -2815,10 +3074,12 @@ true true true + true true true true true + true true true true @@ -2835,10 +3096,12 @@ true true true + true true true true true + true true true true @@ -2855,10 +3118,12 @@ true true true + true true true true true + true true true true @@ -2875,10 +3140,12 @@ true true true + true true true true true + true true true true @@ -2895,10 +3162,12 @@ true true true + true true true true true + true true true true @@ -2915,10 +3184,12 @@ true true true + true true true true true + true true true true @@ -2935,10 +3206,12 @@ true true true + true true true true true + true true true true @@ -2955,10 +3228,12 @@ true true true + true true true true true + true true true true @@ -2975,10 +3250,12 @@ true true true + true true true true true + true true true true @@ -2995,10 +3272,12 @@ true true true + true true true true true + true true true true @@ -3015,10 +3294,12 @@ true true true + true true true true true + true true true true @@ -3035,10 +3316,12 @@ true true true + true true true true true + true true true true @@ -3055,10 +3338,12 @@ true true true + true true true true true + true true true true @@ -3075,10 +3360,12 @@ true true true + true true true true true + true true true true @@ -3095,10 +3382,12 @@ true true true + true true true true true + true true true true @@ -3115,10 +3404,12 @@ true true true + true true true true true + true true true true @@ -3135,10 +3426,12 @@ true true true + true true true true true + true true true true @@ -3155,10 +3448,12 @@ true true true + true true true true true + true true true true @@ -3175,10 +3470,12 @@ true true true + true true true true true + true true true true @@ -3195,10 +3492,12 @@ true true true + true true true true true + true true true true @@ -3215,10 +3514,12 @@ true true true + true true true true true + true true true true @@ -3235,10 +3536,12 @@ true true true + true true true true true + true true true true @@ -3255,10 +3558,12 @@ true true true + true true true true true + true true true true @@ -3275,10 +3580,12 @@ true true true + true true true true true + true true true true @@ -3295,10 +3602,12 @@ true true true + true true true true true + true true true true @@ -3315,10 +3624,12 @@ true true true + true true true true true + true true true true @@ -3335,10 +3646,12 @@ true true true + true true true true true + true true true true @@ -3355,10 +3668,12 @@ true true true + true true true true true + true true true true @@ -3375,10 +3690,12 @@ true true true + true true true true true + true true true true @@ -3395,10 +3712,12 @@ true true true + true true true true true + true true true true @@ -3415,10 +3734,12 @@ true true true + true true true true true + true true true true @@ -3435,10 +3756,12 @@ true true true + true true true true true + true true true true @@ -3455,10 +3778,12 @@ true true true + true true true true true + true true true true @@ -3475,10 +3800,12 @@ true true true + true true true true true + true true true true @@ -3495,10 +3822,12 @@ true true true + true true true true true + true true true true @@ -3515,10 +3844,12 @@ true true true + true true true true true + true true true true @@ -3535,10 +3866,12 @@ true true true + true true true true true + true true true true @@ -3555,10 +3888,12 @@ true true true + true true true true true + true true true true @@ -3575,10 +3910,12 @@ true true true + true true true true true + true true true true @@ -3595,10 +3932,12 @@ true true true + true true true true true + true true true true @@ -3615,10 +3954,12 @@ true true true + true true true true true + true true true true @@ -3635,10 +3976,12 @@ true true true + true true true true true + true true true true @@ -3655,10 +3998,12 @@ true true true + true true true true true + true true true true @@ -3675,10 +4020,12 @@ true true true + true true true true true + true true true true @@ -3695,10 +4042,12 @@ true true true + true true true true true + true true true true @@ -3715,10 +4064,12 @@ true true true + true true true true true + true true true true @@ -3735,10 +4086,12 @@ true true true + true true true true true + true true true true @@ -3755,10 +4108,12 @@ true true true + true true true true true + true true true true @@ -3775,10 +4130,12 @@ true true true + true true true true true + true true true true @@ -3795,10 +4152,12 @@ true true true + true true true true true + true true true true @@ -3815,10 +4174,12 @@ true true true + true true true true true + true true true true @@ -3835,10 +4196,12 @@ true true true + true true true true true + true true true true @@ -3855,10 +4218,12 @@ true true true + true true true true true + true true true true @@ -3875,10 +4240,12 @@ true true true + true true true true true + true true true true @@ -3895,10 +4262,12 @@ true true true + true true true true true + true true true true @@ -3915,10 +4284,12 @@ true true true + true true true true true + true true true true @@ -3935,10 +4306,12 @@ true true true + true true true true true + true true true true @@ -3955,10 +4328,12 @@ true true true + true true true true true + true true true true @@ -3975,10 +4350,12 @@ true true true + true true true true true + true true true true @@ -3995,10 +4372,12 @@ true true true + true true true true true + true true true true @@ -4015,10 +4394,12 @@ true true true + true true true true true + true true true true @@ -4035,10 +4416,12 @@ true true true + true true true true true + true true true true @@ -4055,10 +4438,12 @@ true true true + true true true true true + true true true true @@ -4075,10 +4460,12 @@ true true true + true true true true true + true true true true @@ -4095,10 +4482,12 @@ true true true + true true true true true + true true true true @@ -4115,10 +4504,12 @@ true true true + true true true true true + true true true true @@ -4135,10 +4526,12 @@ true true true + true true true true true + true true true true @@ -4155,10 +4548,12 @@ true true true + true true true true true + true true true true @@ -4175,10 +4570,12 @@ true true true + true true true true true + true true true true @@ -4195,10 +4592,12 @@ true true true + true true true true true + true true true true @@ -4215,10 +4614,12 @@ true true true + true true true true true + true true true true @@ -4235,10 +4636,12 @@ true true true + true true true true true + true true true true @@ -4255,10 +4658,12 @@ true true true + true true true true true + true true true true @@ -4275,10 +4680,12 @@ true true true + true true true true true + true true true true @@ -4295,10 +4702,12 @@ true true true + true true true true true + true true true true @@ -4315,10 +4724,12 @@ true true true + true true true true true + true true true true @@ -4335,10 +4746,12 @@ true true true + true true true true true + true true true true @@ -4355,10 +4768,12 @@ true true true + true true true true true + true true true true @@ -4375,10 +4790,12 @@ true true true + true true true true true + true true true true @@ -4395,10 +4812,12 @@ true true true + true true true true true + true true true true @@ -4415,10 +4834,12 @@ true true true + true true true true true + true true true true @@ -4435,10 +4856,12 @@ true true true + true true true true true + true true true true @@ -4455,10 +4878,12 @@ true true true + true true true true true + true true true true @@ -4475,10 +4900,12 @@ true true true + true true true true true + true true true true @@ -4495,10 +4922,12 @@ true true true + true true true true true + true true true true @@ -4515,10 +4944,12 @@ true true true + true true true true true + true true true true @@ -4535,10 +4966,12 @@ true true true + true true true true true + true true true true @@ -4555,10 +4988,12 @@ true true true + true true true true true + true true true true @@ -4575,10 +5010,12 @@ true true true + true true true true true + true true true true @@ -4595,10 +5032,12 @@ true true true + true true true true true + true true true true @@ -4615,10 +5054,12 @@ true true true + true true true true true + true true true true @@ -4635,10 +5076,12 @@ true true true + true true true true true + true true true true @@ -4655,10 +5098,12 @@ true true true + true true true true true + true true true true @@ -4675,10 +5120,12 @@ true true true + true true true true true + true true true true @@ -4695,10 +5142,12 @@ true true true + true true true true true + true true true true @@ -4715,10 +5164,12 @@ true true true + true true true true true + true true true true @@ -4735,10 +5186,12 @@ true true true + true true true true true + true true true true @@ -4755,10 +5208,12 @@ true true true + true true true true true + true true true true @@ -4775,10 +5230,12 @@ true true true + true true true true true + true true true true @@ -4795,10 +5252,12 @@ true true true + true true true true true + true true true true @@ -4815,10 +5274,12 @@ true true true + true true true true true + true true true true @@ -4835,10 +5296,12 @@ true true true + true true true true true + true true true true @@ -4855,10 +5318,12 @@ true true true + true true true true true + true true true true @@ -4875,10 +5340,12 @@ true true true + true true true true true + true true true true @@ -4895,10 +5362,12 @@ true true true + true true true true true + true true true true @@ -4915,10 +5384,12 @@ true true true + true true true true true + true true true true @@ -4935,10 +5406,12 @@ true true true + true true true true true + true true true true @@ -4955,10 +5428,12 @@ true true true + true true true true true + true true true true @@ -4975,10 +5450,12 @@ true true true + true true true true true + true true true true @@ -4995,10 +5472,12 @@ true true true + true true true true true + true true true true @@ -5015,10 +5494,12 @@ true true true + true true true true true + true true true true @@ -5035,10 +5516,12 @@ true true true + true true true true true + true true true true @@ -5055,10 +5538,12 @@ true true true + true true true true true + true true true true @@ -5075,10 +5560,12 @@ true true true + true true true true true + true true true true @@ -5095,10 +5582,12 @@ true true true + true true true true true + true true true true @@ -5115,10 +5604,12 @@ true true true + true true true true true + true true true true @@ -5135,10 +5626,12 @@ true true true + true true true true true + true true true true @@ -5155,10 +5648,12 @@ true true true + true true true true true + true true true true @@ -5175,10 +5670,12 @@ true true true + true true true true true + true true true true @@ -5195,10 +5692,12 @@ true true true + true true true true true + true true true true @@ -5215,10 +5714,12 @@ true true true + true true true true true + true true true true @@ -5235,10 +5736,12 @@ true true true + true true true true true + true true true true @@ -5255,10 +5758,12 @@ true true true + true true true true true + true true true true @@ -5275,10 +5780,12 @@ true true true + true true true true true + true true true true @@ -5295,10 +5802,12 @@ true true true + true true true true true + true true true true @@ -5315,10 +5824,12 @@ true true true + true true true true true + true true true true @@ -5335,10 +5846,12 @@ true true true + true true true true true + true true true true @@ -5355,10 +5868,12 @@ true true true + true true true true true + true true true true @@ -5375,10 +5890,12 @@ true true true + true true true true true + true true true true @@ -5395,10 +5912,12 @@ true true true + true true true true true + true true true true @@ -5415,10 +5934,12 @@ true true true + true true true true true + true true true true @@ -5435,10 +5956,12 @@ true true true + true true true true true + true true true true @@ -5455,10 +5978,12 @@ true true true + true true true true true + true true true true @@ -5475,10 +6000,12 @@ true true true + true true true true true + true true true true @@ -5495,10 +6022,12 @@ true true true + true true true true true + true true true true @@ -5515,10 +6044,12 @@ true true true + true true true true true + true true true true @@ -5535,10 +6066,12 @@ true true true + true true true true true + true true true true @@ -5555,10 +6088,12 @@ true true true + true true true true true + true true true true @@ -5575,10 +6110,12 @@ true true true + true true true true true + true true true true @@ -5595,10 +6132,12 @@ true true true + true true true true true + true true true true @@ -5615,10 +6154,12 @@ true true true + true true true true true + true true true true @@ -5635,10 +6176,12 @@ true true true + true true true true true + true true true true @@ -5655,10 +6198,12 @@ true true true + true true true true true + true true true true @@ -5675,10 +6220,12 @@ true true true + true true true true true + true true true true @@ -5695,10 +6242,12 @@ true true true + true true true true true + true true true true @@ -5715,10 +6264,12 @@ true true true + true true true true true + true true true true @@ -5735,10 +6286,12 @@ true true true + true true true true true + true true true true @@ -5755,10 +6308,12 @@ true true true + true true true true true + true true true true @@ -5775,10 +6330,12 @@ true true true + true true true true true + true true true true @@ -5795,10 +6352,12 @@ true true true + true true true true true + true true true true @@ -5815,10 +6374,12 @@ true true true + true true true true true + true true true true @@ -5835,10 +6396,12 @@ true true true + true true true true true + true true true true @@ -5855,10 +6418,12 @@ true true true + true true true true true + true true true true @@ -5875,10 +6440,12 @@ true true true + true true true true true + true true true true @@ -5895,10 +6462,12 @@ true true true + true true true true true + true true true true @@ -5915,10 +6484,12 @@ true true true + true true true true true + true true true true @@ -5935,10 +6506,12 @@ true true true + true true true true true + true true true true @@ -5955,10 +6528,12 @@ true true true + true true true true true + true true true true @@ -5975,10 +6550,12 @@ true true true + true true true true true + true true true true @@ -5995,10 +6572,12 @@ true true true + true true true true true + true true true true @@ -6015,10 +6594,12 @@ true true true + true true true true true + true true true true @@ -6035,10 +6616,12 @@ true true true + true true true true true + true true true true @@ -6055,10 +6638,12 @@ true true true + true true true true true + true true true true @@ -6075,10 +6660,12 @@ true true true + true true true true true + true true true true @@ -6095,10 +6682,12 @@ true true true + true true true true true + true true true true @@ -6115,10 +6704,12 @@ true true true + true true true true true + true true true true @@ -6135,10 +6726,12 @@ true true true + true true true true true + true true true true @@ -6155,10 +6748,12 @@ true true true + true true true true true + true true true true @@ -6175,10 +6770,12 @@ true true true + true true true true true + true true true true @@ -6195,10 +6792,12 @@ true true true + true true true true true + true true true true @@ -6215,10 +6814,12 @@ true true true + true true true true true + true true true true @@ -6235,10 +6836,12 @@ true true true + true true true true true + true true true true @@ -6255,10 +6858,12 @@ true true true + true true true true true + true true true true @@ -6275,10 +6880,12 @@ true true true + true true true true true + true true true true @@ -6295,10 +6902,12 @@ true true true + true true true true true + true true true true @@ -6315,10 +6924,12 @@ true true true + true true true true true + true true true true @@ -6335,10 +6946,12 @@ true true true + true true true true true + true true true true @@ -6355,10 +6968,12 @@ true true true + true true true true true + true true true true @@ -6375,10 +6990,12 @@ true true true + true true true true true + true true true true @@ -6395,10 +7012,12 @@ true true true + true true true true true + true true true true @@ -6415,10 +7034,12 @@ true true true + true true true true true + true true true true @@ -6435,10 +7056,12 @@ true true true + true true true true true + true true true true @@ -6455,10 +7078,12 @@ true true true + true true true true true + true true true true @@ -6475,10 +7100,12 @@ true true true + true true true true true + true true true true @@ -6600,11 +7227,13 @@ false false false + false false false false false false + false false false false @@ -6616,11 +7245,13 @@ false false false + false false false false false false + false false false false @@ -6651,11 +7282,13 @@ false false false + false false false false false false + false false false false @@ -6667,11 +7300,13 @@ false false false + false false false false false false + false false false false @@ -6697,11 +7332,13 @@ false false false + false false false false false false + false false false false @@ -6713,11 +7350,13 @@ false false false + false false false false false false + false false false false @@ -6733,11 +7372,13 @@ false false false + false false false false false false + false false false false @@ -6749,11 +7390,13 @@ false false false + false false false false false false + false false false false @@ -6769,11 +7412,13 @@ false false false + false false false false false false + false false false false @@ -6785,11 +7430,13 @@ false false false + false false false false false false + false false false false @@ -6805,11 +7452,13 @@ false false false + false false false false false false + false false false false @@ -6821,11 +7470,13 @@ false false false + false false false false false false + false false false false @@ -6841,11 +7492,13 @@ false false false + false false false false false false + false false false false @@ -6857,11 +7510,13 @@ false false false + false false false false false false + false false false false @@ -6882,11 +7537,13 @@ false false false + false false false false false false + false false false false @@ -6898,11 +7555,13 @@ false false false + false false false false false false + false false false false @@ -6922,11 +7581,13 @@ false false false + false false false false false false + false false false false @@ -6938,11 +7599,13 @@ false false false + false false false false false false + false false false false @@ -6968,11 +7631,13 @@ false false false + false false false false false false + false false false false @@ -6984,11 +7649,13 @@ false false false + false false false false false false + false false false false @@ -7148,4 +7815,4 @@ - + \ No newline at end of file diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 6187d860..f77d1710 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1131,9 +1131,6 @@ ETL\Private - - ETL\Private - ETL\Patterns @@ -1886,9 +1883,6 @@ Source Files - - Source Files - Source Files @@ -2844,4 +2838,4 @@ Resource Files - + \ No newline at end of file From beb95851f28cc708e36d8c4a0a873c96b15578b1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 4 Aug 2021 19:01:08 +0100 Subject: [PATCH 14/25] Refactoring of type traits for GCC compatibility --- .github/workflows/clang.yml | 2 +- .github/workflows/gcc.yml | 2 +- .github/workflows/vs2019.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 71e06811..013c6e36 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -1,7 +1,7 @@ name: clang on: push: - branches: [ master, development ] + branches: [ master ] pull_request: branches: [ master ] diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index 0870442b..ceb234f1 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -1,7 +1,7 @@ name: gcc on: push: - branches: [ master, development ] + branches: [ master ] pull_request: branches: [ master ] diff --git a/.github/workflows/vs2019.yml b/.github/workflows/vs2019.yml index 11ee107f..30c3b9ad 100644 --- a/.github/workflows/vs2019.yml +++ b/.github/workflows/vs2019.yml @@ -1,7 +1,7 @@ name: vs2019 on: push: - branches: [ master, development ] + branches: [ master ] pull_request: branches: [ master ] From a7786e08afde7026b21d44a5f9d01b2e25ebf527 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 5 Aug 2021 09:23:02 +0100 Subject: [PATCH 15/25] Updated type traits generator --- .../etl/generators/type_traits_generator.h | 139 +++++++++++++----- include/etl/type_traits.h | 74 +++++----- 2 files changed, 139 insertions(+), 74 deletions(-) diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 24653e00..4716f9ed 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -471,10 +471,10 @@ namespace etl template <> struct make_signed { typedef etl::conditional::type>::type type; + int16_t, + etl::conditional::type>::type type; }; template <> struct make_signed { typedef short type; }; @@ -500,10 +500,10 @@ namespace etl template <> struct make_unsigned { typedef etl::conditional::type>::type type; + uint16_t, + etl::conditional::type>::type type; }; template <> struct make_unsigned { typedef unsigned int type; }; @@ -1211,6 +1211,7 @@ namespace etl ///\ingroup type_traits template struct alignment_of : std::alignment_of {}; template <> struct alignment_of : std::integral_constant {}; + template <> struct alignment_of : std::integral_constant {}; #if ETL_CPP17_SUPPORTED template @@ -1565,7 +1566,7 @@ namespace etl struct is_trivially_constructible; #endif - //*************************************************************************** + //********************************************* // is_trivially_copy_constructible #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template @@ -1585,7 +1586,7 @@ namespace etl struct is_trivially_copy_constructible; #endif - //*************************************************************************** + //********************************************* // is_trivially_destructible #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template @@ -1605,7 +1606,7 @@ namespace etl struct is_trivially_destructible; #endif - //*************************************************************************** + //********************************************* // is_trivially_copy_assignable #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template @@ -1625,7 +1626,7 @@ namespace etl struct is_trivially_copy_assignable; #endif - //*************************************************************************** + //********************************************* // is_trivially_copyable #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template @@ -1645,7 +1646,7 @@ namespace etl struct is_trivially_copyable; #endif -#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) +#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) //********************************************* // Use the compiler's builtins. @@ -1654,23 +1655,41 @@ namespace etl //********************************************* // is_assignable template - struct is_assignable : public etl::bool_constant<__is_assignable(T1, T2)> + struct is_assignable { + static ETL_CONSTANT bool value = __is_assignable(T1, T2); }; #if ETL_CPP11_SUPPORTED //********************************************* // is_constructible template - struct is_constructible : public etl::bool_constant<__is_constructible(T, TArgs...)> + struct is_constructible { + static ETL_CONSTANT bool value = __is_constructible(T, TArgs...); + }; +#else + //********************************************* + // is_constructible + template + struct is_constructible + { + static ETL_CONSTANT bool value = __is_constructible(T, TArgs); + }; + + //********************************************* + // is_constructible + template + struct is_constructible + { + static ETL_CONSTANT bool value = __is_constructible(T); }; #endif //********************************************* // is_copy_constructible template - struct is_copy_constructible : public etl::is_constructible> + struct is_copy_constructible : public etl::is_constructible::type> { }; @@ -1681,42 +1700,88 @@ namespace etl { }; +#if ETL_CPP11_SUPPORTED + //********************************************* + // is_trivially_constructible + template + struct is_trivially_constructible + { +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_constructor(T); +#else + static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs...); +#endif + }; +#else + //********************************************* + // is_trivially_constructible + template + struct is_trivially_constructible + { +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_constructor(T); +#else + static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs); +#endif + }; + //********************************************* // is_trivially_constructible template - struct is_trivially_constructible : public etl::bool_constant<__is_trivially_constructible(T)> + struct is_trivially_constructible { +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_constructor(T); +#else + static ETL_CONSTANT bool value = __is_trivially_constructible(T); +#endif }; +#endif - //*************************************************************************** + //********************************************* // is_trivially_copy_constructible template - struct is_trivially_copy_constructible : public etl::bool_constant<__is_trivially_copyable(T)> + struct is_trivially_copy_constructible : public is_trivially_constructible::type> { }; - //*************************************************************************** + //********************************************* // is_trivially_destructible template - struct is_trivially_destructible : public etl::bool_constant<__is_trivially_destructible(T)> + struct is_trivially_destructible { +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_destructor(T); +#else + static ETL_CONSTANT bool value = __is_trivially_destructible(T); +#endif }; - //*************************************************************************** + //********************************************* // is_trivially_copy_assignable template - struct is_trivially_copy_assignable : public etl::bool_constant<__is_trivially_copyable(T)> + struct is_trivially_copy_assignable { +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_copy(T); +#else + static ETL_CONSTANT bool value = __is_trivially_copyable(T); +#endif }; - //*************************************************************************** + //********************************************* // is_trivially_copyable template - struct is_trivially_copyable : public etl::bool_constant<__is_trivially_copyable(T)> + struct is_trivially_copyable { +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_copy(T); +#else + static ETL_CONSTANT bool value = __is_trivially_copyable(T); +#endif }; -#elif defined(ETL_USER_DEFINED_TYPE_TRAITS) +#elif defined(ETL_USER_DEFINED_TYPE_TRAITS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) //********************************************* // Force the user to provide specialisations for @@ -1726,9 +1791,9 @@ namespace etl //********************************************* // is_assignable template ::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> - struct is_assignable; + typename T2, + bool B = (etl::is_arithmetic::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> + struct is_assignable; template struct is_assignable : public etl::true_type @@ -1797,7 +1862,7 @@ namespace etl template struct is_trivially_constructible; - //*************************************************************************** + //********************************************* // is_trivially_copy_constructible template ::value || etl::is_pointer::value> struct is_trivially_copy_constructible; @@ -1810,7 +1875,7 @@ namespace etl template struct is_trivially_copy_constructible; - //*************************************************************************** + //********************************************* // is_trivially_destructible template ::value || etl::is_pointer::value> struct is_trivially_destructible; @@ -1823,7 +1888,7 @@ namespace etl template struct is_trivially_destructible; - //*************************************************************************** + //********************************************* // is_trivially_copy_assignable template ::value || etl::is_pointer::value> struct is_trivially_copy_assignable; @@ -1836,7 +1901,7 @@ namespace etl template struct is_trivially_copy_assignable; - //*************************************************************************** + //********************************************* // is_trivially_copyable template ::value || etl::is_pointer::value> struct is_trivially_copyable; @@ -1893,28 +1958,28 @@ namespace etl { }; - //*************************************************************************** + //********************************************* // is_trivially_copy_constructible template struct is_trivially_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - //*************************************************************************** + //********************************************* // is_trivially_destructible template struct is_trivially_destructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - //*************************************************************************** + //********************************************* // is_trivially_copy_assignable template struct is_trivially_copy_assignable : public etl::bool_constant::value || etl::is_pointer::value> { }; - //*************************************************************************** + //********************************************* // is_trivially_copyable template struct is_trivially_copyable : public etl::bool_constant::value || etl::is_pointer::value> diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index a9fad8cf..5ec0db6f 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -488,10 +488,10 @@ namespace etl template <> struct make_unsigned { typedef etl::conditional::type>::type type; + uint16_t, + etl::conditional::type>::type type; }; template <> struct make_unsigned { typedef unsigned int type; }; @@ -1199,7 +1199,7 @@ namespace etl ///\ingroup type_traits template struct alignment_of : std::alignment_of {}; template <> struct alignment_of : std::integral_constant {}; - template <> struct alignment_of : integral_constant {}; + template <> struct alignment_of : std::integral_constant {}; #if ETL_CPP17_SUPPORTED template @@ -1461,8 +1461,8 @@ namespace etl /// conjunction #if ETL_CPP11_SUPPORTED template - struct conjunction : public etl::true_type - { + struct conjunction : public etl::true_type + { }; template @@ -1484,14 +1484,14 @@ namespace etl //*************************************************************************** /// disjunction #if ETL_CPP11_SUPPORTED - template - struct disjunction : public etl::false_type - { + template + struct disjunction : public etl::false_type + { }; template - struct disjunction : public etl::conditional_t> - { + struct disjunction : public etl::conditional_t> + { }; template struct disjunction : public T1 @@ -1640,7 +1640,7 @@ namespace etl #endif #elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) - + //********************************************* // Use the compiler's builtins. //********************************************* @@ -1653,7 +1653,7 @@ namespace etl static ETL_CONSTANT bool value = __is_assignable(T1, T2); }; - #if ETL_CPP11_SUPPORTED +#if ETL_CPP11_SUPPORTED //********************************************* // is_constructible template @@ -1661,7 +1661,7 @@ namespace etl { static ETL_CONSTANT bool value = __is_constructible(T, TArgs...); }; - #else +#else //********************************************* // is_constructible template @@ -1677,7 +1677,7 @@ namespace etl { static ETL_CONSTANT bool value = __is_constructible(T); }; - #endif +#endif //********************************************* // is_copy_constructible @@ -1699,11 +1699,11 @@ namespace etl template struct is_trivially_constructible { - #if defined(ETL_COMPILER_GCC) +#if defined(ETL_COMPILER_GCC) static ETL_CONSTANT bool value = __has_trivial_constructor(T); - #else +#else static ETL_CONSTANT bool value = __is_trivially_constructible(T, TArgs...); - #endif +#endif }; #else //********************************************* @@ -1743,11 +1743,11 @@ namespace etl template struct is_trivially_destructible { - #if defined(ETL_COMPILER_GCC) - static ETL_CONSTANT bool value = __has_trivial_destructor(T); - #else - static ETL_CONSTANT bool value = __is_trivially_destructible(T); - #endif +#if defined(ETL_COMPILER_GCC) + static ETL_CONSTANT bool value = __has_trivial_destructor(T); +#else + static ETL_CONSTANT bool value = __is_trivially_destructible(T); +#endif }; //********************************************* @@ -1755,11 +1755,11 @@ namespace etl template struct is_trivially_copy_assignable { - #if defined(ETL_COMPILER_GCC) +#if defined(ETL_COMPILER_GCC) static ETL_CONSTANT bool value = __has_trivial_copy(T); - #else +#else static ETL_CONSTANT bool value = __is_trivially_copyable(T); - #endif +#endif }; //********************************************* @@ -1767,24 +1767,24 @@ namespace etl template struct is_trivially_copyable { - #if defined(ETL_COMPILER_GCC) +#if defined(ETL_COMPILER_GCC) static ETL_CONSTANT bool value = __has_trivial_copy(T); - #else +#else static ETL_CONSTANT bool value = __is_trivially_copyable(T); - #endif +#endif }; #elif defined(ETL_USER_DEFINED_TYPE_TRAITS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) - + //********************************************* // Force the user to provide specialisations for // anything other than arithmetics and pointers. //********************************************* - + //********************************************* // is_assignable - template ::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> struct is_assignable; @@ -1828,7 +1828,7 @@ namespace etl template struct is_copy_constructible; - + //********************************************* // is_move_constructible template ::value || etl::is_pointer::value> @@ -1921,14 +1921,14 @@ namespace etl { }; - #if ETL_CPP11_SUPPORTED +#if ETL_CPP11_SUPPORTED //********************************************* // is_constructible template struct is_constructible : public etl::bool_constant::value || etl::is_pointer::value> { }; - #endif +#endif //********************************************* // is_copy_constructible From ecff863087e4c87af5e8dd36efd03f7e87ee9583 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 5 Aug 2021 16:52:35 +0100 Subject: [PATCH 16/25] notify_observers() takes universal reference for C++11 and above --- include/etl/observer.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/include/etl/observer.h b/include/etl/observer.h index 50a1e045..7a637b9d 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -57,6 +57,7 @@ SOFTWARE. #include "vector.h" #include "exception.h" #include "error_handler.h" +#include "utility.h" namespace etl { @@ -153,7 +154,7 @@ namespace etl if (i_observer_item == observer_list.end()) { // Is there enough room? - ETL_ASSERT(!observer_list.full(), ETL_ERROR(etl::observer_list_full)); + ETL_ASSERT_AND_RETURN(!observer_list.full(), ETL_ERROR(etl::observer_list_full)); // Add it. observer_list.push_back(observer_item(observer)); @@ -231,6 +232,28 @@ namespace etl return observer_list.size(); } +#if ETL_CPP11_SUPPORTED && !defined(ETL_OBSERVER_FORCE_CPP03) + //***************************************************************** + /// Notify all of the observers, sending them the notification. + ///\tparam TNotification the notification type. + ///\param n The notification. + //***************************************************************** + template + void notify_observers(TNotification&& n) + { + typename Observer_List::iterator i_observer_item = observer_list.begin(); + + while (i_observer_item != observer_list.end()) + { + if (i_observer_item->enabled) + { + i_observer_item->p_observer->notification(etl::forward(n)); + } + + ++i_observer_item; + } + } +#else //***************************************************************** /// Notify all of the observers, sending them the notification. ///\tparam TNotification the notification type. @@ -251,6 +274,7 @@ namespace etl ++i_observer_item; } } +#endif protected: From 3044fb24f9dfba676c96bf4a919a59fc3bcc8a74 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 5 Aug 2021 16:53:33 +0100 Subject: [PATCH 17/25] Added configuration for forcing C++03 code --- test/etl_profile.h | 8 +- test/test_largest.cpp | 4 + test/test_queue_mpmc_mutex.cpp | 2 + test/test_queue_mpmc_mutex_small.cpp | 2 + test/test_queue_spsc_atomic.cpp | 2 + test/test_queue_spsc_atomic_small.cpp | 2 + test/test_queue_spsc_locked.cpp | 2 + test/test_queue_spsc_locked_small.cpp | 2 + test/test_type_lookup.cpp | 18 ++ test/test_type_select.cpp | 6 + test/vs2019/etl.sln | 6 + test/vs2019/etl.vcxproj | 395 ++++++++++++++++++++++---- 12 files changed, 385 insertions(+), 64 deletions(-) diff --git a/test/etl_profile.h b/test/etl_profile.h index 65de9de2..6ccf639b 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -95,10 +95,14 @@ SOFTWARE. #define ETL_CRC_FORCE_CPP03 #define ETL_MEM_CAST_FORCE_CPP03 #define ETL_MESSAGE_PACKET_FORCE_CPP03 + #define ETL_OBSERVER_FORCE_CPP03 +#endif + +#if defined(ETL_FORCE_TEST_CPP11) + #define ETL_OVERLOAD_FORCE_CPP11 + #define ETL_VARIANT_FORCE_CPP11 #endif -//#define ETL_OVERLOAD_FORCE_CPP11 -//#define ETL_VARIANT_FORCE_CPP11 //#define ETL_VARIANT_CPP11_MAX_16_TYPES #if defined(ETL_NO_STL) diff --git a/test/test_largest.cpp b/test/test_largest.cpp index df4e4b96..5c9ec6ce 100644 --- a/test/test_largest.cpp +++ b/test/test_largest.cpp @@ -55,6 +55,7 @@ namespace CHECK(type); } +#if !defined(ETL_LARGEST_TYPE_FORCE_CPP03) //************************************************************************* TEST(test_pod_type_vt) { @@ -73,6 +74,7 @@ namespace CHECK_EQUAL(sizeof(int), size); CHECK(type); } +#endif //************************************************************************* TEST(test_non_pod_type) @@ -97,6 +99,7 @@ namespace CHECK(type); } +#if !defined(ETL_LARGEST_TYPE_FORCE_CPP03) //************************************************************************* TEST(test_non_pod_type_vt) { @@ -119,6 +122,7 @@ namespace CHECK_EQUAL(sizeof(S3), size); CHECK(type); } +#endif //************************************************************************* TEST(test_pod_alignment) diff --git a/test/test_queue_mpmc_mutex.cpp b/test/test_queue_mpmc_mutex.cpp index 7d92539b..08a5304d 100644 --- a/test/test_queue_mpmc_mutex.cpp +++ b/test/test_queue_mpmc_mutex.cpp @@ -153,6 +153,7 @@ namespace CHECK(!queue.pop(i)); } +#if !defined(ETL_FORCE_TEST_CPP03) //************************************************************************* TEST(test_move_push_pop) { @@ -187,6 +188,7 @@ namespace queue.pop(pr); CHECK_EQUAL(4, pr.value); } +#endif //************************************************************************* TEST(test_multiple_emplace) diff --git a/test/test_queue_mpmc_mutex_small.cpp b/test/test_queue_mpmc_mutex_small.cpp index 9cd9edde..d53ae88e 100644 --- a/test/test_queue_mpmc_mutex_small.cpp +++ b/test/test_queue_mpmc_mutex_small.cpp @@ -165,6 +165,7 @@ namespace CHECK(!queue.pop(i)); } +#if !defined(ETL_FORCE_TEST_CPP03) //************************************************************************* TEST(test_move_push_pop) { @@ -199,6 +200,7 @@ namespace queue.pop(pr); CHECK_EQUAL(4, pr.value); } +#endif //************************************************************************* TEST(test_multiple_emplace) diff --git a/test/test_queue_spsc_atomic.cpp b/test/test_queue_spsc_atomic.cpp index 08eb4d99..3c4a83cf 100644 --- a/test/test_queue_spsc_atomic.cpp +++ b/test/test_queue_spsc_atomic.cpp @@ -150,6 +150,7 @@ namespace CHECK(!queue.pop(i)); } +#if !defined(ETL_FORCE_TEST_CPP03) //************************************************************************* TEST(test_move_push_pop) { @@ -184,6 +185,7 @@ namespace queue.pop(pr); CHECK_EQUAL(4, pr.value); } +#endif //************************************************************************* TEST(test_size_push_pop_iqueue) diff --git a/test/test_queue_spsc_atomic_small.cpp b/test/test_queue_spsc_atomic_small.cpp index 6ab6a7ef..b0a3c11b 100644 --- a/test/test_queue_spsc_atomic_small.cpp +++ b/test/test_queue_spsc_atomic_small.cpp @@ -155,6 +155,7 @@ namespace CHECK(!queue.pop(i)); } +#if !defined(ETL_FORCE_TEST_CPP03) //************************************************************************* TEST(test_move_push_pop) { @@ -189,6 +190,7 @@ namespace queue.pop(pr); CHECK_EQUAL(4, pr.value); } +#endif //************************************************************************* TEST(test_size_push_pop_iqueue) diff --git a/test/test_queue_spsc_locked.cpp b/test/test_queue_spsc_locked.cpp index 6e82b0bb..6bcc9720 100644 --- a/test/test_queue_spsc_locked.cpp +++ b/test/test_queue_spsc_locked.cpp @@ -241,6 +241,7 @@ namespace CHECK(!queue.pop_from_unlocked(i)); } +#if !defined(ETL_FORCE_TEST_CPP03) //************************************************************************* TEST(test_move_push_pop) { @@ -275,6 +276,7 @@ namespace queue.pop(pr); CHECK_EQUAL(4, pr.value); } +#endif //************************************************************************* TEST(test_size_push_pop_iqueue) diff --git a/test/test_queue_spsc_locked_small.cpp b/test/test_queue_spsc_locked_small.cpp index 8dcee543..b0847f63 100644 --- a/test/test_queue_spsc_locked_small.cpp +++ b/test/test_queue_spsc_locked_small.cpp @@ -245,6 +245,7 @@ namespace CHECK(!queue.pop_from_unlocked(i)); } +#if !defined(ETL_FORCE_TEST_CPP03) //************************************************************************* TEST(test_move_push_pop) { @@ -279,6 +280,7 @@ namespace queue.pop(pr); CHECK_EQUAL(4, pr.value); } +#endif //************************************************************************* TEST(test_size_push_pop_iqueue) diff --git a/test/test_type_lookup.cpp b/test/test_type_lookup.cpp index 8d16bd3c..1a6ccd3a 100644 --- a/test/test_type_lookup.cpp +++ b/test/test_type_lookup.cpp @@ -134,6 +134,7 @@ namespace CHECK((etl::is_same::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_from_id_t_16) { @@ -154,6 +155,7 @@ namespace CHECK((etl::is_same>::value)); CHECK((etl::is_same>::value)); } +#endif //************************************************************************* TEST(test_type_from_id_8) @@ -168,6 +170,7 @@ namespace CHECK((etl::is_same::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_from_id_t_8) { @@ -180,6 +183,7 @@ namespace CHECK((etl::is_same>::value)); CHECK((etl::is_same>::value)); } +#endif //************************************************************************* TEST(test_type_from_id_1) @@ -187,11 +191,13 @@ namespace CHECK((etl::is_same::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_from_id_t_1) { CHECK((etl::is_same>::value)); } +#endif //************************************************************************* TEST(test_id_from_type_16) @@ -247,6 +253,7 @@ namespace CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type16())); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_id_from_type_v_16) { @@ -267,6 +274,7 @@ namespace CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v); CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup16::id_from_type_v); } +#endif //************************************************************************* TEST(test_id_from_type_8) @@ -298,6 +306,7 @@ namespace CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type16())); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_id_from_type_v_8) { @@ -310,6 +319,7 @@ namespace CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v); CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup8::id_from_type_v); } +#endif //************************************************************************* TEST(test_id_from_type_1) @@ -320,11 +330,13 @@ namespace CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup1::get_id_from_type(Type16())); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_id_from_type_v_1) { CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup1::id_from_type_v); } +#endif //************************************************************************* TEST(test_type_from_type_16) @@ -347,6 +359,7 @@ namespace CHECK((etl::is_same::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_from_type_t_16) { @@ -367,6 +380,7 @@ namespace CHECK((etl::is_same>::value)); CHECK((etl::is_same>::value)); } +#endif //************************************************************************* TEST(test_type_from_type_8) @@ -381,6 +395,7 @@ namespace CHECK((etl::is_same::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_from_type_t_8) { @@ -393,6 +408,7 @@ namespace CHECK((etl::is_same>::value)); CHECK((etl::is_same>::value)); } +#endif //************************************************************************* TEST(test_type_from_type_1) @@ -400,10 +416,12 @@ namespace CHECK((etl::is_same::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_from_type_t_1) { CHECK((etl::is_same>::value)); } +#endif }; } diff --git a/test/test_type_select.cpp b/test/test_type_select.cpp index 6659d9e7..51011b28 100644 --- a/test/test_type_select.cpp +++ b/test/test_type_select.cpp @@ -54,12 +54,14 @@ namespace CHECK(!(etl::is_same, typename Types1::select<0>::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_select_t_1) { CHECK((etl::is_same, typename Types1::select_t<0>>::value)); CHECK(!(etl::is_same, typename Types1::select_t<0>>::value)); } +#endif //************************************************************************* TEST(test_type_select_8) @@ -82,6 +84,7 @@ namespace CHECK(!(etl::is_same, typename Types8::select<7>::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_select_t_8) { @@ -102,6 +105,7 @@ namespace CHECK((etl::is_same, typename Types8::select_t<7>>::value)); CHECK(!(etl::is_same, typename Types8::select_t<7>>::value)); } +#endif //************************************************************************* TEST(test_type_select_16) @@ -140,6 +144,7 @@ namespace CHECK(!(etl::is_same, typename Types16::select<15>::type>::value)); } +#if !defined(ETL_TYPE_SELECT_FORCE_CPP03) //************************************************************************* TEST(test_type_select_t_16) { @@ -176,5 +181,6 @@ namespace CHECK((etl::is_same, typename Types16::select_t<15>>::value)); CHECK(!(etl::is_same, typename Types16::select_t<15>>::value)); } +#endif }; } diff --git a/test/vs2019/etl.sln b/test/vs2019/etl.sln index de7c4e23..e59f7560 100644 --- a/test/vs2019/etl.sln +++ b/test/vs2019/etl.sln @@ -13,6 +13,8 @@ Global Debug LLVM - No STL|x64 = Debug LLVM - No STL|x64 Debug LLVM|Win32 = Debug LLVM|Win32 Debug LLVM|x64 = Debug LLVM|x64 + Debug MSVC - Force cpp03|Win32 = Debug MSVC - Force cpp03|Win32 + Debug MSVC - Force cpp03|x64 = Debug MSVC - Force cpp03|x64 Debug MSVC - No STL - Built-ins|Win32 = Debug MSVC - No STL - Built-ins|Win32 Debug MSVC - No STL - Built-ins|x64 = Debug MSVC - No STL - Built-ins|x64 Debug MSVC - No STL - Force No Advanced|Win32 = Debug MSVC - No STL - Force No Advanced|Win32 @@ -53,6 +55,10 @@ Global {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|Win32.Build.0 = Debug LLVM|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|x64.ActiveCfg = Debug LLVM|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|x64.Build.0 = Debug LLVM|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Force cpp03|Win32.ActiveCfg = Debug MSVC - Force cpp03|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Force cpp03|Win32.Build.0 = Debug MSVC - Force cpp03|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Force cpp03|x64.ActiveCfg = Debug MSVC - Force cpp03|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Force cpp03|x64.Build.0 = Debug MSVC - Force cpp03|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Built-ins|Win32.ActiveCfg = Test1|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Built-ins|Win32.Build.0 = Test1|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Built-ins|x64.ActiveCfg = Test1|x64 diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 62ce00da..51c01cf3 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -25,6 +25,14 @@ Debug LLVM x64 + + Debug MSVC - Force cpp03 + Win32 + + + Debug MSVC - Force cpp03 + x64 + Debug MSVC - No STL - Built-ins Win32 @@ -177,6 +185,13 @@ Unicode false + + Application + true + v142 + Unicode + false + Application true @@ -214,13 +229,6 @@ Unicode false - - Application - true - v142 - Unicode - false - Application true @@ -282,6 +290,12 @@ v142 Unicode + + Application + true + v142 + Unicode + Application true @@ -318,12 +332,6 @@ v142 Unicode - - Application - true - v142 - Unicode - Application true @@ -422,6 +430,9 @@ + + + @@ -440,9 +451,6 @@ - - - @@ -473,6 +481,9 @@ + + + @@ -491,9 +502,6 @@ - - - @@ -545,6 +553,11 @@ true \$(IntDir) + + true + true + $(SolutionDir)$(IntDir) + true true @@ -629,6 +642,10 @@ true true + + true + true + true true @@ -740,6 +757,28 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + true + stdcpp17 + EditAndContinue + + + Console + true + + + $(OutDir)\etl.exe + + @@ -867,28 +906,6 @@ $(OutDir)\etl.exe - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING;ETL_NO_STL;ETL_USE_TYPE_TRAITS_BUILTINS;%(PreprocessorDefinitions) - ./;../../../unittest-cpp/;../../include;../../test - - - true - stdcpp17 - ProgramDatabase - - - Console - true - - - $(OutDir)\etl.exe - - @@ -1142,6 +1159,27 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -1268,27 +1306,6 @@ $(OutDir)\etl.exe - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ../../unittest-cpp/UnitTest++/;../../include/etl;../../test - - - false - stdcpp14 - - - Console - true - - - $(OutDir)\etl.exe - - @@ -1981,6 +1998,7 @@ true true true + true true true true @@ -2003,6 +2021,7 @@ true true true + true true true true @@ -2025,6 +2044,7 @@ true true true + true true true true @@ -2047,6 +2067,7 @@ true true true + true true true true @@ -2069,6 +2090,7 @@ true true true + true true true true @@ -2091,6 +2113,7 @@ true true true + true true true true @@ -2113,6 +2136,7 @@ true true true + true true true true @@ -2135,6 +2159,7 @@ true true true + true true true true @@ -2157,6 +2182,7 @@ true true true + true true true true @@ -2179,6 +2205,7 @@ true true true + true true true true @@ -2201,6 +2228,7 @@ true true true + true true true true @@ -2212,6 +2240,7 @@ true + true true true true @@ -2242,6 +2271,7 @@ true true true + true true true true @@ -2264,6 +2294,7 @@ true true true + true true true true @@ -2286,6 +2317,7 @@ true true true + true true true true @@ -2308,6 +2340,7 @@ true true true + true true true true @@ -2330,6 +2363,7 @@ true true true + true true true true @@ -2352,6 +2386,7 @@ true true true + true true true true @@ -2374,6 +2409,7 @@ true true true + true true true true @@ -2396,6 +2432,7 @@ true true true + true true true true @@ -2418,6 +2455,7 @@ true true true + true true true true @@ -2440,6 +2478,7 @@ true true true + true true true true @@ -2462,6 +2501,7 @@ true true true + true true true true @@ -2484,6 +2524,7 @@ true true true + true true true true @@ -2506,6 +2547,7 @@ true true true + true true true true @@ -2528,6 +2570,7 @@ true true true + true true true true @@ -2550,6 +2593,7 @@ true true true + true true true true @@ -2572,6 +2616,7 @@ true true true + true true true true @@ -2594,6 +2639,7 @@ true true true + true true true true @@ -2616,6 +2662,7 @@ true true true + true true true true @@ -2638,6 +2685,7 @@ true true true + true true true true @@ -2660,6 +2708,7 @@ true true true + true true true true @@ -2682,6 +2731,7 @@ true true true + true true true true @@ -2704,6 +2754,7 @@ true true true + true true true true @@ -2726,6 +2777,7 @@ true true true + true true true true @@ -2748,6 +2800,7 @@ true true true + true true true true @@ -2770,6 +2823,7 @@ true true true + true true true true @@ -2792,6 +2846,7 @@ true true true + true true true true @@ -2814,6 +2869,7 @@ true true true + true true true true @@ -2836,6 +2892,7 @@ true true true + true true true true @@ -2858,6 +2915,7 @@ true true true + true true true true @@ -2880,6 +2938,7 @@ true true true + true true true true @@ -2902,6 +2961,7 @@ true true true + true true true true @@ -2924,6 +2984,7 @@ true true true + true true true true @@ -2946,6 +3007,7 @@ true true true + true true true true @@ -2968,6 +3030,7 @@ true true true + true true true true @@ -2990,6 +3053,7 @@ true true true + true true true true @@ -3012,6 +3076,7 @@ true true true + true true true true @@ -3034,6 +3099,7 @@ true true true + true true true true @@ -3056,6 +3122,7 @@ true true true + true true true true @@ -3078,6 +3145,7 @@ true true true + true true true true @@ -3100,6 +3168,7 @@ true true true + true true true true @@ -3122,6 +3191,7 @@ true true true + true true true true @@ -3144,6 +3214,7 @@ true true true + true true true true @@ -3166,6 +3237,7 @@ true true true + true true true true @@ -3188,6 +3260,7 @@ true true true + true true true true @@ -3210,6 +3283,7 @@ true true true + true true true true @@ -3232,6 +3306,7 @@ true true true + true true true true @@ -3254,6 +3329,7 @@ true true true + true true true true @@ -3276,6 +3352,7 @@ true true true + true true true true @@ -3298,6 +3375,7 @@ true true true + true true true true @@ -3320,6 +3398,7 @@ true true true + true true true true @@ -3342,6 +3421,7 @@ true true true + true true true true @@ -3364,6 +3444,7 @@ true true true + true true true true @@ -3386,6 +3467,7 @@ true true true + true true true true @@ -3408,6 +3490,7 @@ true true true + true true true true @@ -3430,6 +3513,7 @@ true true true + true true true true @@ -3452,6 +3536,7 @@ true true true + true true true true @@ -3474,6 +3559,7 @@ true true true + true true true true @@ -3496,6 +3582,7 @@ true true true + true true true true @@ -3518,6 +3605,7 @@ true true true + true true true true @@ -3540,6 +3628,7 @@ true true true + true true true true @@ -3562,6 +3651,7 @@ true true true + true true true true @@ -3584,6 +3674,7 @@ true true true + true true true true @@ -3606,6 +3697,7 @@ true true true + true true true true @@ -3628,6 +3720,7 @@ true true true + true true true true @@ -3650,6 +3743,7 @@ true true true + true true true true @@ -3672,6 +3766,7 @@ true true true + true true true true @@ -3694,6 +3789,7 @@ true true true + true true true true @@ -3716,6 +3812,7 @@ true true true + true true true true @@ -3738,6 +3835,7 @@ true true true + true true true true @@ -3760,6 +3858,7 @@ true true true + true true true true @@ -3782,6 +3881,7 @@ true true true + true true true true @@ -3804,6 +3904,7 @@ true true true + true true true true @@ -3826,6 +3927,7 @@ true true true + true true true true @@ -3848,6 +3950,7 @@ true true true + true true true true @@ -3870,6 +3973,7 @@ true true true + true true true true @@ -3892,6 +3996,7 @@ true true true + true true true true @@ -3914,6 +4019,7 @@ true true true + true true true true @@ -3936,6 +4042,7 @@ true true true + true true true true @@ -3958,6 +4065,7 @@ true true true + true true true true @@ -3980,6 +4088,7 @@ true true true + true true true true @@ -4002,6 +4111,7 @@ true true true + true true true true @@ -4024,6 +4134,7 @@ true true true + true true true true @@ -4046,6 +4157,7 @@ true true true + true true true true @@ -4068,6 +4180,7 @@ true true true + true true true true @@ -4090,6 +4203,7 @@ true true true + true true true true @@ -4112,6 +4226,7 @@ true true true + true true true true @@ -4134,6 +4249,7 @@ true true true + true true true true @@ -4156,6 +4272,7 @@ true true true + true true true true @@ -4178,6 +4295,7 @@ true true true + true true true true @@ -4200,6 +4318,7 @@ true true true + true true true true @@ -4222,6 +4341,7 @@ true true true + true true true true @@ -4244,6 +4364,7 @@ true true true + true true true true @@ -4266,6 +4387,7 @@ true true true + true true true true @@ -4288,6 +4410,7 @@ true true true + true true true true @@ -4310,6 +4433,7 @@ true true true + true true true true @@ -4332,6 +4456,7 @@ true true true + true true true true @@ -4354,6 +4479,7 @@ true true true + true true true true @@ -4376,6 +4502,7 @@ true true true + true true true true @@ -4398,6 +4525,7 @@ true true true + true true true true @@ -4420,6 +4548,7 @@ true true true + true true true true @@ -4442,6 +4571,7 @@ true true true + true true true true @@ -4464,6 +4594,7 @@ true true true + true true true true @@ -4486,6 +4617,7 @@ true true true + true true true true @@ -4508,6 +4640,7 @@ true true true + true true true true @@ -4530,6 +4663,7 @@ true true true + true true true true @@ -4552,6 +4686,7 @@ true true true + true true true true @@ -4574,6 +4709,7 @@ true true true + true true true true @@ -4596,6 +4732,7 @@ true true true + true true true true @@ -4618,6 +4755,7 @@ true true true + true true true true @@ -4640,6 +4778,7 @@ true true true + true true true true @@ -4662,6 +4801,7 @@ true true true + true true true true @@ -4684,6 +4824,7 @@ true true true + true true true true @@ -4706,6 +4847,7 @@ true true true + true true true true @@ -4728,6 +4870,7 @@ true true true + true true true true @@ -4750,6 +4893,7 @@ true true true + true true true true @@ -4772,6 +4916,7 @@ true true true + true true true true @@ -4794,6 +4939,7 @@ true true true + true true true true @@ -4816,6 +4962,7 @@ true true true + true true true true @@ -4838,6 +4985,7 @@ true true true + true true true true @@ -4860,6 +5008,7 @@ true true true + true true true true @@ -4882,6 +5031,7 @@ true true true + true true true true @@ -4904,6 +5054,7 @@ true true true + true true true true @@ -4926,6 +5077,7 @@ true true true + true true true true @@ -4948,6 +5100,7 @@ true true true + true true true true @@ -4970,6 +5123,7 @@ true true true + true true true true @@ -4992,6 +5146,7 @@ true true true + true true true true @@ -5014,6 +5169,7 @@ true true true + true true true true @@ -5036,6 +5192,7 @@ true true true + true true true true @@ -5058,6 +5215,7 @@ true true true + true true true true @@ -5080,6 +5238,7 @@ true true true + true true true true @@ -5102,6 +5261,7 @@ true true true + true true true true @@ -5124,6 +5284,7 @@ true true true + true true true true @@ -5146,6 +5307,7 @@ true true true + true true true true @@ -5168,6 +5330,7 @@ true true true + true true true true @@ -5190,6 +5353,7 @@ true true true + true true true true @@ -5212,6 +5376,7 @@ true true true + true true true true @@ -5234,6 +5399,7 @@ true true true + true true true true @@ -5256,6 +5422,7 @@ true true true + true true true true @@ -5278,6 +5445,7 @@ true true true + true true true true @@ -5300,6 +5468,7 @@ true true true + true true true true @@ -5322,6 +5491,7 @@ true true true + true true true true @@ -5344,6 +5514,7 @@ true true true + true true true true @@ -5366,6 +5537,7 @@ true true true + true true true true @@ -5388,6 +5560,7 @@ true true true + true true true true @@ -5410,6 +5583,7 @@ true true true + true true true true @@ -5432,6 +5606,7 @@ true true true + true true true true @@ -5454,6 +5629,7 @@ true true true + true true true true @@ -5476,6 +5652,7 @@ true true true + true true true true @@ -5498,6 +5675,7 @@ true true true + true true true true @@ -5520,6 +5698,7 @@ true true true + true true true true @@ -5542,6 +5721,7 @@ true true true + true true true true @@ -5564,6 +5744,7 @@ true true true + true true true true @@ -5586,6 +5767,7 @@ true true true + true true true true @@ -5608,6 +5790,7 @@ true true true + true true true true @@ -5630,6 +5813,7 @@ true true true + true true true true @@ -5652,6 +5836,7 @@ true true true + true true true true @@ -5674,6 +5859,7 @@ true true true + true true true true @@ -5696,6 +5882,7 @@ true true true + true true true true @@ -5718,6 +5905,7 @@ true true true + true true true true @@ -5740,6 +5928,7 @@ true true true + true true true true @@ -5762,6 +5951,7 @@ true true true + true true true true @@ -5784,6 +5974,7 @@ true true true + true true true true @@ -5806,6 +5997,7 @@ true true true + true true true true @@ -5828,6 +6020,7 @@ true true true + true true true true @@ -5850,6 +6043,7 @@ true true true + true true true true @@ -5872,6 +6066,7 @@ true true true + true true true true @@ -5894,6 +6089,7 @@ true true true + true true true true @@ -5916,6 +6112,7 @@ true true true + true true true true @@ -5938,6 +6135,7 @@ true true true + true true true true @@ -5960,6 +6158,7 @@ true true true + true true true true @@ -5982,6 +6181,7 @@ true true true + true true true true @@ -6004,6 +6204,7 @@ true true true + true true true true @@ -6026,6 +6227,7 @@ true true true + true true true true @@ -6048,6 +6250,7 @@ true true true + true true true true @@ -6070,6 +6273,7 @@ true true true + true true true true @@ -6092,6 +6296,7 @@ true true true + true true true true @@ -6114,6 +6319,7 @@ true true true + true true true true @@ -6136,6 +6342,7 @@ true true true + true true true true @@ -6158,6 +6365,7 @@ true true true + true true true true @@ -6180,6 +6388,7 @@ true true true + true true true true @@ -6202,6 +6411,7 @@ true true true + true true true true @@ -6224,6 +6434,7 @@ true true true + true true true true @@ -6246,6 +6457,7 @@ true true true + true true true true @@ -6268,6 +6480,7 @@ true true true + true true true true @@ -6290,6 +6503,7 @@ true true true + true true true true @@ -6312,6 +6526,7 @@ true true true + true true true true @@ -6334,6 +6549,7 @@ true true true + true true true true @@ -6356,6 +6572,7 @@ true true true + true true true true @@ -6378,6 +6595,7 @@ true true true + true true true true @@ -6400,6 +6618,7 @@ true true true + true true true true @@ -6422,6 +6641,7 @@ true true true + true true true true @@ -6444,6 +6664,7 @@ true true true + true true true true @@ -6466,6 +6687,7 @@ true true true + true true true true @@ -6488,6 +6710,7 @@ true true true + true true true true @@ -6510,6 +6733,7 @@ true true true + true true true true @@ -6532,6 +6756,7 @@ true true true + true true true true @@ -6554,6 +6779,7 @@ true true true + true true true true @@ -6576,6 +6802,7 @@ true true true + true true true true @@ -6598,6 +6825,7 @@ true true true + true true true true @@ -6620,6 +6848,7 @@ true true true + true true true true @@ -6642,6 +6871,7 @@ true true true + true true true true @@ -6664,6 +6894,7 @@ true true true + true true true true @@ -6686,6 +6917,7 @@ true true true + true true true true @@ -6708,6 +6940,7 @@ true true true + true true true true @@ -6730,6 +6963,7 @@ true true true + true true true true @@ -6752,6 +6986,7 @@ true true true + true true true true @@ -6774,6 +7009,7 @@ true true true + true true true true @@ -6796,6 +7032,7 @@ true true true + true true true true @@ -6818,6 +7055,7 @@ true true true + true true true true @@ -6840,6 +7078,7 @@ true true true + true true true true @@ -6862,6 +7101,7 @@ true true true + true true true true @@ -6884,6 +7124,7 @@ true true true + true true true true @@ -6906,6 +7147,7 @@ true true true + true true true true @@ -6928,6 +7170,7 @@ true true true + true true true true @@ -6950,6 +7193,7 @@ true true true + true true true true @@ -6972,6 +7216,7 @@ true true true + true true true true @@ -6994,6 +7239,7 @@ true true true + true true true true @@ -7016,6 +7262,7 @@ true true true + true true true true @@ -7038,6 +7285,7 @@ true true true + true true true true @@ -7060,6 +7308,7 @@ true true true + true true true true @@ -7082,6 +7331,7 @@ true true true + true true true true @@ -7104,6 +7354,7 @@ true true true + true true true true @@ -7220,6 +7471,7 @@ false false false + false false false false @@ -7238,6 +7490,7 @@ false false false + false false false false @@ -7275,6 +7528,7 @@ false + false false false false @@ -7293,6 +7547,7 @@ false false false + false false false false @@ -7325,6 +7580,7 @@ false + false false false false @@ -7343,6 +7599,7 @@ false false false + false false false false @@ -7365,6 +7622,7 @@ false + false false false false @@ -7383,6 +7641,7 @@ false false false + false false false false @@ -7405,6 +7664,7 @@ false + false false false false @@ -7423,6 +7683,7 @@ false false false + false false false false @@ -7445,6 +7706,7 @@ false + false false false false @@ -7463,6 +7725,7 @@ false false false + false false false false @@ -7485,6 +7748,7 @@ false + false false false false @@ -7503,6 +7767,7 @@ false false false + false false false false @@ -7530,6 +7795,7 @@ false + false false false false @@ -7548,6 +7814,7 @@ false false false + false false false false @@ -7574,6 +7841,7 @@ true true false + false false false false @@ -7592,6 +7860,7 @@ false false false + false false false false @@ -7624,6 +7893,7 @@ false + false false false false @@ -7642,6 +7912,7 @@ false false false + false false false false From 2056628b931a9888a5dc698ec2570bcf17c01d9a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 5 Aug 2021 17:55:15 +0100 Subject: [PATCH 18/25] Updated version numbers --- support/Release notes.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/support/Release notes.txt b/support/Release notes.txt index bd97feba..11deb07f 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -2,6 +2,8 @@ 20.15.0 Added a Bipartite buffer, by Benedek Kupper. etl::bip_buffer_spsc_atomic +notify_observers() takes universal reference for C++11 and above. +Updated type traits generator. =============================================================================== 20.14.1 From ca322551f3f67422b2e7b2849483e80ad86ed9f8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 29 Jul 2021 17:20:40 +0100 Subject: [PATCH 19/25] Variadic message_packet --- include/etl/message_packet.h | 264 +++++++++++++++++++++++++++++++++++ 1 file changed, 264 insertions(+) diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index 79441d09..556b3e35 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -351,6 +351,270 @@ namespace etl } } }; +#else + //*************************************************************************** + /// Exception base for message_packet. + //*************************************************************************** + class message_packet_exception : public etl::exception + { + public: + + message_packet_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// Exception for illegal message type. + //*************************************************************************** + class message_packet_illegal_type : public etl::message_packet_exception + { + public: + + message_packet_illegal_type(string_type file_name_, numeric_type line_number_) + : message_packet_exception(ETL_ERROR_TEXT("message_packet:illegal type", ETL_MESSAGE_PACKET_FILE_ID"A"), file_name_, line_number_) + { + } + }; + +#if ETL_CPP17_SUPPORTED && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03) + //*************************************************************************** + // The definition for all message types. + //*************************************************************************** + template + class message_packet + { + public: + + //******************************************** + message_packet() + : valid(false) + { + } + + //******************************************** + explicit message_packet(const etl::imessage& msg) + : valid(true) + { + add_new_message(msg); + } + + //******************************************** + explicit message_packet(etl::imessage&& msg) + : valid(true) + { + add_new_message(etl::move(msg)); + } + + //********************************************** + message_packet(const message_packet& other) + : valid(other.is_valid()) + { + if (valid) + { + add_new_message(other.get()); + } + } + + //********************************************** + message_packet(message_packet&& other) + : valid(other.is_valid()) + { + if (valid) + { + add_new_message(etl::move(other.get())); + } + } + + //********************************************** + message_packet& operator =(const message_packet& rhs) + { + delete_current_message(); + valid = rhs.is_valid(); + if (valid) + { + add_new_message(rhs.get()); + } + + return *this; + } + + //********************************************** + message_packet& operator =(message_packet&& rhs) + { + delete_current_message(); + valid = rhs.is_valid(); + if (valid) + { + add_new_message(etl::move(rhs.get())); + } + + return *this; + } + + //******************************************** + ~message_packet() + { + delete_current_message(); + } + + //******************************************** + etl::imessage& get() ETL_NOEXCEPT + { + return *static_cast(data); + } + + //******************************************** + const etl::imessage& get() const ETL_NOEXCEPT + { + return *static_cast(data); + } + + //******************************************** + bool is_valid() const + { + return valid; + } + + //********************************************** + static ETL_CONSTEXPR bool accepts(etl::message_id_t id) + { + return (accepts_message(id) || ...); + } + + //********************************************** + static ETL_CONSTEXPR bool accepts(const etl::imessage& msg) + { + return accepts(msg.get_message_id()); + } + + //********************************************** + template + static ETL_CONSTEXPR bool accepts() + { + return (accepts_message() || ...); + } + + //********************************************** + template + static ETL_CONSTEXPR + typename etl::enable_if::value, bool>::type + accepts() + { + return accepts(TMessage::ID); + } + + enum + { + SIZE = etl::largest::size, + ALIGNMENT = etl::largest::alignment + }; + + private: + + //********************************************** + template + static ETL_CONSTEXPR bool accepts_message() + { + return Id1 == Id2; + } + + //********************************************** + template + static ETL_CONSTEXPR bool accepts_message(etl::message_id_t id2) + { + return Id1 == id2; + } + + //******************************************** + void delete_current_message() + { + if (valid) + { + etl::imessage* pmsg = static_cast(data); + +#if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES) + pmsg->~imessage(); +#else + if (!(delete_current_message_type(pmsg->get_message_id()) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } +#endif + } + } + + //******************************************** + void add_new_message(const etl::imessage& msg) + { + if (!(add_new_message_type(msg) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + //******************************************** + void add_new_message(etl::imessage&& msg) + { + if (!(add_new_message_type(etl::move(msg)) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + typename etl::aligned_storage::type data; + bool valid; + + private: + + //******************************************** + template + bool delete_current_message_type(etl::message_id_t Id) + { + if (TMessage::ID == Id) + { + static_cast(data)->~TMessage(); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(const etl::imessage& msg) + { + if (TMessage::ID == msg.get_message_id()) + { + void* p = data; + new (p) TMessage(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(etl::imessage&& msg) + { + if (TMessage::ID == msg.get_message_id()) + { + void* p = data; + new (p) TMessage(static_cast(msg)); + return true; + } + else + { + return false; + } + } + }; #else //*************************************************************************** // The definition for all 16 message types. From f413fd1a2182d9054328ae636ec789cab6efd1c1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 10 Aug 2021 11:20:00 +0100 Subject: [PATCH 20/25] Fixes after merge --- include/etl/message_packet.h | 264 +------------------------------- test/vs2019/etl.vcxproj.filters | 6 +- 2 files changed, 5 insertions(+), 265 deletions(-) diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index 556b3e35..9858dd24 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -351,271 +351,9 @@ namespace etl } } }; + #else - //*************************************************************************** - /// Exception base for message_packet. - //*************************************************************************** - class message_packet_exception : public etl::exception - { - public: - message_packet_exception(string_type reason_, string_type file_name_, numeric_type line_number_) - : exception(reason_, file_name_, line_number_) - { - } - }; - - //*************************************************************************** - /// Exception for illegal message type. - //*************************************************************************** - class message_packet_illegal_type : public etl::message_packet_exception - { - public: - - message_packet_illegal_type(string_type file_name_, numeric_type line_number_) - : message_packet_exception(ETL_ERROR_TEXT("message_packet:illegal type", ETL_MESSAGE_PACKET_FILE_ID"A"), file_name_, line_number_) - { - } - }; - -#if ETL_CPP17_SUPPORTED && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03) - //*************************************************************************** - // The definition for all message types. - //*************************************************************************** - template - class message_packet - { - public: - - //******************************************** - message_packet() - : valid(false) - { - } - - //******************************************** - explicit message_packet(const etl::imessage& msg) - : valid(true) - { - add_new_message(msg); - } - - //******************************************** - explicit message_packet(etl::imessage&& msg) - : valid(true) - { - add_new_message(etl::move(msg)); - } - - //********************************************** - message_packet(const message_packet& other) - : valid(other.is_valid()) - { - if (valid) - { - add_new_message(other.get()); - } - } - - //********************************************** - message_packet(message_packet&& other) - : valid(other.is_valid()) - { - if (valid) - { - add_new_message(etl::move(other.get())); - } - } - - //********************************************** - message_packet& operator =(const message_packet& rhs) - { - delete_current_message(); - valid = rhs.is_valid(); - if (valid) - { - add_new_message(rhs.get()); - } - - return *this; - } - - //********************************************** - message_packet& operator =(message_packet&& rhs) - { - delete_current_message(); - valid = rhs.is_valid(); - if (valid) - { - add_new_message(etl::move(rhs.get())); - } - - return *this; - } - - //******************************************** - ~message_packet() - { - delete_current_message(); - } - - //******************************************** - etl::imessage& get() ETL_NOEXCEPT - { - return *static_cast(data); - } - - //******************************************** - const etl::imessage& get() const ETL_NOEXCEPT - { - return *static_cast(data); - } - - //******************************************** - bool is_valid() const - { - return valid; - } - - //********************************************** - static ETL_CONSTEXPR bool accepts(etl::message_id_t id) - { - return (accepts_message(id) || ...); - } - - //********************************************** - static ETL_CONSTEXPR bool accepts(const etl::imessage& msg) - { - return accepts(msg.get_message_id()); - } - - //********************************************** - template - static ETL_CONSTEXPR bool accepts() - { - return (accepts_message() || ...); - } - - //********************************************** - template - static ETL_CONSTEXPR - typename etl::enable_if::value, bool>::type - accepts() - { - return accepts(TMessage::ID); - } - - enum - { - SIZE = etl::largest::size, - ALIGNMENT = etl::largest::alignment - }; - - private: - - //********************************************** - template - static ETL_CONSTEXPR bool accepts_message() - { - return Id1 == Id2; - } - - //********************************************** - template - static ETL_CONSTEXPR bool accepts_message(etl::message_id_t id2) - { - return Id1 == id2; - } - - //******************************************** - void delete_current_message() - { - if (valid) - { - etl::imessage* pmsg = static_cast(data); - -#if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES) - pmsg->~imessage(); -#else - if (!(delete_current_message_type(pmsg->get_message_id()) || ...)) - { - ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); - } -#endif - } - } - - //******************************************** - void add_new_message(const etl::imessage& msg) - { - if (!(add_new_message_type(msg) || ...)) - { - ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); - } - } - - //******************************************** - void add_new_message(etl::imessage&& msg) - { - if (!(add_new_message_type(etl::move(msg)) || ...)) - { - ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); - } - } - - typename etl::aligned_storage::type data; - bool valid; - - private: - - //******************************************** - template - bool delete_current_message_type(etl::message_id_t Id) - { - if (TMessage::ID == Id) - { - static_cast(data)->~TMessage(); - return true; - } - else - { - return false; - } - } - - //******************************************** - template - bool add_new_message_type(const etl::imessage& msg) - { - if (TMessage::ID == msg.get_message_id()) - { - void* p = data; - new (p) TMessage(static_cast(msg)); - return true; - } - else - { - return false; - } - } - - //******************************************** - template - bool add_new_message_type(etl::imessage&& msg) - { - if (TMessage::ID == msg.get_message_id()) - { - void* p = data; - new (p) TMessage(static_cast(msg)); - return true; - } - else - { - return false; - } - } - }; -#else //*************************************************************************** // The definition for all 16 message types. //*************************************************************************** diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index f77d1710..25a56d06 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2076,6 +2076,8 @@ Source Files\Sanity Checks + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -2119,8 +2121,8 @@ Source Files\Sanity Checks - Source Files\Sanity Checks - + Source Files\Sanity Checks + Source Files\Sanity Checks From 30f0f5817820ba4ee036ab17d241090bc23479f6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 10 Aug 2021 11:25:54 +0100 Subject: [PATCH 21/25] meson build fix --- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 96086037..8ad40f9a 100644 --- a/meson.build +++ b/meson.build @@ -111,7 +111,8 @@ etl_test_sources = files( 'test/test_type_traits.cpp', 'test/test_user_type.cpp', 'test/test_utility.cpp', - 'test/test_variant.cpp', + 'test/test_variant_legacy.cpp', + 'test/test_variant_variadic.cpp' 'test/test_variant_pool.cpp', 'test/test_vector.cpp', 'test/test_vector_non_trivial.cpp', From 27f520403209c47714ff987f2c7ce17b2f081688 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 10 Aug 2021 11:31:02 +0100 Subject: [PATCH 22/25] Added 'Force C++03' macro --- include/etl/message_router.h | 2 +- test/etl_profile.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/etl/message_router.h b/include/etl/message_router.h index a2fcf299..03b12b8f 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -295,7 +295,7 @@ namespace etl destination.receive(message); } -#if ETL_CPP17_SUPPORTED +#if ETL_CPP17_SUPPORTED && !defined(ETL_MESSAGE_ROUTER_FORCE_CPP03) //*************************************************************************** // The definition for all message types. //*************************************************************************** diff --git a/test/etl_profile.h b/test/etl_profile.h index 6ccf639b..469975bb 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -96,6 +96,7 @@ SOFTWARE. #define ETL_MEM_CAST_FORCE_CPP03 #define ETL_MESSAGE_PACKET_FORCE_CPP03 #define ETL_OBSERVER_FORCE_CPP03 + #define ETL_MESSAGE_ROUTER_FORCE_CPP03 #endif #if defined(ETL_FORCE_TEST_CPP11) From 774384e316ea793a61c3b36149aa48af5fb132ea Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 10 Aug 2021 12:37:33 +0100 Subject: [PATCH 23/25] Fixes after merge --- include/etl/generators/largest_generator.h | 7 +- .../etl/generators/message_packet_generator.h | 292 ++++++++++++++++++ .../etl/generators/message_router_generator.h | 104 +++++++ include/etl/largest.h | 5 + include/etl/message_packet.h | 31 +- 5 files changed, 418 insertions(+), 21 deletions(-) diff --git a/include/etl/generators/largest_generator.h b/include/etl/generators/largest_generator.h index 0c3225a9..d748e2dd 100644 --- a/include/etl/generators/largest_generator.h +++ b/include/etl/generators/largest_generator.h @@ -396,11 +396,8 @@ namespace etl #endif #if ETL_CPP17_SUPPORTED - template - inline constexpr size_t largest_size_v = largest::size; - - template - inline constexpr size_t largest_alignment_v = largest::alignment; + template + inline constexpr size_t largest_size = largest::size; #endif #else diff --git a/include/etl/generators/message_packet_generator.h b/include/etl/generators/message_packet_generator.h index 523840f0..854a575e 100644 --- a/include/etl/generators/message_packet_generator.h +++ b/include/etl/generators/message_packet_generator.h @@ -74,6 +74,297 @@ cog.outl("//******************************************************************** namespace etl { +#if ETL_CPP17_SUPPORTED && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03) + //*************************************************************************** + // The definition for all message types. + //*************************************************************************** + template + class message_packet + { + public: + + //******************************************** + message_packet() + : valid(false) + { + } + + //******************************************** + explicit message_packet(const etl::imessage& msg) + : valid(true) + { + add_new_message(msg); + } + + //******************************************** + explicit message_packet(etl::imessage&& msg) + : valid(true) + { + add_new_message(etl::move(msg)); + } + + //******************************************** + template , etl::imessage> && + !etl::is_same_v, etl::message_packet>, int> = 0> + explicit message_packet(TMessage&& msg) + : valid(true) + { + add_new_message(etl::forward(msg)); + } + + //********************************************** + message_packet(const message_packet& other) + : valid(other.is_valid()) + { + if (valid) + { + add_new_message(other.get()); + } + } + + //********************************************** + message_packet(message_packet&& other) + : valid(other.is_valid()) + { + if (valid) + { + add_new_message(etl::move(other.get())); + } + } + + //********************************************** + message_packet& operator =(const message_packet& rhs) + { + delete_current_message(); + valid = rhs.is_valid(); + if (valid) + { + add_new_message(rhs.get()); + } + + return *this; + } + + //********************************************** + message_packet& operator =(message_packet&& rhs) + { + delete_current_message(); + valid = rhs.is_valid(); + if (valid) + { + add_new_message(etl::move(rhs.get())); + } + + return *this; + } + + //******************************************** + ~message_packet() + { + delete_current_message(); + } + + //******************************************** + etl::imessage& get() ETL_NOEXCEPT + { + return *static_cast(data); + } + + //******************************************** + const etl::imessage& get() const ETL_NOEXCEPT + { + return *static_cast(data); + } + + //******************************************** + bool is_valid() const + { + return valid; + } + + //********************************************** + static ETL_CONSTEXPR bool accepts(etl::message_id_t id) + { + return (accepts_message(id) || ...); + } + + //********************************************** + static ETL_CONSTEXPR bool accepts(const etl::imessage& msg) + { + return accepts(msg.get_message_id()); + } + + //********************************************** + template + static ETL_CONSTEXPR bool accepts() + { + return (accepts_message() || ...); + } + + //********************************************** + template + static ETL_CONSTEXPR + typename etl::enable_if::value, bool>::type + accepts() + { + return accepts(); + } + + enum + { + SIZE = etl::largest::size, + ALIGNMENT = etl::largest::alignment + }; + + private: + + //********************************************** + template + static ETL_CONSTEXPR bool accepts_message() + { + return Id1 == Id2; + } + + //********************************************** + template + static ETL_CONSTEXPR bool accepts_message(etl::message_id_t id2) + { + return Id1 == id2; + } + + //******************************************** + void delete_current_message() + { + if (valid) + { + etl::imessage* pmsg = static_cast(data); + +#if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES) + pmsg->~imessage(); +#else + if (!(delete_current_message_type(pmsg->get_message_id()) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } +#endif + } + } + + //******************************************** + void add_new_message(const etl::imessage& msg) + { + if (!(add_new_message_type(msg) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + //******************************************** + void add_new_message(etl::imessage&& msg) + { + if (!(add_new_message_type(etl::move(msg)) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + //******************************************** + template , etl::imessage>, int> = 0> + void add_new_message(TMessage&& msg) + { + if (!(add_new_message_type::ID>(etl::forward(msg)) || ...)) + { + ETL_ALWAYS_ASSERT(ETL_ERROR(unhandled_message_exception)); + } + } + + typename etl::aligned_storage::type data; + bool valid; + + private: + + //******************************************** + template + bool delete_current_message_type(etl::message_id_t Id) + { + if (TType::ID == Id) + { + static_cast(data)->~TType(); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(const etl::imessage& msg) + { + if (TType::ID == msg.get_message_id()) + { + void* p = data; + new (p) TType(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(const etl::imessage& msg) + { + if (TType::ID == Id) + { + void* p = data; + new (p) TType(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(etl::imessage&& msg) + { + if (TType::ID == msg.get_message_id()) + { + void* p = data; + new (p) TType(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool add_new_message_type(etl::imessage&& msg) + { + if (TType::ID == Id) + { + void* p = data; + new (p) TType(static_cast(msg)); + return true; + } + else + { + return false; + } + } + }; + +#else + /*[[[cog import cog ################################################ @@ -539,6 +830,7 @@ namespace etl cog.outl("};") ]]]*/ /*[[[end]]]*/ +#endif } #endif diff --git a/include/etl/generators/message_router_generator.h b/include/etl/generators/message_router_generator.h index eda0338f..082ce2eb 100644 --- a/include/etl/generators/message_router_generator.h +++ b/include/etl/generators/message_router_generator.h @@ -307,6 +307,109 @@ namespace etl destination.receive(message); } +#if ETL_CPP17_SUPPORTED && !defined(ETL_MESSAGE_ROUTER_FORCE_CPP03) + //*************************************************************************** + // The definition for all message types. + //*************************************************************************** + template + class message_router : public imessage_router + { + public: + + typedef etl::message_packet message_packet; + + //********************************************** + message_router(etl::message_router_id_t id_) + : imessage_router(id_) + { + ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id)); + } + + //********************************************** + message_router(etl::message_router_id_t id_, etl::imessage_router& successor_) + : imessage_router(id_, successor_) + { + ETL_ASSERT(id_ <= etl::imessage_router::MAX_MESSAGE_ROUTER, ETL_ERROR(etl::message_router_illegal_id)); + } + + //********************************************** + using etl::imessage_router::receive; + + void receive(const etl::imessage& msg) ETL_OVERRIDE + { + const bool was_handled = (receive_message_type(msg) || ...); + + if (!was_handled) + { + if (has_successor()) + { + get_successor().receive(msg); + } + else + { + static_cast(this)->on_receive_unknown(msg); + } + } + } + + //********************************************** + using imessage_router::accepts; + + bool accepts(etl::message_id_t id) const ETL_OVERRIDE + { + return (accepts_type(id) || ...); + } + + //******************************************** + ETL_DEPRECATED bool is_null_router() const ETL_OVERRIDE + { + return false; + } + + //******************************************** + bool is_producer() const ETL_OVERRIDE + { + return true; + } + + //******************************************** + bool is_consumer() const ETL_OVERRIDE + { + return true; + } + + private: + + //******************************************** + template + bool receive_message_type(const etl::imessage& msg) + { + if (TMessage::ID == msg.get_message_id()) + { + static_cast(this)->on_receive(static_cast(msg)); + return true; + } + else + { + return false; + } + } + + //******************************************** + template + bool accepts_type(etl::message_id_t id) const + { + if (TMessage::ID == id) + { + return true; + } + else + { + return false; + } + } + }; +#else /*[[[cog import cog ################################################ @@ -536,6 +639,7 @@ namespace etl cog.outl("};") ]]]*/ /*[[[end]]]*/ +#endif } #endif diff --git a/include/etl/largest.h b/include/etl/largest.h index cb5f390b..210b4cee 100644 --- a/include/etl/largest.h +++ b/include/etl/largest.h @@ -347,6 +347,11 @@ namespace etl using largest_t = typename largest::type; #endif +#if ETL_CPP17_SUPPORTED + template + inline constexpr size_t largest_size = largest::size; +#endif + #else //*************************************************************************** /// Template to determine the largest type, size and alignment. diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index 9858dd24..fbdfc342 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -54,7 +54,6 @@ SOFTWARE. #include "message.h" #include "error_handler.h" #include "static_assert.h" -#include "exception.h" #include "largest.h" #include "alignment.h" #include "utility.h" @@ -94,8 +93,8 @@ namespace etl //******************************************** template , etl::imessage> && - !etl::is_same_v, etl::message_packet>, int> = 0> - explicit message_packet(TMessage&& msg) + !etl::is_same_v, etl::message_packet>, int> = 0> + explicit message_packet(TMessage&& msg) : valid(true) { add_new_message(etl::forward(msg)); @@ -201,7 +200,7 @@ namespace etl enum { - SIZE = etl::largest::size, + SIZE = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -285,8 +284,8 @@ namespace etl { return false; } - } - + } + //******************************************** template bool add_new_message_type(const etl::imessage& msg) @@ -498,7 +497,7 @@ namespace etl enum { - Size = etl::largest::size, + SIZE = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -598,7 +597,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -746,7 +745,7 @@ namespace etl enum { - Size = etl::largest::size, + SIZE = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -843,7 +842,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -991,7 +990,7 @@ namespace etl enum { - Size = etl::largest::size, + SIZE = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -1085,7 +1084,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -1233,7 +1232,7 @@ namespace etl enum { - Size = etl::largest::size, + SIZE = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -1324,7 +1323,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; @@ -1471,7 +1470,7 @@ namespace etl enum { - Size = etl::largest::size, + SIZE = etl::largest::size, ALIGNMENT = etl::largest::alignment }; @@ -1559,7 +1558,7 @@ namespace etl } #endif - typename etl::aligned_storage::type data; + typename etl::aligned_storage::type data; bool valid; }; From 5904687e6d7fe2a48c20db4a87583cadb8ced595 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 10 Aug 2021 20:25:27 +0100 Subject: [PATCH 24/25] Variadic FSM --- include/etl/bip_buffer_spsc_atomic.h | 4 +- include/etl/fsm.h | 78 ++++++++++++++++++++++++++ include/etl/generators/fsm_generator.h | 78 ++++++++++++++++++++++++++ include/etl/message.h | 2 +- test/etl_profile.h | 1 + 5 files changed, 161 insertions(+), 2 deletions(-) diff --git a/include/etl/bip_buffer_spsc_atomic.h b/include/etl/bip_buffer_spsc_atomic.h index 4b2427aa..6cc54013 100644 --- a/include/etl/bip_buffer_spsc_atomic.h +++ b/include/etl/bip_buffer_spsc_atomic.h @@ -500,7 +500,9 @@ namespace etl /// Default constructor. //************************************************************************* bip_buffer_spsc_atomic() - : base_t(reinterpret_cast(&buffer[0]), RESERVED_SIZE) + : buffer() + , base_t(reinterpret_cast(&buffer[0]), RESERVED_SIZE) + { } diff --git a/include/etl/fsm.h b/include/etl/fsm.h index cf1216eb..d2429ea3 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -480,6 +480,82 @@ namespace etl etl::fsm_state_id_t number_of_states; ///< The number of states. }; +#if ETL_CPP17_SUPPORTED && !defined(ETL_FSM_FORCE_CPP03) // For C++17 and above + + //*************************************************************************** +// The definition for all types. +//*************************************************************************** + template + class fsm_state : public ifsm_state + { + public: + + public: + + enum + { + STATE_ID = STATE_ID_ + }; + + fsm_state() + : ifsm_state(STATE_ID) + { + } + + protected: + + ~fsm_state() + { + } + + inline TContext& get_fsm_context() const + { + return static_cast(ifsm_state::get_fsm_context()); + } + + private: + + //******************************************** + struct result_t + { + bool was_handled; + etl::fsm_state_id_t state_id; + }; + + //******************************************** + etl::fsm_state_id_t process_event(const etl::imessage& message) + { + etl::fsm_state_id_t new_state_id; + etl::message_id_t event_id = message.get_message_id(); + + const bool was_handled = (process_event_type(message, new_state_id) || ...); + + if (!was_handled) + { + new_state_id = (p_parent != nullptr) ? p_parent->process_event(message) : static_cast(this)->on_event_unknown(message); + } + + return new_state_id; + } + + //******************************************** + template + bool process_event_type(const etl::imessage& msg, etl::fsm_state_id_t& state_id) + { + if (TMessage::ID == msg.get_message_id()) + { + state_id = static_cast(this)->on_event(static_cast(msg)); + return true; + } + else + { + return false; + } + } + }; + +#else // For C++03, C++11 & C++14 + //*************************************************************************** // The definition for all 16 message types. //*************************************************************************** @@ -1411,6 +1487,8 @@ namespace etl return p_parent ? p_parent->process_event(message) : static_cast(this)->on_event_unknown(message); } }; + +#endif } #include "private/minmax_pop.h" diff --git a/include/etl/generators/fsm_generator.h b/include/etl/generators/fsm_generator.h index 8bd67bb8..35638249 100644 --- a/include/etl/generators/fsm_generator.h +++ b/include/etl/generators/fsm_generator.h @@ -506,6 +506,82 @@ namespace etl etl::fsm_state_id_t number_of_states; ///< The number of states. }; +#if ETL_CPP17_SUPPORTED && !defined(ETL_FSM_FORCE_CPP03) // For C++17 and above + + //*************************************************************************** +// The definition for all types. +//*************************************************************************** + template + class fsm_state : public ifsm_state + { + public: + + public: + + enum + { + STATE_ID = STATE_ID_ + }; + + fsm_state() + : ifsm_state(STATE_ID) + { + } + + protected: + + ~fsm_state() + { + } + + inline TContext& get_fsm_context() const + { + return static_cast(ifsm_state::get_fsm_context()); + } + + private: + + //******************************************** + struct result_t + { + bool was_handled; + etl::fsm_state_id_t state_id; + }; + + //******************************************** + etl::fsm_state_id_t process_event(const etl::imessage& message) + { + etl::fsm_state_id_t new_state_id; + etl::message_id_t event_id = message.get_message_id(); + + const bool was_handled = (process_event_type(message, new_state_id) || ...); + + if (!was_handled) + { + new_state_id = (p_parent != nullptr) ? p_parent->process_event(message) : static_cast(this)->on_event_unknown(message); + } + + return new_state_id; + } + + //******************************************** + template + bool process_event_type(const etl::imessage& msg, etl::fsm_state_id_t& state_id) + { + if (TMessage::ID == msg.get_message_id()) + { + state_id = static_cast(this)->on_event(static_cast(msg)); + return true; + } + else + { + return false; + } + } + }; + +#else // For C++03, C++11 & C++14 + /*[[[cog import cog ################################################ @@ -692,6 +768,8 @@ namespace etl cog.outl("};") ]]]*/ /*[[[end]]]*/ + +#endif } #include "private/minmax_pop.h" diff --git a/include/etl/message.h b/include/etl/message.h index 27b634a1..cae10650 100644 --- a/include/etl/message.h +++ b/include/etl/message.h @@ -91,7 +91,7 @@ namespace etl ID = ID_ }; - ETL_CONSTEXPR ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE + ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE { return ID; } diff --git a/test/etl_profile.h b/test/etl_profile.h index 469975bb..c28904c8 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -97,6 +97,7 @@ SOFTWARE. #define ETL_MESSAGE_PACKET_FORCE_CPP03 #define ETL_OBSERVER_FORCE_CPP03 #define ETL_MESSAGE_ROUTER_FORCE_CPP03 + #define ETL_FSM_FORCE_CPP03 #endif #if defined(ETL_FORCE_TEST_CPP11) From 988cd9544064025842fd9b144c618353a99114e9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 11 Aug 2021 15:48:17 +0100 Subject: [PATCH 25/25] Added C++17 variadic versions of etl::message_router ans etl::fsm Fixed meson.build --- .gitignore | 1 + include/etl/fsm.h | 26 ++- include/etl/generators/fsm_generator.h | 22 ++- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 5 + test/runsanitychecks.sh | 256 +++++++++++++++++++++---- test/runtests.sh | 48 ++++- test/vs2019/etl.vcxproj | 8 +- test/vs2019/etl.vcxproj.filters | 6 + 11 files changed, 322 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index a3f4ac99..3797ca0d 100644 --- a/.gitignore +++ b/.gitignore @@ -321,3 +321,4 @@ test/vs2019/Debug-LLVM-NoSTL-Builtins/etl.exe test/vs2019/cmake-build test/vs2019/Debug MSVC - No STL - Built-ins test/vs2019/Test1 +test/vs2019/Test2 diff --git a/include/etl/fsm.h b/include/etl/fsm.h index d2429ea3..df724384 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -80,12 +80,17 @@ namespace etl // For internal FSM use. typedef typename etl::larger_type::type fsm_internal_id_t; - template +#if ETL_CPP17_SUPPORTED && !defined(ETL_FSM_FORCE_CPP03) // For C++17 and above + template class fsm_state; +#else + template + class fsm_state; +#endif //*************************************************************************** /// Base exception class for FSM. @@ -178,12 +183,18 @@ namespace etl /// Allows ifsm_state functions to be private. friend class etl::fsm; friend class etl::hfsm; + +#if ETL_CPP17_SUPPORTED && !defined(ETL_FSM_FORCE_CPP03) // For C++17 and above + template + friend class fsm_state; +#else template friend class etl::fsm_state; +#endif //******************************************* /// Gets the id for this state. @@ -483,8 +494,8 @@ namespace etl #if ETL_CPP17_SUPPORTED && !defined(ETL_FSM_FORCE_CPP03) // For C++17 and above //*************************************************************************** -// The definition for all types. -//*************************************************************************** + // The definition for all types. + //*************************************************************************** template class fsm_state : public ifsm_state { @@ -526,7 +537,6 @@ namespace etl etl::fsm_state_id_t process_event(const etl::imessage& message) { etl::fsm_state_id_t new_state_id; - etl::message_id_t event_id = message.get_message_id(); const bool was_handled = (process_event_type(message, new_state_id) || ...); diff --git a/include/etl/generators/fsm_generator.h b/include/etl/generators/fsm_generator.h index 35638249..131e8018 100644 --- a/include/etl/generators/fsm_generator.h +++ b/include/etl/generators/fsm_generator.h @@ -92,19 +92,24 @@ namespace etl // For internal FSM use. typedef typename etl::larger_type::type fsm_internal_id_t; +#if ETL_CPP17_SUPPORTED && !defined(ETL_FSM_FORCE_CPP03) // For C++17 and above + template + class fsm_state; +#else /*[[[cog import cog - cog.outl("template " % int(Handlers)) + cog.outl("typename>") cog.outl("class fsm_state;") ]]]*/ /*[[[end]]]*/ +#endif //*************************************************************************** /// Base exception class for FSM. @@ -197,6 +202,11 @@ namespace etl /// Allows ifsm_state functions to be private. friend class etl::fsm; friend class etl::hfsm; + +#if ETL_CPP17_SUPPORTED && !defined(ETL_FSM_FORCE_CPP03) // For C++17 and above + template + friend class fsm_state; +#else /*[[[cog import cog cog.outl(" template class fsm_state : public ifsm_state { @@ -552,7 +563,6 @@ namespace etl etl::fsm_state_id_t process_event(const etl::imessage& message) { etl::fsm_state_id_t new_state_id; - etl::message_id_t event_id = message.get_message_id(); const bool was_handled = (process_event_type(message, new_state_id) || ...); diff --git a/include/etl/version.h b/include/etl/version.h index 581d4f6b..129a8b88 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 15 +#define ETL_VERSION_MINOR 16 #define ETL_VERSION_PATCH 0 #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) diff --git a/library.json b/library.json index 98bbae72..c12b64fb 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.15.0", + "version": "20.16.0", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index d09ea365..70a6923a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.15.0 +version=20.16.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 11deb07f..06259d00 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +20.16.0 +Added C++17 variadic versions of etl::message_router ans etl::fsm +Fixed meson.build + =============================================================================== 20.15.0 Added a Bipartite buffer, by Benedek Kupper. diff --git a/test/runsanitychecks.sh b/test/runsanitychecks.sh index a0de3ff3..de9b5486 100755 --- a/test/runsanitychecks.sh +++ b/test/runsanitychecks.sh @@ -16,42 +16,90 @@ echo "-----------------------------------------------" echo "GCC - STL"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "GCC - No STL"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "GCC - No STL - Builtins"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ##{ echo ""; echo "GCC - No STL - User defined traits"; } | tee -a ../log.txt #g++ --version | head --lines=1 | tee -a ../log.txt #CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -#cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +#cmake --build bgcc +#if [ $? -eq 0 ]; then +# echo "Passed" +#else +# echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +# exit $? +#fi { echo ""; echo "Clang - STL"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - No STL"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - No STL - Builtins"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ##{ echo ""; echo "Clang - No STL - User defined traits"; } | tee -a ../log.txt #clang++ --version | head --lines=1 | tee -a ../log.txt #CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -#cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +#cmake --build bclang +#if [ $? -eq 0 ]; then +# echo "Passed" +#else +# echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +# exit $? +#fi ############################################################################### cd ../c++11 || exit 1 @@ -64,42 +112,90 @@ echo "-----------------------------------------------" echo "GCC - STL"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "GCC - No STL"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "GCC - No STL - Builtins"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ##{ echo ""; echo "GCC - No STL - User defined traits"; } | tee -a ../log.txt #g++ --version | head --lines=1 | tee -a ../log.txt #CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -#cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +#cmake --build bgcc +#if [ $? -eq 0 ]; then +# echo "Passed" +#else +# echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +# exit $? +#fi { echo ""; echo "Clang - STL"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - No STL"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - No STL - Builtins"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ##{ echo ""; echo "Clang - No STL - User defined traits"; } | tee -a ../log.txt #clang++ --version | head --lines=1 | tee -a ../log.txt #CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -#cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +#cmake --build bclang +#if [ $? -eq 0 ]; then +# echo "Passed" +#else +# echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +# exit $? +#fi ############################################################################### cd ../c++14 || exit 1 @@ -112,42 +208,90 @@ echo "-----------------------------------------------" echo "GCC - STL"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "GCC - No STL"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "GCC - No STL - Builtins"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ##{ echo ""; echo "GCC - No STL - User defined traits"; } | tee -a ../log.txt #g++ --version | head --lines=1 | tee -a ../log.txt #CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -#cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +#cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - STL"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - No STL"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - No STL - Builtins"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ##{ echo ""; echo "Clang - No STL - User defined traits"; } | tee -a ../log.txt #clang++ --version | head --lines=1 | tee -a ../log.txt #CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -#cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +#cmake --build bclang +#if [ $? -eq 0 ]; then +# echo "Passed" +#else +# echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +# exit $? +#fi ############################################################################### cd ../c++17 || exit 1 @@ -160,42 +304,90 @@ echo "-----------------------------------------------" echo "GCC - STL"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "GCC - No STL"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "GCC - No STL - Builtins"; } | tee -a ../log.txt g++ --version | head --lines=1 | tee -a ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bgcc +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ##{ echo ""; echo "GCC - No STL - User defined traits"; } | tee -a ../log.txt #g++ --version | head --lines=1 | tee -a ../log.txt #CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -#cmake --build bgcc || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +#cmake --build bgcc +#if [ $? -eq 0 ]; then +# echo "Passed" +#else +# echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +# exit $? +#fi { echo ""; echo "Clang - STL"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - No STL"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi { echo ""; echo "Clang - No STL - Builtins"; } | tee -a ../log.txt clang++ --version | head --lines=1 | tee -a ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +cmake --build bclang +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ##{ echo ""; echo "Clang - No STL - User defined traits"; } | tee -a ../log.txt #clang++ --version | head --lines=1 | tee -a ../log.txt #CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=ON .. -#cmake --build bclang || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +#cmake --build bclang +#if [ $? -eq 0 ]; then +# echo "Passed" +#else +# echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +# exit $? +#fi { echo "" echo "-----------------------------------------------" diff --git a/test/runtests.sh b/test/runtests.sh index 9bbb9c4f..4c887d8e 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -9,7 +9,13 @@ echo " GCC" | tee -a log.txt echo "-----------------------------------------------" | tee -a log.txt gcc --version | grep gcc | tee -a log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +make -j8 +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt @@ -17,7 +23,13 @@ echo " GCC - No STL" | tee -a log.txt echo "-----------------------------------------------" | tee -a log.txt gcc --version | grep gcc | tee -a log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +make -j8 +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt @@ -25,7 +37,13 @@ echo " GCC - No STL - Builtins" | tee -a log.txt echo "-----------------------------------------------" | tee -a log.txt gcc --version | grep gcc | tee -a log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +make -j8 +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt @@ -33,7 +51,13 @@ echo " Clang" | tee -a log.txt echo "-----------------------------------------------" | tee -a log.txt clang --version | grep clang | tee -a log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +make -j8 +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt @@ -41,7 +65,13 @@ echo " Clang - No STL" | tee -a log.txt echo "-----------------------------------------------" | tee -a log.txt clang --version | grep clang | tee -a log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +make -j8 +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt @@ -49,7 +79,13 @@ echo " Clang - No STL - Builtins" | tee -a log.txt echo "-----------------------------------------------" | tee -a log.txt clang --version | grep clang | tee -a log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON -DETL_USER_DEFINED_TYPE_TRAITS=OFF .. -make -j8 || echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt +make -j8 +if [ $? -eq 0 ]; then + echo "Passed" +else + echo "****************\n**** Failed ****\n****************" | tee -a ../log.txt + exit $? +fi ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" | tee -a log.txt diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 51c01cf3..29d2d692 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -424,6 +424,12 @@ true Unicode + + v142 + + + v142 + @@ -1073,7 +1079,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_USE_TYPE_TRAITS_BUILTINS;__clang__;%(PreprocessorDefinitions) - ../../../unittest-cpp/;../../include;../../test + ./;../../../unittest-cpp/;../../include;../../test false diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 25a56d06..46a2c31d 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2696,6 +2696,12 @@ Source Files\Sanity Checks + + Source Files + + + Source Files +