From 199d96f3e3f6077235be8e0bf9482d2a46e108c2 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 7 Sep 2000 15:41:11 +0000 Subject: 2000-09-08 Ross Johnson * cancel.c (pthread_cancel): Must get "self" through calling pthread_self() which will ensure a POSIX thread struct is built for non-POSIX threads; return an error if this fails - Ollie Leahy (pthread_setcancelstate): Likewise. (pthread_setcanceltype): Likewise. * misc.c (ptw32_cancelable_wait): Likewise. * private.c (ptw32_tkAssocCreate): Remove unused #if 0 wrapped code. * pthread.h (ptw32_get_exception_services_code): Needed to be forward declared unconditionally. 2000-09-06 Ross Johnson * cancel.c (pthread_cancel): If called from the main thread "self" would be NULL; get "self" via pthread_self() instead of directly from TLS so that an implicit pthread object is created. * misc.c (pthread_equal): Strengthen test for NULLs. --- misc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 724bbc2..e79819d 100644 --- a/misc.c +++ b/misc.c @@ -229,7 +229,11 @@ pthread_equal (pthread_t t1, pthread_t t2) { int result; - result = ((t1 == t2) && (t1->thread == t2->thread)); + /* + * We also accept NULL == NULL - treating NULL as a thread + * for this special case, because there is no error that we can return. + */ + result = ( ( t1 == t2 ) && ( t1 == NULL || ( t1->thread == t2->thread ) ) ); return (result); @@ -260,8 +264,7 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) handles[0] = waitHandle; - if ((self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey)) - != NULL) + if ((self = pthread_self()) != NULL) { /* * Get cancelEvent handle -- cgit v1.2.3