From 11eb4dfd2d42417327fc205c649ea32ee623cf92 Mon Sep 17 00:00:00 2001 From: rpj Date: Fri, 18 Aug 2000 08:02:29 +0000 Subject: 2000-08-18 Ross Johnson * Several: Fix typos from scripted edit session yesterday. * nonportable.c (pthread_mutexattr_setforcecs_np): Moved this function from mutex.c. (pthread_getw32threadhandle_np): New function to return the win32 thread handle that the POSIX thread is using. * mutex.c (pthread_mutexattr_setforcecs_np): Moved to new file "nonportable.c". * pthread.h (PTW32_BUILD): Only redefine __except and catch compiler keywords if we aren't building the library (ie. PTW32_BUILD is not defined) - this is safer than defining and then undefining if not building the library. * implement.h: Remove __except and catch undefines. * Makefile (CFLAGS): Define PTW32_BUILD. * GNUmakefile (CFLAGS): Define PTW32_BUILD. * All appropriate: Change Pthread_exception* to ptw32_exception* to be consistent with internal identifier naming. * private.c (ptw32_throw): New function to provide a generic exception throw for all internal exceptions and EH schemes. (ptw32_threadStart): pthread_exit() value is now returned via the thread structure exitStatus element. * exit.c (pthread_exit): pthread_exit() value is now returned via the thread structure exitStatus element. * cancel.c (ptw32_cancel_self): Now uses ptw32_throw. (pthread_setcancelstate): Ditto. (pthread_setcanceltype): Ditto. (pthread_testcancel): Ditto. (pthread_cancel): Ditto. * misc.c (CancelableWait): Ditto. * exit.c (pthread_exit): Ditto. * All applicable: Change PTW32_ prefix to PTW32_ prefix to remove leading underscores from private library identifiers. --- cancel.c | 58 ++++++---------------------------------------------------- 1 file changed, 6 insertions(+), 52 deletions(-) (limited to 'cancel.c') diff --git a/cancel.c b/cancel.c index 3273299..9e5b789 100644 --- a/cancel.c +++ b/cancel.c @@ -30,29 +30,7 @@ static void ptw32_cancel_self(void) { -#if defined(_MSC_VER) && !defined(__cplusplus) - - DWORD exceptionInformation[3]; - - exceptionInformation[0] = (DWORD) (_PTHREAD_EPS_CANCEL); - exceptionInformation[1] = (DWORD) (0); - exceptionInformation[2] = (DWORD) (0); - - RaiseException ( - EXCEPTION_PTHREAD_SERVICES, - 0, - 3, - exceptionInformation); - -#else /* _MSC_VER && ! __cplusplus */ - -# ifdef __cplusplus - - throw Pthread_exception_cancel(); - -# endif /* __cplusplus */ - -#endif /* _MSC_VER && ! __cplusplus */ + ptw32_throw(PTW32_EPS_CANCEL); /* Never reached */ } @@ -62,7 +40,7 @@ ptw32_cancel_self(void) * ptw32_cancel_thread implements asynchronous cancellation. */ static void -ptw32_ancel_thread(pthread_t thread) +ptw32_cancel_thread(pthread_t thread) { HANDLE threadH = thread->threadH; @@ -158,7 +136,7 @@ pthread_setcancelstate (int state, int *oldstate) { ResetEvent(self->cancelEvent); (void) pthread_mutex_unlock(&self->cancelLock); - ptw32_cancel_self(); + ptw32_throw(PTW32_EPS_CANCEL); /* Never reached */ } @@ -242,7 +220,7 @@ pthread_setcanceltype (int type, int *oldtype) { ResetEvent(self->cancelEvent); (void) pthread_mutex_unlock(&self->cancelLock); - ptw32_cancel_self(); + ptw32_throw(PTW32_EPS_CANCEL); /* Never reached */ } @@ -293,31 +271,7 @@ pthread_testcancel (void) /* * Canceling! */ - -#if defined(_MSC_VER) && !defined(__cplusplus) - - DWORD exceptionInformation[3]; - - exceptionInformation[0] = (DWORD) (_PTHREAD_EPS_CANCEL); - exceptionInformation[1] = (DWORD) (0); - exceptionInformation[2] = (DWORD) (0); - - RaiseException ( - EXCEPTION_PTHREAD_SERVICES, - 0, - 3, - exceptionInformation); - -#else /* _MSC_VER && ! __cplusplus */ - -#ifdef __cplusplus - - throw Pthread_exception_cancel(); - -#endif /* __cplusplus */ - -#endif /* _MSC_VER && ! __cplusplus */ - + ptw32_throw(PTW32_EPS_CANCEL); } } /* pthread_testcancel */ @@ -384,7 +338,7 @@ pthread_cancel (pthread_t thread) if (cancel_self) { (void) pthread_mutex_unlock(&self->cancelLock); - ptw32_cancel_self(); + ptw32_throw(PTW32_EPS_CANCEL); /* Never reached */ } -- cgit v1.2.3