summaryrefslogtreecommitdiff
path: root/dll.c
diff options
context:
space:
mode:
authorrpj <rpj>1999-02-20 02:56:35 +0000
committerrpj <rpj>1999-02-20 02:56:35 +0000
commit4a30695c72d49a8d4a7c9dd7892456170eaa39d6 (patch)
treeb89c57145b21edc2daa7c031e18e3e2acc4391cf /dll.c
parent2f59893abc1ef66e851c4bba56c4b421710d4183 (diff)
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.
Diffstat (limited to 'dll.c')
-rw-r--r--dll.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/dll.c b/dll.c
index b440500..25d89c3 100644
--- a/dll.c
+++ b/dll.c
@@ -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: