summaryrefslogtreecommitdiff
path: root/testThreads.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2003-10-29 13:39:15 +0000
committerDaniel Veillard <veillard@src.gnome.org>2003-10-29 13:39:15 +0000
commit82cb31994f93a6f73f77c05e4e3d45c4ef750d3a (patch)
tree2b77a2a66f6fdf7c97e4f63a68c69bc67a82f1c7 /testThreads.c
parent9d751504d56ee9591a5094d570555367d814c614 (diff)
downloadlibxml2-82cb31994f93a6f73f77c05e4e3d45c4ef750d3a.tar.gz
applied patch from Marcin 'Shard' Konicki to provide BeOS thread support.
* nanoftp.c nanohttp.c testThreads.c threads.c: applied patch from Marcin 'Shard' Konicki to provide BeOS thread support. Daniel
Diffstat (limited to 'testThreads.c')
-rw-r--r--testThreads.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/testThreads.c b/testThreads.c
index 24633eee..d740a144 100644
--- a/testThreads.c
+++ b/testThreads.c
@@ -7,7 +7,11 @@
#include <libxml/threads.h>
#include <libxml/parser.h>
#include <libxml/catalog.h>
+#ifdef HAVE_PTHREAD_H
#include <pthread.h>
+#elif defined HAVE_BEOS_THREADS
+#include <OS.h>
+#endif
#include <string.h>
#if !defined(_MSC_VER)
#include <unistd.h>
@@ -15,7 +19,11 @@
#include <assert.h>
#define MAX_ARGC 20
+#ifdef HAVE_PTHREAD_H
static pthread_t tid[MAX_ARGC];
+#elif defined HAVE_BEOS_THREADS
+static thread_id tid[MAX_ARGC];
+#endif
static const char *catalog = "test/threads/complex.xml";
static const char *testfiles[] = {
@@ -83,6 +91,7 @@ thread_specific_data(void *private_data)
return ((void *) Okay);
}
+#ifdef HAVE_PTHREAD_H
int
main(void)
{
@@ -125,6 +134,62 @@ main(void)
xmlMemoryDump();
return (0);
}
+#elif defined HAVE_BEOS_THREADS
+int
+main(void)
+{
+ unsigned int i, repeat;
+ unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]);
+ void *results[MAX_ARGC];
+ status_t ret;
+
+ xmlInitParser();
+ printf("Parser initialized\n");
+ for (repeat = 0;repeat < 500;repeat++) {
+ printf("repeat: %d\n",repeat);
+ xmlLoadCatalog(catalog);
+ printf("loaded catalog: %s\n", catalog);
+ for (i = 0; i < num_threads; i++) {
+ results[i] = NULL;
+ tid[i] = (thread_id) -1;
+ }
+ printf("cleaned threads\n");
+ for (i = 0; i < num_threads; i++) {
+ tid[i] = spawn_thread(thread_specific_data, "xmlTestThread", B_NORMAL_PRIORITY, (void *) testfiles[i]);
+ if (tid[i] < B_OK) {
+ perror("beos_thread_create");
+ exit(1);
+ }
+ printf("beos_thread_create %d -> %d\n", i, tid[i]);
+ }
+ for (i = 0; i < num_threads; i++) {
+ ret = wait_for_thread(tid[i], &results[i]);
+ printf("beos_thread_wait %d -> %d\n", i, ret);
+ if (ret != B_OK) {
+ perror("beos_thread_wait");
+ exit(1);
+ }
+ }
+
+ xmlCatalogCleanup();
+ ret = B_OK;
+ for (i = 0; i < num_threads; i++)
+ if (results[i] != (void *) Okay) {
+ printf("Thread %d handling %s failed\n", i, testfiles[i]);
+ ret = B_ERROR;
+ }
+ }
+ xmlCleanupParser();
+ xmlMemoryDump();
+
+ if (ret == B_OK)
+ printf("testThread : BeOS : SUCCESS!\n");
+ else
+ printf("testThread : BeOS : FAILED!\n");
+
+ return (0);
+}
+#endif /* pthreads or BeOS threads */
#else /* !LIBXML_THREADS_ENABLED */
int