diff options
author | Daniel Richard G <oss@teragram.com> | 2012-08-07 10:14:56 +0800 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2012-08-07 10:14:56 +0800 |
commit | 495a73df82de30b5d7d991ede3da80b21ff01f36 (patch) | |
tree | ee4333bb076de697769090ee17558a524bd03f50 | |
parent | 5d6c02ba6149fcf3046b2c34d9da9f895686a251 (diff) | |
download | android_external_libxml2-495a73df82de30b5d7d991ede3da80b21ff01f36.tar.gz android_external_libxml2-495a73df82de30b5d7d991ede3da80b21ff01f36.tar.bz2 android_external_libxml2-495a73df82de30b5d7d991ede3da80b21ff01f36.zip |
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.
-rw-r--r-- | runtest.c | 108 |
1 files changed, 54 insertions, 54 deletions
@@ -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) |