Skip to content
Snippets Groups Projects
Commit 6fd2258f authored by James David Berry's avatar James David Berry
Browse files

Use OSAtomic routines, rather than DriverSyncronization routines, for...

Use OSAtomic routines, rather than DriverSyncronization routines, for compatibility with 64 bit pointers when we're being used on a 64 bit architecture.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@634493 13f79535-47bb-0310-9956-ffa450edef68
parent ebc10988
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <xercesc/util/XercesDefs.hpp> #include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.hpp> #include <xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.hpp>
#include <CoreServices/CoreServices.h> #include <libkern/OSAtomic.h>
XERCES_CPP_NAMESPACE_BEGIN XERCES_CPP_NAMESPACE_BEGIN
...@@ -46,11 +46,11 @@ MacOSAtomicOpMgr::compareAndSwap(void** toFill ...@@ -46,11 +46,11 @@ MacOSAtomicOpMgr::compareAndSwap(void** toFill
{ {
// Replace *toFill with newValue iff *toFill == toCompare, // Replace *toFill with newValue iff *toFill == toCompare,
// returning previous value of *toFill // returning previous value of *toFill
bool success = OSAtomicCompareAndSwapPtrBarrier(
Boolean success = CompareAndSwap( const_cast<void*>(toCompare),
reinterpret_cast<UInt32>(toCompare), const_cast<void*>(newValue),
reinterpret_cast<UInt32>(newValue), toFill
reinterpret_cast<UInt32*>(toFill)); );
return (success) ? const_cast<void*>(toCompare) : *toFill; return (success) ? const_cast<void*>(toCompare) : *toFill;
} }
...@@ -59,22 +59,19 @@ MacOSAtomicOpMgr::compareAndSwap(void** toFill ...@@ -59,22 +59,19 @@ MacOSAtomicOpMgr::compareAndSwap(void** toFill
// //
// Atomic Increment and Decrement // Atomic Increment and Decrement
// //
// Apple's routines return the value as it was before the // The return value is the value following the increment or decrement operation
// operation, while these routines want to return it as it
// is after. So we perform the translation before returning
// the value.
// //
int int
MacOSAtomicOpMgr::increment(int &location) MacOSAtomicOpMgr::increment(int &location)
{ {
return IncrementAtomic(reinterpret_cast<long*>(&location)) + 1; return OSAtomicIncrement32Barrier(reinterpret_cast<int32_t*>(&location));
} }
int int
MacOSAtomicOpMgr::decrement(int &location) MacOSAtomicOpMgr::decrement(int &location)
{ {
return DecrementAtomic(reinterpret_cast<long*>(&location)) - 1; return OSAtomicDecrement32Barrier(reinterpret_cast<int32_t*>(&location));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment