diff options
author | Virgile Bello <virgile.bello@gmail.com> | 2013-09-18 09:11:16 +0000 |
---|---|---|
committer | Virgile Bello <virgile.bello@gmail.com> | 2013-09-18 09:11:16 +0000 |
commit | 90ec1643ad81364cc64dd23a9b98f097cf96c5fc (patch) | |
tree | 857821a1c3454fc72b81f6c3f2f632b54dd98d82 | |
parent | b88c30facd07c2d3b6a37138f66a9001ddc442c7 (diff) | |
download | bcm5719-llvm-90ec1643ad81364cc64dd23a9b98f097cf96c5fc.tar.gz bcm5719-llvm-90ec1643ad81364cc64dd23a9b98f097cf96c5fc.zip |
Added new Host/Atomic.h to replace use of <atomic> in LLDB headers.
llvm-svn: 190927
-rw-r--r-- | lldb/include/lldb/DataFormatters/FormatManager.h | 7 | ||||
-rw-r--r-- | lldb/include/lldb/Host/Atomic.h | 47 | ||||
-rw-r--r-- | lldb/include/lldb/Utility/SharingPtr.h | 14 |
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>; |