[RWMutex] Simplify availability check
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 16 Aug 2019 21:25:40 +0000 (21:25 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 16 Aug 2019 21:25:40 +0000 (21:25 +0000)
Check for the actual version number for the scenarios where the macOS
version isn't available (__MAC_10_12).

llvm-svn: 369154

llvm/include/llvm/Support/RWMutex.h
llvm/lib/Support/RWMutex.cpp

index b8e13fc..150bc7d 100644 (file)
 #include <shared_mutex>
 
 // std::shared_timed_mutex is only availble on macOS 10.12 and later.
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&                  \
-    defined(__MAC_10_12) &&                                                    \
-    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < __MAC_10_12
-#define USE_RW_MUTEX_IMPL
+#if defined(__APPLE__) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
+#define LLVM_USE_RW_MUTEX_IMPL
+#endif
 #endif
 
 namespace llvm {
 namespace sys {
 
-#if defined(USE_RW_MUTEX_IMPL)
+#if defined(LLVM_USE_RW_MUTEX_IMPL)
 /// Platform agnostic RWMutex class.
 class RWMutexImpl {
   /// @name Constructors
@@ -97,7 +97,7 @@ template <bool mt_only> class SmartRWMutex {
 #if defined(_MSC_VER) || __cplusplus > 201402L
   std::shared_mutex impl;
 #else
-#if !defined(USE_RW_MUTEX_IMPL)
+#if !defined(LLVM_USE_RW_MUTEX_IMPL)
   std::shared_timed_mutex impl;
 #else
   RWMutexImpl impl;
@@ -162,7 +162,7 @@ public:
 typedef SmartRWMutex<false> RWMutex;
 
 /// ScopedReader - RAII acquisition of a reader lock
-#if !defined(USE_RW_MUTEX_IMPL)
+#if !defined(LLVM_USE_RW_MUTEX_IMPL)
 template <bool mt_only>
 using SmartScopedReader = const std::shared_lock<SmartRWMutex<mt_only>>;
 #else
@@ -179,7 +179,7 @@ template <bool mt_only> struct SmartScopedReader {
 typedef SmartScopedReader<false> ScopedReader;
 
 /// ScopedWriter - RAII acquisition of a writer lock
-#if !defined(USE_RW_MUTEX_IMPL)
+#if !defined(LLVM_USE_RW_MUTEX_IMPL)
 template <bool mt_only>
 using SmartScopedWriter = std::lock_guard<SmartRWMutex<mt_only>>;
 #else
index f89e0ed..5accf73 100644 (file)
@@ -14,7 +14,7 @@
 #include "llvm/Support/RWMutex.h"
 #include "llvm/Config/config.h"
 
-#if defined(USE_RW_MUTEX_IMPL)
+#if defined(LLVM_USE_RW_MUTEX_IMPL)
 using namespace llvm;
 using namespace sys;