diff options
author | Magnus Hagander <magnus@hagander.net> | 2007-03-29 15:30:52 +0000 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2007-03-29 15:30:52 +0000 |
commit | 96b171903d5d52ca46b46bc3f73f13978705eae5 (patch) | |
tree | ef3d6422c44693c74439533c8b27979952be77d2 /src/interfaces/ecpg/test/thread/thread.pgc | |
parent | ddcb5bbf76dd991b5a7024bc3d4e212b97d27936 (diff) | |
download | postgresql-96b171903d5d52ca46b46bc3f73f13978705eae5.tar.gz postgresql-96b171903d5d52ca46b46bc3f73f13978705eae5.zip |
Make ECPG regression tests use native threading instead of pthreads, now that
ecpglib supports it.
Change configure (patch from Bruce) and msvc build system to no longer require
pthreads on win32, since all parts of postgresql can be thread-safe using the
native platform functions.
Diffstat (limited to 'src/interfaces/ecpg/test/thread/thread.pgc')
-rw-r--r-- | src/interfaces/ecpg/test/thread/thread.pgc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/interfaces/ecpg/test/thread/thread.pgc b/src/interfaces/ecpg/test/thread/thread.pgc index e7f0b4d1dca..726121d2ca2 100644 --- a/src/interfaces/ecpg/test/thread/thread.pgc +++ b/src/interfaces/ecpg/test/thread/thread.pgc @@ -13,7 +13,11 @@ main(void) return 0; } #else +#ifndef WIN32 #include <pthread.h> +#else +#include <windows.h> +#endif exec sql include ../regression; @@ -24,7 +28,11 @@ int iterations = 20; int main(int argc, char *argv[]) { +#ifndef WIN32 pthread_t *threads; +#else + HANDLE *threads; +#endif int n; EXEC SQL BEGIN DECLARE SECTION; int l_rows; @@ -47,7 +55,7 @@ int main(int argc, char *argv[]) EXEC SQL DISCONNECT; /* create, and start, threads */ - threads = calloc(nthreads, sizeof(pthread_t)); + threads = calloc(nthreads, sizeof(threads[0])); if( threads == NULL ) { fprintf(stderr, "Cannot alloc memory\n"); @@ -55,14 +63,22 @@ int main(int argc, char *argv[]) } for( n = 0; n < nthreads; n++ ) { +#ifndef WIN32 pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1)); +#else + threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread, (void *) (n + 1), 0, NULL); +#endif } /* wait for thread completion */ +#ifndef WIN32 for( n = 0; n < nthreads; n++ ) { pthread_join(threads[n], NULL); } +#else + WaitForMultipleObjects(nthreads, threads, TRUE, INFINITE); +#endif free(threads); /* and check results */ |