cas_flag CompareAndSwap(volatile cas_flag* ptr,
cas_flag new_value,
cas_flag old_value);
cas_flag CompareAndSwap(volatile cas_flag* ptr,
cas_flag new_value,
cas_flag old_value);
- cas_flag AtomicPostIncrement(volatile cas_flag* ptr);
- cas_flag AtomicPostDecrement(volatile cas_flag* ptr);
+ cas_flag AtomicIncrement(volatile cas_flag* ptr);
+ cas_flag AtomicDecrement(volatile cas_flag* ptr);
#include "llvm/AbstractTypeUser.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/AbstractTypeUser.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
+#include "llvm/System/Atomic.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator.h"
#include <string>
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator.h"
#include <string>
/// has no AbstractTypeUsers, the type is deleted. This is only sensical for
/// derived types.
///
/// has no AbstractTypeUsers, the type is deleted. This is only sensical for
/// derived types.
///
- mutable unsigned RefCount;
+ mutable sys::cas_flag RefCount;
const Type *getForwardedTypeInternal() const;
const Type *getForwardedTypeInternal() const;
void addRef() const {
assert(isAbstract() && "Cannot add a reference to a non-abstract type!");
void addRef() const {
assert(isAbstract() && "Cannot add a reference to a non-abstract type!");
+ sys::AtomicIncrement(&RefCount);
// If this is the last PATypeHolder using this object, and there are no
// PATypeHandles using it, the type is dead, delete it now.
// If this is the last PATypeHolder using this object, and there are no
// PATypeHandles using it, the type is dead, delete it now.
- if (--RefCount == 0 && AbstractTypeUsers.empty())
+ sys::cas_flag OldCount = sys::AtomicDecrement(&RefCount);
+ if (OldCount == 0 && AbstractTypeUsers.empty())
-sys::cas_flag sys::AtomicPostIncrement(volatile sys::cas_flag* ptr) {
+sys::cas_flag sys::AtomicIncrement(volatile sys::cas_flag* ptr) {
#if LLVM_MULTITHREADED==0
++(*ptr);
return *ptr;
#if LLVM_MULTITHREADED==0
++(*ptr);
return *ptr;
-sys::cas_flag sys::AtomicPostDecrement(volatile sys::cas_flag* ptr) {
+sys::cas_flag sys::AtomicDecrement(volatile sys::cas_flag* ptr) {
#if LLVM_MULTITHREADED==0
--(*ptr);
return *ptr;
#if LLVM_MULTITHREADED==0
--(*ptr);
return *ptr;