You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by jb...@apache.org on 2008/03/07 02:09:45 UTC

svn commit: r634493 - /xerces/c/trunk/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp

Author: jberry
Date: Thu Mar  6 17:09:44 2008
New Revision: 634493

URL: http://svn.apache.org/viewvc?rev=634493&view=rev
Log:
Use OSAtomic routines, rather than DriverSyncronization routines, for compatibility with 64 bit pointers when we're being used on a 64 bit architecture.

Modified:
    xerces/c/trunk/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp

Modified: xerces/c/trunk/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp?rev=634493&r1=634492&r2=634493&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/AtomicOpManagers/MacOSAtomicOpMgr.cpp Thu Mar  6 17:09:44 2008
@@ -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 @@
 {
     // 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 @@
 //
 //	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));
 }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org