summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/DataFormatters/FormatManager.h7
-rw-r--r--lldb/include/lldb/Host/Atomic.h47
-rw-r--r--lldb/include/lldb/Utility/SharingPtr.h14
3 files changed, 58 insertions, 10 deletions
diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h
index 0b1086e0c3e..09904a6e1f2 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -12,7 +12,6 @@
// C Includes
// C++ Includes
-#include <atomic>
// Other libraries and framework includes
// Project includes
@@ -24,6 +23,8 @@
#include "lldb/DataFormatters/TypeCategory.h"
#include "lldb/DataFormatters/TypeCategoryMap.h"
+#include "lldb/Host/Atomic.h"
+
namespace lldb_private {
// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
@@ -192,7 +193,7 @@ public:
void
Changed ()
{
- m_last_revision.fetch_add(1);
+ AtomicIncrement((cas_flag*)&m_last_revision);
m_format_cache.Clear ();
}
@@ -210,7 +211,7 @@ private:
FormatCache m_format_cache;
ValueNavigator m_value_nav;
NamedSummariesMap m_named_summaries_map;
- std::atomic<uint32_t> m_last_revision;
+ uint32_t m_last_revision;
TypeCategoryMap m_categories_map;
ConstString m_default_category_name;
diff --git a/lldb/include/lldb/Host/Atomic.h b/lldb/include/lldb/Host/Atomic.h
new file mode 100644
index 00000000000..697f738e52a
--- /dev/null
+++ b/lldb/include/lldb/Host/Atomic.h
@@ -0,0 +1,47 @@
+//===-- Atomic.h ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Atomic_h_
+#define liblldb_Atomic_h_
+
+#ifdef _MSC_VER
+#include <intrin.h>
+#endif
+
+namespace lldb_private {
+
+#ifdef _MSC_VER
+typedef long cas_flag;
+#else
+typedef uint32_t cas_flag;
+#endif
+
+inline cas_flag
+AtomicIncrement(volatile cas_flag* ptr)
+{
+#ifdef _MSC_VER
+ return _InterlockedIncrement(ptr);
+#else
+ return __sync_add_and_fetch(ptr, 1);
+#endif
+}
+
+inline cas_flag
+AtomicDecrement(volatile cas_flag* ptr)
+{
+#ifdef _MSC_VER
+ return _InterlockedDecrement(ptr);
+#else
+ return __sync_add_and_fetch(ptr, -1);
+#endif
+}
+
+}
+
+#endif
diff --git a/lldb/include/lldb/Utility/SharingPtr.h b/lldb/include/lldb/Utility/SharingPtr.h
index afae0ee0809..8359c1caf94 100644
--- a/lldb/include/lldb/Utility/SharingPtr.h
+++ b/lldb/include/lldb/Utility/SharingPtr.h
@@ -12,7 +12,7 @@
#include <algorithm>
#include <memory>
-#include <atomic>
+#include "lldb/Host/Atomic.h"
//#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT
#if defined (ENABLE_SP_LOGGING)
@@ -27,16 +27,16 @@ namespace imp {
template <class T>
inline T
-increment(std::atomic<T>& t)
+increment(T& t)
{
- return t.fetch_add(1);
+ return AtomicIncrement((cas_flag*)&t);
}
template <class T>
inline T
-decrement(std::atomic<T>& t)
+decrement(T& t)
{
- return t.fetch_sub(1);
+ return AtomicDecrement((cas_flag*)&t);
}
class shared_count
@@ -45,7 +45,7 @@ class shared_count
shared_count& operator=(const shared_count&);
protected:
- std::atomic<long> shared_owners_;
+ long shared_owners_;
virtual ~shared_count();
private:
virtual void on_zero_shared() = 0;
@@ -580,7 +580,7 @@ public:
}
protected:
- std::atomic<long> shared_owners_;
+ long shared_owners_;
friend class IntrusiveSharingPtr<T>;
OpenPOWER on IntegriCloud