From 8fd64d5e3783607ce31e89c7f4db78528dbe17fa Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Tue, 3 Jun 2014 18:02:36 +0200 Subject: C99 compliant function pointer casting --- test/Makefile | 4 +++- wglarb.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/test/Makefile b/test/Makefile index 946272e..52128ef 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,5 +1,5 @@ TARGET64=x86_64-w64-mingw32 -TARGET32=mingw32 +TARGET32=i686-w64-mingw32 CC64=-$(TARGET64)-gcc CC32=-$(TARGET32)-gcc CFLAGS=-static-libgcc -static-libstdc++ -I.. @@ -25,3 +25,5 @@ layered64_rc.o: layered.rc manifest.xml layered32_rc.o: layered.rc manifest.xml $(WINDRES32) --input layered.rc --output layered32_rc.o +clean: + rm *.o *.exe diff --git a/wglarb.c b/wglarb.c index 7ccc320..3c76608 100644 --- a/wglarb.c +++ b/wglarb.c @@ -33,7 +33,9 @@ static DWORD wglarb_intermediary_lock(void) if( !wglarb_intermediary_mutex ) { /* Between testing for the validity of the mutex handle, * creating a new mutex handle and using the interlocked - * exchange there is a race. */ + * exchange there is a race... */ + + /* //// START \\\\ */ HANDLE const new_mutex = CreateMutex(NULL, TRUE, NULL); @@ -44,6 +46,8 @@ static DWORD wglarb_intermediary_lock(void) new_mutex, NULL ); + /* //// FINISH \\\\ */ + if( dst_mutex ) { /* In this case we lost the race and another thread * beat this thread in creating a mutex object. @@ -85,7 +89,6 @@ static BOOL wglarb_intermediary_create_Wnd(void) wc.lpszClassName = WGLARB_INTERMEDIARY_CLASS; RegisterClass(&wc); - /* Create a temporaray context to get address of wgl extensions. */ wglarb_intermediary_hWnd = CreateWindowEx( WGLARB_INTERMEDIARY_EXSTYLE, @@ -95,7 +98,7 @@ static BOOL wglarb_intermediary_create_Wnd(void) 0,0,0,0, NULL,NULL, hInstance, - NULL); + NULL ); if( !wglarb_intermediary_hWnd ) { FALSE; @@ -160,7 +163,7 @@ static BOOL wglarb_intermediary_makecurrent(HDC *hOrigDC, HGLRC *hOrigRC) *hOrigRC = wglGetCurrentContext(); if( !wglarb_intermediary_hRC - && !wglarb_intermediary_create_RC() ) { + && !wglarb_intermediary_create_RC() ) { return FALSE; } @@ -183,9 +186,8 @@ HGLRC WINAPI wglarb_CreateContextAttribsARB( return NULL; } - PFNWGLCREATECONTEXTATTRIBSARBPROC impl = - (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress( - "wglCreateContextAttribsARB"); + PFNWGLCREATECONTEXTATTRIBSARBPROC impl; + *(PROC*)(&impl) = wglGetProcAddress("wglCreateContextAttribsARB"); HGLRC ret = NULL; if( impl ) { @@ -216,9 +218,8 @@ BOOL WINAPI wglarb_ChoosePixelFormatARB( return FALSE; } - PFNWGLCHOOSEPIXELFORMATARBPROC impl = - (PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress( - "wglChoosePixelFormatARB"); + PFNWGLCHOOSEPIXELFORMATARBPROC impl; + *(PROC*)(&impl) = wglGetProcAddress("wglChoosePixelFormatARB"); BOOL ret = FALSE; if( impl ) { -- cgit v1.2.3 From de56626b62f4d6a9beee0589a45bc55bfcf9973e Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Tue, 3 Jun 2014 18:22:01 +0200 Subject: C99 compliant function pointer casting --- test/layered.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/layered.c b/test/layered.c index 80f25cf..f28c677 100644 --- a/test/layered.c +++ b/test/layered.c @@ -304,12 +304,10 @@ int main(int argc, char *argv[]) if( 6 <= os_vinfo.dwMajorVersion ) { hDwmAPI_DLL = LoadLibrary("dwmapi.dll"); if( hDwmAPI_DLL ) { - impl_DwmEnableBlurBehindWindow = - (procp_DwmEnableBlurBehindWindow) + *(PROC*)(&impl_DwmEnableBlurBehindWindow) = GetProcAddress(hDwmAPI_DLL, "DwmEnableBlurBehindWindow"); - impl_DwmExtendFrameIntoClientArea = - (procp_DwmExtendFrameIntoClientArea) + *(PROC*)(&impl_DwmExtendFrameIntoClientArea) = GetProcAddress(hDwmAPI_DLL, "DwmExtendFrameIntoClientArea"); } } -- cgit v1.2.3