You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2004/01/06 18:31:20 UTC

cvs commit: xml-xerces/c/src/xercesc/util/Platforms/NetBSD NetBSDPlatformUtils.cpp

neilg       2004/01/06 09:31:20

  Modified:    c/src/xercesc/util/Platforms/BeOS BeOSPlatformUtils.cpp
               c/src/xercesc/util/Platforms/FreeBSD
                        FreeBSDPlatformUtils.cpp
               c/src/xercesc/util/Platforms/HPUX HPPlatformUtils.cpp
               c/src/xercesc/util/Platforms/IRIX IRIXPlatformUtils.cpp
               c/src/xercesc/util/Platforms/Linux LinuxPlatformUtils.cpp
               c/src/xercesc/util/Platforms/NetBSD NetBSDPlatformUtils.cpp
  Log:
  fix static initialization problems, bug 28517; thanks to Reid Spencer
  
  Revision  Changes    Path
  1.12      +18 -9     xml-xerces/c/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp
  
  Index: BeOSPlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/BeOS/BeOSPlatformUtils.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- BeOSPlatformUtils.cpp	24 Dec 2003 15:24:14 -0000	1.11
  +++ BeOSPlatformUtils.cpp	6 Jan 2004 17:31:20 -0000	1.12
  @@ -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 @@
   //  XMLPlatformUtils: Platform init method
   // ---------------------------------------------------------------------------
   
  -static XMLMutex atomicOpsMutex;
  +static XMLMutex* atomicOpsMutex = 0;
   
   void XMLPlatformUtils::platformInit()
   {
  @@ -492,8 +495,12 @@
       // 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 @@
                                        , const void* const newValue
                                        , const void* const toCompare)
   {
  -    XMLMutexLock lockMutex(&atomicOpsMutex);
  +    XMLMutexLock lockMutex(atomicOpsMutex);
   
       void *retVal = *toFill;
       if (*toFill == toCompare)
  @@ -572,14 +579,14 @@
   
   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 @@
   {
   #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
   }
   
  
  
  
  1.20      +18 -9     xml-xerces/c/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp
  
  Index: FreeBSDPlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/FreeBSD/FreeBSDPlatformUtils.cpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- FreeBSDPlatformUtils.cpp	24 Dec 2003 15:24:14 -0000	1.19
  +++ FreeBSDPlatformUtils.cpp	6 Jan 2004 17:31:20 -0000	1.20
  @@ -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 @@
   //  XMLPlatformUtils: Platform init method
   // ---------------------------------------------------------------------------
   
  -static XMLMutex atomicOpsMutex;
  +static XMLMutex *atomicOpsMutex = 0;
   
   void XMLPlatformUtils::platformInit()
   {
  @@ -535,8 +538,12 @@
       // 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 @@
                                        , const void* const newValue
                                        , const void* const toCompare)
   {
  -    XMLMutexLock lockMutex(&atomicOpsMutex);
  +    XMLMutexLock lockMutex(atomicOpsMutex);
   
       void *retVal = *toFill;
       if (*toFill == toCompare)
  @@ -615,14 +622,14 @@
   
   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 @@
   {
   #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
   }
   
  
  
  
  1.18      +18 -9     xml-xerces/c/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp
  
  Index: HPPlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- HPPlatformUtils.cpp	24 Dec 2003 15:24:14 -0000	1.17
  +++ HPPlatformUtils.cpp	6 Jan 2004 17:31:20 -0000	1.18
  @@ -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 @@
   // ---------------------------------------------------------------------------
   //  XMLPlatformUtils: Platform init method
   // ---------------------------------------------------------------------------
  -static XMLMutex atomicOpsMutex;
  +static XMLMutex *atomicOpsMutex = 0;
   
   void XMLPlatformUtils::platformInit()
   {
  @@ -578,8 +581,12 @@
       // 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 @@
                                      const void* const newValue,
                                      const void* const toCompare)
   {
  -    XMLMutexLock  localLock(&atomicOpsMutex);
  +    XMLMutexLock  localLock(atomicOpsMutex);
       void *retVal = *toFill;
       if (*toFill == toCompare)
       {
  @@ -667,13 +674,13 @@
   
   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 @@
   {
   #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
   }
   
  
  
  
  1.18      +28 -13    xml-xerces/c/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp
  
  Index: IRIXPlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/IRIX/IRIXPlatformUtils.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- IRIXPlatformUtils.cpp	24 Dec 2003 15:24:14 -0000	1.17
  +++ IRIXPlatformUtils.cpp	6 Jan 2004 17:31:20 -0000	1.18
  @@ -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 @@
   
   #if !defined(APP_NO_THREADS)
   
  -static XMLMutex atomicOpsMutex;
  +static XMLMutex *atomicOpsMutex = 0;
   
   #ifdef XML_USE_SPROC
   // ---------------------------------------------------------------------------
  @@ -561,15 +564,21 @@
       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 @@
       // 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 @@
                                        , const void* const newValue
                                        , const void* const toCompare)
   {
  -    XMLMutexLock lockMutex(&atomicOpsMutex);
  +    XMLMutexLock lockMutex(atomicOpsMutex);
   
       void *retVal = *toFill;
       if (*toFill == toCompare)
  @@ -738,14 +753,14 @@
   
   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;
   }
  
  
  
  1.21      +18 -9     xml-xerces/c/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp
  
  Index: LinuxPlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- LinuxPlatformUtils.cpp	24 Dec 2003 15:24:14 -0000	1.20
  +++ LinuxPlatformUtils.cpp	6 Jan 2004 17:31:20 -0000	1.21
  @@ -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 @@
   //  XMLPlatformUtils: Platform init method
   // ---------------------------------------------------------------------------
   
  -static XMLMutex atomicOpsMutex;
  +static XMLMutex* atomicOpsMutex = 0;
   
   void XMLPlatformUtils::platformInit()
   {
  @@ -588,8 +591,12 @@
       // 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 @@
                                        , const void* const newValue
                                        , const void* const toCompare)
   {
  -    XMLMutexLock lockMutex(&atomicOpsMutex);
  +    XMLMutexLock lockMutex(atomicOpsMutex);
   
       void *retVal = *toFill;
       if (*toFill == toCompare)
  @@ -668,14 +675,14 @@
   
   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 @@
   {
   #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
   }
   
  
  
  
  1.10      +14 -8     xml-xerces/c/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp
  
  Index: NetBSDPlatformUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Platforms/NetBSD/NetBSDPlatformUtils.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NetBSDPlatformUtils.cpp	24 Dec 2003 15:24:14 -0000	1.9
  +++ NetBSDPlatformUtils.cpp	6 Jan 2004 17:31:20 -0000	1.10
  @@ -508,7 +508,7 @@
   //  XMLPlatformUtils: Platform init method
   // ---------------------------------------------------------------------------
   
  -static XMLMutex atomicOpsMutex;
  +static XMLMutex *atomicOpsMutex = 0;
   
   void XMLPlatformUtils::platformInit()
   {
  @@ -518,8 +518,12 @@
       // 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 @@
                                        , const void* const newValue
                                        , const void* const toCompare)
   {
  -    XMLMutexLock lockMutex(&atomicOpsMutex);
  +    XMLMutexLock lockMutex(atomicOpsMutex);
   
       void *retVal = *toFill;
       if (*toFill == toCompare)
  @@ -598,14 +602,14 @@
   
   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 @@
   {
   #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
   }
   
  
  
  

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