Jacek Caban : winex11.drv: Use InitOnceExecuteOnce in has_opengl.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Apr 14 11:48:51 CDT 2016
Module: wine
Branch: master
Commit: ef6890835d4148dfce9cc7500f3848ba6306ec22
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ef6890835d4148dfce9cc7500f3848ba6306ec22
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Apr 13 16:31:07 2016 +0200
winex11.drv: Use InitOnceExecuteOnce in has_opengl.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winex11.drv/opengl.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index ab29ce4..0f7534e 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -573,18 +573,14 @@ done:
return ret;
}
-static BOOL has_opengl(void)
-{
- static BOOL init_done = FALSE;
- static void *opengl_handle;
+static void *opengl_handle;
+static BOOL WINAPI init_opengl( INIT_ONCE *once, void *param, void **context )
+{
char buffer[200];
int error_base, event_base;
unsigned int i;
- if (init_done) return (opengl_handle != NULL);
- init_done = TRUE;
-
/* No need to load any other libraries as according to the ABI, libGL should be self-sufficient
and include all dependencies */
opengl_handle = wine_dlopen(SONAME_LIBGL, RTLD_NOW|RTLD_GLOBAL, buffer, sizeof(buffer));
@@ -592,7 +588,7 @@ static BOOL has_opengl(void)
{
ERR( "Failed to load libGL: %s\n", buffer );
ERR( "OpenGL support is disabled.\n");
- return FALSE;
+ return TRUE;
}
for (i = 0; i < sizeof(opengl_func_names)/sizeof(opengl_func_names[0]); i++)
@@ -757,7 +753,14 @@ static BOOL has_opengl(void)
failed:
wine_dlclose(opengl_handle, NULL, 0);
opengl_handle = NULL;
- return FALSE;
+ return TRUE;
+}
+
+static BOOL has_opengl(void)
+{
+ static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
+ InitOnceExecuteOnce(&init_once, init_opengl, NULL, NULL);
+ return opengl_handle != NULL;
}
static const char *debugstr_fbconfig( GLXFBConfig fbconfig )
More information about the wine-cvs
mailing list