diff --git a/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp b/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp index 936bdc44a2519ff0339fe19974d9cc6a585e487c..b6ba450703ffc53598a62fa24615b2677e85faac 100644 --- a/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2004/01/06 17:31:20 neilg + * fix static initialization problems, bug 28517; thanks to Reid Spencer + * * Revision 1.11 2003/12/24 15:24:14 cargilld * More updates to memory management so that the static memory manager. * @@ -483,7 +486,7 @@ unsigned long XMLPlatformUtils::getCurrentMillis() // XMLPlatformUtils: Platform init method // --------------------------------------------------------------------------- -static XMLMutex atomicOpsMutex; +static XMLMutex* atomicOpsMutex = 0; void XMLPlatformUtils::platformInit() { @@ -492,8 +495,12 @@ void XMLPlatformUtils::platformInit() // Normally, mutexes are created on first use, but there is a // circular dependency between compareAndExchange() and // mutex creation that must be broken. - if (atomicOpsMutex.fHandle == 0) - atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex(); + if(!atomicOpsMutex) + { + atomicOpsMutex = new (fgMemoryManager) XMLMutex(); + if (atomicOpsMutex->fHandle == 0) + atomicOpsMutex->fHandle = XMLPlatformUtils::makeMutex(); + } } void* XMLPlatformUtils::makeMutex() @@ -561,7 +568,7 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill , const void* const newValue , const void* const toCompare) { - XMLMutexLock lockMutex(&atomicOpsMutex); + XMLMutexLock lockMutex(atomicOpsMutex); void *retVal = *toFill; if (*toFill == toCompare) @@ -572,14 +579,14 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill int XMLPlatformUtils::atomicIncrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return ++location; } int XMLPlatformUtils::atomicDecrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return --location; } @@ -633,8 +640,10 @@ void XMLPlatformUtils::platformTerm() { #if !defined(APP_NO_THREADS) // delete the mutex we created - closeMutex(atomicOpsMutex.fHandle); - atomicOpsMutex.fHandle = 0; + closeMutex(atomicOpsMutex->fHandle); + atomicOpsMutex->fHandle = 0; + delete atomicOpsMutex; + atomicOpsMutex = 0; #endif } diff --git a/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp b/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp index c2bcfb63dfebdc8c82edf3c870d12396af25d619..477c8e9792d5f88d809a4abc2b64aa1cdf13e458 100644 --- a/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.20 2004/01/06 17:31:20 neilg + * fix static initialization problems, bug 28517; thanks to Reid Spencer + * * Revision 1.19 2003/12/24 15:24:14 cargilld * More updates to memory management so that the static memory manager. * @@ -526,7 +529,7 @@ unsigned long XMLPlatformUtils::getCurrentMillis() // XMLPlatformUtils: Platform init method // --------------------------------------------------------------------------- -static XMLMutex atomicOpsMutex; +static XMLMutex *atomicOpsMutex = 0; void XMLPlatformUtils::platformInit() { @@ -535,8 +538,12 @@ void XMLPlatformUtils::platformInit() // Normally, mutexes are created on first use, but there is a // circular dependency between compareAndExchange() and // mutex creation that must be broken. - if (atomicOpsMutex.fHandle == 0) - atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex(); + if(!atomicOpsMutex) + { + atomicOpsMutex = new (fgMemoryManager) atomicOpsMutex(); + if (atomicOpsMutex->fHandle == 0) + atomicOpsMutex->fHandle = XMLPlatformUtils::makeMutex(); + } } void* XMLPlatformUtils::makeMutex() @@ -604,7 +611,7 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill , const void* const newValue , const void* const toCompare) { - XMLMutexLock lockMutex(&atomicOpsMutex); + XMLMutexLock lockMutex(atomicOpsMutex); void *retVal = *toFill; if (*toFill == toCompare) @@ -615,14 +622,14 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill int XMLPlatformUtils::atomicIncrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return ++location; } int XMLPlatformUtils::atomicDecrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return --location; } @@ -676,8 +683,10 @@ void XMLPlatformUtils::platformTerm() { #if !defined(APP_NO_THREADS) // delete the mutex we created - closeMutex(atomicOpsMutex.fHandle); - atomicOpsMutex.fHandle = 0; + closeMutex(atomicOpsMutex->fHandle); + atomicOpsMutex->fHandle = 0; + delete atomicOpsMutex; + atomicOpsMutex = 0; #endif } diff --git a/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp b/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp index dd6b917ddb039d0b7e0b082f7e48408cc57cdc00..e2932732e3d9d1576e9f0df5362abb9a27bf890d 100644 --- a/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.18 2004/01/06 17:31:20 neilg + * fix static initialization problems, bug 28517; thanks to Reid Spencer + * * Revision 1.17 2003/12/24 15:24:14 cargilld * More updates to memory management so that the static memory manager. * @@ -569,7 +572,7 @@ unsigned long XMLPlatformUtils::getCurrentMillis() // --------------------------------------------------------------------------- // XMLPlatformUtils: Platform init method // --------------------------------------------------------------------------- -static XMLMutex atomicOpsMutex; +static XMLMutex *atomicOpsMutex = 0; void XMLPlatformUtils::platformInit() { @@ -578,8 +581,12 @@ void XMLPlatformUtils::platformInit() // Normally, mutexes are created on first use, but there is a // circular dependency between compareAndExchange() and // mutex creation that must be broken. - if (atomicOpsMutex.fHandle == 0) - atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex(); + if(!atomicOpsMutex) + { + atomicOpsMutex = new (fgMemoryManager) XMLMutex(); + if (atomicOpsMutex->fHandle == 0) + atomicOpsMutex->fHandle = XMLPlatformUtils::makeMutex(); + } } void* XMLPlatformUtils::makeMutex() @@ -656,7 +663,7 @@ void* XMLPlatformUtils::compareAndSwap ( void** toFill, const void* const newValue, const void* const toCompare) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); void *retVal = *toFill; if (*toFill == toCompare) { @@ -667,13 +674,13 @@ void* XMLPlatformUtils::compareAndSwap ( void** toFill, int XMLPlatformUtils::atomicIncrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return ++location; } int XMLPlatformUtils::atomicDecrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return --location; } @@ -728,8 +735,10 @@ void XMLPlatformUtils::platformTerm() { #if !defined(APP_NO_THREADS) // delete the mutex we created - closeMutex(atomicOpsMutex.fHandle); - atomicOpsMutex.fHandle = 0; + closeMutex(atomicOpsMutex->fHandle); + atomicOpsMutex->fHandle = 0; + delete atomicOpsMutex; + atomicOpsMutex = 0; #endif } diff --git a/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp b/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp index 4b735f8ea50215ff9228782ee1f17bdcd09708e5..af63c9c576d211d1143f16c09728b436a91a0dab 100644 --- a/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.18 2004/01/06 17:31:20 neilg + * fix static initialization problems, bug 28517; thanks to Reid Spencer + * * Revision 1.17 2003/12/24 15:24:14 cargilld * More updates to memory management so that the static memory manager. * @@ -535,7 +538,7 @@ unsigned long XMLPlatformUtils::getCurrentMillis() #if !defined(APP_NO_THREADS) -static XMLMutex atomicOpsMutex; +static XMLMutex *atomicOpsMutex = 0; #ifdef XML_USE_SPROC // --------------------------------------------------------------------------- @@ -561,15 +564,21 @@ void XMLPlatformUtils::platformInit() arenaName = strdup ("/var/tmp/xerces-sharedmemXXXXXX"); arena = usinit (mktemp (arenaName)); - if (atomicOpsMutex.fHandle == 0) - atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex(); + if(!atomicOpsMutex) + { + atomicOpsMutex = new (fgMemoryManager) XMLMutex(); + if (atomicOpsMutex->fHandle == 0) + atomicOpsMutex->fHandle = XMLPlatformUtils::makeMutex(); + } } void XMLPlatformUtils::platformTerm() { // delete the mutex we created - closeMutex(atomicOpsMutex.fHandle); - atomicOpsMutex.fHandle = 0; + closeMutex(atomicOpsMutex->fHandle); + atomicOpsMutex->fHandle = 0; + delete atomicOpsMutex; + atomicOpsMutex = 0; usdetach (arena); unlink (arenaName); @@ -650,15 +659,21 @@ void XMLPlatformUtils::platformInit() // Normally, mutexes are created on first use, but there is a // circular dependency between compareAndExchange() and // mutex creation that must be broken. - if (atomicOpsMutex.fHandle == 0) - atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex(); + if(!atomicOpsMutex) + { + atomicOpsMutex = new (fgMemoryManager) XMLMutex(); + if (atomicOpsMutex->fHandle == 0) + atomicOpsMutex->fHandle = XMLPlatformUtils::makeMutex(); + } } void XMLPlatformUtils::platformTerm() { // delete the mutex we created - closeMutex(atomicOpsMutex.fHandle); - atomicOpsMutex.fHandle = 0; + closeMutex(atomicOpsMutex->fHandle); + atomicOpsMutex->fHandle = 0; + delete atomicOpsMutex; + atomicOpsMutex = 0; } void* XMLPlatformUtils::makeMutex() @@ -727,7 +742,7 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill , const void* const newValue , const void* const toCompare) { - XMLMutexLock lockMutex(&atomicOpsMutex); + XMLMutexLock lockMutex(atomicOpsMutex); void *retVal = *toFill; if (*toFill == toCompare) @@ -738,14 +753,14 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill int XMLPlatformUtils::atomicIncrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return ++location; } int XMLPlatformUtils::atomicDecrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return --location; } diff --git a/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp b/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp index 5c30189bf2770dfa7baef3a37083c94fb7c1dabc..0ac570184228af1fa8e542df1b9c82a4be27bc04 100644 --- a/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.21 2004/01/06 17:31:20 neilg + * fix static initialization problems, bug 28517; thanks to Reid Spencer + * * Revision 1.20 2003/12/24 15:24:14 cargilld * More updates to memory management so that the static memory manager. * @@ -579,7 +582,7 @@ unsigned long XMLPlatformUtils::getCurrentMillis() // XMLPlatformUtils: Platform init method // --------------------------------------------------------------------------- -static XMLMutex atomicOpsMutex; +static XMLMutex* atomicOpsMutex = 0; void XMLPlatformUtils::platformInit() { @@ -588,8 +591,12 @@ void XMLPlatformUtils::platformInit() // Normally, mutexes are created on first use, but there is a // circular dependency between compareAndExchange() and // mutex creation that must be broken. - if (atomicOpsMutex.fHandle == 0) - atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex(); + if ( atomicOpsMutex == 0 ) + { + atomicOpsMutex = new (fgMemoryManager) XMLMutex; + if (atomicOpsMutex->fHandle == 0) + atomicOpsMutex->fHandle = XMLPlatformUtils::makeMutex(); + } } void* XMLPlatformUtils::makeMutex() @@ -657,7 +664,7 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill , const void* const newValue , const void* const toCompare) { - XMLMutexLock lockMutex(&atomicOpsMutex); + XMLMutexLock lockMutex(atomicOpsMutex); void *retVal = *toFill; if (*toFill == toCompare) @@ -668,14 +675,14 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill int XMLPlatformUtils::atomicIncrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return ++location; } int XMLPlatformUtils::atomicDecrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return --location; } @@ -729,8 +736,10 @@ void XMLPlatformUtils::platformTerm() { #if !defined(APP_NO_THREADS) // delete the mutex we created - closeMutex(atomicOpsMutex.fHandle); - atomicOpsMutex.fHandle = 0; + closeMutex(atomicOpsMutex->fHandle); + atomicOpsMutex->fHandle = 0; + delete atomicOpsMutex; + atomicOpsMutex = 0; #endif } diff --git a/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp b/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp index 71c58d7ba9cd903e45acaf5e046300f7fc314c4c..e5a4b81c28f2b05d16eb85b75dfcdaccded186ff 100644 --- a/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp +++ b/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp @@ -508,7 +508,7 @@ inline bool XMLPlatformUtils::isAnySlash(XMLCh c) // XMLPlatformUtils: Platform init method // --------------------------------------------------------------------------- -static XMLMutex atomicOpsMutex; +static XMLMutex *atomicOpsMutex = 0; void XMLPlatformUtils::platformInit() { @@ -518,8 +518,12 @@ void XMLPlatformUtils::platformInit() // circular dependency between compareAndExchange() and // mutex creation that must be broken. - if (atomicOpsMutex.fHandle == 0) - atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex(); + if(!atomicOpsMutex) + { + atomicOpsMutex = new (fgMemoryManager) XMLMutex(); + if (atomicOpsMutex->fHandle == 0) + atomicOpsMutex->fHandle = XMLPlatformUtils::makeMutex(); + } } void* XMLPlatformUtils::makeMutex() @@ -587,7 +591,7 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill , const void* const newValue , const void* const toCompare) { - XMLMutexLock lockMutex(&atomicOpsMutex); + XMLMutexLock lockMutex(atomicOpsMutex); void *retVal = *toFill; if (*toFill == toCompare) @@ -598,14 +602,14 @@ void* XMLPlatformUtils::compareAndSwap(void** toFill int XMLPlatformUtils::atomicIncrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return ++location; } int XMLPlatformUtils::atomicDecrement(int &location) { - XMLMutexLock localLock(&atomicOpsMutex); + XMLMutexLock localLock(atomicOpsMutex); return --location; } @@ -659,8 +663,10 @@ void XMLPlatformUtils::platformTerm() { #if !defined(APP_NO_THREADS) // delete the mutex we created - closeMutex(atomicOpsMutex.fHandle); - atomicOpsMutex.fHandle = 0; + closeMutex(atomicOpsMutex->fHandle); + atomicOpsMutex->fHandle = 0; + delete atomicOpsMutex; + atomicOpsMutex = 0; #endif }