From 8200f6ff1edca15756a22e6359f20836c4b5425b Mon Sep 17 00:00:00 2001 From: rpj Date: Wed, 27 Feb 2002 22:53:15 +0000 Subject: * exception3.c (terminateFunction): For MSVC++, call exit() rather than pthread_exit(). Add comments to explain why. * rwlock2_t.c: New test. * rwlock3_t.c: New test. * rwlock4_t.c: New test. * rwlock5_t.c: New test. * rwlock6_t.c: New test. * rwlock6_t2.c: New test. * rwlock6.c (main): Swap thread and result variables to correspond to actual thread functions. * rwlock1.c: Change test description comment to correspond to the actual test. --- CONTRIBUTORS | 137 ++++++++++++++++++++++++++++++++++++++--------------- ChangeLog | 2 +- GNUmakefile | 6 ++- Makefile | 20 ++++---- Nmakefile.tests | 12 +++++ exit.c | 60 +---------------------- pthread.dsp | 11 +---- pthread.h | 2 +- pthread_exit.c | 102 +++++++++++++++++++++++++++++++++++++++ tests/ChangeLog | 28 +++++++++++ tests/GNUmakefile | 19 ++++++-- tests/Makefile | 26 ++++++---- tests/exception3.c | 45 ++++++++++++++++-- tests/rwlock1.c | 4 +- tests/rwlock6.c | 20 ++++---- 15 files changed, 347 insertions(+), 147 deletions(-) create mode 100644 pthread_exit.c diff --git a/CONTRIBUTORS b/CONTRIBUTORS index b844556..513b637 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,37 +1,100 @@ -Contributors (in approximate order of appearance) - -[See also the ChangeLog file where individuals are -attributed in log entries. Likewise in the FAQ file.] - -Ben Elliston bje@cygnus.com -Ross Johnson rpj@ise.canberra.edu.au -Robert Colquhoun rjc@trump.net.au -John E. Bossom John.Bossom@cognos.com -Anders Norlander anorland@hem2.passagen.se -Tor Lillqvist tml@iki.fi -Kevin Ruland Kevin.Ruland@anheuser-busch.com -Mike Russo miker@eai.com -Mark E. Armstrong avail@pacbell.net -Lorin Hochstein lmh@xiphos.ca -Peter Slacik Peter.Slacik@tatramed.sk -Mumit Khan khan@xraylith.wisc.edu -Aurelio Medina aureliom@crt.com -Milan Gardian mg@tatramed.sk -Graham Dumpleton Graham.Dumpleton@ra.pad.otc.telstra.com.au -Tristan Savatier tristan@mpegtv.com -Erik Hensema erik@hensema.xs4all.nl -Rich Peters rpeters@micro-magic.com -Todd Owen towen@lucidcalm.dropbear.id.au -Jason Nye jnye@nbnet.nb.ca -Fred Forester fforest@eticomm.net -Kevin D. Clark kclark@cabletron.com -David Baggett dmb@itasoftware.com -Paul Redondo paul@matchvision.com -Scott McCaskill scott@3dfx.om -Thomas Pfaff tpfaff@gmx.net -Franco Bez franco.bez@gmx.de -Alexander Terekhov TEREKHOV@de.ibm.com -Louis Thomas lthomas@arbitrade.com -David Korn dgk@research.att.com -Phil Frisbie, Jr. phil@hawksoft.com - +Contributors (in approximate order of appearance) + +[See also the ChangeLog file where individuals are +attributed in log entries. Likewise in the FAQ file.] + +Ben Elliston bje@cygnus.com + Initiated the project; + setup the project infrastructure (CVS, web page, etc.); + early prototype routines. +Ross Johnson rpj@ise.canberra.edu.au + early prototype routines; + ongoing project coordination/maintenance; + implementation of spin locks and barriers; + bug fixes; + documentation; + testsuite. +Robert Colquhoun rjc@trump.net.au + Early bug fixes. +John E. Bossom John.Bossom@cognos.com + Contributed substantial original working implementation; + bug fixes; + ongoing guidance and standards interpretation. +Anders Norlander anorland@hem2.passagen.se + Early enhancements and runtime checking for supported + Win32 routines. +Tor Lillqvist tml@iki.fi + General enhancements; + early bug fixes to condition variables. +Scott Lightner scott@curriculum.com + Bug fix. +Kevin Ruland Kevin.Ruland@anheuser-busch.com + Various bug fixes. +Mike Russo miker@eai.com + Bug fix. +Mark E. Armstrong avail@pacbell.net + Bug fixes. +Lorin Hochstein lmh@xiphos.ca + general bug fixes; bug fixes to condition variables. +Peter Slacik Peter.Slacik@tatramed.sk + Bug fixes. +Mumit Khan khan@xraylith.wisc.edu + Fixes to work with Mingw32. +Milan Gardian mg@tatramed.sk + Bug fixes and reports/analyses of obscure problems. +Aurelio Medina aureliom@crt.com + First implementation of read-write locks. +Graham Dumpleton Graham.Dumpleton@ra.pad.otc.telstra.com.au + Bug fix in condition variables. +Tristan Savatier tristan@mpegtv.com + WinCE port. +Erik Hensema erik@hensema.xs4all.nl + Bug fixes. +Rich Peters rpeters@micro-magic.com +Todd Owen towen@lucidcalm.dropbear.id.au + Bug fixes to dll loading. +Jason Nye jnye@nbnet.nb.ca + Implementation of async cancelation. +Fred Forester fforest@eticomm.net +Kevin D. Clark kclark@cabletron.com +David Baggett dmb@itasoftware.com + Bug fixes. +Paul Redondo paul@matchvision.com +Scott McCaskill scott@3dfx.om + Bug fixes. +Jef Gearhart jgearhart@tpssys.com + Bug fix. +Arthur Kantor akantor@bexusa.com + Mutex enhancements. +Steven Reddie smr@essemer.com.au + Bug fix. +Alexander Terekhov TEREKHOV@de.ibm.com + Re-implemented and improved read-write locks; + (with Louis Thomas) re-implemented and improved + condition variables; + enhancements to semaphores; + system clock change handling re CV timeouts; + bug fixes. +Thomas Pfaff tpfaff@gmx.net + Changes to make C version usable with C++ applications; + re-implemented mutex routines to avoid Win32 mutexes + and TryEnterCriticalSection; + procedure to fix Mingw32 thread-safety issues. +Franco Bez franco.bez@gmx.de + procedure to fix Mingw32 thread-safety issues. +Louis Thomas lthomas@arbitrade.com + (with Alexander Terekhov) re-implemented and improved + condition variables. +David Korn dgk@research.att.com + Ported to UWIN. +Phil Frisbie, Jr. phil@hawksoft.com + Bug fix. +Ralf Brese Ralf.Brese@pdb4.siemens.de + Bug fix. +prionx@juno.com prionx@juno.com + Bug fixes. +Max Woodbury mtew@cds.duke.edu + POSIX versioning conditionals; + reduced namespace pollution; + idea to separate routines to reduce statically + linked image sizes. diff --git a/ChangeLog b/ChangeLog index b9b4422..9c1adff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1978,7 +1978,7 @@ Tue Feb 2 18:07:43 1999 Ross Johnson * implement.h: Add #include . Change sem_t to ptw32_sem_t. - Various patches by Kevin Ruland +Tue Feb 2 18:07:43 1999 Kevin Ruland * signal.c (pthread_sigmask): Add and modify casts. Reverse LHS/RHS bitwise assignments. diff --git a/GNUmakefile b/GNUmakefile index aaa19bb..46558fd 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -132,7 +132,7 @@ SMALL_STATIC_OBJS = \ create.o \ dll.o \ errno.o \ - exit.o \ + pthread_exit.o \ fork.o \ global.o \ pthread_mutex_init.o \ @@ -267,6 +267,9 @@ CONDVAR_SRCS = \ pthread_cond_signal.c \ pthread_cond_wait.c +EXIT_SRCS = \ + pthread_exit.c + MISC_SRCS = \ pthread_equal.c \ pthread_getconcurrency.c \ @@ -467,6 +470,7 @@ attr.o: attr.c $(ATTR_SRCS) $(INCL) barrier.o: barrier.c $(BARRIER_SRCS) $(INCL) cancel.o: cancel.c $(CANCEL_SRCS) $(INCL) condvar.o: condvar.c $(CONDVAR_SRCS) $(INCL) +exit.o: exit.c $(EXIT_SRCS) $(INCL) misc.o: misc.c $(MISC_SRCS) $(INCL) mutex.o: mutex.c $(MUTEX_SRCS) $(INCL) nonportable.o: nonportable.c $(NONPORTABLE_SRCS) $(INCL) diff --git a/Makefile b/Makefile index 6f318f0..5f8767a 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ INLINED_STAMPS = pthreadVCE.stamp pthreadVSE.stamp pthreadVC.stamp OPTIM = /O2 -#CFLAGS = /W3 /MT /nologo /Yd /Zi /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H /DTEST_ICE -CFLAGS = /W3 /MT /nologo /Yd /Zi /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H +#CFLAGS = /W3 /MD /nologo /Yd /Zi /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H /DTEST_ICE +CFLAGS = /W3 /MD /nologo /Yd /Zi /I. /D_WIN32_WINNT=0x400 /DHAVE_CONFIG_H # C++ Exceptions VCEFLAGS = /GX /TP /D__CLEANUP_CXX $(CFLAGS) @@ -94,7 +94,7 @@ SMALL_STATIC_OBJS = \ create.obj \ dll.obj \ errno.obj \ - exit.obj \ + pthread_exit.obj \ fork.obj \ global.obj \ pthread_mutex_init.obj \ @@ -224,6 +224,9 @@ CONDVAR_SRCS = \ pthread_cond_signal.c \ pthread_cond_wait.c +EXIT_SRCS = \ + pthread_exit.c + MISC_SRCS = \ pthread_equal.c \ pthread_getconcurrency.c \ @@ -338,7 +341,7 @@ TSD_SRCS = \ pthread_getspecific.c -all: +help: @ echo Run one of the following command lines: @ echo nmake clean VCE (to build the MSVC dll with C++ exception handling) @ echo nmake clean VSE (to build the MSVC dll with structured exception handling) @@ -347,10 +350,10 @@ all: @ echo nmake clean VSE-inlined (to build the MSVC inlined dll with structured exception handling) @ echo nmake clean VC-inlined (to build the MSVC inlined dll with C cleanup code) -auto: - @ nmake clean VCE - @ nmake clean VSE - @ nmake clean VC +all: + @ nmake clean VCE-inlined + @ nmake clean VSE-inlined + @ nmake clean VC-inlined VCE: @ nmake /nologo EHFLAGS="$(OPTIM) $(VCEFLAGS)" pthreadVCE.dll @@ -408,6 +411,7 @@ attr.obj: attr.c $(ATTR_SRCS) $(INCL) barrier.obj: barrier.c $(BARRIER_SRCS) $(INCL) cancel.obj: cancel.c $(CANCEL_SRCS) $(INCL) condvar.obj: condvar.c $(CONDVAR_SRCS) $(INCL) +exit.obj: exit.c $(EXIT_SRCS) $(INCL) misc.obj: misc.c $(MISC_SRCS) $(INCL) mutex.obj: mutex.c $(MUTEX_SRCS) $(INCL) nonportable.obj: nonportable.c $(NONPORTABLE_SRCS) $(INCL) diff --git a/Nmakefile.tests b/Nmakefile.tests index 6ca0b5c..a623304 100644 --- a/Nmakefile.tests +++ b/Nmakefile.tests @@ -79,6 +79,12 @@ rwlock4:: rwlock4.c rwlock5:: rwlock5.c rwlock6:: rwlock6.c rwlock7:: rwlock7.c +rwlock2_t:: rwlock2_t.c +rwlock3_t:: rwlock3_t.c +rwlock4_t:: rwlock4_t.c +rwlock5_t:: rwlock5_t.c +rwlock6_t:: rwlock6_t.c +rwlock6_t2:: rwlock6_t2.c context1:: context1.c cancel3:: cancel3.c cancel4:: cancel4.c @@ -166,6 +172,12 @@ rwlock3 :test: rwlock2 rwlock4 :test: rwlock3 rwlock5 :test: rwlock4 rwlock6 :test: rwlock5 +rwlock2_t :test: rwlock2 +rwlock3_t :test: rwlock2_t +rwlock4_t :test: rwlock3_t +rwlock5_t :test: rwlock4_t +rwlock6_t :test: rwlock5_t +rwlock6_t2 :test: rwlock6_t context1 :test: cancel2 cancel3 :test: context1 cancel4 :test: cancel3 diff --git a/exit.c b/exit.c index 2da0e1e..b181077 100644 --- a/exit.c +++ b/exit.c @@ -41,62 +41,4 @@ # include #endif -void -pthread_exit (void *value_ptr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function terminates the calling thread, returning - * the value 'value_ptr' to any joining thread. - * - * PARAMETERS - * value_ptr - * a generic data value (i.e. not the address of a value) - * - * - * DESCRIPTION - * This function terminates the calling thread, returning - * the value 'value_ptr' to any joining thread. - * NOTE: thread should be joinable. - * - * RESULTS - * N/A - * - * ------------------------------------------------------ - */ -{ - pthread_t self; - - /* If the current thread is implicit it was not started through - pthread_create(), therefore we cleanup and end the thread - here. Otherwise we raise an exception to unwind the exception - stack. The exception will be caught by ptw32_threadStart(), - which will cleanup and end the thread for us. - */ - - self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey); -#ifdef _UWIN - if(--pthread_count <= 0) - exit((int)value_ptr); -#endif - - if (self == NULL || self->implicit) - { - ptw32_callUserDestroyRoutines(self); - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - _endthreadex ((unsigned) value_ptr); -#else - _endthread (); -#endif - - /* Never reached */ - } - - self->exitStatus = value_ptr; - - ptw32_throw(PTW32_EPS_EXIT); - - /* Never reached. */ - -} +#include "pthread_exit.c" diff --git a/pthread.dsp b/pthread.dsp index 75d0bb9..16b7ec8 100644 --- a/pthread.dsp +++ b/pthread.dsp @@ -180,10 +180,6 @@ SOURCE=.\tsd.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File -SOURCE=.\acconfig.h -# End Source File -# Begin Source File - SOURCE=.\config.h # End Source File # Begin Source File @@ -212,8 +208,5 @@ SOURCE=.\semaphore.h # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File -SOURCE=.\pthread.def -# End Source File -# End Group -# End Target -# End Project + + diff --git a/pthread.h b/pthread.h index 66c5f0e..e197ebe 100644 --- a/pthread.h +++ b/pthread.h @@ -1104,7 +1104,7 @@ PTW32_DLLPORT int pthreadCancelableTimedWait (HANDLE waitHandle, * Thread-Safe C Runtime Library Mappings. */ #ifndef _UWIN -#if (! defined(HAVE_ERRNO)) && (! defined(_REENTRANT)) && (! defined(_MT)) && (! defined(_MD)) +#if (! defined(HAVE_ERRNO)) && (! defined(_REENTRANT)) && (! defined(_MT)) PTW32_DLLPORT int * _errno( void ); #endif #endif diff --git a/pthread_exit.c b/pthread_exit.c new file mode 100644 index 0000000..ad77ebd --- /dev/null +++ b/pthread_exit.c @@ -0,0 +1,102 @@ +/* + * pthread_exit.c + * + * Description: + * This translation unit implements routines associated with exiting from + * a thread. + * + * -------------------------------------------------------------------------- + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright(C) 1998 John E. Bossom + * Copyright(C) 1999,2002 Pthreads-win32 contributors + * + * Contact Email: rpj@ise.canberra.edu.au + * + * The current list of contributors is contained + * in the file CONTRIBUTORS included with the source + * code distribution. The list can also be seen at the + * following World Wide Web location: + * http://sources.redhat.com/pthreads-win32/contributors.html + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library in the file COPYING.LIB; + * if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include "pthread.h" +#include "implement.h" +#ifndef _UWIN +# include +#endif + +void +pthread_exit (void *value_ptr) + /* + * ------------------------------------------------------ + * DOCPUBLIC + * This function terminates the calling thread, returning + * the value 'value_ptr' to any joining thread. + * + * PARAMETERS + * value_ptr + * a generic data value (i.e. not the address of a value) + * + * + * DESCRIPTION + * This function terminates the calling thread, returning + * the value 'value_ptr' to any joining thread. + * NOTE: thread should be joinable. + * + * RESULTS + * N/A + * + * ------------------------------------------------------ + */ +{ + pthread_t self; + + /* If the current thread is implicit it was not started through + pthread_create(), therefore we cleanup and end the thread + here. Otherwise we raise an exception to unwind the exception + stack. The exception will be caught by ptw32_threadStart(), + which will cleanup and end the thread for us. + */ + + self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey); +#ifdef _UWIN + if(--pthread_count <= 0) + exit((int)value_ptr); +#endif + + if (self == NULL || self->implicit) + { + ptw32_callUserDestroyRoutines(self); + +#if ! defined (__MINGW32__) || defined (__MSVCRT__) + _endthreadex ((unsigned) value_ptr); +#else + _endthread (); +#endif + + /* Never reached */ + } + + self->exitStatus = value_ptr; + + ptw32_throw(PTW32_EPS_EXIT); + + /* Never reached. */ + +} diff --git a/tests/ChangeLog b/tests/ChangeLog index afd2cbb..663db9b 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,33 @@ +2002-02-28 Ross Johnson + + * exception3.c (terminateFunction): For MSVC++, call + exit() rather than pthread_exit(). Add comments to explain + why. + * Notes from the MSVC++ manual: + * 1) A term_func() should call exit(), otherwise + * abort() will be called on return to the caller. + * abort() raises SIGABRT. The default signal handler + * for all signals terminates the calling program with + * exit code 3. + * 2) A term_func() must not throw an exception. Therefore + * term_func() should not call pthread_exit() if an + * an exception-using version of pthreads-win32 library + * is being used (i.e. either pthreadVCE or pthreadVSE). + + 2002-02-23 Ross Johnson + * rwlock2_t.c: New test. + * rwlock3_t.c: New test. + * rwlock4_t.c: New test. + * rwlock5_t.c: New test. + * rwlock6_t.c: New test. + * rwlock6_t2.c: New test. + * rwlock6.c (main): Swap thread and result variables + to correspond to actual thread functions. + * rwlock1.c: Change test description comment to correspond + to the actual test. + * condvar1_2.c: Loop over the test many times in the hope of detecting any intermittent deadlocks. This is to test a fixed problem in pthread_cond_destroy.c. diff --git a/tests/GNUmakefile b/tests/GNUmakefile index 9e6cf89..800d33a 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -77,6 +77,7 @@ TESTS = loadfree \ condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ errno1 \ rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 \ + rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \ context1 cancel3 cancel4 cancel5 cancel6a cancel6d \ cleanup0 cleanup1 cleanup2 cleanup3 \ priority1 priority2 inherit1 \ @@ -91,17 +92,18 @@ BENCHTESTS = \ PASSES = $(TESTS:%=%.pass) BENCHRESULTS = $(BENCHTESTS:%=%.bench) -default: +help: @ $(ECHO) Run one of the following command lines: - @ $(ECHO) nmake clean GCE (to test using GCE dll with C++ (EH) applications) @ $(ECHO) nmake clean GC (to test using GC dll with C (no EH) applications) @ $(ECHO) nmake clean GCX (to test using GC dll with C++ (EH) applications) - @ $(ECHO) nmake clean GCE-bench (to benchtest using GNU C dll with C++ exception handling) + @ $(ECHO) nmake clean GCE (to test using GCE dll with C++ (EH) applications) @ $(ECHO) nmake clean GC-bench (to benchtest using GNU C dll with C cleanup code) + @ $(ECHO) nmake clean GCE-bench (to benchtest using GNU C dll with C++ exception handling) -auto: - @ $(MAKE) clean GCE +all: @ $(MAKE) clean GC + @ $(MAKE) clean GCX + @ $(MAKE) clean GCE GC: $(MAKE) GCX=GC XXCFLAGS="-x c -D__CLEANUP_C" all-pass @@ -212,6 +214,12 @@ rwlock4.pass: rwlock3.pass rwlock5.pass: rwlock4.pass rwlock6.pass: rwlock5.pass rwlock7.pass: rwlock6.pass +rwlock2_t.pass: rwlock2.pass +rwlock3_t.pass: rwlock2_t.pass +rwlock4_t.pass: rwlock3_t.pass +rwlock5_t.pass: rwlock4_t.pass +rwlock6_t.pass: rwlock5_t.pass +rwlock6_t2.pass: rwlock6_t.pass self1.pass: self2.pass: create1.pass spin1.pass: @@ -264,3 +272,4 @@ clean: - $(RM) *.exe - $(RM) *.pass - $(RM) *.bench + - $(RM) *.log diff --git a/tests/Makefile b/tests/Makefile index 9532b41..00e886f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -40,7 +40,7 @@ ECHO = @echo CPHDR = pthread.h semaphore.h sched.h -OPTIM = /O2 +OPTIM = /O2 /Ob0 # C++ Exceptions VCEFLAGS = /GX /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX @@ -89,6 +89,7 @@ PASSES= loadfree.pass \ condvar7.pass condvar8.pass condvar9.pass \ errno1.pass \ rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass rwlock5.pass rwlock6.pass rwlock7.pass \ + rwlock2_t.pass rwlock3_t.pass rwlock4_t.pass rwlock5_t.pass rwlock6_t.pass rwlock6_t2.pass \ context1.pass \ cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass \ cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \ @@ -101,22 +102,22 @@ PASSES= loadfree.pass \ BENCHRESULTS = \ benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench -all: +help: @ $(ECHO) Run one of the following command lines: - @ $(ECHO) nmake clean VCE (to test using the VCE dll with VC++ EH applications) - @ $(ECHO) nmake clean VSE (to test using VSE dll with VC (SEH) applications) @ $(ECHO) nmake clean VC (to test using VC dll with VC (no EH) applications) @ $(ECHO) nmake clean VCX (to test using VC dll with VC++ (EH) applications) - @ $(ECHO) nmake clean VCE-bench (to benchtest using VCE dll with C++ bench app) - @ $(ECHO) nmake clean VSE-bench (to benchtest using VSE dll with SEH bench app) + @ $(ECHO) nmake clean VCE (to test using the VCE dll with VC++ EH applications) + @ $(ECHO) nmake clean VSE (to test using VSE dll with VC (SEH) applications) @ $(ECHO) nmake clean VC-bench (to benchtest using VC dll with C bench app) @ $(ECHO) nmake clean VCX-bench (to benchtest using VC dll with C++ bench app) + @ $(ECHO) nmake clean VCE-bench (to benchtest using VCE dll with C++ bench app) + @ $(ECHO) nmake clean VSE-bench (to benchtest using VSE dll with SEH bench app) -auto: - @ nmake clean VCE - @ nmake clean VSE +all: @ nmake clean VC @ nmake clean VCX + @ nmake clean VCE + @ nmake clean VSE @ nmake clean VC-bench tests: $(CPLIB) $(CPDLL) $(CPHDR) $(PASSES) @@ -190,6 +191,7 @@ clean: - $(RM) *.exe - $(RM) *.pass - $(RM) *.bench + - $(RM) *.log benchtest1.bench: benchtest2.bench: @@ -277,6 +279,12 @@ rwlock4.pass: rwlock3.pass rwlock5.pass: rwlock4.pass rwlock6.pass: rwlock5.pass rwlock7.pass: rwlock6.pass +rwlock2_t.pass: rwlock2.pass +rwlock3_t.pass: rwlock2_t.pass +rwlock4_t.pass: rwlock3_t.pass +rwlock5_t.pass: rwlock4_t.pass +rwlock6_t.pass: rwlock5_t.pass +rwlock6_t2.pass: rwlock6_t.pass self1.pass: self2.pass: create1.pass spin1.pass: diff --git a/tests/exception3.c b/tests/exception3.c index 5faa3e1..3d9ea86 100644 --- a/tests/exception3.c +++ b/tests/exception3.c @@ -87,16 +87,16 @@ * Create NUMTHREADS threads in addition to the Main thread. */ enum { - NUMTHREADS = 20 + NUMTHREADS = 1 }; int caught = 0; -pthread_mutex_t caughtLock = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t caughtLock; void terminateFunction () { - pthread_mutex_lock(&caughtLock); + assert(pthread_mutex_lock(&caughtLock) == 0); caught++; #if 1 { @@ -105,8 +105,34 @@ terminateFunction () fclose(fp); } #endif - pthread_mutex_unlock(&caughtLock); - pthread_exit((void *) 0); + assert(pthread_mutex_unlock(&caughtLock) == 0); + +#if defined(__MINGW32__) + /* + * Seems to work. That is, threads exit and the process + * continues. Note: need to check correct POSIX behaviour. + * My guess is: this is because of the + * eh incompatibility between g++ and MSVC++. That is, + * an exception thrown in g++ code doesn't propogate + * through or to MSVC++ code, and vice versa. + * Applications should probably not depend on this. + */ + pthread_exit((void *) 0)); +#else + /* + * Notes from the MSVC++ manual: + * 1) A term_func() should call exit(), otherwise + * abort() will be called on return to the caller. + * abort() raises SIGABRT. The default signal handler + * for all signals terminates the calling program with + * exit code 3. + * 2) A term_func() must not throw an exception. Therefore + * term_func() should not call pthread_exit() if an + * an exception-using version of pthreads-win32 library + * is being used (i.e. either pthreadVCE or pthreadVSE). + */ + exit(0); +#endif } void * @@ -115,6 +141,7 @@ exceptionedThread(void * arg) int dummy = 0x1; (void) set_terminate(&terminateFunction); + throw dummy; return (void *) 0; @@ -126,9 +153,17 @@ main() int i; pthread_t mt; pthread_t et[NUMTHREADS]; + pthread_mutexattr_t ma; assert((mt = pthread_self()) != NULL); + printf("See the notes inside of exception3.c re term_funcs.\n"); + + assert(pthread_mutexattr_init(&ma) == 0); + assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0); + assert(pthread_mutex_init(&caughtLock, &ma) == 0); + assert(pthread_mutexattr_destroy(&ma) == 0); + for (i = 0; i < NUMTHREADS; i++) { assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0); diff --git a/tests/rwlock1.c b/tests/rwlock1.c index 72bce85..cebb485 100644 --- a/tests/rwlock1.c +++ b/tests/rwlock1.c @@ -35,12 +35,10 @@ * * -------------------------------------------------------------------------- * - * Create a simple rwlock object, lock it, and then unlock it again. + * Create a simple rwlock object and then destroy it. * * Depends on API functions: * pthread_rwlock_init() - * pthread_rwlock_lock() - * pthread_rwlock_unlock() * pthread_rwlock_destroy() */ diff --git a/tests/rwlock6.c b/tests/rwlock6.c index 78fd7b3..86bedff 100644 --- a/tests/rwlock6.c +++ b/tests/rwlock6.c @@ -35,9 +35,9 @@ * * -------------------------------------------------------------------------- * - * Check that writer locks have priority. + * Check writer and reader locking * - * Depends on API functions: + * Depends on API functions: * pthread_rwlock_rdlock() * pthread_rwlock_wrlock() * pthread_rwlock_unlock() @@ -51,23 +51,25 @@ static int bankAccount = 0; void * wrfunc(void * arg) { + int ba; + assert(pthread_rwlock_wrlock(&rwlock1) == 0); Sleep(2000); bankAccount += 10; + ba = bankAccount; assert(pthread_rwlock_unlock(&rwlock1) == 0); - return ((void *) bankAccount); + return ((void *) ba); } void * rdfunc(void * arg) { - int ba = 0; + int ba; assert(pthread_rwlock_rdlock(&rwlock1) == 0); ba = bankAccount; assert(pthread_rwlock_unlock(&rwlock1) == 0); - ba += 10; return ((void *) ba); } @@ -85,17 +87,17 @@ main() assert(pthread_create(&wrt1, NULL, wrfunc, NULL) == 0); Sleep(500); - assert(pthread_create(&wrt2, NULL, rdfunc, NULL) == 0); + assert(pthread_create(&rdt, NULL, rdfunc, NULL) == 0); Sleep(500); - assert(pthread_create(&rdt, NULL, wrfunc, NULL) == 0); + assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0); assert(pthread_join(wrt1, (void **) &wr1Result) == 0); - assert(pthread_join(wrt2, (void **) &wr2Result) == 0); assert(pthread_join(rdt, (void **) &rdResult) == 0); + assert(pthread_join(wrt2, (void **) &wr2Result) == 0); assert(wr1Result == 10); + assert(rdResult == 10); assert(wr2Result == 20); - assert(rdResult == 20); return 0; } -- cgit v1.2.3