Dear all,

attached you find a patch supporting dce threading on:
- AIX 4x with IBM xlC_r4 compiler
- SunOS with SUN CC compiler and Transarc DCE implementation (transarc belongs
  to IBM); it seems to be the only DCE implementation for SunOS

I would be very glad if you integrate this patch into the xerces library.

This patch is for xerces 1.5 which I downloaded about a weeks ago

regards,
-- 
Miroslaw Dobrzanski-Neumann

MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: [EMAIL PROTECTED]
diff -Nrc xerces-c-src1_5_0.org/samples/Makefile.incl 
xerces-c-src1_5_0/samples/Makefile.incl
*** xerces-c-src1_5_0.org/samples/Makefile.incl Sun Jun 17 01:55:32 2001
--- xerces-c-src1_5_0/samples/Makefile.incl     Thu Jun 28 11:09:23 2001
***************
*** 143,152 ****
  #================= AIX SPECIFIC OPTIONS ===========================
  ifeq (${PLATFORM}, AIX)
  CMP= -c ${CXXFLAGS} -qnotempinc
! CC=xlC_r -D${PLATFORM}
! LINK =  ${CC}
! PLATFORM_LIB_LINK_OPTIONS=-L/usr/lpp/xlC/lib
! EXTRA_LINK_OPTIONS=-lC
  SHLIBSUFFIX=.a
  endif
  
--- 143,153 ----
  #================= AIX SPECIFIC OPTIONS ===========================
  ifeq (${PLATFORM}, AIX)
  CMP= -c ${CXXFLAGS} -qnotempinc
! CC=${COMPILER} -D${PLATFORM}
! LINK =  ${COMPILER}
! # the compiler knows about this two
! # PLATFORM_LIB_LINK_OPTIONS=-L/usr/lpp/xlC/lib
! # EXTRA_LINK_OPTIONS=-lC
  SHLIBSUFFIX=.a
  endif
  
diff -Nrc xerces-c-src1_5_0.org/samples/runConfigure 
xerces-c-src1_5_0/samples/runConfigure
*** xerces-c-src1_5_0.org/samples/runConfigure  Sun Jun 17 01:55:40 2001
--- xerces-c-src1_5_0/samples/runConfigure      Thu Jun 28 11:26:45 2001
***************
*** 149,154 ****
--- 149,161 ----
     esac
  done
  
+ if test $platform = "aix"; then
+       if test ! -n "$ccompiler" -o ! -n "$cppcompiler"; then
+               ccompiler=xlc
+               cppcompiler=xlC
+       fi
+ fi
+ 
  echo "Generating makefiles with the following options ..."
  echo "Platform: $platform"
  echo "C Compiler: $ccompiler"
***************
*** 180,188 ****
  CXX=$cppcompiler; export CXX
  
  case $cppcompiler in
!    xlC | xlc | xlC_r | xlc_r)
!        LDFLAGS="-lC"; export LDFLAGS
!        LIBS="-L/usr/lpp/xlC/lib"; export LIBS ;;
  
     g++ | c++)
         LDFLAGS="-lc"; export LDFLAGS
--- 187,197 ----
  CXX=$cppcompiler; export CXX
  
  case $cppcompiler in
!    xlC* | xlc*)
!       #the compiler knows better about this stuff
!       #LDFLAGS="-lC"; export LDFLAGS
!       #LIBS="-L/usr/lpp/xlC/lib"; export LIBS
!        ;;
  
     g++ | c++)
         LDFLAGS="-lc"; export LDFLAGS
diff -Nrc xerces-c-src1_5_0.org/src/Makefile.incl xerces-c-src1_5_0/src/Makefile.incl
*** xerces-c-src1_5_0.org/src/Makefile.incl     Sun Jun 17 01:56:06 2001
--- xerces-c-src1_5_0/src/Makefile.incl Thu Jun 28 10:12:33 2001
***************
*** 122,135 ****
    else
        PLATFORM_COMPILE_OPTIONS = -KPIC -mt -xs -ptr$(XML_OBJ_DIR) \
                                 -features=rtti -D${PLATFORM} -D_REENTRANT
!  MAKE_SHARED = ${CXX} -D${PLATFORM} -G -ptr$(XML_OBJ_DIR) ${LDFLAGS}
!     MAKE_SHARED_C = ${CC} -D${PLATFORM} -G ${LDFLAGS}
      ifeq (${TRANSCODER}, ICU)
!         ALLLIBS = -mt ${LIBS} -L/usr/local/SUNWspro/lib -L/usr/ccs/lib \
!                   -licuuc -licudata -lc -lgen
      else
!         ALLLIBS = -mt ${LIBS} -L/usr/local/SUNWspro/lib -L/usr/ccs/lib \
!                   -lc -lgen
      endif
    endif
    SHLIBSUFFIX=.so
--- 122,133 ----
    else
        PLATFORM_COMPILE_OPTIONS = -KPIC -mt -xs -ptr$(XML_OBJ_DIR) \
                                 -features=rtti -D${PLATFORM} -D_REENTRANT
!     MAKE_SHARED = ${CXX} -D${PLATFORM} -G -ptr$(XML_OBJ_DIR)
!     MAKE_SHARED_C = ${CC} -D${PLATFORM} -G
      ifeq (${TRANSCODER}, ICU)
!         ALLLIBS = -mt -licuuc -licudata ${LIBS}
      else
!         ALLLIBS = -mt ${LIBS}
      endif
    endif
    SHLIBSUFFIX=.so
***************
*** 202,207 ****
--- 200,216 ----
  PLATFORM_COMPILE_OPTIONS = -qnotempinc -D_THREAD_SAFE
  MAKE_SHARED = makeC++SharedLib_r -p 5000
  MAKE_SHARED_C = makeC++SharedLib_r -p 5000
+ ifeq (xlC_r4,$(CXX))
+   ifeq (AIX41,$(OSVER))
+     ALLLIBS += -lC_r -lC -L/usr/lib/threads -ldcelibc_r -ldcepthreads
+   endif
+   ifeq (AIX42,$(OSVER))
+     ALLLIBS += -lC_r -lC -L/usr/lib/threads -ldcelibc_r -ldcepthreads
+   endif
+   ifeq (AIX43,$(OSVER))
+     ALLLIBS += -L/usr/lib/threads -ldcelibc_r -ldcepthreads -lpthreads_compat
+   endif
+ endif
  SHLIBSUFFIX=.a
  endif
  
diff -Nrc xerces-c-src1_5_0.org/src/configure xerces-c-src1_5_0/src/configure
*** xerces-c-src1_5_0.org/src/configure Sun Jun 17 01:55:48 2001
--- xerces-c-src1_5_0/src/configure     Thu Jun 28 10:12:33 2001
***************
*** 1303,1309 ****
          *-*-unixware*)  platform=UNIXWARE ;;
          *-*-linux*)     platform=LINUX ;;
          *-*-irix*)      platform=IRIX ;;
!         *-*-aix*)       platform=AIX ;;
          *-sequent-*)    platform=PTX ;;
          *-*-hp*)        platform=HPUX ;
                          case "${host}" in
--- 1303,1315 ----
          *-*-unixware*)  platform=UNIXWARE ;;
          *-*-linux*)     platform=LINUX ;;
          *-*-irix*)      platform=IRIX ;;
!         *-*-aix*)       platform=AIX
!                       case "${host}" in
!                          *-*-aix4.1*)   osver=AIX41;;
!                          *-*-aix4.2*)   osver=AIX42;;
!                          *-*-aix4.3*)   osver=AIX43;;
!                          *-*-aix4.*)    osver=AIX43;;
!                       esac;;
          *-sequent-*)    platform=PTX ;;
          *-*-hp*)        platform=HPUX ;
                          case "${host}" in
diff -Nrc xerces-c-src1_5_0.org/src/configure.in xerces-c-src1_5_0/src/configure.in
*** xerces-c-src1_5_0.org/src/configure.in      Sun Jun 17 01:55:48 2001
--- xerces-c-src1_5_0/src/configure.in  Thu Jun 28 10:12:33 2001
***************
*** 35,41 ****
          *-*-unixware*)  platform=UNIXWARE ;;
          *-*-linux*)     platform=LINUX ;;
          *-*-irix*)      platform=IRIX ;;
!         *-*-aix*)       platform=AIX ;;
          *-sequent-*)    platform=PTX ;;
          *-*-hp*)        platform=HPUX ;
                          case "${host}" in
--- 35,47 ----
          *-*-unixware*)  platform=UNIXWARE ;;
          *-*-linux*)     platform=LINUX ;;
          *-*-irix*)      platform=IRIX ;;
!         *-*-aix*)       platform=AIX
!                       case "${host}" in
!                          *-*-aix4.1*)   osver=AIX41;;
!                          *-*-aix4.2*)   osver=AIX42;;
!                          *-*-aix4.3*)   osver=AIX43;;
!                          *-*-aix4.*)    osver=AIX43;;
!                       esac;;
          *-sequent-*)    platform=PTX ;;
          *-*-hp*)        platform=HPUX ;
                          case "${host}" in
diff -Nrc xerces-c-src1_5_0.org/src/runConfigure xerces-c-src1_5_0/src/runConfigure
*** xerces-c-src1_5_0.org/src/runConfigure      Sun Jun 17 01:56:08 2001
--- xerces-c-src1_5_0/src/runConfigure  Thu Jun 28 10:20:01 2001
***************
*** 86,92 ****
      echo "       -m <message loader> can be 'inmem', 'icu', 'MsgFile' or 'iconv'"
      echo "       -n <net accessor> can be 'fileonly', 'libwww', 'socket' or 'native'"
      echo "       -t <transcoder> can be 'icu', 'Iconv400', 'Iconv390' or 'native'"
!     echo "       -r <thread option> can be 'pthread' or 'dce' (only used on HP-11)"
      echo "       -l <extra linker options>"
      echo "       -z <extra compiler options>"
      echo "       -P <install-prefix>"
--- 86,92 ----
      echo "       -m <message loader> can be 'inmem', 'icu', 'MsgFile' or 'iconv'"
      echo "       -n <net accessor> can be 'fileonly', 'libwww', 'socket' or 'native'"
      echo "       -t <transcoder> can be 'icu', 'Iconv400', 'Iconv390' or 'native'"
!     echo "       -r <thread option> can be 'pthread' or 'dce' (only used on aix, 
HP-11 and solaris)"
      echo "       -l <extra linker options>"
      echo "       -z <extra compiler options>"
      echo "       -P <install-prefix>"
***************
*** 196,201 ****
--- 196,211 ----
  echo "Extra configure options: $configureoptions"
  
  
+ if test -z "$ccompiler" -a -n "$cppcompiler"; then
+       echo "either both c/c++ compiler must be given or nothing at all"
+       exit ${ERROR_EXIT_CODE};
+ fi
+ if test -n "$ccompiler" -a -z "$cppcompiler"; then
+       echo "either both c/c++ compiler must be given or nothing at all"
+       exit ${ERROR_EXIT_CODE};
+ fi
+ 
+ 
  #
  # Now check if the options are correct or not, bail out if incorrect
  #
***************
*** 259,272 ****
      esac
      fi
  elif test $platform = "aix"; then
!     aix_version=`./config.guess`;
      echo Found host system to be $aix_version
!     case $aix_version in
!        *4.3*)
!           threadingLibs="-lpthreads_compat -lpthreads";;
!        *)
!           threadingLibs="-lpthreads";;
      esac
  elif test $platform = "ptx"; then
      threadingLibs=" "
      if test -z $XMLINSTALL; then
--- 269,310 ----
      esac
      fi
  elif test $platform = "aix"; then
!     aix_version=`sh ./config.guess`;
      echo Found host system to be $aix_version
!     if test -n "$ccompiler"; then
!         if test -n "$thread"; then
!             echo "user given compiler no threadig available"
!       fi;
!       case $aix_version in
!          *4.3*)
!             threadingLibs="-lpthreads_compat -lpthreads";;
!          *)
!             threadingLibs="-lpthreads";;
!       esac
!     elif test -z "$thread"; then
!           ccompiler=xlc
!           cppcompiler=xlC
!           threadingLibs=
!           threadingDefines=
!     else
!     case $thread in
!       pthread)
!           ccompiler=xlc_r
!           cppcompiler=xlC_r
!           threadingLibs=
!           threadingDefines=
!           ;;
!       dce)
!           ccompiler=xlc_r4
!           cppcompiler=xlC_r4
!           threadingLibs=
!           threadingDefines="-DXML_USE_DCE"
!           ;;
!       *)
!            echo "I do not recognize the thread option '$thread'. Please type '${0} 
-h' for help."
!            exit ${ERROR_EXIT_CODE};;
      esac
+     fi
  elif test $platform = "ptx"; then
      threadingLibs=" "
      if test -z $XMLINSTALL; then
***************
*** 277,282 ****
--- 315,333 ----
      threadingDefines="-DXML_USE_DCE"
  elif test $platform = "unixware"; then
        threadingLibs="-lthread"
+ elif test $platform = "solaris"; then
+      if test $thread; then
+      case $thread in
+         pthread)
+             ;;
+         dce)
+             threadingLibs="-ldce";
+             threadingDefines="-DXML_USE_DCE";;
+         *)
+             echo "I do not recognize the thread option '$thread'. Please type '${0} 
+-h' for help."
+             exit ${ERROR_EXIT_CODE};;
+      esac
+      fi
  fi
  
  
***************
*** 370,376 ****
         netaccessorDefines="-DXML_USE_NETACCESSOR_SOCKET"
         case $platform in
             solaris)
!                netaccessorLibs="-lnsl -lsocket";;
             *)
                 ;;
         esac;;
--- 421,431 ----
         netaccessorDefines="-DXML_USE_NETACCESSOR_SOCKET"
         case $platform in
             solaris)
!                netaccessorLibs="-lnsl -lsocket"
!              if test $thread = "dce"; then
!                  netaccessorLibs=""
!              fi
!              ;;
             *)
                 ;;
         esac;;
***************
*** 406,412 ****
  #
  
  case $cppcompiler in
!    xlC | xlc | xlC_r | xlc_r | g++ | c++ | cc | CC | aCC | icc | ICC | cxx)
        ;;
  
     *)
--- 461,467 ----
  #
  
  case $cppcompiler in
!    xlC* | xlc* | g++ | c++ | cc | CC | aCC | icc | ICC | cxx)
        ;;
  
     *)
***************
*** 420,426 ****
  CXX="$cppcompiler"
  export CXX
  
- 
  #
  # Set the extra C and C++ compiler flags
  #
--- 475,480 ----
***************
*** 454,460 ****
  elif test $platform = "ptx"; then
  ./configure --prefix=$XMLINSTALL
  else
! ./configure $configureoptions
  fi
  echo
  echo In future, you may also directly type the following commands to create the 
Makefiles.
--- 508,514 ----
  elif test $platform = "ptx"; then
  ./configure --prefix=$XMLINSTALL
  else
! sh ./configure $configureoptions
  fi
  echo
  echo In future, you may also directly type the following commands to create the 
Makefiles.
diff -Nrc xerces-c-src1_5_0.org/src/util/Compilers/Makefile.in 
xerces-c-src1_5_0/src/util/Compilers/Makefile.in
*** xerces-c-src1_5_0.org/src/util/Compilers/Makefile.in        Sun Jun 17 01:56:12 
2001
--- xerces-c-src1_5_0/src/util/Compilers/Makefile.in    Thu Jun 28 10:12:33 2001
***************
*** 108,114 ****
          CPP_OBJECTS = SCOCCDefs.$(TO)
      endif
  endif
! ifeq (${CXX},xlC_r)
      CPP_OBJECTS = CSetDefs.$(TO)
  endif
  ifeq (${CXX},g++)
--- 108,114 ----
          CPP_OBJECTS = SCOCCDefs.$(TO)
      endif
  endif
! ifeq (xlC_r,$(findstring xlC_r,${CXX}))
      CPP_OBJECTS = CSetDefs.$(TO)
  endif
  ifeq (${CXX},g++)
diff -Nrc xerces-c-src1_5_0.org/src/util/Platforms/AIX/AIXPlatformUtils.cpp 
xerces-c-src1_5_0/src/util/Platforms/AIX/AIXPlatformUtils.cpp
*** xerces-c-src1_5_0.org/src/util/Platforms/AIX/AIXPlatformUtils.cpp   Sun Jun 17 
01:56:20 2001
--- xerces-c-src1_5_0/src/util/Platforms/AIX/AIXPlatformUtils.cpp       Thu Jun 28 
10:26:12 2001
***************
*** 63,69 ****
  //  Includes
  // ---------------------------------------------------------------------------
  #ifndef APP_NO_THREADS
! #include    <pthread.h>
  #include    <sys/atomic_op.h>
  #endif
  
--- 63,73 ----
  //  Includes
  // ---------------------------------------------------------------------------
  #ifndef APP_NO_THREADS
! #  if defined(XML_USE_DCE)
! #    include    <dce/pthread.h>
! #  else
! #    include    <pthread.h>
! #  endif // XML_USE_DCE
  #include    <sys/atomic_op.h>
  #endif
  
***************
*** 503,508 ****
--- 507,522 ----
                   XMLExcepts::Mutex_CouldNotCreate);
      }
      pthread_mutexattr_t*  attr = new pthread_mutexattr_t;
+ #if defined(XML_USE_DCE)
+     pthread_mutexattr_create(attr);
+     pthread_mutexattr_setkind_np(attr, MUTEX_RECURSIVE_NP);
+     if (pthread_mutex_init(mutex, *attr))
+     {
+           ThrowXML(XMLPlatformUtilsException,
+                    XMLExcepts::Mutex_CouldNotCreate);
+     }
+     pthread_mutexattr_delete(attr);
+ #else
      pthread_mutexattr_init(attr);
      pthread_mutexattr_setkind_np(attr, MUTEX_RECURSIVE_NP);
      if (pthread_mutex_init(mutex, attr))
***************
*** 511,516 ****
--- 525,531 ----
                   XMLExcepts::Mutex_CouldNotCreate);
      }
      pthread_mutexattr_destroy(attr);
+ #endif
      delete attr;
      return (void*)(mutex);
  }
diff -Nrc xerces-c-src1_5_0.org/src/util/Platforms/Solaris/SolarisPlatformUtils.cpp 
xerces-c-src1_5_0/src/util/Platforms/Solaris/SolarisPlatformUtils.cpp
*** xerces-c-src1_5_0.org/src/util/Platforms/Solaris/SolarisPlatformUtils.cpp   Sun 
Jun 17 01:56:24 2001
--- xerces-c-src1_5_0/src/util/Platforms/Solaris/SolarisPlatformUtils.cpp       Thu 
Jun 28 09:19:33 2001
***************
*** 64,70 ****
  // ---------------------------------------------------------------------------
  
  #if !defined (APP_NO_THREADS)
! #include    <pthread.h>
  #endif // APP_NO_THREADS
  
  
--- 64,74 ----
  // ---------------------------------------------------------------------------
  
  #if !defined (APP_NO_THREADS)
! #  if defined (XML_USE_DCE)
! #    include  <dce/pthread.h>
! #  else
! #    include    <pthread.h>
! #  endif
  #endif // APP_NO_THREADS
  
  
***************
*** 107,113 ****
  
  
  
- 
  // ---------------------------------------------------------------------------
  //  Local Methods
  // ---------------------------------------------------------------------------
--- 111,116 ----
***************
*** 521,530 ****
--- 524,540 ----
  
      gAtomicOpMutex = new pthread_mutex_t;   
  
+ #if defined(XML_USE_DCE)
+     if (pthread_mutex_init(gAtomicOpMutex, pthread_mutexattr_default))
+         panic( XMLPlatformUtils::Panic_SystemInit );
+ #else // XML_USE_DCE
      if (pthread_mutex_init(gAtomicOpMutex, NULL))
          panic( XMLPlatformUtils::Panic_SystemInit );
+ #endif // XML_USE_DCE
  }
  
+ #ifndef XML_USE_DCE
+ // inlining the class with dce threading causes segmentation fault
  class  RecursiveMutex
  {
  public:
***************
*** 566,575 ****
--- 576,605 ----
                            tid = 0;
                         };
     };
+ #endif // ifndef XML_USE_DCE
  
  void* XMLPlatformUtils::makeMutex()
  {
+ #if defined(XML_USE_DCE)
+     pthread_mutex_t* mutex = new pthread_mutex_t;
+     if (mutex ==  NULL)
+     {
+         ThrowXML(XMLPlatformUtilsException,
+                  XMLExcepts::Mutex_CouldNotCreate);
+     }
+     pthread_mutexattr_t attr;
+     pthread_mutexattr_create(&attr);
+     pthread_mutexattr_setkind_np(&attr, MUTEX_RECURSIVE_NP);
+     if (pthread_mutex_init(mutex, attr))
+     {
+         ThrowXML(XMLPlatformUtilsException,
+                  XMLExcepts::Mutex_CouldNotCreate);
+     }
+     pthread_mutexattr_delete(&attr);
+     return (void*)(mutex);
+ #else
      return new RecursiveMutex;
+ #endif
  };
  
  
***************
*** 577,583 ****
--- 607,618 ----
  {
      if (mtxHandle == NULL)
          return;
+ #if defined(XML_USE_DCE)
+     pthread_mutex_t *rm = (pthread_mutex_t *)mtxHandle;
+     pthread_mutex_destroy(rm);
+ #else
      RecursiveMutex *rm = (RecursiveMutex *)mtxHandle;
+ #endif
      delete rm;
  };
  
***************
*** 586,601 ****
--- 621,646 ----
  {
      if (mtxHandle == NULL)
          return;
+ #if defined(XML_USE_DCE)
+     pthread_mutex_t *rm = (pthread_mutex_t *)mtxHandle;
+     pthread_mutex_lock(rm);
+ #else
      RecursiveMutex *rm = (RecursiveMutex *)mtxHandle;
      rm->lock();
+ #endif
  }
  
  void XMLPlatformUtils::unlockMutex(void* const mtxHandle)
  {
      if (mtxHandle == NULL)
          return;
+ #if defined(XML_USE_DCE)
+     pthread_mutex_t *rm = (pthread_mutex_t *)mtxHandle;
+     pthread_mutex_unlock(rm);
+ #else
      RecursiveMutex *rm = (RecursiveMutex *)mtxHandle;
      rm->unlock();
+ #endif
  }
  
  // -----------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to