You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2007/07/04 02:20:59 UTC
svn commit: r553026 - in /logging/log4cxx/trunk:
include/log4cxx/helpers/objectptr.h src/objectptr.cpp
Author: carnold
Date: Tue Jul 3 17:20:55 2007
New Revision: 553026
URL: http://svn.apache.org/viewvc?view=rev&rev=553026
Log:
LOGCXX-186: Use apr_atomic_xchg32 when void* is 32-bits
Modified:
logging/log4cxx/trunk/include/log4cxx/helpers/objectptr.h
logging/log4cxx/trunk/src/objectptr.cpp
Modified: logging/log4cxx/trunk/include/log4cxx/helpers/objectptr.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/helpers/objectptr.h?view=diff&rev=553026&r1=553025&r2=553026
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/helpers/objectptr.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/helpers/objectptr.h Tue Jul 3 17:20:55 2007
@@ -29,7 +29,6 @@
public:
static void checkNull(const int& null);
static void* exchange(void** destination, void* newValue);
- static void* unsynchronizedExchange(void** destination, void* newValue);
};
Modified: logging/log4cxx/trunk/src/objectptr.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/objectptr.cpp?view=diff&rev=553026&r1=553025&r2=553026
==============================================================================
--- logging/log4cxx/trunk/src/objectptr.cpp (original)
+++ logging/log4cxx/trunk/src/objectptr.cpp Tue Jul 3 17:20:55 2007
@@ -21,6 +21,7 @@
#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/aprinitializer.h>
#include <log4cxx/helpers/synchronized.h>
+#include <apr.h>
#include <apr_atomic.h>
using namespace log4cxx::helpers;
@@ -32,15 +33,14 @@
}
void* ObjectPtrBase::exchange(void** destination, void* newValue) {
+#if APR_SIZEOF_VOIDP == 4
+ return (void*) apr_atomic_xchg32((volatile apr_uint32_t*) destination,
+ (apr_uint32_t) newValue);
+#else
static Mutex mutex(APRInitializer::getRootPool());
synchronized sync(mutex);
void* oldValue = *destination;
*destination = newValue;
return oldValue;
-}
-
-void* ObjectPtrBase::unsynchronizedExchange(void** destination, void* newValue) {
- void* oldValue = *destination;
- *destination = newValue;
- return oldValue;
+#endif
}