diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | dll.c | 22 | ||||
-rw-r--r-- | mutex.c | 6 |
3 files changed, 32 insertions, 8 deletions
@@ -1,11 +1,19 @@ -Fri Feb 19 16:2s1703:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> +Sat Feb 20 16:03:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> + + * 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. + +Fri Feb 19 16:03:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * sync.c (pthread_join): Fix pthread_equal() test. * mutex.c (pthread_mutex_trylock): Check mutex != NULL before using it. -Thu Feb 18 16:2s1703:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> +Thu Feb 18 16:17:30 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * misc.c (pthread_equal): Fix inverted result. @@ -16,6 +16,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 */ static HINSTANCE _pthread_h_kernel32; @@ -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: @@ -513,12 +513,6 @@ pthread_mutex_trylock(pthread_mutex_t *mutex) return EINVAL; } - if (mutex->mutex == 0 && _pthread_try_enter_critical_section == NULL) - { - /* TryEnterCriticalSection does not exist in the OS; return ENOSYS. */ - return ENOSYS; - } - /* * We do a quick check to see if we need to do more work * to initialise a static mutex. We check 'staticinit' |