Use <atomic> instead of "llvm/Support/Atomic.h". Removed unused RefCounter class.
authorVirgile Bello <virgile.bello@gmail.com>
Thu, 5 Sep 2013 16:38:02 +0000 (16:38 +0000)
committerVirgile Bello <virgile.bello@gmail.com>
Thu, 5 Sep 2013 16:38:02 +0000 (16:38 +0000)
llvm-svn: 190062

lldb/include/lldb/DataFormatters/FormatManager.h
lldb/include/lldb/Utility/RefCounter.h [deleted file]
lldb/include/lldb/Utility/SharingPtr.h
lldb/lldb.xcodeproj/project.pbxproj
lldb/source/Utility/CMakeLists.txt
lldb/source/Utility/RefCounter.cpp [deleted file]

index 41ca1f4..0b1086e 100644 (file)
@@ -12,6 +12,7 @@
 
 // C Includes
 // C++ Includes
+#include <atomic>
 
 // Other libraries and framework includes
 // Project includes
@@ -23,8 +24,6 @@
 #include "lldb/DataFormatters/TypeCategory.h"
 #include "lldb/DataFormatters/TypeCategoryMap.h"
 
-#include "llvm/Support/Atomic.h"
-
 namespace lldb_private {
     
 // this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
@@ -193,7 +192,7 @@ public:
     void
     Changed ()
     {
-        llvm::sys::AtomicIncrement(&m_last_revision);
+        m_last_revision.fetch_add(1);
         m_format_cache.Clear ();
     }
     
@@ -211,7 +210,7 @@ private:
     FormatCache m_format_cache;
     ValueNavigator m_value_nav;
     NamedSummariesMap m_named_summaries_map;
-    llvm::sys::cas_flag m_last_revision;
+    std::atomic<uint32_t> m_last_revision;
     TypeCategoryMap m_categories_map;
     
     ConstString m_default_category_name;
diff --git a/lldb/include/lldb/Utility/RefCounter.h b/lldb/include/lldb/Utility/RefCounter.h
deleted file mode 100644 (file)
index 0480406..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//===-- RefCounter.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_RefCounter_h_
-#define liblldb_RefCounter_h_
-
-#include "lldb/lldb-public.h"
-#include "llvm/Support/Atomic.h"
-
-namespace lldb_utility {
-
-//----------------------------------------------------------------------
-// A simple reference counter object. You need an uint32_t* to use it
-// Once that is in place, everyone who needs to ref-count, can say
-// RefCounter ref(ptr);
-// (of course, the pointer is a shared resource, and must be accessible to
-// everyone who needs it). Synchronization is handled by RefCounter itself
-// The counter is decreased each time a RefCounter to it goes out of scope
-//----------------------------------------------------------------------
-class RefCounter
-{
-public:
-    typedef uint32_t value_type;
-    
-    RefCounter(value_type* ctr);
-    
-    ~RefCounter();
-    
-private:
-    value_type* m_counter;
-    DISALLOW_COPY_AND_ASSIGN (RefCounter);
-    
-    template <class T>
-    inline T
-    increment(T* t)
-    {
-        return llvm::sys::AtomicIncrement((llvm::sys::cas_flag*)&t);
-    }
-    
-    template <class T>
-    inline T
-    decrement(T* t)
-    {
-        return llvm::sys::AtomicDecrement((llvm::sys::cas_flag*)&t);
-    }
-    
-};
-
-} // namespace lldb_utility
-
-#endif // #ifndef liblldb_RefCounter_h_
index b512104..afae0ee 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <algorithm>
 #include <memory>
-#include "llvm/Support/Atomic.h"
+#include <atomic>
 
 //#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(T& t)
+increment(std::atomic<T>& t)
 {
-    return llvm::sys::AtomicIncrement((llvm::sys::cas_flag*)&t);
+    return t.fetch_add(1);
 }
 
 template <class T>
 inline T
-decrement(T& t)
+decrement(std::atomic<T>& t)
 {
-    return llvm::sys::AtomicDecrement((llvm::sys::cas_flag*)&t);
+    return t.fetch_sub(1);
 }
 
 class shared_count
@@ -45,7 +45,7 @@ class shared_count
     shared_count& operator=(const shared_count&);
 
 protected:
-    long shared_owners_;
+    std::atomic<long> shared_owners_;
     virtual ~shared_count();
 private:
     virtual void on_zero_shared() = 0;
@@ -580,7 +580,7 @@ public:
     }
     
 protected:
-    long shared_owners_;
+    std::atomic<long> shared_owners_;
    
     friend class IntrusiveSharingPtr<T>;
     
index 2bf84fd..9c1275c 100644 (file)
                945E8D80152F6AB40019BCCD /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945E8D7F152F6AB40019BCCD /* StreamGDBRemote.cpp */; };
                9452573A16262D0200325455 /* SBDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9452573916262D0200325455 /* SBDeclaration.cpp */; };
                9456F2241616671900656F91 /* DynamicLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9456F2211616644B00656F91 /* DynamicLibrary.cpp */; };
-               94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; };
                9461569A14E358A6003A195C /* SBTypeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568A14E35621003A195C /* SBTypeFilter.cpp */; };
                9461569B14E358A6003A195C /* SBTypeFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568B14E35621003A195C /* SBTypeFormat.cpp */; };
                9461569C14E358A6003A195C /* SBTypeSummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568C14E35621003A195C /* SBTypeSummary.cpp */; };
                9452573916262D0200325455 /* SBDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBDeclaration.cpp; path = source/API/SBDeclaration.cpp; sourceTree = "<group>"; };
                9456F2211616644B00656F91 /* DynamicLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLibrary.cpp; sourceTree = "<group>"; };
                9456F2231616645A00656F91 /* DynamicLibrary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DynamicLibrary.h; path = include/lldb/Host/DynamicLibrary.h; sourceTree = "<group>"; };
-               94611EAF13CCA363003A22AF /* RefCounter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RefCounter.h; path = include/lldb/Utility/RefCounter.h; sourceTree = "<group>"; };
-               94611EB113CCA4A4003A22AF /* RefCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RefCounter.cpp; path = source/Utility/RefCounter.cpp; sourceTree = "<group>"; };
                9461568614E355F2003A195C /* SBTypeFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeFilter.h; path = include/lldb/API/SBTypeFilter.h; sourceTree = "<group>"; };
                9461568714E355F2003A195C /* SBTypeFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeFormat.h; path = include/lldb/API/SBTypeFormat.h; sourceTree = "<group>"; };
                9461568814E355F2003A195C /* SBTypeSummary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeSummary.h; path = include/lldb/API/SBTypeSummary.h; sourceTree = "<group>"; };
                                94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */,
                                2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */,
                                2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */,
-                               94611EAF13CCA363003A22AF /* RefCounter.h */,
-                               94611EB113CCA4A4003A22AF /* RefCounter.cpp */,
                                261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */,
                                4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */,
                                261B5A5311C3F2AD00AABD0A /* SharingPtr.h */,
                                9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */,
                                49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */,
                                26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */,
-                               94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */,
                                94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */,
                                2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */,
                                2642FBB013D003B400ED6808 /* ProcessKDP.cpp in Sources */,
index ca677bc..64b1787 100644 (file)
@@ -5,7 +5,6 @@ add_lldb_library(lldbUtility
   KQueue.cpp\r
   PseudoTerminal.cpp\r
   Range.cpp\r
-  RefCounter.cpp\r
   SharingPtr.cpp\r
   StringExtractor.cpp\r
   StringExtractorGDBRemote.cpp\r
diff --git a/lldb/source/Utility/RefCounter.cpp b/lldb/source/Utility/RefCounter.cpp
deleted file mode 100644 (file)
index c3acedd..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-//===---------------------RefCounter.cpp ------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Utility/RefCounter.h"
-
-namespace lldb_utility {
-
-RefCounter::RefCounter(RefCounter::value_type* ctr):
-m_counter(ctr)
-{
-    increment(m_counter);
-}
-
-RefCounter::~RefCounter()
-{
-    decrement(m_counter);
-}
-
-} // namespace lldb_utility