summaryrefslogtreecommitdiff
path: root/private.c
diff options
context:
space:
mode:
authorrpj <rpj>1999-08-19 05:26:02 +0000
committerrpj <rpj>1999-08-19 05:26:02 +0000
commit5e87a0d9bdd4c2c2ab0e45a6379b4df0f1471ffa (patch)
treec8b65744680e1ca884470f2f345b929e2abc4ff8 /private.c
parentb1972e47c0359b818522f6aa822f3457be938060 (diff)
1999-08-19 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* private.c (_pthread_threadStart): Return exit status from the application thread startup routine. - Milan Gardian <mg@tatramed.sk> 1999-08-18 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * exit.c (pthread_exit): Put status into pthread_t->exitStatus - John Bossom <john.Bossom@cognos.com> * private.c (_pthread_threadStart): Set pthread->exitStatus on exit of try{} block. - John Bossom <john.Bossom@cognos.com> * sync.c (pthread_join): use pthread_exitStatus value if the thread exit doesn't return a value (for Mingw32 CRTDLL which uses endthread instead of _endthreadex). - John Bossom <john.Bossom@cognos.com> Tue Aug 17 20:17:58 CDT 1999 Mumit Khan <khan@xraylith.wisc.edu> * create.c (pthread_create): Add CRTDLL suppport. * exit.c (pthread_exit): Likewise. * private.c (_pthread_threadStart): Likewise. (_pthread_threadDestroy): Likewise. * sync.c (pthread_join): Likewise. * tests/join1.c (main): Warn about partial support for CRTDLL. Tue Aug 17 20:00:08 1999 Mumit Khan <khan@xraylith.wisc.edu> * Makefile.in (LD): Delete entry point. * acconfig.h (STDCALL): Delete unused macro. * configure.in: Remove test for STDCALL. * config.h.in: Regenerate. * errno.c (_errno): Fix self type. * pthread.h (PT_STDCALL): Move from here to * implement.h (PT_STDCALL): here. (_pthread_threadStart): Fix prototype. * private.c (_pthread_threadStart): Likewise. 1999-08-14 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * exit.c (pthread_exit): Don't call pthread_self() but get thread handle directly from TSD for efficiency.
Diffstat (limited to 'private.c')
-rw-r--r--private.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/private.c b/private.c
index 3c533f1..58bf148 100644
--- a/private.c
+++ b/private.c
@@ -159,7 +159,11 @@ ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei)
#endif /* _MSC_VER */
-void *
+#if ! defined (__MINGW32__) || defined (__MSVCRT__)
+unsigned PT_STDCALL
+#else
+void
+#endif
_pthread_threadStart (ThreadParms * threadParms)
{
pthread_t self;
@@ -178,6 +182,11 @@ _pthread_threadStart (ThreadParms * threadParms)
start = threadParms->start;
arg = threadParms->arg;
+#if defined (__MINGW32__) && ! defined (__MSVCRT__)
+ /* beginthread does not return the thread id, and so we do it here. */
+ self->thread = GetCurrentThreadId ();
+#endif
+
free (threadParms);
pthread_setspecific (_pthread_selfThreadKey, self);
@@ -189,8 +198,7 @@ _pthread_threadStart (ThreadParms * threadParms)
/*
* Run the caller's routine;
*/
- (*start) (arg);
- status = (void *) 0;
+ status = (*start) (arg);
}
__except (ExceptionFilter(GetExceptionInformation(), ei))
{
@@ -230,7 +238,7 @@ _pthread_threadStart (ThreadParms * threadParms)
* Run the caller's routine;
*/
(*start) (arg);
- status = (void *) 0;
+ status = self->exitStatus = (void *) 0;
}
catch (Pthread_exception_cancel)
{
@@ -244,7 +252,7 @@ _pthread_threadStart (ThreadParms * threadParms)
/*
* Thread was exited via pthread_exit().
*/
- status = self->exceptionInformation;
+ status = self->exitStatus;
}
catch (...)
{
@@ -270,12 +278,19 @@ _pthread_threadStart (ThreadParms * threadParms)
_pthread_callUserDestroyRoutines(self);
+#if ! defined (__MINGW32__) || defined (__MSVCRT__)
_endthreadex ((unsigned) status);
+#else
+ _endthread ();
+#endif
/*
* Never reached.
*/
- return (status);
+
+#if ! defined (__MINGW32__) || defined (__MSVCRT__)
+ return (unsigned) status;
+#endif
} /* _pthread_threadStart */
@@ -291,10 +306,13 @@ _pthread_threadDestroy (pthread_t thread)
CloseHandle (thread->cancelEvent);
}
+#if ! defined (__MINGW32__) || defined (__MSVCRT__)
+ /* See documentation for endthread vs endthreadex. */
if( thread->threadH != 0 )
{
CloseHandle( thread->threadH );
}
+#endif
free (thread);
}