summaryrefslogtreecommitdiff
path: root/ACE/ace/Atomic_Op.inl
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/Atomic_Op.inl')
-rw-r--r--ACE/ace/Atomic_Op.inl32
1 files changed, 32 insertions, 0 deletions
diff --git a/ACE/ace/Atomic_Op.inl b/ACE/ace/Atomic_Op.inl
index 123df4dc505..714bfe9c1be 100644
--- a/ACE/ace/Atomic_Op.inl
+++ b/ACE/ace/Atomic_Op.inl
@@ -189,6 +189,22 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator= (
}
ACE_INLINE long
+ACE_Atomic_Op<ACE_Thread_Mutex, long>::exchange (long newval)
+{
+#if defined (ACE_HAS_INTRINSIC_INTERLOCKED)
+ return ::_InterlockedExchange (const_cast<long *> (&this->value_), newval);
+#elif defined (WIN32)
+ return ::InterlockedExchange (const_cast<long *> (&this->value_), newval);
+#elif defined (ACE_HAS_VXATOMICLIB)
+ return ::vxAtomicSet (reinterpret_cast <atomic_t*>(const_cast<long *> (&this->value_)), newval);
+#elif defined (ACE_HAS_SOLARIS_ATOMIC_LIB)
+ return ::atomic_swap_ulong (reinterpret_cast<volatile unsigned long*>(&this->value_), newval);
+#else /* WIN32 */
+ return (*exchange_fn_) (&this->value_, newval);
+#endif /* WIN32 */
+}
+
+ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::value (void) const
{
return this->value_;
@@ -373,6 +389,22 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator= (
}
ACE_INLINE unsigned long
+ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::exchange (unsigned long newval)
+{
+#if defined (ACE_HAS_INTRINSIC_INTERLOCKED)
+ return ::_InterlockedExchange (const_cast<long *> (reinterpret_cast<volatile long*> (&this->value_)), newval);
+#elif defined (WIN32)
+ return ::InterlockedExchange (const_cast<long *> (reinterpret_cast<volatile long*> (&this->value_)), newval);
+#elif defined (ACE_HAS_VXATOMICLIB)
+ return ::vxAtomicSet (reinterpret_cast <atomic_t*>(const_cast<long *> (reinterpret_cast<volatile long*> (&this->value_))), newval);
+#elif defined (ACE_HAS_SOLARIS_ATOMIC_LIB)
+ return ::atomic_swap_ulong (&this->value_, newval);
+#else /* WIN32 */
+ return (*exchange_fn_) (reinterpret_cast<volatile long *> (&this->value_), newval);
+#endif /* WIN32 */
+}
+
+ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::value (void) const
{
return this->value_;