From 4a30695c72d49a8d4a7c9dd7892456170eaa39d6 Mon Sep 17 00:00:00 2001 From: rpj Date: Sat, 20 Feb 1999 02:56:35 +0000 Subject: Sat Feb 20 16:03:30 1999 Ross Johnson * dll.c (DLLMain): Expand TryEnterCriticalSection support test. * mutex.c (pthread_mutex_trylock): The check for _pthread_try_enter_critical_section == NULL should have been removed long ago. --- dll.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'dll.c') diff --git a/dll.c b/dll.c index b440500..25d89c3 100644 --- a/dll.c +++ b/dll.c @@ -15,6 +15,11 @@ */ BOOL (WINAPI *_pthread_try_enter_critical_section)(LPCRITICAL_SECTION) = NULL; +/* + * We use this to double-check that TryEnterCriticalSection works. + */ +CRITICAL_SECTION cs; + /* * Handle to kernel32.dll */ @@ -67,6 +72,23 @@ DllMain ( (BOOL (PT_STDCALL *)(LPCRITICAL_SECTION)) GetProcAddress(_pthread_h_kernel32, (LPCSTR) "TryEnterCriticalSection"); + + if (_pthread_try_enter_critical_section != NULL) + { + InitializeCriticalSection(&cs); + if ((*_pthread_try_enter_critical_section)(&cs)) + { + LeaveCriticalSection(&cs); + } + else + { + /* + * Not really supported (Win98?). + */ + _pthread_try_enter_critical_section = NULL; + } + DeleteCriticalSection(&cs); + } break; case DLL_THREAD_ATTACH: -- cgit v1.2.3