From 982f30e09b3f88388630f06dad2597d4eadc854f Mon Sep 17 00:00:00 2001 From: Miguel Barro <miguel.barro@live.com> Date: Tue, 19 Nov 2019 14:19:06 +0100 Subject: [PATCH 1/2] Updating std::hast<EntityId_t> to recover the actual participant entity counter. --- include/fastrtps/rtps/common/EntityId_t.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/fastrtps/rtps/common/EntityId_t.hpp b/include/fastrtps/rtps/common/EntityId_t.hpp index e0a2121bf67..500bb86bb4a 100644 --- a/include/fastrtps/rtps/common/EntityId_t.hpp +++ b/include/fastrtps/rtps/common/EntityId_t.hpp @@ -325,13 +325,25 @@ template <> struct hash<eprosima::fastrtps::rtps::EntityId_t> { std::size_t operator()( - const eprosima::fastrtps::rtps::EntityId_t& k) const + const eprosima::fastrtps::rtps::EntityId_t& k) const { - const uint32_t* aux = reinterpret_cast<const uint32_t*>(k.value); - return static_cast<std::size_t>(*aux); + // recover the participant entity counter + eprosima::fastrtps::rtps::octet value[4]; + +#if __BIG_ENDIAN__ + value[3] = k.value[2]; + value[2] = k.value[1]; + value[1] = k.value[0]; + value[0] = 0; +#else + value[3] = 0; + value[2] = k.value[0]; + value[1] = k.value[1]; + value[0] = k.value[2]; +#endif + return static_cast<std::size_t>(*reinterpret_cast<const uint32_t*>(&value)); } }; - } // namespace std From f40ac3685e58220743f37482498fb806cb45148d Mon Sep 17 00:00:00 2001 From: Miguel Barro <miguel.barro@live.com> Date: Tue, 19 Nov 2019 17:44:40 +0100 Subject: [PATCH 2/2] Aplying review comments --- include/fastrtps/rtps/common/EntityId_t.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fastrtps/rtps/common/EntityId_t.hpp b/include/fastrtps/rtps/common/EntityId_t.hpp index 500bb86bb4a..fd781f76226 100644 --- a/include/fastrtps/rtps/common/EntityId_t.hpp +++ b/include/fastrtps/rtps/common/EntityId_t.hpp @@ -325,7 +325,7 @@ template <> struct hash<eprosima::fastrtps::rtps::EntityId_t> { std::size_t operator()( - const eprosima::fastrtps::rtps::EntityId_t& k) const + const eprosima::fastrtps::rtps::EntityId_t& k) const { // recover the participant entity counter eprosima::fastrtps::rtps::octet value[4]; @@ -344,6 +344,7 @@ struct hash<eprosima::fastrtps::rtps::EntityId_t> return static_cast<std::size_t>(*reinterpret_cast<const uint32_t*>(&value)); } }; + } // namespace std