Added new Host/Atomic.h to replace use of <atomic> in LLDB headers.

llvm-svn: 190927
This commit is contained in:
Virgile Bello 2013-09-18 09:11:16 +00:00
parent b88c30facd
commit 90ec1643ad
3 changed files with 58 additions and 10 deletions

View File

@ -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;

View File

@ -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

View File

@ -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>;