// -*- C++ -*- #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) # include "ace/os_include/os_intrin.h" # pragma intrinsic (_InterlockedExchange, _InterlockedExchangeAdd, _InterlockedIncrement, _InterlockedDecrement) #endif /* ACE_HAS_INTRINSIC_INTERLOCKED */ #if defined (ACE_HAS_VXATOMICLIB) # include #endif ACE_BEGIN_VERSIONED_NAMESPACE_DECL #if defined (ACE_HAS_BUILTIN_ATOMIC_OP) ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : value_ (0) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (long c) : value_ (c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op ( const ACE_Atomic_Op &rhs) : value_ (rhs.value_) { } ACE_INLINE long ACE_Atomic_Op::operator++ () { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return ::_InterlockedIncrement (const_cast (&this->value_)); #elif defined (WIN32) return ::InterlockedIncrement (const_cast (&this->value_)); #elif defined (ACE_HAS_VXATOMICLIB) return ::vxAtomicInc (reinterpret_cast (const_cast (&this->value_))) + 1; #else /* WIN32 */ return (*increment_fn_) (&this->value_); #endif /* WIN32 */ } ACE_INLINE long ACE_Atomic_Op::operator++ (int) { return ++*this - 1; } ACE_INLINE long ACE_Atomic_Op::operator-- () { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return ::_InterlockedDecrement (const_cast (&this->value_)); #elif defined (WIN32) return ::InterlockedDecrement (const_cast (&this->value_)); #elif defined (ACE_HAS_VXATOMICLIB) return ::vxAtomicDec (reinterpret_cast (const_cast (&this->value_))) - 1; #else /* WIN32 */ return (*decrement_fn_) (&this->value_); #endif /* WIN32 */ } ACE_INLINE long ACE_Atomic_Op::operator-- (int) { return --*this + 1; } ACE_INLINE long ACE_Atomic_Op::operator+= (long rhs) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return ::_InterlockedExchangeAdd (const_cast (&this->value_), rhs) + rhs; #elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) return ::InterlockedExchangeAdd (const_cast (&this->value_), rhs) + rhs; #elif defined (ACE_HAS_VXATOMICLIB) return ::vxAtomicAdd (reinterpret_cast (const_cast (&this->value_)), rhs) + rhs; #else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ return (*exchange_add_fn_) (&this->value_, rhs) + rhs; #endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ } ACE_INLINE long ACE_Atomic_Op::operator-= (long rhs) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return ::_InterlockedExchangeAdd (const_cast (&this->value_), -rhs) - rhs; #elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) return ::InterlockedExchangeAdd (const_cast (&this->value_), -rhs) - rhs; #elif defined (ACE_HAS_VXATOMICLIB) return ::vxAtomicSub (reinterpret_cast (const_cast (&this->value_)), rhs) - rhs; #else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ return (*exchange_add_fn_) (&this->value_, -rhs) - rhs; #endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ } ACE_INLINE bool ACE_Atomic_Op::operator== (long rhs) const { return (this->value_ == rhs); } ACE_INLINE bool ACE_Atomic_Op::operator!= (long rhs) const { return (this->value_ != rhs); } ACE_INLINE bool ACE_Atomic_Op::operator>= (long rhs) const { return (this->value_ >= rhs); } ACE_INLINE bool ACE_Atomic_Op::operator> (long rhs) const { return (this->value_ > rhs); } ACE_INLINE bool ACE_Atomic_Op::operator<= (long rhs) const { return (this->value_ <= rhs); } ACE_INLINE bool ACE_Atomic_Op::operator< (long rhs) const { return (this->value_ < rhs); } ACE_INLINE ACE_Atomic_Op & ACE_Atomic_Op::operator= (long rhs) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) ::_InterlockedExchange (const_cast (&this->value_), rhs); #elif defined (WIN32) ::InterlockedExchange (const_cast (&this->value_), rhs); #elif defined (ACE_HAS_VXATOMICLIB) ::vxAtomicSet (reinterpret_cast (const_cast (&this->value_)), rhs); #else /* WIN32 */ (*exchange_fn_) (&this->value_, rhs); #endif /* WIN32 */ return *this; } ACE_INLINE ACE_Atomic_Op & ACE_Atomic_Op::operator= ( const ACE_Atomic_Op &rhs) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) ::_InterlockedExchange (const_cast (&this->value_), rhs.value_); #elif defined (WIN32) ::InterlockedExchange (const_cast (&this->value_), rhs.value_); #elif defined (ACE_HAS_VXATOMICLIB) ::vxAtomicSet (reinterpret_cast (const_cast (&this->value_)), rhs.value_); #else /* WIN32 */ (*exchange_fn_) (&this->value_, rhs.value_); #endif /* WIN32 */ return *this; } ACE_INLINE long ACE_Atomic_Op::exchange (long newval) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return ::_InterlockedExchange (const_cast (&this->value_), newval); #elif defined (WIN32) return ::InterlockedExchange (const_cast (&this->value_), newval); #elif defined (ACE_HAS_VXATOMICLIB) return ::vxAtomicSet (reinterpret_cast (const_cast (&this->value_)), newval); #else /* WIN32 */ return (*exchange_fn_) (&this->value_, newval); #endif /* WIN32 */ } ACE_INLINE long ACE_Atomic_Op::value () const { return this->value_; } ACE_INLINE volatile long & ACE_Atomic_Op::value_i () { return this->value_; } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : value_ (0) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (unsigned long c) : value_ (c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op ( const ACE_Atomic_Op &rhs) : value_ (rhs.value_) { } ACE_INLINE unsigned long ACE_Atomic_Op::operator++ () { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return static_cast (::_InterlockedIncrement (const_cast (reinterpret_cast(&this->value_)))); #elif defined (WIN32) return static_cast (::InterlockedIncrement (const_cast (reinterpret_cast(&this->value_)))); #elif defined (ACE_HAS_VXATOMICLIB) return static_cast (::vxAtomicInc (reinterpret_cast (const_cast (reinterpret_cast(&this->value_))))) + 1; #else /* WIN32 */ return static_cast ((*increment_fn_) (reinterpret_cast (&this->value_))); #endif /* WIN32 */ } ACE_INLINE unsigned long ACE_Atomic_Op::operator++ (int) { return ++*this - 1; } ACE_INLINE unsigned long ACE_Atomic_Op::operator-- () { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return static_cast (::_InterlockedDecrement (const_cast (reinterpret_cast(&this->value_)))); #elif defined (WIN32) return static_cast (::InterlockedDecrement (const_cast (reinterpret_cast(&this->value_)))); #elif defined (ACE_HAS_VXATOMICLIB) return static_cast (::vxAtomicDec (reinterpret_cast (const_cast (reinterpret_cast(&this->value_))))) - 1; #else /* WIN32 */ return static_cast ((*decrement_fn_) (reinterpret_cast (&this->value_))); #endif /* WIN32 */ } ACE_INLINE unsigned long ACE_Atomic_Op::operator-- (int) { return --*this + 1; } ACE_INLINE unsigned long ACE_Atomic_Op::operator+= (unsigned long rhs) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return static_cast (::_InterlockedExchangeAdd (const_cast (reinterpret_cast (&this->value_)), rhs)) + rhs; #elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) return static_cast (::InterlockedExchangeAdd (const_cast (reinterpret_cast (&this->value_)), rhs)) + rhs; #elif defined (ACE_HAS_VXATOMICLIB) return static_cast (::vxAtomicAdd (reinterpret_cast (const_cast (reinterpret_cast(&this->value_))), rhs)) + rhs; #else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ return static_cast ((*exchange_add_fn_) (reinterpret_cast (&this->value_), rhs)) + rhs; #endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ } ACE_INLINE unsigned long ACE_Atomic_Op::operator-= (unsigned long rhs) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return static_cast (::_InterlockedExchangeAdd (const_cast (reinterpret_cast(&this->value_)), -static_cast(rhs))) - rhs; #elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) return static_cast (::InterlockedExchangeAdd (const_cast (reinterpret_cast(&this->value_)), -static_cast(rhs))) - rhs; #elif defined (ACE_HAS_VXATOMICLIB) return static_cast (::vxAtomicSub (reinterpret_cast (const_cast (reinterpret_cast(&this->value_))), rhs)) - rhs; #else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ long l_rhs = static_cast (rhs); return static_cast ((*exchange_add_fn_) (reinterpret_cast (&this->value_), -l_rhs)) - rhs; #endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ } ACE_INLINE bool ACE_Atomic_Op::operator== (unsigned long rhs) const { return (this->value_ == rhs); } ACE_INLINE bool ACE_Atomic_Op::operator!= (unsigned long rhs) const { return (this->value_ != rhs); } ACE_INLINE bool ACE_Atomic_Op::operator>= (unsigned long rhs) const { return (this->value_ >= rhs); } ACE_INLINE bool ACE_Atomic_Op::operator> (unsigned long rhs) const { return (this->value_ > rhs); } ACE_INLINE bool ACE_Atomic_Op::operator<= (unsigned long rhs) const { return (this->value_ <= rhs); } ACE_INLINE bool ACE_Atomic_Op::operator< (unsigned long rhs) const { return (this->value_ < rhs); } ACE_INLINE ACE_Atomic_Op & ACE_Atomic_Op::operator= (unsigned long rhs) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) ::_InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs); #elif defined (WIN32) ::InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs); #elif defined (ACE_HAS_VXATOMICLIB) ::vxAtomicSet (reinterpret_cast (const_cast (reinterpret_cast (&this->value_))), rhs); #else /* WIN32 */ (*exchange_fn_) (reinterpret_cast (&this->value_), rhs); #endif /* WIN32 */ return *this; } ACE_INLINE ACE_Atomic_Op & ACE_Atomic_Op::operator= ( const ACE_Atomic_Op &rhs) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) ::_InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs.value_); #elif defined (WIN32) ::InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs.value_); #elif defined (ACE_HAS_VXATOMICLIB) ::vxAtomicSet (reinterpret_cast (const_cast (reinterpret_cast (&this->value_))), rhs.value_); #else /* WIN32 */ (*exchange_fn_) (reinterpret_cast (&this->value_), rhs.value_); #endif /* WIN32 */ return *this; } ACE_INLINE unsigned long ACE_Atomic_Op::exchange (unsigned long newval) { #if defined (ACE_HAS_INTRINSIC_INTERLOCKED) return ::_InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), newval); #elif defined (WIN32) return ::InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), newval); #elif defined (ACE_HAS_VXATOMICLIB) return ::vxAtomicSet (reinterpret_cast (const_cast (reinterpret_cast (&this->value_))), newval); #else /* WIN32 */ return (*exchange_fn_) (reinterpret_cast (&this->value_), newval); #endif /* WIN32 */ } ACE_INLINE unsigned long ACE_Atomic_Op::value () const { return this->value_; } ACE_INLINE volatile unsigned long & ACE_Atomic_Op::value_i () { return this->value_; } #endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ #if defined (ACE_HAS_GCC_ATOMIC_BUILTINS) && (ACE_HAS_GCC_ATOMIC_BUILTINS == 1) ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC () { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (int c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (int rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC() { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (unsigned int c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (unsigned int rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC() { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (long c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (long rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC () { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (unsigned long c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (unsigned long rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } // The long long intrinsics are not available on PPC #if !defined (__powerpc__) ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC() { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (long long c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (long long rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC () { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (unsigned long long c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (unsigned long long rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } #endif /* !__powerpc__ */ #if !defined (ACE_LACKS_GCC_ATOMIC_BUILTINS_2) ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC() { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (short c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (short rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC () { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (unsigned short c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (unsigned short rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } #endif #if !defined (ACE_LACKS_GCC_ATOMIC_BUILTINS_1) ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op () : ACE_Atomic_Op_GCC () { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (bool c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op::ACE_Atomic_Op (const ACE_Atomic_Op &c) : ACE_Atomic_Op_GCC(c) { } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (bool rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } ACE_INLINE ACE_Atomic_Op& ACE_Atomic_Op::operator= (const ACE_Atomic_Op &rhs) { ACE_Atomic_Op_GCC::operator= (rhs); return *this; } #endif #endif /* ACE_HAS_GCC_ATOMIC_BUILTINS==1 */ ACE_END_VERSIONED_NAMESPACE_DECL