From 6237335fec273ac2b00c32609a8eef91c6ec7473 Mon Sep 17 00:00:00 2001 From: rpj Date: Sat, 23 Jan 1999 06:58:47 +0000 Subject: Fixing problems building with GNU compilers: Sun Jan 24 01:34:52 1999 Ross Johnson * semaphore.c (sem_wait): Remove second arg to pthreadCancelableWait() call. Fri Jan 22 14:31:59 1999 Ross Johnson * Makefile.in (CFLAGS): Remove -fhandle-exceptions. Not needed with egcs. Add -g for debugging. * create.c (pthread_create): Replace __stdcall with PT_STDCALL macro. This is a hack and must be fixed. * misc.c (CancelableWait): Remove redundant statement. * mutex.c (pthread_mutexattr_init): Cast calloc return value. * misc.c (CancelableWait): Add cast. (pthread_self): Add cast. * exit.c (pthread_exit): Add cast. * condvar.c (pthread_condattr_init): Cast calloc return value. * cleanup.c: Reorganise conditional compilation. * attr.c (pthread_attr_init): Remove unused 'result'. Cast malloc return value. * private.c (_pthread_callUserDestroyRoutines): Redo conditional compilation. * misc.c (CancelableWait): C++ version uses 'throw'. * cancel.c (pthread_testcancel): Ditto. * implement.h (class pthread_exception): Define for C++. * pthread.h: Fix C, C++, and Win32 SEH condition compilation mayhem around pthread_cleanup_* defines. C++ version now uses John Bossom's cleanup handlers. (pthread_attr_t): Make 'valid' unsigned. Define '_timeb' as 'timeb' for Ming32. Define PT_STDCALL as nothing for Mingw32. May be temporary. * cancel.c (pthread_testcancel): Cast return value. --- private.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 12 deletions(-) (limited to 'private.c') diff --git a/private.c b/private.c index dd32ccd..615271d 100644 --- a/private.c +++ b/private.c @@ -6,11 +6,11 @@ * the implementation and may be used throughout it. */ +#include + #include "pthread.h" #include "implement.h" -#include - /* * Code contributed by John E. Bossom . */ @@ -133,7 +133,7 @@ _pthread_threadStart (ThreadParms * threadParms) pthread_setspecific (_pthread_selfThreadKey, tid); -#ifdef _WIN32 +#ifdef _MSC_VER __try { @@ -152,7 +152,7 @@ _pthread_threadStart (ThreadParms * threadParms) status = -1; } -#else /* _WIN32 */ +#else /* _MSC_VER */ #ifdef __cplusplus @@ -164,19 +164,26 @@ _pthread_threadStart (ThreadParms * threadParms) (*start) (arg); status = 0; } + catch (Pthread_exception) + { + /* + * Thread was cancelled. + */ + status = -1; + } catch (...) - { - /* - * A system unexpected exception had occurred running the user's - * routine. We get control back within this block. - */ - status = -1; - } + { + /* + * A system unexpected exception had occurred running the user's + * routine. We get control back within this block. + */ + status = -1; + } #else /* __cplusplus */ #if defined(__CYGWIN__) || defined(__CYGWIN32__) -#warning Compile __FILE__ as C++ or thread cancellation will not work properly. +#warning File __FILE__, Line __LINE__: Cancelation not supported under C. #endif /* @@ -407,6 +414,8 @@ _pthread_callUserDestroyRoutines (pthread_t thread) if (value != NULL && k->destructor != NULL) { +#ifdef _MSC_VER + __try { /* @@ -422,6 +431,35 @@ _pthread_callUserDestroyRoutines (pthread_t thread) * We get control back within this block. */ } + +#else /* _MSC_VER */ +#ifdef __cplusplus + + try + { + /* + * Run the caller's cleanup routine. + */ + (*(k->destructor)) (value); + } + catch (...) + { + /* + * A system unexpected exception had occurred + * running the user's destructor. + * We get control back within this block. + */ + } + +#else /* __cplusplus */ + + /* + * Run the caller's cleanup routine. + */ + (*(k->destructor)) (value); + +#endif /* __cplusplus */ +#endif /* _MSC_VER */ } } -- cgit v1.2.3