From 6eb5bba145940501ca972e4243d7417c8120d569 Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 6 Aug 2000 12:15:47 +0000 Subject: 2000-08-06 Ross Johnson * pthread.h: Remove #warning - VC++ doesn't accept it. 2000-08-05 Ross Johnson * pthread.h (PtW32CatchAll): Add macro. When compiling applications using VC++ with C++ EH rather than SEH 'PtW32CatchAll' must be used in place of any 'catch( ... )' if the application wants pthread cancelation or pthread_exit() to work. 2000-08-03 Ross Johnson * pthread.h: Add a base class Pthread_exception for library internal exceptions and change the "catch" re-define macro to use it. 2000-08-02 Ross Johnson * GNUmakefile (CFLAGS): Add -mthreads. Add new targets to generate cpp and asm output. * sync.c (pthread_join): Remove dead code. tests: 2000-08-06 Ross Johnson * ccl.bat: Add /nologo to remove extraneous output. * exception1.c (exceptionedThread): Init 'dummy'; put expression into if condition to prevent optimising away; remove unused variable. * cancel4.c (mythread): Cast return value to avoid warnings. * cancel2.c (mythread): Missing #endif. * condvar9.c (mythread): Cast return value to avoid warnings. * condvar8.c (mythread): Cast return value to avoid warnings. * condvar7.c (mythread): Cast return value to avoid warnings. * cleanup3.c (mythread): Cast return value to avoid warnings. * cleanup2.c (mythread): Cast return value to avoid warnings. * cleanup1.c (mythread): Cast return value to avoid warnings. * condvar5.c (mythread): Cast return value to avoid warnings. * condvar3.c (mythread): Cast return value to avoid warnings. * condvar6.c (mythread): Cast return value to avoid warnings. * condvar4.c (mythread): Cast return value to avoid warnings. 2000-08-05 Ross Johnson * cancel2.c: Use PtW32CatchAll macro if defined. * exception1.c: Use PtW32CatchAll macro if defined. 2000-08-02 Ross Johnson * tsd1.c: Fix typecasts of &result [g++ is now very fussy]. * test.h (assert): Return 0's explicitly to allay g++ errors. * join2.c: Add explicit typecasts. * join1.c: Add explicit typecasts. * join0.c: Add explicit typecasts. * eyal1.c: Add explicit typecasts. * count1.c (main): Add type cast to remove g++ parse warning [gcc-2.95.2 seems to have tightened up on this]. * Makefile (GLANG): Use c++ explicitly. Remove MSVC sections (was commented out). Add target to generate cpp output. --- tests/ChangeLog | 60 ++++++++++++++ tests/Makefile | 230 ++++++++++++++++++++++++++--------------------------- tests/cancel2.c | 8 +- tests/cancel4.c | 2 +- tests/ccl.bat | 2 +- tests/cleanup1.c | 2 +- tests/cleanup2.c | 2 +- tests/cleanup3.c | 2 +- tests/condvar3.c | 2 +- tests/condvar4.c | 2 +- tests/condvar5.c | 2 +- tests/condvar6.c | 2 +- tests/condvar7.c | 2 +- tests/condvar8.c | 2 +- tests/condvar9.c | 2 +- tests/count1.c | 2 +- tests/exception1.c | 27 +++++-- tests/eyal1.c | 5 +- tests/join0.c | 2 +- tests/join1.c | 2 +- tests/join2.c | 2 +- tests/test.h | 4 +- tests/tsd1.c | 2 +- 23 files changed, 221 insertions(+), 147 deletions(-) (limited to 'tests') diff --git a/tests/ChangeLog b/tests/ChangeLog index 902a809..3a18a5b 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,63 @@ +2000-08-06 Ross Johnson + + * ccl.bat: Add /nologo to remove extraneous output. + + * exception1.c (exceptionedThread): Init 'dummy'; + put expression into if condition to prevent optimising away; + remove unused variable. + + * cancel4.c (mythread): Cast return value to avoid warnings. + + * cancel2.c (mythread): Missing #endif. + + * condvar9.c (mythread): Cast return value to avoid warnings. + + * condvar8.c (mythread): Cast return value to avoid warnings. + + * condvar7.c (mythread): Cast return value to avoid warnings. + + * cleanup3.c (mythread): Cast return value to avoid warnings. + + * cleanup2.c (mythread): Cast return value to avoid warnings. + + * cleanup1.c (mythread): Cast return value to avoid warnings. + + * condvar5.c (mythread): Cast return value to avoid warnings. + + * condvar3.c (mythread): Cast return value to avoid warnings. + + * condvar6.c (mythread): Cast return value to avoid warnings. + + * condvar4.c (mythread): Cast return value to avoid warnings. + +2000-08-05 Ross Johnson + + * cancel2.c: Use PtW32CatchAll macro if defined. + + * exception1.c: Use PtW32CatchAll macro if defined. + +2000-08-02 Ross Johnson + + * tsd1.c: Fix typecasts of &result [g++ is now very fussy]. + + * test.h (assert): Return 0's explicitly to allay + g++ errors. + + * join2.c: Add explicit typecasts. + + * join1.c: Add explicit typecasts. + + * join0.c: Add explicit typecasts. + + * eyal1.c: Add explicit typecasts. + + * count1.c (main): Add type cast to remove g++ parse warning + [gcc-2.95.2 seems to have tightened up on this]. + + * Makefile (GLANG): Use c++ explicitly. + Remove MSVC sections (was commented out). + Add target to generate cpp output. + 2000-07-25 Ross Johnson * runtest.bat: modified to work under W98. diff --git a/tests/Makefile b/tests/Makefile index 5931855..0775ea3 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,118 +1,112 @@ -# Makefile for the pthreads test suite. -# If all of the .pass files can be created, the test suite has passed. - - -CP = copy -RM = erase -MKDIR = mkdir -TOUCH = echo Passed > -ECHO = @echo - -# -# Mingw32 -# -GLANG = c -CC = gcc -CFLAGS = -g -O2 -UNDEBUG -Wall -x $(GLANG) -o $@ $^ -BUILD_DIR = .. -INCLUDES = -I. -LIBS = -L. -lpthread32 - -## -## MSVC -## -#CC = cl -#CFLAGS = /W3 /MT /nologo /Yd /Zi /Fe$@ $^ -#BUILD_DIR = .. -#INCLUDES = -I. -#LIBS = pthread.lib - -HDR = pthread.h semaphore.h sched.h -LIB = libpthread32.a -DLL = pthread.dll - -COPYFILES = $(HDR) $(LIB) $(DLL) - -# If a test case returns a non-zero exit code to the shell, make will -# stop. - -TESTS = loadfree \ - mutex1 condvar1 condvar2 exit1 create1 equal1 \ - exit2 exit3 \ - join0 join1 join2 mutex2 mutex3 \ - count1 once1 tsd1 self1 self2 cancel1 eyal1 \ - condvar3 condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ - errno1 \ - rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 \ - context1 cancel3 cancel4 cleanup1 cleanup2 cleanup3 \ - exception1 - -PASSES = $(TESTS:%=%.pass) - -all: $(PASSES) - @ $(ECHO) ALL TESTS PASSED! Congratulations! - -loadfree.pass: -mutex1.pass: -mutex2.pass: -exit1.pass: -condvar1.pass: -self1.pass: -condvar2.pass: condvar1.pass -create1.pass: mutex2.pass -mutex3.pass: create1.pass -equal1.pass: create1.pass -exit2.pass: create1.pass -exit3.pass: create1.pass -join0.pass: create1.pass -join1.pass: create1.pass -join2.pass: create1.pass -count1.pass: join1.pass -once1.pass: create1.pass -tsd1.pass: join1.pass -self2.pass: create1.pass -eyal1.pass: tsd1.pass -condvar3.pass: create1.pass -condvar4.pass: create1.pass -condvar5.pass: condvar4.pass -condvar6.pass: condvar5.pass -condvar7.pass: condvar6.pass cleanup1.pass -condvar8.pass: condvar7.pass -condvar9.pass: condvar8.pass -errno1.pass: mutex3.pass -rwlock1.pass: condvar6.pass -rwlock2.pass: rwlock1.pass -rwlock3.pass: rwlock2.pass -rwlock4.pass: rwlock3.pass -rwlock5.pass: rwlock4.pass -rwlock6.pass: rwlock5.pass -context1.pass: cancel2.pass -cancel3.pass: context1.pass -cancel4.pass: cancel3.pass -cleanup1.pass: cancel4.pass -cleanup2.pass: cleanup1.pass -cleanup3.pass: cleanup2.pass -exception1.pass: cancel4.pass - -%.pass: %.exe $(LIB) $(DLL) $(HDR) - $* - @ $(ECHO) Passed - @ $(TOUCH) $@ - -%.exe: %.c - @ $(CC) $(CFLAGS) $(INCLUDES) $(LIBS) - -$(COPYFILES): - @ $(ECHO) Copying $@ - @ $(CP) $(BUILD_DIR)\$@ . - -clean: - - $(RM) *.dll - - $(RM) pthread.h - - $(RM) semaphore.h - - $(RM) sched.h - - $(RM) *.a - - $(RM) *.e - - $(RM) *.exe - - $(RM) *.pass - +# Makefile for the pthreads test suite. +# If all of the .pass files can be created, the test suite has passed. + + +CP = copy +RM = erase +MKDIR = mkdir +TOUCH = echo Passed > +ECHO = @echo + +# +# Mingw32 +# +GLANG = c++ +CC = gcc +CFLAGS = -g -O2 -UNDEBUG -Wall -x $(GLANG) +BUILD_DIR = .. +INCLUDES = -I. +LIBS = -L. -lpthread32 + +HDR = pthread.h semaphore.h sched.h +LIB = libpthread32.a +DLL = pthread.dll + +COPYFILES = $(HDR) $(LIB) $(DLL) + +# If a test case returns a non-zero exit code to the shell, make will +# stop. + +TESTS = loadfree \ + mutex1 condvar1 condvar2 exit1 create1 equal1 \ + exit2 exit3 \ + join0 join1 join2 mutex2 mutex3 \ + count1 once1 tsd1 self1 self2 cancel1 eyal1 \ + condvar3 condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ + errno1 \ + rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 \ + context1 cancel3 cancel4 cleanup1 cleanup2 cleanup3 \ + exception1 + +PASSES = $(TESTS:%=%.pass) + +all: $(PASSES) + @ $(ECHO) ALL TESTS PASSED! Congratulations! + +loadfree.pass: +mutex1.pass: +mutex2.pass: +exit1.pass: +condvar1.pass: +self1.pass: +condvar2.pass: condvar1.pass +create1.pass: mutex2.pass +mutex3.pass: create1.pass +equal1.pass: create1.pass +exit2.pass: create1.pass +exit3.pass: create1.pass +join0.pass: create1.pass +join1.pass: create1.pass +join2.pass: create1.pass +count1.pass: join1.pass +once1.pass: create1.pass +tsd1.pass: join1.pass +self2.pass: create1.pass +eyal1.pass: tsd1.pass +condvar3.pass: create1.pass +condvar4.pass: create1.pass +condvar5.pass: condvar4.pass +condvar6.pass: condvar5.pass +condvar7.pass: condvar6.pass cleanup1.pass +condvar8.pass: condvar7.pass +condvar9.pass: condvar8.pass +errno1.pass: mutex3.pass +rwlock1.pass: condvar6.pass +rwlock2.pass: rwlock1.pass +rwlock3.pass: rwlock2.pass +rwlock4.pass: rwlock3.pass +rwlock5.pass: rwlock4.pass +rwlock6.pass: rwlock5.pass +context1.pass: cancel2.pass +cancel3.pass: context1.pass +cancel4.pass: cancel3.pass +cleanup1.pass: cancel4.pass +cleanup2.pass: cleanup1.pass +cleanup3.pass: cleanup2.pass +exception1.pass: cancel4.pass + +%.pass: %.exe $(LIB) $(DLL) $(HDR) + $* + @ $(ECHO) Passed + @ $(TOUCH) $@ + +%.exe: %.c + @ $(CC) $(CFLAGS) -o $@ $^ $(INCLUDES) $(LIBS) + +%.pre: %.c + @ $(CC) -E $(CFLAGS) -o $@ $^ $(INCLUDES) + +$(COPYFILES): + @ $(ECHO) Copying $@ + @ $(CP) $(BUILD_DIR)\$@ . + +clean: + - $(RM) *.dll + - $(RM) pthread.h + - $(RM) semaphore.h + - $(RM) sched.h + - $(RM) *.a + - $(RM) *.e + - $(RM) *.exe + - $(RM) *.pass + diff --git a/tests/cancel2.c b/tests/cancel2.c index 44d1b77..b09eab9 100644 --- a/tests/cancel2.c +++ b/tests/cancel2.c @@ -88,7 +88,7 @@ mythread(void * arg) break; } -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__cplusplus) __try #else try @@ -104,10 +104,14 @@ mythread(void * arg) pthread_testcancel(); } } -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__cplusplus) __except(EXCEPTION_EXECUTE_HANDLER) +#else +#if defined(PtW32CatchAll) + PtW32CatchAll #else catch(...) +#endif #endif { /* diff --git a/tests/cancel4.c b/tests/cancel4.c index 59c2f8e..f63241f 100644 --- a/tests/cancel4.c +++ b/tests/cancel4.c @@ -88,7 +88,7 @@ mythread(void * arg) for (bag->count = 0; bag->count < 100; bag->count++) Sleep(100); - return result; + return (void *) result; } int diff --git a/tests/ccl.bat b/tests/ccl.bat index d80ea03..0c42f3d 100644 --- a/tests/ccl.bat +++ b/tests/ccl.bat @@ -5,5 +5,5 @@ REM Generate object file cl /W3 /MT /nologo /Yd /Zi -I. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c ..\%1.c REM Generate executable -cl /Feaout.exe /Zi %1.obj .\pthread.lib +cl /nologo /Feaout.exe /Zi %1.obj .\pthread.lib del %1.obj > nul: diff --git a/tests/cleanup1.c b/tests/cleanup1.c index 4939e6f..2be711c 100644 --- a/tests/cleanup1.c +++ b/tests/cleanup1.c @@ -98,7 +98,7 @@ mythread(void * arg) pthread_cleanup_pop(0); - return result; + return (void *) result; } int diff --git a/tests/cleanup2.c b/tests/cleanup2.c index c6ca529..515f676 100644 --- a/tests/cleanup2.c +++ b/tests/cleanup2.c @@ -88,7 +88,7 @@ mythread(void * arg) pthread_cleanup_pop(1); - return result; + return (void *) result; } int diff --git a/tests/cleanup3.c b/tests/cleanup3.c index ff84c0b..4f05eea 100644 --- a/tests/cleanup3.c +++ b/tests/cleanup3.c @@ -91,7 +91,7 @@ mythread(void * arg) pthread_cleanup_pop(0); - return result; + return (void *) result; } int diff --git a/tests/condvar3.c b/tests/condvar3.c index deb130a..a25c15a 100644 --- a/tests/condvar3.c +++ b/tests/condvar3.c @@ -67,7 +67,7 @@ mythread(void * arg) assert(pthread_cond_signal(&cv) == 0); - return 0; + return (void *) 0; } int diff --git a/tests/condvar4.c b/tests/condvar4.c index 3feaebb..4729063 100644 --- a/tests/condvar4.c +++ b/tests/condvar4.c @@ -74,7 +74,7 @@ mythread(void * arg) assert(pthread_cond_signal(&cvthing.notbusy) == 0); - return 0; + return (void *) 0; } int diff --git a/tests/condvar5.c b/tests/condvar5.c index d406a2b..d0d15a1 100644 --- a/tests/condvar5.c +++ b/tests/condvar5.c @@ -73,7 +73,7 @@ mythread(void * arg) assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - return 0; + return (void *) 0; } int diff --git a/tests/condvar6.c b/tests/condvar6.c index 6acc666..7348346 100644 --- a/tests/condvar6.c +++ b/tests/condvar6.c @@ -102,7 +102,7 @@ mythread(void * arg) assert(pthread_mutex_unlock(&cvthing.lock) == 0); - return 0; + return (void *) 0; } int diff --git a/tests/condvar7.c b/tests/condvar7.c index ae51a10..3745f02 100644 --- a/tests/condvar7.c +++ b/tests/condvar7.c @@ -106,7 +106,7 @@ mythread(void * arg) assert(pthread_mutex_unlock(&cvthing.lock) == 0); - return 0; + return (void *) 0; } int diff --git a/tests/condvar8.c b/tests/condvar8.c index 3522546..d1076e3 100644 --- a/tests/condvar8.c +++ b/tests/condvar8.c @@ -110,7 +110,7 @@ mythread(void * arg) assert(pthread_mutex_unlock(&cvthing.lock) == 0); - return 0; + return (void *) 0; } int diff --git a/tests/condvar9.c b/tests/condvar9.c index 9b4f2f8..7d24d09 100644 --- a/tests/condvar9.c +++ b/tests/condvar9.c @@ -111,7 +111,7 @@ mythread(void * arg) assert(pthread_mutex_unlock(&cvthing.lock) == 0); - return 0; + return (void *) 0; } int diff --git a/tests/count1.c b/tests/count1.c index e88a955..ae30ed0 100644 --- a/tests/count1.c +++ b/tests/count1.c @@ -53,7 +53,7 @@ main() /* * Check the number of threads created. */ - assert(numThreads == maxThreads); + assert((int) numThreads == maxThreads); /* * Success. diff --git a/tests/exception1.c b/tests/exception1.c index a7d8e22..eddd8fb 100644 --- a/tests/exception1.c +++ b/tests/exception1.c @@ -56,7 +56,7 @@ exceptionedThread(void * arg) int result = ((int)PTHREAD_CANCELED + 1); int one = 1; int zero = 0; - int dummy; + int dummy = 0; /* Set to async cancelable */ @@ -66,22 +66,32 @@ exceptionedThread(void * arg) Sleep(100); -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__cplusplus) __try { - dummy = one/zero; + /* Avoid being optimised out */ + if (dummy == one/zero) + Sleep(0); } __except (EXCEPTION_EXECUTE_HANDLER) { + /* Should get into here. */ result = ((int)PTHREAD_CANCELED + 2); } #elif defined(__cplusplus) try { - dummy = one/zero; + /* Avoid being optimised out */ + if (dummy == one/zero) + Sleep(0); } +#if defined(PtW32CatchAll) + PtW32CatchAll +#else catch (...) +#endif { + /* Should get into here. */ result = ((int)PTHREAD_CANCELED + 2); } #endif @@ -93,7 +103,6 @@ void * canceledThread(void * arg) { int result = ((int)PTHREAD_CANCELED + 1); - int dummy; int count; /* Set to async cancelable */ @@ -102,7 +111,7 @@ canceledThread(void * arg) assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__cplusplus) __try { /* @@ -114,6 +123,7 @@ canceledThread(void * arg) } __except (EXCEPTION_EXECUTE_HANDLER) { + /* Should NOT get into here. */ result = ((int)PTHREAD_CANCELED + 2); } #elif defined(__cplusplus) @@ -126,8 +136,13 @@ canceledThread(void * arg) for (count = 0; count < 100; count++) Sleep(100); } +#if defined(_MSC_VER) + AltCatchAll +#else catch (...) +#endif { + /* Should NOT get into here. */ result = ((int)PTHREAD_CANCELED + 2); } #endif diff --git a/tests/eyal1.c b/tests/eyal1.c index 7a2dc37..849e632 100644 --- a/tests/eyal1.c +++ b/tests/eyal1.c @@ -230,7 +230,7 @@ main (int argc, char *argv[]) { int i; - assert(NULL != (tcs = calloc (nthreads, sizeof (*tcs)))); + assert(NULL != (tcs = (TC *) calloc (nthreads, sizeof (*tcs)))); /* * Launch threads @@ -250,7 +250,8 @@ main (int argc, char *argv[]) assert((tcs[i].stat = pthread_create (&tcs[i].thread, NULL, - (void*)&print_server, (void *)&tcs[i]) + (void*)&print_server, + (void *)&tcs[i]) ) == 0); /* diff --git a/tests/join0.c b/tests/join0.c index cd481ee..54b0bee 100644 --- a/tests/join0.c +++ b/tests/join0.c @@ -26,7 +26,7 @@ main(int argc, char * argv[]) /* Create a single thread and wait for it to exit. */ assert(pthread_create(&id, NULL, func, (void *) 123) == 0); - assert(pthread_join(id, (void *) &result) == 0); + assert(pthread_join(id, (void **) &result) == 0); #if ! defined (__MINGW32__) || defined (__MSVCRT__) assert(result == 123); diff --git a/tests/join1.c b/tests/join1.c index c29e5e6..8cc80e5 100644 --- a/tests/join1.c +++ b/tests/join1.c @@ -37,7 +37,7 @@ main(int argc, char * argv[]) for (i = 0; i < 4; i++) { - assert(pthread_join(id[i], (void *) &result) == 0); + assert(pthread_join(id[i], (void **) &result) == 0); #if ! defined (__MINGW32__) || defined (__MSVCRT__) assert(result == i); #else diff --git a/tests/join2.c b/tests/join2.c index 8b1636c..cdc8ca2 100644 --- a/tests/join2.c +++ b/tests/join2.c @@ -28,7 +28,7 @@ main(int argc, char * argv[]) for (i = 0; i < 4; i++) { - assert(pthread_join(id[i], (void *) &result) == 0); + assert(pthread_join(id[i], (void **) &result) == 0); #if ! defined (__MINGW32__) || defined (__MSVCRT__) /* CRTDLL _beginthread doesn't support return value, so the assertion is guaranteed to fail. */ diff --git a/tests/test.h b/tests/test.h index ffb8180..018b215 100644 --- a/tests/test.h +++ b/tests/test.h @@ -85,9 +85,9 @@ char * error_string[] = { "Assertion succeeded: (%s), file %s, line %d\n", \ #e, __FILE__, (int) __LINE__), \ fflush(stderr) : \ - (void) 0) : \ + 0) : \ (fprintf(stderr, "Assertion failed: (%s), file %s, line %d\n", \ - #e, __FILE__, (int) __LINE__), exit(1))) + #e, __FILE__, (int) __LINE__), exit(1), 0)) #endif /* NDEBUG */ diff --git a/tests/tsd1.c b/tests/tsd1.c index 9926a30..a65cf66 100644 --- a/tests/tsd1.c +++ b/tests/tsd1.c @@ -142,7 +142,7 @@ main() { int result = 0; - assert(pthread_join(thread[i], (void *) &result) == 0); + assert(pthread_join(thread[i], (void **) &result) == 0); } assert(pthread_key_delete(key) == 0); -- cgit v1.2.3