From 6fd2258f86c29e0aa50b2b52f4c2c857e957e48c Mon Sep 17 00:00:00 2001 From: James David Berry <jberry@apache.org> Date: Fri, 7 Mar 2008 01:09:44 +0000 Subject: [PATCH] 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 --- .../AtomicOpManagers/MacOSAtomicOpMgr.cpp | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp b/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp index 628db8718..9b8448efc 100644 --- a/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp +++ b/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp @@ -23,7 +23,7 @@ #include <xercesc/util/XercesDefs.hpp> #include <xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.hpp> -#include <CoreServices/CoreServices.h> +#include <libkern/OSAtomic.h> XERCES_CPP_NAMESPACE_BEGIN @@ -46,11 +46,11 @@ MacOSAtomicOpMgr::compareAndSwap(void** toFill { // Replace *toFill with newValue iff *toFill == toCompare, // returning previous value of *toFill - - Boolean success = CompareAndSwap( - reinterpret_cast<UInt32>(toCompare), - reinterpret_cast<UInt32>(newValue), - reinterpret_cast<UInt32*>(toFill)); + bool success = OSAtomicCompareAndSwapPtrBarrier( + const_cast<void*>(toCompare), + const_cast<void*>(newValue), + toFill + ); return (success) ? const_cast<void*>(toCompare) : *toFill; } @@ -59,22 +59,19 @@ MacOSAtomicOpMgr::compareAndSwap(void** toFill // // Atomic Increment and Decrement // -// Apple's routines return the value as it was before the -// operation, while these routines want to return it as it -// is after. So we perform the translation before returning -// the value. +// The return value is the value following the increment or decrement operation // int MacOSAtomicOpMgr::increment(int &location) { - return IncrementAtomic(reinterpret_cast<long*>(&location)) + 1; + return OSAtomicIncrement32Barrier(reinterpret_cast<int32_t*>(&location)); } int MacOSAtomicOpMgr::decrement(int &location) { - return DecrementAtomic(reinterpret_cast<long*>(&location)) - 1; + return OSAtomicDecrement32Barrier(reinterpret_cast<int32_t*>(&location)); } -- GitLab