diff --git a/CMakeLists.txt b/CMakeLists.txt index d4c1bb8e59a..105bae2f5de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -207,6 +207,15 @@ endif() option(SQLITE3_SUPPORT "Activate SQLITE3 support" ON) +option(USE_THIRDPARTY_SHARED_MUTEX [=[ +Forces the use of a Boost-based shared_mutex implementation +instead of the framework one. Useful to cope with issues on +framework implementations like misguided sanitizer reports. +This implementation will be used by default on frameworks +lacking the shared_mutex feature like those not fulfilling +C++17. +]=] OFF) + ############################################################################### # SHM as Default transport ############################################################################### diff --git a/include/fastrtps/config.h.in b/include/fastrtps/config.h.in index 323282dadab..e7c31b4fca8 100644 --- a/include/fastrtps/config.h.in +++ b/include/fastrtps/config.h.in @@ -62,6 +62,8 @@ #define HAVE_SQLITE3 @HAVE_SQLITE3@ #endif /* ifndef HAVE_SQLITE3 */ +// Using thirdparty shared_mutex +#cmakedefine01 USE_THIRDPARTY_SHARED_MUTEX // TLS support #ifndef TLS_FOUND diff --git a/include/fastrtps/utils/shared_mutex.hpp b/include/fastrtps/utils/shared_mutex.hpp index d5dd91d2e28..d2fbf9b5f81 100644 --- a/include/fastrtps/utils/shared_mutex.hpp +++ b/include/fastrtps/utils/shared_mutex.hpp @@ -8,12 +8,23 @@ #ifndef _UTILS_SHARED_MUTEX_HPP_ #define _UTILS_SHARED_MUTEX_HPP_ +#ifndef USE_THIRDPARTY_SHARED_MUTEX +# if defined(_MSC_VER) && _MSVC_LANG < 202302L +# pragma message("warning: USE_THIRDPARTY_SHARED_MUTEX not defined. By default use framework version.") +# else +# warning "USE_THIRDPARTY_SHARED_MUTEX not defined. By default use framework version." +# endif // if defined(_MSC_VER) && _MSVC_LANG < 202302L +# define USE_THIRDPARTY_SHARED_MUTEX 0 +#endif // ifndef USE_THIRDPARTY_SHARED_MUTEX + #if defined(__has_include) && __has_include() # include #endif // if defined(__has_include) && __has_include() // Detect if the share_mutex feature is available #if defined(__has_include) && __has_include() && !defined(__cpp_lib_shared_mutex) || \ + /* allow users to ignore shared_mutex framework implementation */ \ + (~USE_THIRDPARTY_SHARED_MUTEX + 1) || \ /* deprecated procedure if the good one is not available*/ \ ( !(defined(__has_include) && __has_include()) && \ !(defined(HAVE_CXX17) && HAVE_CXX17) && __cplusplus < 201703 ) @@ -353,9 +364,8 @@ shared_lock::try_lock() namespace eprosima { -using shared_mutex = std::shared_mutex; -template< class Mutex > -using shared_lock = std::shared_lock; +using std::shared_mutex; +using std::shared_lock; } //namespace eprosima diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 675d0555797..5c6ef49412a 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -565,10 +565,10 @@ endif() install(TARGETS ${PROJECT_NAME} eProsima_atomic EXPORT ${PROJECT_NAME}-${FASTDDS_LINKING}-targets + COMPONENT libraries RUNTIME DESTINATION ${BIN_INSTALL_DIR}${MSVCARCH_DIR_EXTENSION} LIBRARY DESTINATION ${LIB_INSTALL_DIR}${MSVCARCH_DIR_EXTENSION} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}${MSVCARCH_DIR_EXTENSION} - COMPONENT libraries ) export(TARGETS ${PROJECT_NAME} eProsima_atomic FILE ${PROJECT_BINARY_DIR}/cmake/config/${PROJECT_NAME}-${FASTDDS_LINKING}-targets.cmake) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index cfeba1f424b..d90018b1399 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -28,9 +28,6 @@ #include #include -#include -#include - #if defined(_WIN32) #include #else @@ -68,6 +65,9 @@ #include #endif // if HAVE_SECURITY +#include +#include + namespace eprosima { namespace fastdds { diff --git a/versions.md b/versions.md index fe0b685dedb..e5f563bbe19 100644 --- a/versions.md +++ b/versions.md @@ -1,3 +1,8 @@ +Version 2.7.1 +------------- + +* Added a new CMake option to allow users to force the use of our third party shared_mutex + Version 2.7.0 -------------