]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: skip boost shared_mutex with mingw-llvm
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Tue, 30 May 2023 13:46:54 +0000 (13:46 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 30 Aug 2023 12:59:00 +0000 (12:59 +0000)
Because of winpthreads issues, we had to use Boost's shared_mutex
implementation.

When using mingw-llvm, we can safely use libc++'s shared mutex
implementation.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
CMakeLists.txt
src/common/ceph_mutex.h

index 1778a7202649afa6b313a44302b9d0a00a626931..ceffeccc29a782ef62a47071bc366077150ecd82 100644 (file)
@@ -41,15 +41,19 @@ if(WIN32)
   # the targeted Windows version. The availability of certain functions and
   # structures will depend on it.
   set(WIN32_WINNT "0x0A00" CACHE STRING "Targeted Windows version.")
-  # In order to avoid known winpthread issues, we're using the boost
-  # shared mutex implementation.
-  # https://github.com/msys2/MINGW-packages/issues/3319
   add_definitions(
     -D_WIN32_WINNT=${WIN32_WINNT}
     -DFMT_USE_TZSET=0
-    -DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
-    -DBOOST_THREAD_V2_SHARED_MUTEX
   )
+  # In order to avoid known winpthread issues, we're using the Boost
+  # shared mutex implementation. This isn't required with llvm/libc++.
+  # https://github.com/msys2/MINGW-packages/issues/3319
+  if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
+    add_definitions(
+      -DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
+      -DBOOST_THREAD_V2_SHARED_MUTEX
+    )
+  endif()
   set(Boost_THREADAPI "win32")
 endif()
 
index 8d87e605b84a5269d5e4fc9d0b719e1bde52857a..6ed8c56d5dad3b8227c3faf036462ab2cab64ca6 100644 (file)
@@ -151,7 +151,7 @@ namespace ceph {
 // The winpthreads shared mutex implementation is broken.
 // We'll use boost::shared_mutex instead.
 // https://github.com/msys2/MINGW-packages/issues/3319
-#if __MINGW32__
+#if defined(__MINGW32__) && !defined(__clang__)
 #include <boost/thread/shared_mutex.hpp>
 #else
 #include <shared_mutex>
@@ -163,7 +163,7 @@ namespace ceph {
   typedef std::recursive_mutex recursive_mutex;
   typedef std::condition_variable condition_variable;
 
-#if __MINGW32__
+#if defined(__MINGW32__) && !defined(__clang__)
   typedef boost::shared_mutex shared_mutex;
 #else
   typedef std::shared_mutex shared_mutex;