From 48bb81863f2daee5625e10bf228452fdd2ef9b0d Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 5 Oct 2023 13:12:32 +0200 Subject: [PATCH 1/2] Refs #19642: Use STL implementation of Timed/RecursiveTimedMutex in MSVC >= 19.36 Signed-off-by: Mario Dominguez --- include/fastrtps/utils/TimedMutex.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/fastrtps/utils/TimedMutex.hpp b/include/fastrtps/utils/TimedMutex.hpp index e4ff36a7368..ce22a7365d4 100644 --- a/include/fastrtps/utils/TimedMutex.hpp +++ b/include/fastrtps/utils/TimedMutex.hpp @@ -23,10 +23,16 @@ #include #if defined(_WIN32) + +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 +#include +#else #include extern int clock_gettime( int, struct timespec* tv); +#endif + #elif _GTHREAD_USE_MUTEX_TIMEDLOCK #include #else @@ -38,14 +44,12 @@ namespace fastrtps { #if defined(_WIN32) +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 +using TimedMutex = std::timed_mutex; +using RecursiveTimedMutex = std::recursive_timed_mutex; +#else class TimedMutex { - // On MSVC 19.36.32528.95 `xtime` was changed into `_timespec64`. - // See https://github.com/eProsima/Fast-DDS/issues/3451 - // See https://github.com/microsoft/STL/pull/3594 -#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 - using xtime = _timespec64; -#endif // _MSC_FULL_VER check public: @@ -190,6 +194,8 @@ class RecursiveTimedMutex _Mtx_t mutex_; }; +#endif + #elif _GTHREAD_USE_MUTEX_TIMEDLOCK || !defined(__unix__) using TimedMutex = std::timed_mutex; using RecursiveTimedMutex = std::recursive_timed_mutex; From 7944e5960f80df253dbb9165ebad37b1f5bd9530 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 5 Oct 2023 15:32:53 +0200 Subject: [PATCH 2/2] Refs #19642: Linter Signed-off-by: Mario Dominguez --- include/fastrtps/utils/TimedMutex.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fastrtps/utils/TimedMutex.hpp b/include/fastrtps/utils/TimedMutex.hpp index ce22a7365d4..d20fae9cb4a 100644 --- a/include/fastrtps/utils/TimedMutex.hpp +++ b/include/fastrtps/utils/TimedMutex.hpp @@ -31,7 +31,7 @@ extern int clock_gettime( int, struct timespec* tv); -#endif +#endif // if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 #elif _GTHREAD_USE_MUTEX_TIMEDLOCK #include @@ -194,7 +194,7 @@ class RecursiveTimedMutex _Mtx_t mutex_; }; -#endif +#endif // if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 #elif _GTHREAD_USE_MUTEX_TIMEDLOCK || !defined(__unix__) using TimedMutex = std::timed_mutex;