I wanted to submit this patch which provides support for another
threading
option (sproc) under IRIX. All the code changes use ifdefs, and the
default
is still to use pthreads, so anyone who does not expressly choose to use
this option will notice absolutely no change.
For the curious, sproc is an IRIX variant of fork() which creates
separate
processes that use a shared memory space. It is used by many important
IRIX software packages, including most versions of OpenGL Performer. It
is,
unfortunately, completely incompatible with pthreads.
The patch replaces the pthread-based mutex code in IRIXPlatformUtils.cpp
with equivalent code using usinitsema. I have been using this version
for several weeks and it appears to be quite stable. The patch is
against
the current CVS version of xerces-c
Christopher [EMAIL PROTECTED]
http://www.public.iastate.edu/~coronax
"You're pretty stupid if you get hit by a car _after_ the apocolypse."
-- Crow T. Robot
diff -u -r xml-xerces/c/src/runConfigure
my-xml-xerces/c/src/runConfigure
--- xml-xerces/c/src/runConfigure Wed Jul 25 16:33:55 2001
+++ my-xml-xerces/c/src/runConfigure Wed Jul 25 17:13:46 2001
@@ -86,7 +86,7 @@
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) or 'none'"
+ echo " -r <thread option> can be 'pthread' or 'dce' (only
used on aix, HP-11 and solaris) or 'sproc' (only on IRIX) or 'none'"
echo " -l <extra linker options>"
echo " -z <extra compiler options>"
echo " -P <install-prefix>"
@@ -313,6 +313,20 @@
*)
echo "I do not recognize the thread option '$thread'.
Please type '${0} -h' for help."
exit ${ERROR_EXIT_CODE};;
+ esac
+ fi
+ elif test $platform = "irix"; then
+ if test $thread; then
+ case $thread in
+ pthread)
+ ;;
+
+ sproc)
+ threadingLibs=" ";
+ threadingDefines="-DXML_IRIX_SPROC" ;;
+ *)
+ echo "I do not recognize the thread option '$thread'. Please
type '${0} -h' for help."
+ exit ${ERROR_EXIT_CODE};;
esac
fi
fi
diff -u -r xml-xerces/c/src/util/Platforms/IRIX/IRIXPlatformUtils.cpp
my-xml-xerces/c/src/util/Platforms/IRIX/IRIXPlatformUtils.cpp
--- xml-xerces/c/src/util/Platforms/IRIX/IRIXPlatformUtils.cpp Wed Jul
25 16:03:17 2001
+++ my-xml-xerces/c/src/util/Platforms/IRIX/IRIXPlatformUtils.cpp Wed
Jul 25 16:09:50 2001
@@ -105,8 +105,12 @@
//
---------------------------------------------------------------------------
#if !defined(APP_NO_THREADS)
+#ifdef XML_IRIX_SPROC
+#include <ulocks.h>
+#else
#include <pthread.h>
#endif
+#endif
#include <unistd.h>
#include <stdio.h>
@@ -537,6 +541,102 @@
#if !defined(APP_NO_THREADS)
+static XMLMutex atomicOpsMutex;
+
+#ifdef XML_IRIX_SPROC
+//
---------------------------------------------------------------------------
+// XMLPlatformUtils: Platform init method
+//
---------------------------------------------------------------------------
+
+static char* arenaName = 0;
+static usptr_t* arena = 0;
+
+void XMLPlatformUtils::platformInit()
+{
+ //
+ // The atomicOps mutex needs to be created early.
+ // Normally, mutexes are created on first use, but there is a
+ // circular dependency between compareAndExchange() and
+ // mutex creation that must be broken.
+
+ // need a shared memory space
+ usconfig(CONF_INITUSERS, 128);
+ usconfig(CONF_INITSIZE, 16000);
+ usconfig(CONF_AUTOGROW, 1); // Default, but we set anyway
+
+ arenaName = strdup ("/var/tmp/xerces-sharedmemXXXXXX");
+ arena = usinit (mktemp (arenaName));
+
+ atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex();
+}
+
+void XMLPlatformUtils::platformTerm()
+{
+ usdetach (arena);
+ unlink (arenaName);
+ free (arenaName);
+ // We don't have any termination requirements at this time
+}
+
+
+void* XMLPlatformUtils::makeMutex()
+{
+ if (arena) {
+ usema_t* sema = usnewsema (arena, 1);
+ if (sema && (usctlsema (sema, CS_RECURSIVEON) != -1)) {
+ return (void*)sema;
+ }
+ else
+ ThrowXML (XMLPlatformUtilsException,
+ XMLExcepts::Mutex_CouldNotCreate);
+ }
+ else {
+ // arena==0; therefore platformInit hasn't been called.
+ // it's important that we fail quietly here so that we don't
+ // throw an exception when trying to initizlize the
+ // atomicOpsMutex, which we re-initizlize in platformInit
anyay.
+ return 0;
+ }
+}
+
+
+void XMLPlatformUtils::closeMutex(void* const mtxHandle)
+{
+
+ if (mtxHandle != NULL) {
+ usfreesema (mtxHandle, arena);
+ // never returns anything testable for failure, so nothing
+ // to throw an exception about.
+ }
+}
+
+
+void XMLPlatformUtils::lockMutex(void* const mtxHandle)
+{
+
+ if (mtxHandle != NULL) {
+ if (uspsema (mtxHandle) != 1)
+ ThrowXML(XMLPlatformUtilsException,
+ XMLExcepts::Mutex_CouldNotLock);
+ }
+
+}
+
+
+void XMLPlatformUtils::unlockMutex(void* const mtxHandle)
+{
+ if (mtxHandle != NULL)
+ {
+ if (usvsema(mtxHandle) == -1)
+ {
+ ThrowXML(XMLPlatformUtilsException,
+ XMLExcepts::Mutex_CouldNotUnlock);
+ }
+ }
+}
+
+#else
+
//
---------------------------------------------------------------------------
// XMLPlatformUtils: Platform init method
//
---------------------------------------------------------------------------
@@ -553,6 +653,10 @@
atomicOpsMutex.fHandle = XMLPlatformUtils::makeMutex();
}
+void XMLPlatformUtils::platformTerm()
+{
+ // We don't have any termination requirements at this time
+}
void* XMLPlatformUtils::makeMutex()
{
@@ -610,6 +714,7 @@
}
}
+#endif // XML_IRIX_SPROC
//
-----------------------------------------------------------------------
// Miscellaneous synchronization methods
@@ -685,10 +790,15 @@
return --location;
}
-#endif // APP_NO_THREADS
-
void XMLPlatformUtils::platformTerm()
{
// We don't have any termination requirements at this time
}
+
+#endif // APP_NO_THREADS
+
+//void XMLPlatformUtils::platformTerm()
+//{
+ // We don't have any termination requirements at this time
+//}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]