Use pthread instead of kernel32.
-- v2: winemac: Use pthread_once for wine_vk_init. winemac: Use pthread for window data locking. winemac: Use pthread for synchronization in opengl.c.
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/display.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index c6b54c5fd82..4b6740b9274 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -53,14 +53,7 @@ static const WCHAR pixelencodingW[] = {'P','i','x','e','l','E','n','c','o','d',' static CFArrayRef modes; static BOOL modes_has_8bpp, modes_has_16bpp; static int default_mode_bpp; -static CRITICAL_SECTION modes_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &modes_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": modes_section") } -}; -static CRITICAL_SECTION modes_section = { &critsect_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t modes_mutex = PTHREAD_MUTEX_INITIALIZER;
static BOOL inited_original_display_mode;
@@ -515,8 +508,6 @@ static int get_default_bpp(void) { int ret;
- EnterCriticalSection(&modes_section); - if (!default_mode_bpp) { CGDisplayModeRef mode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay); @@ -532,8 +523,6 @@ static int get_default_bpp(void)
ret = default_mode_bpp;
- LeaveCriticalSection(&modes_section); - TRACE(" -> %d\n", ret); return ret; } @@ -895,7 +884,9 @@ LONG macdrv_ChangeDisplaySettingsEx(LPCWSTR devname, LPDEVMODEW devmode, return DISP_CHANGE_FAILED; }
+ pthread_mutex_lock(&modes_mutex); bpp = get_default_bpp(); + pthread_mutex_unlock(&modes_mutex); if ((devmode->dmFields & DM_BITSPERPEL) && devmode->dmBitsPerPel != bpp) TRACE("using default %d bpp instead of caller's request %d bpp\n", bpp, devmode->dmBitsPerPel);
@@ -1088,7 +1079,7 @@ BOOL macdrv_EnumDisplaySettingsEx(LPCWSTR devname, DWORD mode, DEVMODEW *devmode { DWORD count, i;
- EnterCriticalSection(&modes_section); + pthread_mutex_lock(&modes_mutex);
if (mode == 0 || !modes) { @@ -1168,7 +1159,7 @@ BOOL macdrv_EnumDisplaySettingsEx(LPCWSTR devname, DWORD mode, DEVMODEW *devmode } }
- LeaveCriticalSection(&modes_section); + pthread_mutex_unlock(&modes_mutex); }
if (!display_mode)
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- 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; }
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/keyboard.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index acd6fe6bf0a..79f208edfc8 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -437,14 +437,7 @@ struct layout BOOL enabled; /* is the input source enabled - ie displayed in the input source selector UI */ };
-static CRITICAL_SECTION layout_list_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &layout_list_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": layout_list_section") } -}; -static CRITICAL_SECTION layout_list_section = { &critsect_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t layout_list_mutex = PTHREAD_MUTEX_INITIALIZER;
int macdrv_layout_list_needs_update = TRUE;
@@ -486,7 +479,7 @@ static HKL get_hkl(CFStringRef lang, CFStringRef type) /****************************************************************** * get_layout_from_source * - * Must be called while holding the layout_list_section. + * Must be called while holding the layout_list_mutex. * Note, returned layout may not currently be enabled. */ static struct layout *get_layout_from_source(TISInputSourceRef input) @@ -507,7 +500,7 @@ static struct layout *get_layout_from_source(TISInputSourceRef input) /*********************************************************************** * update_layout_list * - * Must be called while holding the layout_list_section + * Must be called while holding the layout_list_mutex * * If an input source has been disabled (ie. removed from the UI) its * entry remains in the layout list but is marked as such and is not @@ -563,13 +556,13 @@ HKL macdrv_get_hkl_from_source(TISInputSourceRef input) struct layout *layout; HKL ret = 0;
- EnterCriticalSection(&layout_list_section); + pthread_mutex_lock(&layout_list_mutex);
update_layout_list(); layout = get_layout_from_source(input); if (layout) ret = layout->hkl;
- LeaveCriticalSection(&layout_list_section); + pthread_mutex_unlock(&layout_list_mutex);
return ret; } @@ -1172,7 +1165,7 @@ BOOL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) if (hkl == thread_data->active_keyboard_layout) return TRUE;
- EnterCriticalSection(&layout_list_section); + pthread_mutex_lock(&layout_list_mutex); update_layout_list();
LIST_FOR_EACH_ENTRY(layout, &layout_list, struct layout, entry) @@ -1195,7 +1188,7 @@ BOOL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) break; } } - LeaveCriticalSection(&layout_list_section); + pthread_mutex_unlock(&layout_list_mutex);
return ret; } @@ -1306,7 +1299,7 @@ UINT macdrv_GetKeyboardLayoutList(INT size, HKL *list)
TRACE("%d, %p\n", size, list);
- EnterCriticalSection(&layout_list_section); + pthread_mutex_lock(&layout_list_mutex);
update_layout_list();
@@ -1321,7 +1314,7 @@ UINT macdrv_GetKeyboardLayoutList(INT size, HKL *list) } count++; } - LeaveCriticalSection(&layout_list_section); + pthread_mutex_unlock(&layout_list_mutex);
TRACE("returning %d\n", count); return count;
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/mouse.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index 55bed52ae8e..d101d2513c8 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -32,15 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(cursor);
-static CRITICAL_SECTION cursor_cache_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &cursor_cache_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": cursor_cache_section") } -}; -static CRITICAL_SECTION cursor_cache_section = { &critsect_debug, -1, 0, 0, 0, 0 }; - +static pthread_mutex_t cursor_cache_mutex = PTHREAD_MUTEX_INITIALIZER; static CFMutableDictionaryRef cursor_cache;
@@ -647,10 +639,10 @@ void macdrv_DestroyCursorIcon(HCURSOR cursor) { TRACE("cursor %p\n", cursor);
- EnterCriticalSection(&cursor_cache_section); + pthread_mutex_lock(&cursor_cache_mutex); if (cursor_cache) CFDictionaryRemoveValue(cursor_cache, cursor); - LeaveCriticalSection(&cursor_cache_section); + pthread_mutex_unlock(&cursor_cache_mutex); }
@@ -731,7 +723,7 @@ void macdrv_SetCursor(HCURSOR cursor) { ICONINFOEXW info;
- EnterCriticalSection(&cursor_cache_section); + pthread_mutex_lock(&cursor_cache_mutex); if (cursor_cache) { CFTypeRef cached_cursor = CFDictionaryGetValue(cursor_cache, cursor); @@ -743,7 +735,7 @@ void macdrv_SetCursor(HCURSOR cursor) cursor_frames = CFRetain(cached_cursor); } } - LeaveCriticalSection(&cursor_cache_section); + pthread_mutex_unlock(&cursor_cache_mutex); if (cursor_name || cursor_frames) goto done;
@@ -790,13 +782,13 @@ void macdrv_SetCursor(HCURSOR cursor)
if (cursor_name || cursor_frames) { - EnterCriticalSection(&cursor_cache_section); + pthread_mutex_lock(&cursor_cache_mutex); if (!cursor_cache) cursor_cache = CFDictionaryCreateMutable(NULL, 0, NULL, &kCFTypeDictionaryValueCallBacks); CFDictionarySetValue(cursor_cache, cursor, cursor_name ? (CFTypeRef)cursor_name : (CFTypeRef)cursor_frames); - LeaveCriticalSection(&cursor_cache_section); + pthread_mutex_unlock(&cursor_cache_mutex); } else cursor_name = CFRetain(CFSTR("arrowCursor"));
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/opengl.c | 84 +++++++++++++++------------------------ 1 file changed, 31 insertions(+), 53 deletions(-)
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index d61d0a6ea66..f553b93da5a 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -77,15 +77,7 @@ struct wgl_context };
static struct list context_list = LIST_INIT(context_list); - -static CRITICAL_SECTION context_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &context_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": context_section") } -}; -static CRITICAL_SECTION context_section = { &critsect_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER;
struct wgl_pbuffer @@ -99,15 +91,7 @@ struct wgl_pbuffer };
static CFMutableDictionaryRef dc_pbuffers; - -static CRITICAL_SECTION dc_pbuffers_section; -static CRITICAL_SECTION_DEBUG dc_pbuffers_section_debug = -{ - 0, 0, &dc_pbuffers_section, - { &dc_pbuffers_section_debug.ProcessLocksList, &dc_pbuffers_section_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": dc_pbuffers_section") } -}; -static CRITICAL_SECTION dc_pbuffers_section = { &dc_pbuffers_section_debug, -1, 0, 0, 0, 0 }; +static pthread_mutex_t dc_pbuffers_mutex = PTHREAD_MUTEX_INITIALIZER;
static struct opengl_funcs opengl_funcs; @@ -1363,7 +1347,7 @@ static int get_dc_pixel_format(HDC hdc) { struct wgl_pbuffer *pbuffer;
- EnterCriticalSection(&dc_pbuffers_section); + pthread_mutex_lock(&dc_pbuffers_mutex); pbuffer = (struct wgl_pbuffer*)CFDictionaryGetValue(dc_pbuffers, hdc); if (pbuffer) format = pbuffer->format; @@ -1372,7 +1356,7 @@ static int get_dc_pixel_format(HDC hdc) WARN("no window or pbuffer for DC %p\n", hdc); format = 0; } - LeaveCriticalSection(&dc_pbuffers_section); + pthread_mutex_unlock(&dc_pbuffers_mutex); }
return format; @@ -1612,13 +1596,13 @@ static void mark_contexts_for_moved_view(macdrv_view view) { struct wgl_context *context;
- EnterCriticalSection(&context_section); + pthread_mutex_lock(&context_mutex); LIST_FOR_EACH_ENTRY(context, &context_list, struct wgl_context, entry) { if (context->draw_view == view) InterlockedExchange(&context->view_moved, TRUE); } - LeaveCriticalSection(&context_section); + pthread_mutex_unlock(&context_mutex); }
@@ -2885,9 +2869,9 @@ static struct wgl_context *macdrv_wglCreateContextAttribsARB(HDC hdc, return NULL; }
- EnterCriticalSection(&context_section); + pthread_mutex_lock(&context_mutex); list_add_tail(&context_list, &context->entry); - LeaveCriticalSection(&context_section); + pthread_mutex_unlock(&context_mutex);
return context; } @@ -3090,7 +3074,7 @@ static HDC macdrv_wglGetPbufferDCARB(struct wgl_pbuffer *pbuffer) hdc = CreateDCA("DISPLAY", NULL, NULL, NULL); if (!hdc) return 0;
- EnterCriticalSection(&dc_pbuffers_section); + pthread_mutex_lock(&dc_pbuffers_mutex); prev = (struct wgl_pbuffer*)CFDictionaryGetValue(dc_pbuffers, hdc); if (prev) { @@ -3098,7 +3082,7 @@ static HDC macdrv_wglGetPbufferDCARB(struct wgl_pbuffer *pbuffer) HeapFree(GetProcessHeap(), 0, prev); } CFDictionarySetValue(dc_pbuffers, hdc, pbuffer); - LeaveCriticalSection(&dc_pbuffers_section); + pthread_mutex_unlock(&dc_pbuffers_mutex);
TRACE("pbuffer %p -> hdc %p\n", pbuffer, hdc); return hdc; @@ -3538,14 +3522,14 @@ static BOOL macdrv_wglMakeContextCurrentARB(HDC draw_hdc, HDC read_hdc, struct w { struct wgl_pbuffer *pbuffer;
- EnterCriticalSection(&dc_pbuffers_section); + pthread_mutex_lock(&dc_pbuffers_mutex); pbuffer = (struct wgl_pbuffer*)CFDictionaryGetValue(dc_pbuffers, draw_hdc); if (pbuffer) { if (context->format != pbuffer->format) { WARN("mismatched pixel format draw_hdc %p %u context %p %u\n", draw_hdc, pbuffer->format, context, context->format); - LeaveCriticalSection(&dc_pbuffers_section); + pthread_mutex_unlock(&dc_pbuffers_mutex); SetLastError(ERROR_INVALID_PIXEL_FORMAT); return FALSE; } @@ -3556,7 +3540,7 @@ static BOOL macdrv_wglMakeContextCurrentARB(HDC draw_hdc, HDC read_hdc, struct w else { WARN("no window or pbuffer for DC\n"); - LeaveCriticalSection(&dc_pbuffers_section); + pthread_mutex_unlock(&dc_pbuffers_mutex); SetLastError(ERROR_INVALID_HANDLE); return FALSE; } @@ -3564,7 +3548,7 @@ static BOOL macdrv_wglMakeContextCurrentARB(HDC draw_hdc, HDC read_hdc, struct w context->draw_hwnd = NULL; context->draw_view = NULL; context->draw_pbuffer = pbuffer; - LeaveCriticalSection(&dc_pbuffers_section); + pthread_mutex_unlock(&dc_pbuffers_mutex); }
context->read_view = NULL; @@ -3586,9 +3570,9 @@ static BOOL macdrv_wglMakeContextCurrentARB(HDC draw_hdc, HDC read_hdc, struct w } else { - EnterCriticalSection(&dc_pbuffers_section); + pthread_mutex_lock(&dc_pbuffers_mutex); context->read_pbuffer = (struct wgl_pbuffer*)CFDictionaryGetValue(dc_pbuffers, read_hdc); - LeaveCriticalSection(&dc_pbuffers_section); + pthread_mutex_unlock(&dc_pbuffers_mutex); } }
@@ -3933,7 +3917,7 @@ static int macdrv_wglReleasePbufferDCARB(struct wgl_pbuffer *pbuffer, HDC hdc)
TRACE("pbuffer %p hdc %p\n", pbuffer, hdc);
- EnterCriticalSection(&dc_pbuffers_section); + pthread_mutex_lock(&dc_pbuffers_mutex);
prev = (struct wgl_pbuffer*)CFDictionaryGetValue(dc_pbuffers, hdc); if (prev) @@ -3946,7 +3930,7 @@ static int macdrv_wglReleasePbufferDCARB(struct wgl_pbuffer *pbuffer, HDC hdc) } else hdc = 0;
- LeaveCriticalSection(&dc_pbuffers_section); + pthread_mutex_unlock(&dc_pbuffers_mutex);
return hdc && DeleteDC(hdc); } @@ -4109,13 +4093,13 @@ static BOOL macdrv_wglSwapIntervalEXT(int interval) { struct wgl_context *ctx;
- EnterCriticalSection(&context_section); + pthread_mutex_lock(&context_mutex); LIST_FOR_EACH_ENTRY(ctx, &context_list, struct wgl_context, entry) { if (ctx != context && ctx->draw_hwnd == context->draw_hwnd) InterlockedExchange(&context->update_swap_interval, TRUE); } - LeaveCriticalSection(&context_section); + pthread_mutex_unlock(&context_mutex); }
return TRUE; @@ -4222,21 +4206,17 @@ static void load_extensions(void) }
-static BOOL CALLBACK init_opengl(INIT_ONCE *init_once, void *context, void **param) +static void init_opengl(void) { - static BOOL init_done = FALSE; unsigned int i;
- if (init_done) return (opengl_handle != NULL); - init_done = TRUE; - TRACE("()\n");
dc_pbuffers = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); if (!dc_pbuffers) { WARN("CFDictionaryCreateMutable failed\n"); - return FALSE; + return; }
opengl_handle = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY|RTLD_LOCAL|RTLD_NOLOAD); @@ -4244,7 +4224,7 @@ static BOOL CALLBACK init_opengl(INIT_ONCE *init_once, void *context, void **par { ERR("Failed to load OpenGL: %s\n", dlerror()); ERR("OpenGL support is disabled.\n"); - return FALSE; + return; }
for (i = 0; i < ARRAY_SIZE(opengl_func_names); i++) @@ -4285,12 +4265,11 @@ static BOOL CALLBACK init_opengl(INIT_ONCE *init_once, void *context, void **par if (!init_pixel_formats()) goto failed;
- return TRUE; + return;
failed: dlclose(opengl_handle); opengl_handle = NULL; - return FALSE; }
@@ -4419,9 +4398,9 @@ static BOOL WINAPI macdrv_wglDeleteContext(struct wgl_context *context) { TRACE("deleting context %p/%p/%p\n", context, context->context, context->cglcontext);
- EnterCriticalSection(&context_section); + pthread_mutex_lock(&context_mutex); list_remove(&context->entry); - LeaveCriticalSection(&context_section); + pthread_mutex_unlock(&context_mutex);
macdrv_dispose_opengl_context(context->context); return HeapFree(GetProcessHeap(), 0, context); @@ -4583,9 +4562,9 @@ static BOOL WINAPI macdrv_wglSwapBuffers(HDC hdc) { struct wgl_pbuffer *pbuffer;
- EnterCriticalSection(&dc_pbuffers_section); + pthread_mutex_lock(&dc_pbuffers_mutex); pbuffer = (struct wgl_pbuffer*)CFDictionaryGetValue(dc_pbuffers, hdc); - LeaveCriticalSection(&dc_pbuffers_section); + pthread_mutex_unlock(&dc_pbuffers_mutex);
if (!pbuffer) { @@ -4634,7 +4613,7 @@ static struct opengl_funcs opengl_funcs = */ struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) { - static INIT_ONCE opengl_init = INIT_ONCE_STATIC_INIT; + static pthread_once_t init_once = PTHREAD_ONCE_INIT;
if (version != WINE_WGL_DRIVER_VERSION) { @@ -4642,7 +4621,6 @@ struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) return NULL; }
- if (!InitOnceExecuteOnce(&opengl_init, init_opengl, NULL, NULL)) return (void *)-1; - - return &opengl_funcs; + pthread_once(&init_once, init_opengl); + return opengl_handle ? &opengl_funcs : (void *)-1; }
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/macdrv.h | 1 + dlls/winemac.drv/macdrv_main.c | 1 + dlls/winemac.drv/window.c | 32 +++++++++++++++++++------------- 3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 0a0c42aefd0..71a8d9f5bd2 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -205,6 +205,7 @@ struct macdrv_win_data
extern struct macdrv_win_data *get_win_data(HWND hwnd) DECLSPEC_HIDDEN; extern void release_win_data(struct macdrv_win_data *data) DECLSPEC_HIDDEN; +extern void init_win_context(void) DECLSPEC_HIDDEN; extern macdrv_window macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen) DECLSPEC_HIDDEN; extern RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp) DECLSPEC_HIDDEN; extern void activate_on_following_focus(void) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 5f61c9491b7..f7b530f50a7 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -459,6 +459,7 @@ static BOOL process_attach(void) if (status != noErr || !(attributes & sessionHasGraphicAccess)) return FALSE;
+ init_win_context(); setup_options(); load_strings(macdrv_module);
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index b00514d30bf..147c979ebde 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -38,15 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
-static CRITICAL_SECTION win_data_section; -static CRITICAL_SECTION_DEBUG critsect_debug = -{ - 0, 0, &win_data_section, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": win_data_section") } -}; -static CRITICAL_SECTION win_data_section = { &critsect_debug, -1, 0, 0, 0, 0 }; - +static pthread_mutex_t win_data_mutex; static CFMutableDictionaryRef win_datas;
static DWORD activate_on_focus_time; @@ -251,7 +243,7 @@ static struct macdrv_win_data *alloc_win_data(HWND hwnd) data->hwnd = hwnd; data->color_key = CLR_INVALID; data->swap_interval = 1; - EnterCriticalSection(&win_data_section); + pthread_mutex_lock(&win_data_mutex); if (!win_datas) win_datas = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); CFDictionarySetValue(win_datas, hwnd, data); @@ -270,10 +262,10 @@ struct macdrv_win_data *get_win_data(HWND hwnd) struct macdrv_win_data *data;
if (!hwnd) return NULL; - EnterCriticalSection(&win_data_section); + pthread_mutex_lock(&win_data_mutex); if (win_datas && (data = (struct macdrv_win_data*)CFDictionaryGetValue(win_datas, hwnd))) return data; - LeaveCriticalSection(&win_data_section); + pthread_mutex_unlock(&win_data_mutex); return NULL; }
@@ -285,7 +277,7 @@ struct macdrv_win_data *get_win_data(HWND hwnd) */ void release_win_data(struct macdrv_win_data *data) { - if (data) LeaveCriticalSection(&win_data_section); + if (data) pthread_mutex_unlock(&win_data_mutex); }
@@ -2910,3 +2902,17 @@ BOOL query_min_max_info(HWND hwnd) sync_window_min_max_info(hwnd); return TRUE; } + + +/*********************************************************************** + * init_win_context + */ +void init_win_context(void) +{ + pthread_mutexattr_t attr; + + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&win_data_mutex, &attr); + pthread_mutexattr_destroy(&attr); +}
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/vulkan.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/winemac.drv/vulkan.c b/dlls/winemac.drv/vulkan.c index 67273b8f20b..de99e4035bc 100644 --- a/dlls/winemac.drv/vulkan.c +++ b/dlls/winemac.drv/vulkan.c @@ -101,12 +101,12 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle)
static void *vulkan_handle;
-static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) +static void wine_vk_init(void) { if (!(vulkan_handle = dlopen(SONAME_LIBMOLTENVK, RTLD_NOW))) { ERR("Failed to load %s\n", SONAME_LIBMOLTENVK); - return TRUE; + return; }
#define LOAD_FUNCPTR(f) if ((p##f = dlsym(vulkan_handle, #f)) == NULL) goto fail; @@ -130,12 +130,11 @@ static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) LOAD_FUNCPTR(vkQueuePresentKHR) #undef LOAD_FUNCPTR
- return TRUE; + return;
fail: dlclose(vulkan_handle); vulkan_handle = NULL; - return TRUE; }
/* Helper function for converting between win32 and MoltenVK compatible VkInstanceCreateInfo. @@ -625,7 +624,7 @@ static void *macdrv_get_vk_instance_proc_addr(VkInstance instance, const char *n
static const struct vulkan_funcs *get_vulkan_driver(UINT version) { - static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; + static pthread_once_t init_once = PTHREAD_ONCE_INIT;
if (version != WINE_VULKAN_DRIVER_VERSION) { @@ -633,7 +632,7 @@ static const struct vulkan_funcs *get_vulkan_driver(UINT version) return NULL; }
- InitOnceExecuteOnce(&init_once, wine_vk_init, NULL, NULL); + pthread_once(&init_once, wine_vk_init); if (vulkan_handle) return &vulkan_funcs;
This merge request was approved by Huw Davies.