[libxml2] fix runtests to use pthreads support for various Unix platforms
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] fix runtests to use pthreads support for various Unix platforms
- Date: Tue, 7 Aug 2012 02:18:11 +0000 (UTC)
commit 495a73df82de30b5d7d991ede3da80b21ff01f36
Author: Daniel Richard G <oss teragram com>
Date: Tue Aug 7 10:14:56 2012 +0800
fix runtests to use pthreads support for various Unix platforms
The runtests program currently fails with
Specific platform thread support not detected
on HP-UX, AIX and other Unix systems which do not match the conditional
#if defined(linux) || defined(__sun) || defined(__APPLE_CC__)
It is silly to try to enumerate all systems which use pthreads in a conditional
like this. I am attaching a patch (against git master) that rewrites the cpp
conditional structure so that pthreads is used if HAVE_PTHREAD_H is defined,
and moves that section of code down below the Win32 and BeOS cases so that
native thread libraries are used preferentially in those two cases.
runtest.c | 108 ++++++++++++++++++++++++++++++------------------------------
1 files changed, 54 insertions(+), 54 deletions(-)
---
diff --git a/runtest.c b/runtest.c
index dd74c88..c7214f2 100644
--- a/runtest.c
+++ b/runtest.c
@@ -3939,60 +3939,7 @@ thread_specific_data(void *private_data)
return ((void *) Okay);
}
-#if defined(linux) || defined(__sun) || defined(__APPLE_CC__)
-
-#include <pthread.h>
-
-static pthread_t tid[MAX_ARGC];
-
-static int
-testThread(void)
-{
- unsigned int i, repeat;
- unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]);
- void *results[MAX_ARGC];
- int ret;
- int res = 0;
-
- xmlInitParser();
-
- for (repeat = 0; repeat < 500; repeat++) {
- xmlLoadCatalog(catalog);
- nb_tests++;
-
- for (i = 0; i < num_threads; i++) {
- results[i] = NULL;
- tid[i] = (pthread_t) - 1;
- }
-
- for (i = 0; i < num_threads; i++) {
- ret = pthread_create(&tid[i], 0, thread_specific_data,
- (void *) testfiles[i]);
- if (ret != 0) {
- fprintf(stderr, "pthread_create failed\n");
- return (1);
- }
- }
- for (i = 0; i < num_threads; i++) {
- ret = pthread_join(tid[i], &results[i]);
- if (ret != 0) {
- fprintf(stderr, "pthread_join failed\n");
- return (1);
- }
- }
-
- xmlCatalogCleanup();
- for (i = 0; i < num_threads; i++)
- if (results[i] != (void *) Okay) {
- fprintf(stderr, "Thread %d handling %s failed\n",
- i, testfiles[i]);
- res = 1;
- }
- }
- return (res);
-}
-
-#elif defined WIN32
+#if defined WIN32
#include <windows.h>
#include <string.h>
@@ -4118,6 +4065,59 @@ testThread(void)
return(1);
return (0);
}
+
+#elif defined HAVE_PTHREAD_H
+#include <pthread.h>
+
+static pthread_t tid[MAX_ARGC];
+
+static int
+testThread(void)
+{
+ unsigned int i, repeat;
+ unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]);
+ void *results[MAX_ARGC];
+ int ret;
+ int res = 0;
+
+ xmlInitParser();
+
+ for (repeat = 0; repeat < 500; repeat++) {
+ xmlLoadCatalog(catalog);
+ nb_tests++;
+
+ for (i = 0; i < num_threads; i++) {
+ results[i] = NULL;
+ tid[i] = (pthread_t) - 1;
+ }
+
+ for (i = 0; i < num_threads; i++) {
+ ret = pthread_create(&tid[i], 0, thread_specific_data,
+ (void *) testfiles[i]);
+ if (ret != 0) {
+ fprintf(stderr, "pthread_create failed\n");
+ return (1);
+ }
+ }
+ for (i = 0; i < num_threads; i++) {
+ ret = pthread_join(tid[i], &results[i]);
+ if (ret != 0) {
+ fprintf(stderr, "pthread_join failed\n");
+ return (1);
+ }
+ }
+
+ xmlCatalogCleanup();
+ for (i = 0; i < num_threads; i++)
+ if (results[i] != (void *) Okay) {
+ fprintf(stderr, "Thread %d handling %s failed\n",
+ i, testfiles[i]);
+ res = 1;
+ }
+ }
+ return (res);
+}
+
#else
static int
testThread(void)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]