Jacek Caban : winemac: Use pthread for GDI device locking.

Alexandre Julliard julliard at winehq.org
Wed May 18 15:38:30 CDT 2022


Module: wine
Branch: master
Commit: e24c2fa33f3491a2fd0c98aec7bf2152f8240e19
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e24c2fa33f3491a2fd0c98aec7bf2152f8240e19

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue May 17 01:09:18 2022 +0200

winemac: Use pthread for GDI device locking.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winemac.drv/gdi.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c
index 264781c6ac1..673dca40270 100644
--- a/dlls/winemac.drv/gdi.c
+++ b/dlls/winemac.drv/gdi.c
@@ -47,15 +47,7 @@ static int device_data_valid;   /* do the above variables have up-to-date values
 
 int retina_on = FALSE;
 
-static CRITICAL_SECTION device_data_section;
-static CRITICAL_SECTION_DEBUG critsect_debug =
-{
-    0, 0, &device_data_section,
-    { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
-      0, 0, { (DWORD_PTR)(__FILE__ ": device_data_section") }
-};
-static CRITICAL_SECTION device_data_section = { &critsect_debug, -1, 0, 0, 0, 0 };
-
+static pthread_mutex_t device_data_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static const struct user_driver_funcs macdrv_funcs;
 
@@ -90,7 +82,7 @@ CGRect macdrv_get_desktop_rect(void)
 {
     CGRect ret;
 
-    EnterCriticalSection(&device_data_section);
+    pthread_mutex_lock(&device_data_mutex);
 
     if (!device_data_valid)
     {
@@ -99,7 +91,7 @@ CGRect macdrv_get_desktop_rect(void)
     }
     ret = desktop_rect;
 
-    LeaveCriticalSection(&device_data_section);
+    pthread_mutex_unlock(&device_data_mutex);
 
     TRACE("%s\n", wine_dbgstr_cgrect(ret));
 
@@ -151,9 +143,9 @@ static void device_init(void)
 
 void macdrv_reset_device_metrics(void)
 {
-    EnterCriticalSection(&device_data_section);
+    pthread_mutex_lock(&device_data_mutex);
     device_data_valid = FALSE;
-    LeaveCriticalSection(&device_data_section);
+    pthread_mutex_unlock(&device_data_mutex);
 }
 
 
@@ -161,9 +153,9 @@ static MACDRV_PDEVICE *create_mac_physdev(void)
 {
     MACDRV_PDEVICE *physDev;
 
-    EnterCriticalSection(&device_data_section);
+    pthread_mutex_lock(&device_data_mutex);
     if (!device_data_valid) device_init();
-    LeaveCriticalSection(&device_data_section);
+    pthread_mutex_unlock(&device_data_mutex);
 
     if (!(physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev)))) return NULL;
 
@@ -227,7 +219,7 @@ static INT CDECL macdrv_GetDeviceCaps(PHYSDEV dev, INT cap)
 {
     INT ret;
 
-    EnterCriticalSection(&device_data_section);
+    pthread_mutex_lock(&device_data_mutex);
 
     if (!device_data_valid) device_init();
 
@@ -245,7 +237,7 @@ static INT CDECL macdrv_GetDeviceCaps(PHYSDEV dev, INT cap)
     case HORZRES:
     case VERTRES:
     default:
-        LeaveCriticalSection(&device_data_section);
+        pthread_mutex_unlock(&device_data_mutex);
         dev = GET_NEXT_PHYSDEV( dev, pGetDeviceCaps );
         ret = dev->funcs->pGetDeviceCaps( dev, cap );
         if ((cap == HORZRES || cap == VERTRES) && retina_on)
@@ -255,7 +247,7 @@ static INT CDECL macdrv_GetDeviceCaps(PHYSDEV dev, INT cap)
 
     TRACE("cap %d -> %d\n", cap, ret);
 
-    LeaveCriticalSection(&device_data_section);
+    pthread_mutex_unlock(&device_data_mutex);
     return ret;
 }
 




More information about the wine-cvs mailing list