From ec8290acdaea21b16d98f1ef5d4ae8a28ab2109a Mon Sep 17 00:00:00 2001 From: rpj Date: Wed, 3 Nov 2004 01:08:41 +0000 Subject: Mutex, semaphore, thread ID, test suite changes - see ChangeLogs --- pthread_win32_attach_detach_np.c | 46 +++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'pthread_win32_attach_detach_np.c') diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c index 4aedccc..6fd7f27 100644 --- a/pthread_win32_attach_detach_np.c +++ b/pthread_win32_attach_detach_np.c @@ -92,8 +92,6 @@ pthread_win32_process_attach_np () #endif -#ifndef TEST_ICE - /* * Load KERNEL32 and try to get address of InterlockedCompareExchange */ @@ -136,12 +134,6 @@ pthread_win32_process_attach_np () ptw32_features |= PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE; } -#else /* TEST_ICE */ - - ptw32_interlocked_compare_exchange = ptw32_InterlockedCompareExchange; - -#endif /* TEST_ICE */ - /* * Load QUSEREX.DLL and try to get address of QueueUserAPCEx */ @@ -204,16 +196,19 @@ pthread_win32_process_detach_np () { if (ptw32_processInitialized) { - pthread_t self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey); + ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - /* - * Detached threads have their resources automatically - * cleaned up upon exit (others must be 'joined'). - */ - if (self != NULL && self->detachState == PTHREAD_CREATE_DETACHED) + if (sp != NULL) { - ptw32_threadDestroy (self); - TlsSetValue (ptw32_selfThreadKey->key, NULL); + /* + * Detached threads have their resources automatically + * cleaned up upon exit (others must be 'joined'). + */ + if (sp->detachState == PTHREAD_CREATE_DETACHED) + { + ptw32_threadDestroy (sp->ptHandle); + TlsSetValue (ptw32_selfThreadKey->key, NULL); + } } /* @@ -265,16 +260,19 @@ pthread_win32_thread_detach_np () * Don't use pthread_self() - to avoid creating an implicit POSIX thread handle * unnecessarily. */ - pthread_t self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey); + ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - /* - * Detached threads have their resources automatically - * cleaned up upon exit (others must be 'joined'). - */ - if (self != NULL && self->detachState == PTHREAD_CREATE_DETACHED) + if (sp != NULL) { - ptw32_threadDestroy (self); - TlsSetValue (ptw32_selfThreadKey->key, NULL); + /* + * Detached threads have their resources automatically + * cleaned up upon exit (others must be 'joined'). + */ + if (sp->detachState == PTHREAD_CREATE_DETACHED) + { + ptw32_threadDestroy (sp->ptHandle); + TlsSetValue (ptw32_selfThreadKey->key, NULL); + } } } -- cgit v1.2.3