From Mathias Froehlich, "fixed win32/win64 configure check and win32/win64

atomic related compile failures with msvs2005. Attached changes to make win32
really use the atomic stuff. There are pointer typecast problems and some
historic alignment restrictions that I just took from a previous similar
implementation of mine without looking deep enough. "
This commit is contained in:
Robert Osfield
2008-06-23 14:51:34 +00:00
parent 62fb2d4634
commit 0b6e605795
2 changed files with 7 additions and 9 deletions

View File

@@ -99,7 +99,7 @@ class Atomic {
mutable Mutex _mutex;
#endif
#if defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
__declspec(align(32)) volatile long _value;
volatile long _value;
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
volatile uint_t _value;
#else
@@ -129,7 +129,7 @@ public:
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return ptrOld == atomic_cas_ptr(&_ptr, ptrOld, ptrNew);
#elif defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
return ptrOld == InterlockedCompareExchangePointer(&_ptr, ptrNew, ptrOld);
return ptrOld == InterlockedCompareExchangePointer((PVOID volatile*)&_ptr, (PVOID)ptrNew, (PVOID)ptrOld);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock<Mutex> lock(_mutex);
if (_ptr != ptrOld)
@@ -171,9 +171,6 @@ private:
#if defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
mutable Mutex _mutex;
#endif
#if defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
__declspec(align(32))
#endif
T* volatile _ptr;
};