[PATCH 4/5] Add thread data management to the quartzdrv.
Pierre d'Herbemont
pdherbemont at free.fr
Fri Oct 20 14:47:24 CDT 2006
---
dlls/winequartz.drv/quartzdrv.h | 48
++++++++++++++++++++++++++++++++++
dlls/winequartz.drv/quartzdrv_main.c | 40 ++++++++++++++++++++++++++--
2 files changed, 85 insertions(+), 3 deletions(-)
-------------- next part --------------
diff --git a/dlls/winequartz.drv/quartzdrv.h b/dlls/winequartz.drv/quartzdrv.h
new file mode 100644
index 0000000..4f97bb1
--- /dev/null
+++ b/dlls/winequartz.drv/quartzdrv.h
@@ -0,0 +1,48 @@
+/*
+ * Quartz driver definitions
+ *
+ * Copyright 1996 Alexandre Julliard
+ * Copyright 1999 Patrik Stridvall
+ * Copyright 2006 Emmanuel Maillard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_QUARTZDRV_H
+#define __WINE_QUARTZDRV_H
+
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
+
+/* ---------------------------------------------------------------------
+ per-Thread data management
+*/
+struct quartzdrv_thread_data
+{
+ int process_event_count; /* recursion count for event processing */
+};
+
+extern struct quartzdrv_thread_data *quartzdrv_init_thread_data(void);
+extern DWORD thread_data_tls_index;
+
+inline static struct quartzdrv_thread_data *quartzdrv_thread_data(void)
+{
+ struct quartzdrv_thread_data *data = TlsGetValue( thread_data_tls_index );
+ if (!data) data = quartzdrv_init_thread_data();
+ return data;
+}
+
+#endif /* __WINE_QUARTZDRV_H */
diff --git a/dlls/winequartz.drv/quartzdrv_main.c b/dlls/winequartz.drv/quartzdrv_main.c
index 8d65c5a..2b6d2b0 100644
--- a/dlls/winequartz.drv/quartzdrv_main.c
+++ b/dlls/winequartz.drv/quartzdrv_main.c
@@ -28,8 +28,42 @@ #include "winreg.h"
#include "wine/debug.h"
+#include "quartzdrv.h"
+
WINE_DEFAULT_DEBUG_CHANNEL(quartzdrv);
+DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
+
+static CRITICAL_SECTION QDRV_CritSection;
+static CRITICAL_SECTION_DEBUG critsect_debug =
+{
+ 0, 0, &QDRV_CritSection,
+ { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": QDRV_CritSection") }
+};
+static CRITICAL_SECTION QDRV_CritSection = { &critsect_debug, -1, 0, 0, 0, 0 };
+
+
+/***********************************************************************
+ * QDRV thread initialisation routine
+ */
+struct quartzdrv_thread_data *quartzdrv_init_thread_data(void)
+{
+ struct quartzdrv_thread_data *data;
+
+ if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) )))
+ {
+ ERR( "could not create data\n" );
+ ExitProcess(1);
+ }
+
+ data->process_event_count = 0;
+
+ TlsSetValue( thread_data_tls_index, data );
+
+ return data;
+}
+
/***********************************************************************
* process initialisation routine
*/
@@ -67,13 +101,13 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DW
switch(reason)
{
case DLL_PROCESS_ATTACH:
- /* Do attach */
+ ret = process_attach();
break;
case DLL_THREAD_DETACH:
- /* do thread detach */
+ thread_detach();
break;
case DLL_PROCESS_DETACH:
- /* do detach */
+ process_detach();
break;
}
return ret;
More information about the wine-patches
mailing list