You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2005/06/13 20:36:27 UTC

svn commit: r190476 - in /xerces/c/branches/jberry/3.0-unstable/tests: Makefile.am src/ThreadTest/ThreadTest.cpp

Author: amassari
Date: Mon Jun 13 11:36:25 2005
New Revision: 190476

URL: http://svn.apache.org/viewcvs?rev=190476&view=rev
Log:
ThreadTest now uses HAS_PTHREAD to decide whether to use the <pthread.h> headers

Modified:
    xerces/c/branches/jberry/3.0-unstable/tests/Makefile.am
    xerces/c/branches/jberry/3.0-unstable/tests/src/ThreadTest/ThreadTest.cpp

Modified: xerces/c/branches/jberry/3.0-unstable/tests/Makefile.am
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/tests/Makefile.am?rev=190476&r1=190475&r2=190476&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/tests/Makefile.am (original)
+++ xerces/c/branches/jberry/3.0-unstable/tests/Makefile.am Mon Jun 13 11:36:25 2005
@@ -83,9 +83,8 @@
 #									src/ParserTest/ParserTest_Parser.cpp \
 #									src/ParserTest/ParserTest_Parser.hpp
 
-# Needs to use generic pthread conditionals HAS_PTHREADS
-#testprogs +=						ThreadTest
-#ThreadTest_SOURCES = 				src/ThreadTest/ThreadTest.cpp
+testprogs +=						ThreadTest
+ThreadTest_SOURCES = 				src/ThreadTest/ThreadTest.cpp
 
 # Fails to compile under gcc 4 (ambiguous calls to NullPointerException)
 # dcargill says this is obsolete and we can delete it.

Modified: xerces/c/branches/jberry/3.0-unstable/tests/src/ThreadTest/ThreadTest.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/tests/src/ThreadTest/ThreadTest.cpp?rev=190476&r1=190475&r2=190476&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/tests/src/ThreadTest/ThreadTest.cpp (original)
+++ xerces/c/branches/jberry/3.0-unstable/tests/src/ThreadTest/ThreadTest.cpp Mon Jun 13 11:36:25 2005
@@ -20,6 +20,10 @@
  * @author Andy Heninger, IBM
  */
 
+#if HAVE_CONFIG_H
+#	include <config.h>
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -44,51 +48,7 @@
 
 void clearFileInfoMemory();
 
-//------------------------------------------------------------------------------
-//
-//   Windows specific code for starting threads
-//
-//------------------------------------------------------------------------------
-#ifdef PLATFORM_WIN32
-
-#include "Windows.h"
-#include "process.h"
-
-typedef DWORD (WINAPI *ThreadFunc)(void *);
-
-class ThreadFuncs           // This class isolates OS dependent threading
-{                           //   functions from the rest of ThreadTest program.
-public:
-    static void Sleep(int millis) {::Sleep(millis);};
-    static void startThread(ThreadFunc, void *param);
-};
-
-void ThreadFuncs::startThread(ThreadFunc func, void *param)
-{
-    HANDLE  tHandle;
-    DWORD   threadID;
-
-    tHandle = CreateThread(0,          // Security Attributes,
-                           0x10000,    // Stack Size,
-                           func,       // Starting Address.
-                           param,      // Parmeters
-                           0,          // Creation Flags,
-                           &threadID); // Thread ID (Can not be null on 95/98)
-
-    if (tHandle == 0)
-    {
-        fprintf(stderr, "Error starting thread.  Errno = %d\n", errno);
-        clearFileInfoMemory();
-        exit(-1);
-    }
-
-    // Set the priority of the working threads low, so that the UI of the running system will
-    //   remain responsive.
-    SetThreadPriority(tHandle, THREAD_PRIORITY_IDLE);
-}
-
-
-#elif defined (AIX) || defined(SOLARIS) || defined(LINUX) || defined(HPUX) || defined (OS390) || defined(MACOSX) || defined(FREEBSD) || defined(__CYGWIN__) || defined(__QNXNTO__) || defined(INTERIX)
+#ifdef HAVE_PTHREAD
 #include <pthread.h>
 #include <unistd.h>
 #include <errno.h>
@@ -148,8 +108,51 @@
 }
 
 } // end of extern "C"
+
 #else
-#error This platform is not supported
+
+//------------------------------------------------------------------------------
+//
+//   Windows specific code for starting threads
+//
+//------------------------------------------------------------------------------
+
+#include <Windows.h>
+#include <process.h>
+
+typedef DWORD (WINAPI *ThreadFunc)(void *);
+
+class ThreadFuncs           // This class isolates OS dependent threading
+{                           //   functions from the rest of ThreadTest program.
+public:
+    static void Sleep(int millis) {::Sleep(millis);};
+    static void startThread(ThreadFunc, void *param);
+};
+
+void ThreadFuncs::startThread(ThreadFunc func, void *param)
+{
+    HANDLE  tHandle;
+    DWORD   threadID;
+
+    tHandle = CreateThread(0,          // Security Attributes,
+                           0x10000,    // Stack Size,
+                           func,       // Starting Address.
+                           param,      // Parmeters
+                           0,          // Creation Flags,
+                           &threadID); // Thread ID (Can not be null on 95/98)
+
+    if (tHandle == 0)
+    {
+        fprintf(stderr, "Error starting thread.  Errno = %d\n", errno);
+        clearFileInfoMemory();
+        exit(-1);
+    }
+
+    // Set the priority of the working threads low, so that the UI of the running system will
+    //   remain responsive.
+    SetThreadPriority(tHandle, THREAD_PRIORITY_IDLE);
+}
+
 #endif
 
 
@@ -1045,11 +1048,11 @@
 //
 //----------------------------------------------------------------------
 
-#ifdef PLATFORM_WIN32
-unsigned long WINAPI threadMain (void *param)
-#else
+#ifdef HAVE_PTHREAD
 extern "C" {
 void threadMain (void *param)
+#else
+unsigned long WINAPI threadMain (void *param)
 #endif
 {
     ThreadInfo   *thInfo = (ThreadInfo *)param;
@@ -1133,11 +1136,11 @@
         }
     }
     delete thParser;
-#ifdef PLATFORM_WIN32
-    return 0;
-#else
-    return;
+#ifdef HAVE_PTHREAD
+	return;
 }
+#else
+    return 0;
 #endif
 }
 



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