Modified: xerces/c/trunk/src/xercesc/util/Platforms/QNX/QNXPlatformUtils.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/Platforms/QNX/QNXPlatformUtils.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/Platforms/QNX/QNXPlatformUtils.cpp (original) +++ xerces/c/trunk/src/xercesc/util/Platforms/QNX/QNXPlatformUtils.cpp Sat Jun 4 11:36:08 2005 @@ -34,6 +34,7 @@ #include <xercesc/util/Janitor.hpp> #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/RuntimeException.hpp> +#include <xercesc/util/XMLHolder.hpp> #include <xercesc/util/XMLExceptMsgs.hpp> #include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLUniDefs.hpp> @@ -253,41 +254,63 @@ // Mutex methods // --------------------------------------------------------------------------- -void* XMLPlatformUtils::makeMutex() +typedef XMLHolder<pthread_mutex_t> MutexHolderType; + +void* XMLPlatformUtils::makeMutex(MemoryManager* manager) { pthread_mutexattr_t attr; pthread_mutexattr_init( &attr ); pthread_mutexattr_setrecursive( &attr, PTHREAD_RECURSIVE_ENABLE ); - pthread_mutex_t *mutex = new pthread_mutex_t; - if( pthread_mutex_init( mutex, &attr ) != EOK ) { - delete mutex; + + MutexHolderType* const holder = new (manager) MutexHolderType; + + if( pthread_mutex_init( &holder->fInstance, &attr ) != EOK ) { + delete holder; panic(PanicHandler::Panic_MutexErr); } pthread_mutexattr_destroy( &attr ); - return mutex; + return holder; } void XMLPlatformUtils::closeMutex(void* const mtxHandle) { - if( mtxHandle == NULL || pthread_mutex_destroy( (pthread_mutex_t *)mtxHandle ) != EOK ) { - ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotClose, fgMemoryManager); + if (mtxHandle != NULL) + { + MutexHolderType* const holder = + MutexHolderType::castTo(mtxHandle); + + if (pthread_mutex_destroy(&holder->fInstance)) + { + delete holder; + + ThrowXMLwithMemMgr(XMLPlatformUtilsException, + XMLExcepts::Mutex_CouldNotDestroy, fgMemoryManager); + } + delete holder; } - delete mtxHandle; } void XMLPlatformUtils::lockMutex(void* const mtxHandle) { - if( mtxHandle == NULL || pthread_mutex_lock( (pthread_mutex_t *)mtxHandle ) != EOK ) { - panic(PanicHandler::Panic_MutexErr); + if (mtxHandle != NULL) + { + if (pthread_mutex_lock(&MutexHolderType::castTo(mtxHandle)->fInstance)) + { + panic(PanicHandler::Panic_MutexErr); + } } } void XMLPlatformUtils::unlockMutex(void* const mtxHandle) { - if( mtxHandle == NULL || pthread_mutex_unlock( (pthread_mutex_t *)mtxHandle ) != EOK ) { - panic(PanicHandler::Panic_MutexErr); + if (mtxHandle != NULL) + { + if (pthread_mutex_unlock(&MutexHolderType::castTo(mtxHandle)->fInstance)) + { + panic(PanicHandler::Panic_MutexErr); + } } } @@ -340,9 +363,9 @@ XMLNetAccessor* XMLPlatformUtils::makeNetAccessor() { #if defined (XML_USE_NETACCESSOR_LIBWWW) - return new LibWWWNetAccessor(); + return new (fgMemoryManager) LibWWWNetAccessor(); #else - return new SocketNetAccessor(); + return new (fgMemoryManager) SocketNetAccessor(); #endif } @@ -355,9 +378,9 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) { #if defined (XML_USE_ICU_MESSAGELOADER) - return new ICUMsgLoader(msgDomain); + return new (fgMemoryManager) ICUMsgLoader(msgDomain); #else - return new InMemMsgLoader(msgDomain); + return new (fgMemoryManager) InMemMsgLoader(msgDomain); #endif } @@ -371,9 +394,9 @@ XMLTransService* XMLPlatformUtils::makeTransService() { #if defined (XML_USE_ICU_TRANSCODER) - return new ICUTransService; + return new (fgMemoryManager) ICUTransService; #elif defined (XML_USE_GNU_TRANSCODER) - return new IconvGNUTransService; + return new (fgMemoryManager) IconvGNUTransService; #else #error You must provide a transcoding service implementation #endif
Modified: xerces/c/trunk/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp (original) +++ xerces/c/trunk/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp Sat Jun 4 11:36:08 2005 @@ -49,6 +49,7 @@ #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/RuntimeException.hpp> #include <xercesc/util/Mutexes.hpp> +#include <xercesc/util/XMLHolder.hpp> #include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> @@ -90,9 +91,9 @@ XMLNetAccessor* XMLPlatformUtils::makeNetAccessor() { #if defined (XML_USE_NETACCESSOR_LIBWWW) - return new LibWWWNetAccessor(); + return new (fgMemoryManager) LibWWWNetAccessor(); #elif defined (XML_USE_NETACCESSOR_SOCKET) - return new SocketNetAccessor(); + return new (fgMemoryManager) SocketNetAccessor(); #else return 0; #endif @@ -111,11 +112,11 @@ try { #if defined (XML_USE_ICU_MESSAGELOADER) - retVal = new ICUMsgLoader(msgDomain); + retVal = new (fgMemoryManager) ICUMsgLoader(msgDomain); #elif defined (XML_USE_ICONV_MESSAGELOADER) - retVal = new MsgCatalogLoader(msgDomain); + retVal = new (fgMemoryManager) MsgCatalogLoader(msgDomain); #else - retVal = new InMemMsgLoader(msgDomain); + retVal = new (fgMemoryManager) InMemMsgLoader(msgDomain); #endif } catch(const OutOfMemoryException&) @@ -140,15 +141,15 @@ #if defined (XML_USE_ICU_TRANSCODER) { - return new ICUTransService; + return new (fgMemoryManager) ICUTransService; } #elif defined (XML_USE_ICONV_TRANSCODER) { - return new IconvTransService; + return new (fgMemoryManager) IconvTransService; } #else // Use Native transcoding service { - return new IconvTransService; + return new (fgMemoryManager) IconvTransService; } #endif @@ -389,7 +390,9 @@ // XMLPlatformUtils: Platform init method // --------------------------------------------------------------------------- -static pthread_mutex_t* gAtomicOpMutex =0 ; +typedef XMLHolder<pthread_mutex_t> MutexHolderType; + +static MutexHolderType* gAtomicOpMutex = 0; void XMLPlatformUtils::platformInit() { @@ -401,42 +404,41 @@ // circular dependency between compareAndExchange() and // mutex creation that must be broken. - gAtomicOpMutex = new pthread_mutex_t; + gAtomicOpMutex = new (fgMemoryManager) MutexHolderType; #if defined(XML_USE_DCE) - if (pthread_mutex_init(gAtomicOpMutex, pthread_mutexattr_default)) { - delete gAtomicOpMutex; - gAtomicOpMutex = 0; - panic( PanicHandler::Panic_SystemInit ); - } + if (pthread_mutex_init(&gAtomicOpMutex->fInstance, pthread_mutexattr_default)) { #else // XML_USE_DCE - if (pthread_mutex_init(gAtomicOpMutex, NULL)) { - delete gAtomicOpMutex; - gAtomicOpMutex = 0; + if (pthread_mutex_init(&gAtomicOpMutex->fInstance, NULL)) { +#endif // XML_USE_DCE + delete gAtomicOpMutex; + gAtomicOpMutex = 0; panic( PanicHandler::Panic_SystemInit ); } -#endif // XML_USE_DCE } #ifndef XML_USE_DCE // inlining the class with dce threading causes segmentation fault -class RecursiveMutex +class RecursiveMutex : public XMemory { public: - pthread_mutex_t mutex; - int recursionCount; - pthread_t tid; - - RecursiveMutex() { + pthread_mutex_t mutex; + int recursionCount; + pthread_t tid; + MemoryManager* const fMemoryManager; + + RecursiveMutex(MemoryManager* manager) : + mutex(), + recursionCount(0), + tid(0), + fMemoryManager(manager) { if (pthread_mutex_init(&mutex, NULL)) XMLPlatformUtils::panic(PanicHandler::Panic_MutexErr); - recursionCount = 0; - tid = 0; } ~RecursiveMutex() { if (pthread_mutex_destroy(&mutex)) - ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotDestroy, XMLPlatformUtils::fgMemoryManager); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotDestroy, fMemoryManager); } void lock() { @@ -463,25 +465,27 @@ }; #endif // ifndef XML_USE_DCE -void* XMLPlatformUtils::makeMutex() +void* XMLPlatformUtils::makeMutex(MemoryManager* manager) { #if defined(XML_USE_DCE) - pthread_mutex_t* mutex = new pthread_mutex_t; - if (mutex == NULL) + + MutexHolderType* const holder = new (manager) MutexHolderType; + + if (holder == NULL) { panic(PanicHandler::Panic_MutexErr); } pthread_mutexattr_t attr; pthread_mutexattr_create(&attr); pthread_mutexattr_setkind_np(&attr, MUTEX_RECURSIVE_NP); - if (pthread_mutex_init(mutex, attr)) + if (pthread_mutex_init(&holder->fInstance, attr)) { panic(PanicHandler::Panic_MutexErr); } pthread_mutexattr_delete(&attr); - return (void*)(mutex); + return holder; #else - return new RecursiveMutex; + return new (manager) RecursiveMutex(manager); #endif } @@ -491,8 +495,8 @@ if (mtxHandle == NULL) return; #if defined(XML_USE_DCE) - pthread_mutex_t *rm = (pthread_mutex_t *)mtxHandle; - pthread_mutex_destroy(rm); + MutexHolderType *rm = MutexHolderType::castTo(mtxHandle); + pthread_mutex_destroy(&rm->fInstance); #else RecursiveMutex *rm = (RecursiveMutex *)mtxHandle; #endif @@ -505,8 +509,9 @@ if (mtxHandle == NULL) return; #if defined(XML_USE_DCE) - pthread_mutex_t *rm = (pthread_mutex_t *)mtxHandle; - pthread_mutex_lock(rm); + MutexHolderType *rm = MutexHolderType::castTo(mtxHandle); + + pthread_mutex_lock(&rm->fInstance); #else RecursiveMutex *rm = (RecursiveMutex *)mtxHandle; rm->lock(); @@ -518,8 +523,9 @@ if (mtxHandle == NULL) return; #if defined(XML_USE_DCE) - pthread_mutex_t *rm = (pthread_mutex_t *)mtxHandle; - pthread_mutex_unlock(rm); + MutexHolderType *rm = MutexHolderType::castTo(mtxHandle); + + pthread_mutex_unlock(&rm->fInstance); #else RecursiveMutex *rm = (RecursiveMutex *)mtxHandle; rm->unlock(); @@ -541,14 +547,14 @@ // the below calls are temporarily made till the above functions are part of user library // Currently its supported only in the kernel mode - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock(&gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); void *retVal = *toFill; if (*toFill == toCompare) *toFill = (void *)newValue; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock(&gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); return retVal; @@ -558,12 +564,12 @@ { //return (int)atomic_add_32_nv( (uint32_t*)&location, 1); - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock(&gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); int tmp = ++location; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock(&gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); return tmp; @@ -572,12 +578,12 @@ { //return (int)atomic_add_32_nv( (uint32_t*)&location, -1); - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock(&gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); int tmp = --location; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock(&gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); return tmp; @@ -589,20 +595,20 @@ { } -void XMLPlatformUtils::closeMutex(void* const mtxHandle) +void XMLPlatformUtils::closeMutex(void* const) { } -void XMLPlatformUtils::lockMutex(void* const mtxHandle) +void XMLPlatformUtils::lockMutex(void* const) { } -void* XMLPlatformUtils::makeMutex() +void* XMLPlatformUtils::makeMutex(MemoryManager*) { return 0; } -void XMLPlatformUtils::unlockMutex(void* const mtxHandle) +void XMLPlatformUtils::unlockMutex(void* const) { } @@ -638,7 +644,7 @@ void XMLPlatformUtils::platformTerm() { #if !defined(APP_NO_THREADS) - pthread_mutex_destroy(gAtomicOpMutex); + pthread_mutex_destroy(&gAtomicOpMutex->fInstance); delete gAtomicOpMutex; gAtomicOpMutex = 0; #endif Modified: xerces/c/trunk/src/xercesc/util/Platforms/Tandem/TandemPlatformUtils.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/Platforms/Tandem/TandemPlatformUtils.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/Platforms/Tandem/TandemPlatformUtils.cpp (original) +++ xerces/c/trunk/src/xercesc/util/Platforms/Tandem/TandemPlatformUtils.cpp Sat Jun 4 11:36:08 2005 @@ -94,6 +94,7 @@ #include <sys/timeb.h> #include <string.h> #include <xercesc/util/OutOfMemoryException.hpp> +#include <xercesc/util/XMLHolder.hpp> #if defined (XML_USE_ICU_MESSAGELOADER) #include <xercesc/util/MsgLoaders/ICU/ICUMsgLoader.hpp> @@ -123,11 +124,11 @@ try { #if defined (XML_USE_ICU_MESSAGELOADER) - retVal = new ICUMsgLoader(msgDomain); + retVal = new (fgMemoryManager) ICUMsgLoader(msgDomain); #elif defined (XML_USE_ICONV_MESSAGELOADER) - retVal = new MsgCatalogLoader(msgDomain); + retVal = new (fgMemoryManager) MsgCatalogLoader(msgDomain); #else - retVal = new InMemMsgLoader(msgDomain); + retVal = new (fgMemoryManager) InMemMsgLoader(msgDomain); #endif } catch(const OutOfMemoryException&) @@ -312,49 +313,60 @@ // ----------------------------------------------------------------------- // Mutex methods // ----------------------------------------------------------------------- + +typedef XMLHolder<pthread_mutex_t> MutexHolderType; + void XMLPlatformUtils::closeMutex(void* const mtxHandle) { - if (mtxHandle == NULL) - return; - if (pthread_mutex_destroy( (pthread_mutex_t*)mtxHandle)) + if (mtxHandle != NULL) { - throw XMLPlatformUtilsException("Could not destroy a mutex"); + MutexHolderType* const holder = + MutexHolderType::castTo(mtxHandle); + + if (pthread_mutex_destroy(&holder->fInstance)) + { + delete holder; + + ThrowXMLwithMemMgr(XMLPlatformUtilsException, + XMLExcepts::Mutex_CouldNotDestroy, fgMemoryManager); + } + delete holder; } - if ( (pthread_mutex_t*)mtxHandle) - delete (pthread_mutex_t*) mtxHandle; } + void XMLPlatformUtils::lockMutex(void* const mtxHandle) { - if (mtxHandle == NULL) - return; - if (pthread_mutex_lock( (pthread_mutex_t*)mtxHandle)) + if (mtxHandle != NULL) { - throw XMLPlatformUtilsException("Could not lock a mutex"); + if (pthread_mutex_lock(&MutexHolderType::castTo(mtxHandle)->fInstance)) + { + panic(PanicHandler::Panic_MutexErr); + } } - } -void* XMLPlatformUtils::makeMutex() + +void* XMLPlatformUtils::makeMutex(MemoryManager* manager) { - pthread_mutex_t* mutex = new pthread_mutex_t; - if (mutex == NULL) - { - throw XMLPlatformUtilsException("Could not initialize a mutex"); - } + MutexHolderType* const holder = new (manager) MutexHolderType; - if (pthread_mutex_init(mutex, NULL)) + if (pthread_mutex_init(&holder->fInstance, NULL)) { - throw XMLPlatformUtilsException("Could not create a mutex"); + delete holder; + + panic(PanicHandler::Panic_MutexErr); } - return (void*)(mutex); + return holder; } + void XMLPlatformUtils::unlockMutex(void* const mtxHandle) { - if (mtxHandle == NULL) - return; - if (pthread_mutex_unlock( (pthread_mutex_t*)mtxHandle)) + if (mtxHandle != NULL) { - throw XMLPlatformUtilsException("Could not unlock a mutex"); + if (pthread_mutex_unlock(&MutexHolderType::castTo(mtxHandle)->fInstance)) + { + panic(PanicHandler::Panic_MutexErr); + } } } Modified: xerces/c/trunk/src/xercesc/util/Platforms/Tru64/Tru64PlatformUtils.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/Platforms/Tru64/Tru64PlatformUtils.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/Platforms/Tru64/Tru64PlatformUtils.cpp (original) +++ xerces/c/trunk/src/xercesc/util/Platforms/Tru64/Tru64PlatformUtils.cpp Sat Jun 4 11:36:08 2005 @@ -35,6 +35,7 @@ #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/RuntimeException.hpp> #include <xercesc/util/Mutexes.hpp> +#include <xercesc/util/XMLHolder.hpp> #include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/XMLUniDefs.hpp> @@ -83,11 +84,11 @@ XMLNetAccessor* XMLPlatformUtils::makeNetAccessor() #if defined (XML_USE_NETACCESSOR_LIBWWW) { - return new LibWWWNetAccessor(); + return new (fgMemoryManager) LibWWWNetAccessor(); } #elif defined (XML_USE_NETACCESSOR_SOCKET) { - return new SocketNetAccessor(); + return new (fgMemoryManager) SocketNetAccessor(); } #else { @@ -106,11 +107,11 @@ try { #if defined (XML_USE_ICU_MESSAGELOADER) - retVal = new ICUMsgLoader(msgDomain); + retVal = new (fgMemoryManager) ICUMsgLoader(msgDomain); #elif defined (XML_USE_ICONV_MESSAGELOADER) - retVal = new MsgCatalogLoader(msgDomain); + retVal = new (fgMemoryManager) MsgCatalogLoader(msgDomain); #else - retVal = new InMemMsgLoader(msgDomain); + retVal = new (fgMemoryManager) InMemMsgLoader(msgDomain); #endif } catch(const OutOfMemoryException&) @@ -134,15 +135,15 @@ XMLTransService* XMLPlatformUtils::makeTransService() #if defined (XML_USE_ICU_TRANSCODER) { - return new ICUTransService; + return new (fgMemoryManager) ICUTransService; } #elif defined (XML_USE_ICONV_TRANSCODER) { - return new IconvTransService; + return new (fgMemoryManager) IconvTransService; } #else // Use Native transcoding service { - return new IconvTransService; + return new (fgMemoryManager) IconvTransService; } #endif @@ -387,7 +388,9 @@ // XMLPlatformUtils: Platform init method // --------------------------------------------------------------------------- -static pthread_mutex_t* gAtomicOpMutex =0 ; +typedef XMLHolder<pthread_mutex_t> MutexHolderType; + +static MutexHolderType* gAtomicOpMutex = 0; void XMLPlatformUtils::platformInit() { @@ -399,9 +402,10 @@ // circular dependency between compareAndExchange() and // mutex creation that must be broken. - gAtomicOpMutex = new pthread_mutex_t; + gAtomicOpMutex = new (fgMemoryManager) MutexHolderType; + - if (pthread_mutex_init(gAtomicOpMutex, NULL)) { + if (pthread_mutex_init(&gAtomicOpMutex->fInstance, NULL)) { delete gAtomicOpMutex; gAtomicOpMutex = 0; panic( PanicHandler::Panic_SystemInit ); @@ -420,19 +424,22 @@ pthread_mutex_t mutex; int recursionCount; pthread_t tid; + MemoryManager* const fMemoryManager; - RecursiveMutex() + RecursiveMutex(MemoryManager* manager) : + mutex(), + recursionCount(0), + tid(0), + fMemoryManager(manager) { if (pthread_mutex_init(&mutex, NULL)) XMLPlatformUtils::panic(PanicHandler::Panic_MutexErr); - recursionCount = 0; - tid = 0; } ~RecursiveMutex() { if (pthread_mutex_destroy(&mutex)) - ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotDestroy, XMLPlatformUtils::fgMemoryManager); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotDestroy, fMemoryManager); } void lock() @@ -460,9 +467,9 @@ } }; -void* XMLPlatformUtils::makeMutex() +void* XMLPlatformUtils::makeMutex(MemoryManager* manager) { - return new RecursiveMutex; + return new (manager) RecursiveMutex(manager); } @@ -506,14 +513,14 @@ // the below calls are temporarily made till the above functions are part of user library // Currently its supported only in the kernel mode - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); void *retVal = *toFill; if (*toFill == toCompare) *toFill = (void *)newValue; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); return retVal; @@ -523,12 +530,12 @@ { //return (int)atomic_add_32_nv( (uint32_t*)&location, 1); - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); int tmp = ++location; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); return tmp; @@ -537,12 +544,12 @@ { //return (int)atomic_add_32_nv( (uint32_t*)&location, -1); - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); int tmp = --location; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); return tmp; @@ -555,20 +562,20 @@ // do nothing } -void XMLPlatformUtils::closeMutex(void* const mtxHandle) +void XMLPlatformUtils::closeMutex(void* const) { } -void XMLPlatformUtils::lockMutex(void* const mtxHandle) +void XMLPlatformUtils::lockMutex(void* const) { } -void* XMLPlatformUtils::makeMutex() +void* XMLPlatformUtils::makeMutex(MemoryManager*) { return 0; } -void XMLPlatformUtils::unlockMutex(void* const mtxHandle) +void XMLPlatformUtils::unlockMutex(void* const) { } @@ -604,7 +611,7 @@ void XMLPlatformUtils::platformTerm() { #if !defined (APP_NO_THREADS) - pthread_mutex_destroy(gAtomicOpMutex); + pthread_mutex_destroy(&gAtomicOpMutex->fInstance); delete gAtomicOpMutex; gAtomicOpMutex = 0; #endif Modified: xerces/c/trunk/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp (original) +++ xerces/c/trunk/src/xercesc/util/Platforms/UnixWare/UnixWarePlatformUtils.cpp Sat Jun 4 11:36:08 2005 @@ -139,6 +139,7 @@ #include <xercesc/util/RuntimeException.hpp> #include <xercesc/util/Janitor.hpp> #include <xercesc/util/Mutexes.hpp> +#include <xercesc/util/XMLHolder.hpp> #include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> @@ -491,7 +492,9 @@ // --------------------------------------------------------------------------- // XMLPlatformUtils: Platform init method // --------------------------------------------------------------------------- -static pthread_mutex_t* gAtomicOpMutex =0 ; +typedef XMLHolder<pthread_mutex_t> MutexHolderType; + +static MutexHolderType* gAtomicOpMutex = 0; void XMLPlatformUtils::platformInit() { @@ -503,10 +506,14 @@ // circular dependency between compareAndExchange() and // mutex creation that must be broken. - gAtomicOpMutex = new pthread_mutex_t; + gAtomicOpMutex = new (fgMemoryManager) MutexHolderType; - if (pthread_mutex_init(gAtomicOpMutex, NULL)) + if (pthread_mutex_init(&gAtomicOpMutex->fInstance, NULL)) + { + delete gAtomicOpMutex; + gAtomicOpMutex = 0; panic( PanicHandler::Panic_SystemInit ); + } } class RecursiveMutex : public XMemory @@ -593,14 +600,14 @@ const void* const newValue , const void* const toCompare) { - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); void *retVal = *toFill; if (*toFill == toCompare) *toFill = (void *)newValue; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); @@ -609,12 +616,12 @@ int XMLPlatformUtils::atomicIncrement(int &location) { - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); int tmp = ++location; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); return tmp; @@ -622,12 +629,12 @@ int XMLPlatformUtils::atomicDecrement(int &location) { - if (pthread_mutex_lock( gAtomicOpMutex)) + if (pthread_mutex_lock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); int tmp = --location; - if (pthread_mutex_unlock( gAtomicOpMutex)) + if (pthread_mutex_unlock( &gAtomicOpMutex->fInstance)) panic(PanicHandler::Panic_SynchronizationErr); return tmp; @@ -639,20 +646,20 @@ { } -void* XMLPlatformUtils::makeMutex() +void* XMLPlatformUtils::makeMutex(MemoryManager*) { return 0; } -void XMLPlatformUtils::closeMutex(void* const mtxHandle) +void XMLPlatformUtils::closeMutex(void* const) { } -void XMLPlatformUtils::lockMutex(void* const mtxHandle) +void XMLPlatformUtils::lockMutex(void* const) { } -void XMLPlatformUtils::unlockMutex(void* const mtxHandle) +void XMLPlatformUtils::unlockMutex(void* const) { } @@ -684,7 +691,7 @@ { #if !defined (APP_NO_THREADS) // delete the mutex we created - pthread_mutex_destroy(gAtomicOpMutex); + pthread_mutex_destroy(&gAtomicOpMutex->fInstance); delete gAtomicOpMutex; gAtomicOpMutex = 0; #endif Modified: xerces/c/trunk/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp (original) +++ xerces/c/trunk/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp Sat Jun 4 11:36:08 2005 @@ -24,6 +24,8 @@ #include <xercesc/util/Janitor.hpp> #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/RuntimeException.hpp> +#include <xercesc/util/XMemory.hpp> +#include <xercesc/util/XMLHolder.hpp> #include <xercesc/util/XMLExceptMsgs.hpp> #include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLUniDefs.hpp> @@ -638,34 +640,40 @@ } +typedef XMLHolder<CRITICAL_SECTION> MutexHolderType; + // --------------------------------------------------------------------------- // Mutex methods // --------------------------------------------------------------------------- void XMLPlatformUtils::closeMutex(void* const mtxHandle) { - ::DeleteCriticalSection((LPCRITICAL_SECTION)mtxHandle); - delete (CRITICAL_SECTION*)mtxHandle; + MutexHolderType* const holder = MutexHolderType::castTo(mtxHandle); + + ::DeleteCriticalSection(&holder->fInstance); + delete holder; } void XMLPlatformUtils::lockMutex(void* const mtxHandle) { - ::EnterCriticalSection((LPCRITICAL_SECTION)mtxHandle); + ::EnterCriticalSection(&MutexHolderType::castTo(mtxHandle)->fInstance); } -void* XMLPlatformUtils::makeMutex() +void* XMLPlatformUtils::makeMutex(MemoryManager* manager) { - CRITICAL_SECTION* newCS = new CRITICAL_SECTION; - InitializeCriticalSection(newCS); - return newCS; + MutexHolderType* const holder = new (manager) MutexHolderType; + + InitializeCriticalSection(&holder->fInstance); + + return holder; } void XMLPlatformUtils::unlockMutex(void* const mtxHandle) { - ::LeaveCriticalSection((LPCRITICAL_SECTION)mtxHandle); + ::LeaveCriticalSection(&MutexHolderType::castTo(mtxHandle)->fInstance); } @@ -745,9 +753,9 @@ XMLNetAccessor* XMLPlatformUtils::makeNetAccessor() { #if defined (XML_USE_NETACCESSOR_LIBWWW) - return new LibWWWNetAccessor(); + return new (fgMemoryManager) LibWWWNetAccessor(); #elif defined (XML_USE_NETACCESSOR_WINSOCK) - return new WinSockNetAccessor(); + return new (fgMemoryManager) WinSockNetAccessor(); #else return 0; #endif @@ -762,11 +770,11 @@ XMLMsgLoader* XMLPlatformUtils::loadAMsgSet(const XMLCh* const msgDomain) { #if defined (XML_USE_INMEM_MESSAGELOADER) - return new InMemMsgLoader(msgDomain); + return new (fgMemoryManager) InMemMsgLoader(msgDomain); #elif defined (XML_USE_WIN32_MSGLOADER) - return new Win32MsgLoader(msgDomain); + return new (fgMemoryManager) Win32MsgLoader(msgDomain); #elif defined (XML_USE_ICU_MESSAGELOADER) - return new ICUMsgLoader(msgDomain); + return new (fgMemoryManager) ICUMsgLoader(msgDomain); #else #error You must provide a message loader #endif @@ -788,11 +796,11 @@ // to our DLL. // #if defined (XML_USE_ICU_TRANSCODER) - return new ICUTransService; + return new (fgMemoryManager) ICUTransService; #elif defined (XML_USE_WIN32_TRANSCODER) - return new Win32TransService; + return new (fgMemoryManager) Win32TransService; #elif defined (XML_USE_CYGWIN_TRANSCODER) - return new CygwinTransService; + return new (fgMemoryManager) CygwinTransService; #else #error You must provide a transcoding service implementation #endif Modified: xerces/c/trunk/src/xercesc/util/SynchronizedStringPool.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/SynchronizedStringPool.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/SynchronizedStringPool.cpp (original) +++ xerces/c/trunk/src/xercesc/util/SynchronizedStringPool.cpp Sat Jun 4 11:36:08 2005 @@ -45,6 +45,7 @@ XMLStringPool(modulus, manager) , fConstPool(constPool) + , fMutex(manager) { } Modified: xerces/c/trunk/src/xercesc/util/XMLException.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/XMLException.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/XMLException.cpp (original) +++ xerces/c/trunk/src/xercesc/util/XMLException.cpp Sat Jun 4 11:36:08 2005 @@ -59,7 +59,7 @@ if (!sScannerMutexRegistered) { - sMsgMutex = new XMLMutex; + sMsgMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); msgMutexCleanup.registerCleanup(XMLException::reinitMsgMutex); sScannerMutexRegistered = true; } Modified: xerces/c/trunk/src/xercesc/util/regx/RangeTokenMap.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/regx/RangeTokenMap.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/regx/RangeTokenMap.cpp (original) +++ xerces/c/trunk/src/xercesc/util/regx/RangeTokenMap.cpp Sat Jun 4 11:36:08 2005 @@ -128,7 +128,7 @@ // If we got here first, then register it and set the registered flag if (!sRangeTokMapMutex) { - sRangeTokMapMutex = new XMLMutex; + sRangeTokMapMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); rangeTokMapRegistryCleanup.registerCleanup(reinitRangeTokMapMutex); } } @@ -142,7 +142,7 @@ void XMLInitializer::initializeRangeTokenMap() { - RangeTokenMap::fInstance = new RangeTokenMap(); + RangeTokenMap::fInstance = new RangeTokenMap(XMLPlatformUtils::fgMemoryManager); if (RangeTokenMap::fInstance) { rangeTokMapInstanceCleanup.registerCleanup(RangeTokenMap::reinitInstance); @@ -170,17 +170,18 @@ // --------------------------------------------------------------------------- // RangeTokenMap: Constructors and Destructor // --------------------------------------------------------------------------- -RangeTokenMap::RangeTokenMap() : +RangeTokenMap::RangeTokenMap(MemoryManager* manager) : fTokenRegistry(0) , fRangeMap(0) , fCategories(0) , fTokenFactory(0) + , fMutex(manager) { try { - fTokenRegistry = new RefHashTableOf<RangeTokenElemMap>(109); - fRangeMap = new RefHashTableOf<RangeFactory>(29); - fCategories = new XMLStringPool(109); - fTokenFactory = new TokenFactory(); + fTokenRegistry = new (manager) RefHashTableOf<RangeTokenElemMap>(109, manager); + fRangeMap = new (manager) RefHashTableOf<RangeFactory>(29, manager); + fCategories = new (manager) XMLStringPool(109, manager); + fTokenFactory = new (manager) TokenFactory(manager); initializeRegistry(); } catch(...) { @@ -362,7 +363,7 @@ if (!fInstance) { - fInstance = new RangeTokenMap(); + fInstance = new RangeTokenMap(XMLPlatformUtils::fgMemoryManager); rangeTokMapInstanceCleanup.registerCleanup(RangeTokenMap::reinitInstance); } } Modified: xerces/c/trunk/src/xercesc/util/regx/RangeTokenMap.hpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/regx/RangeTokenMap.hpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/regx/RangeTokenMap.hpp (original) +++ xerces/c/trunk/src/xercesc/util/regx/RangeTokenMap.hpp Sat Jun 4 11:36:08 2005 @@ -107,7 +107,7 @@ // ----------------------------------------------------------------------- // Constructor and destructors // ----------------------------------------------------------------------- - RangeTokenMap(); + RangeTokenMap(MemoryManager* manager); ~RangeTokenMap(); // ----------------------------------------------------------------------- Modified: xerces/c/trunk/src/xercesc/util/regx/RegxParser.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/regx/RegxParser.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/regx/RegxParser.cpp (original) +++ xerces/c/trunk/src/xercesc/util/regx/RegxParser.cpp Sat Jun 4 11:36:08 2005 @@ -167,8 +167,6 @@ return 0; } - XMLMutexLock lockInit(&fMutex); - fOptions = options; fOffset = 0; fNoGroups = 1; Modified: xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp (original) +++ xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp Sat Jun 4 11:36:08 2005 @@ -29,7 +29,6 @@ // --------------------------------------------------------------------------- #include <xercesc/util/RefVectorOf.hpp> #include <xercesc/util/XMLUniDefs.hpp> -#include <xercesc/util/Mutexes.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -203,7 +202,6 @@ XMLCh* fString; RefVectorOf<ReferencePosition>* fReferences; TokenFactory* fTokenFactory; - XMLMutex fMutex; }; Modified: xerces/c/trunk/src/xercesc/validators/DTD/DTDGrammar.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/validators/DTD/DTDGrammar.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/validators/DTD/DTDGrammar.cpp (original) +++ xerces/c/trunk/src/xercesc/validators/DTD/DTDGrammar.cpp Sat Jun 4 11:36:08 2005 @@ -291,7 +291,7 @@ { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sEntityPoolMutex) - sEntityPoolMutex = new XMLMutex; + sEntityPoolMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); } // Use a faux scope to synchronize while we do this Modified: xerces/c/trunk/src/xercesc/validators/datatype/DatatypeValidatorFactory.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/validators/datatype/DatatypeValidatorFactory.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/validators/datatype/DatatypeValidatorFactory.cpp (original) +++ xerces/c/trunk/src/xercesc/validators/datatype/DatatypeValidatorFactory.cpp Sat Jun 4 11:36:08 2005 @@ -375,7 +375,7 @@ { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sBuiltInRegistryMutex) - sBuiltInRegistryMutex = new XMLMutex; + sBuiltInRegistryMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); } // Use a faux scope to synchronize while we do this Modified: xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp (original) +++ xerces/c/trunk/src/xercesc/validators/schema/ComplexTypeInfo.cpp Sat Jun 4 11:36:08 2005 @@ -261,7 +261,7 @@ { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sAnyTypeMutex) - sAnyTypeMutex = new XMLMutex; + sAnyTypeMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); } // Use a faux scope to synchronize while we do this Modified: xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.cpp (original) +++ xerces/c/trunk/src/xercesc/validators/schema/GeneralAttributeCheck.cpp Sat Jun 4 11:36:08 2005 @@ -264,7 +264,7 @@ XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sGeneralAttCheckMutex) - sGeneralAttCheckMutex = new XMLMutex; + sGeneralAttCheckMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); } // Use a faux scope to synchronize while we do this Modified: xerces/c/trunk/src/xercesc/validators/schema/XSDErrorReporter.cpp URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/validators/schema/XSDErrorReporter.cpp?rev=180011&r1=180010&r2=180011&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/validators/schema/XSDErrorReporter.cpp (original) +++ xerces/c/trunk/src/xercesc/validators/schema/XSDErrorReporter.cpp Sat Jun 4 11:36:08 2005 @@ -111,7 +111,7 @@ if (!sErrRprtrMutex) { - sErrRprtrMutex = new XMLMutex; + sErrRprtrMutex = new XMLMutex(XMLPlatformUtils::fgMemoryManager); errRprtrMutexCleanup.registerCleanup(reinitErrRprtrMutex); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
