diff options
-rw-r--r-- | lldb/include/lldb/DataFormatters/FormatManager.h | 7 | ||||
-rw-r--r-- | lldb/include/lldb/Utility/RefCounter.h | 57 | ||||
-rw-r--r-- | lldb/include/lldb/Utility/SharingPtr.h | 14 | ||||
-rw-r--r-- | lldb/lldb.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | lldb/source/Utility/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lldb/source/Utility/RefCounter.cpp | 25 |
6 files changed, 10 insertions, 100 deletions
diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h index 41ca1f419d7..0b1086e0c3e 100644 --- a/lldb/include/lldb/DataFormatters/FormatManager.h +++ b/lldb/include/lldb/DataFormatters/FormatManager.h @@ -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 index 0480406dfbc..00000000000 --- a/lldb/include/lldb/Utility/RefCounter.h +++ /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_ diff --git a/lldb/include/lldb/Utility/SharingPtr.h b/lldb/include/lldb/Utility/SharingPtr.h index b512104fa7e..afae0ee0809 100644 --- a/lldb/include/lldb/Utility/SharingPtr.h +++ b/lldb/include/lldb/Utility/SharingPtr.h @@ -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>; diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 2bf84fd28e6..9c1275c3324 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -536,7 +536,6 @@ 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 */; }; @@ -1583,8 +1582,6 @@ 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>"; }; @@ -2417,8 +2414,6 @@ 94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */, 2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */, 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */, - 94611EAF13CCA363003A22AF /* RefCounter.h */, - 94611EB113CCA4A4003A22AF /* RefCounter.cpp */, 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */, 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */, 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */, @@ -4312,7 +4307,6 @@ 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 */, diff --git a/lldb/source/Utility/CMakeLists.txt b/lldb/source/Utility/CMakeLists.txt index ca677bc0394..64b17871fb0 100644 --- a/lldb/source/Utility/CMakeLists.txt +++ b/lldb/source/Utility/CMakeLists.txt @@ -5,7 +5,6 @@ add_lldb_library(lldbUtility KQueue.cpp
PseudoTerminal.cpp
Range.cpp
- RefCounter.cpp
SharingPtr.cpp
StringExtractor.cpp
StringExtractorGDBRemote.cpp
diff --git a/lldb/source/Utility/RefCounter.cpp b/lldb/source/Utility/RefCounter.cpp deleted file mode 100644 index c3acedd2f05..00000000000 --- a/lldb/source/Utility/RefCounter.cpp +++ /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 |