[Lldb-commits] [lldb] r190927 - Added new Host/Atomic.h to replace use of <atomic> in LLDB headers.
Virgile Bello
virgile.bello at gmail.com
Wed Sep 18 02:11:16 PDT 2013
Author: xen2
Date: Wed Sep 18 04:11:16 2013
New Revision: 190927
URL: http://llvm.org/viewvc/llvm-project?rev=190927&view=rev
Log:
Added new Host/Atomic.h to replace use of <atomic> in LLDB headers.
Added:
lldb/trunk/include/lldb/Host/Atomic.h
Modified:
lldb/trunk/include/lldb/DataFormatters/FormatManager.h
lldb/trunk/include/lldb/Utility/SharingPtr.h
Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=190927&r1=190926&r2=190927&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Wed Sep 18 04:11:16 2013
@@ -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;
Added: lldb/trunk/include/lldb/Host/Atomic.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Atomic.h?rev=190927&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/Atomic.h (added)
+++ lldb/trunk/include/lldb/Host/Atomic.h Wed Sep 18 04:11:16 2013
@@ -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
Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=190927&r1=190926&r2=190927&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/SharingPtr.h (original)
+++ lldb/trunk/include/lldb/Utility/SharingPtr.h Wed Sep 18 04:11:16 2013
@@ -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>;
More information about the lldb-commits
mailing list