From: Pedro Alves Date: Tue, 17 Nov 2015 15:17:44 +0000 (+0000) Subject: [C++/mingw] windows-nat.c casts X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=43499ea30db2a866412c86952c7e1d7b158d806f;p=binutils-gdb.git [C++/mingw] windows-nat.c casts Fixes a set of errors like: ../../src/gdb/windows-nat.c: In function 'void _initialize_loadable()': ../../src/gdb/windows-nat.c:2778:30: error: invalid conversion from 'void*' to 'BOOL (*)(DWORD) {aka int (*)(long unsigned int)}' [-fpermissive] DebugActiveProcessStop = (void *) ^ gdb/ChangeLog: 2015-11-17 Pedro Alves * windows-nat.c (AdjustTokenPrivileges_ftype) (DebugActiveProcessStop_ftype, DebugBreakProcess_ftype) (DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype) (GetCurrentConsoleFont_ftype, GetModuleInformation_ftype) (LookupPrivilegeValueA_ftype, OpenProcessToken_ftype) (GetConsoleFontSize_ftype): New typedefs. (AdjustTokenPrivileges, DebugActiveProcessStop) (DebugBreakProcess, DebugSetProcessKillOnExit, EnumProcessModules) (GetConsoleFontSize, GetCurrentConsoleFont, GetModuleInformation) (LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize): Adjust. (GetModuleFileNameEx_ftype): New typedef. (GetModuleFileNameEx): Use it. (_initialize_loadable): Define GPA macro and use it. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a3bc676af76..8de7c2585f8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2015-11-17 Pedro Alves + + * windows-nat.c (AdjustTokenPrivileges_ftype) + (DebugActiveProcessStop_ftype, DebugBreakProcess_ftype) + (DebugSetProcessKillOnExit_ftype, EnumProcessModules_ftype) + (GetCurrentConsoleFont_ftype, GetModuleInformation_ftype) + (LookupPrivilegeValueA_ftype, OpenProcessToken_ftype) + (GetConsoleFontSize_ftype): New typedefs. + (AdjustTokenPrivileges, DebugActiveProcessStop) + (DebugBreakProcess, DebugSetProcessKillOnExit, EnumProcessModules) + (GetConsoleFontSize, GetCurrentConsoleFont, GetModuleInformation) + (LookupPrivilegeValueA, OpenProcessToken, GetConsoleFontSize): + Adjust. + (GetModuleFileNameEx_ftype): New typedef. + (GetModuleFileNameEx): Use it. + (_initialize_loadable): Define GPA macro and use it. + 2015-11-17 Pedro Alves * gdb-dlfcn.c (gdb_dlsym, gdb_dlclose) [__MINGW32__]: Add casts to diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 8dfe21127ea..2e1249300f3 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -77,20 +77,41 @@ #define GetConsoleFontSize dyn_GetConsoleFontSize #define GetCurrentConsoleFont dyn_GetCurrentConsoleFont -static BOOL WINAPI (*AdjustTokenPrivileges)(HANDLE, BOOL, PTOKEN_PRIVILEGES, - DWORD, PTOKEN_PRIVILEGES, PDWORD); -static BOOL WINAPI (*DebugActiveProcessStop) (DWORD); -static BOOL WINAPI (*DebugBreakProcess) (HANDLE); -static BOOL WINAPI (*DebugSetProcessKillOnExit) (BOOL); -static BOOL WINAPI (*EnumProcessModules) (HANDLE, HMODULE *, DWORD, - LPDWORD); -static BOOL WINAPI (*GetModuleInformation) (HANDLE, HMODULE, LPMODULEINFO, - DWORD); -static BOOL WINAPI (*LookupPrivilegeValueA)(LPCSTR, LPCSTR, PLUID); -static BOOL WINAPI (*OpenProcessToken)(HANDLE, DWORD, PHANDLE); -static BOOL WINAPI (*GetCurrentConsoleFont) (HANDLE, BOOL, - CONSOLE_FONT_INFO *); -static COORD WINAPI (*GetConsoleFontSize) (HANDLE, DWORD); +typedef BOOL WINAPI (AdjustTokenPrivileges_ftype) (HANDLE, BOOL, + PTOKEN_PRIVILEGES, + DWORD, PTOKEN_PRIVILEGES, + PDWORD); +static AdjustTokenPrivileges_ftype *AdjustTokenPrivileges; + +typedef BOOL WINAPI (DebugActiveProcessStop_ftype) (DWORD); +static DebugActiveProcessStop_ftype *DebugActiveProcessStop; + +typedef BOOL WINAPI (DebugBreakProcess_ftype) (HANDLE); +static DebugBreakProcess_ftype *DebugBreakProcess; + +typedef BOOL WINAPI (DebugSetProcessKillOnExit_ftype) (BOOL); +static DebugSetProcessKillOnExit_ftype *DebugSetProcessKillOnExit; + +typedef BOOL WINAPI (EnumProcessModules_ftype) (HANDLE, HMODULE *, DWORD, + LPDWORD); +static EnumProcessModules_ftype *EnumProcessModules; + +typedef BOOL WINAPI (GetModuleInformation_ftype) (HANDLE, HMODULE, + LPMODULEINFO, DWORD); +static GetModuleInformation_ftype *GetModuleInformation; + +typedef BOOL WINAPI (LookupPrivilegeValueA_ftype) (LPCSTR, LPCSTR, PLUID); +static LookupPrivilegeValueA_ftype *LookupPrivilegeValueA; + +typedef BOOL WINAPI (OpenProcessToken_ftype) (HANDLE, DWORD, PHANDLE); +static OpenProcessToken_ftype *OpenProcessToken; + +typedef BOOL WINAPI (GetCurrentConsoleFont_ftype) (HANDLE, BOOL, + CONSOLE_FONT_INFO *); +static GetCurrentConsoleFont_ftype *GetCurrentConsoleFont; + +typedef COORD WINAPI (GetConsoleFontSize_ftype) (HANDLE, DWORD); +static GetConsoleFontSize_ftype *GetConsoleFontSize; #undef STARTUPINFO #undef CreateProcess @@ -98,7 +119,8 @@ static COORD WINAPI (*GetConsoleFontSize) (HANDLE, DWORD); #ifndef __CYGWIN__ # define __PMAX (MAX_PATH + 1) - static DWORD WINAPI (*GetModuleFileNameEx) (HANDLE, HMODULE, LPSTR, DWORD); + typedef DWORD WINAPI (GetModuleFileNameEx_ftype) (HANDLE, HMODULE, LPSTR, DWORD); + static GetModuleFileNameEx_ftype *GetModuleFileNameEx; # define STARTUPINFO STARTUPINFOA # define CreateProcess CreateProcessA # define GetModuleFileNameEx_name "GetModuleFileNameExA" @@ -110,8 +132,9 @@ static COORD WINAPI (*GetConsoleFontSize) (HANDLE, DWORD); static CORE_ADDR cygwin_load_end; # define __USEWIDE typedef wchar_t cygwin_buf_t; - static DWORD WINAPI (*GetModuleFileNameEx) (HANDLE, HMODULE, - LPWSTR, DWORD); + typedef DWORD WINAPI (GetModuleFileNameEx_ftype) (HANDLE, HMODULE, + LPWSTR, DWORD); + static GetModuleFileNameEx_ftype *GetModuleFileNameEx; # define STARTUPINFO STARTUPINFOW # define CreateProcess CreateProcessW # define GetModuleFileNameEx_name "GetModuleFileNameExW" @@ -2784,19 +2807,18 @@ _initialize_loadable (void) { HMODULE hm = NULL; +#define GPA(m, func) \ + func = (func ## _ftype *) GetProcAddress (m, #func) + hm = LoadLibrary ("kernel32.dll"); if (hm) { - DebugActiveProcessStop = (void *) - GetProcAddress (hm, "DebugActiveProcessStop"); - DebugBreakProcess = (void *) - GetProcAddress (hm, "DebugBreakProcess"); - DebugSetProcessKillOnExit = (void *) - GetProcAddress (hm, "DebugSetProcessKillOnExit"); - GetConsoleFontSize = (void *) - GetProcAddress (hm, "GetConsoleFontSize"); - GetCurrentConsoleFont = (void *) - GetProcAddress (hm, "GetCurrentConsoleFont"); + GPA (hm, DebugActiveProcessStop); + GPA (hm, DebugBreakProcess); + GPA (hm, DebugSetProcessKillOnExit); + GPA (hm, GetConsoleFontSize); + GPA (hm, DebugActiveProcessStop); + GPA (hm, GetCurrentConsoleFont); } /* Set variables to dummy versions of these processes if the function @@ -2818,12 +2840,9 @@ _initialize_loadable (void) hm = LoadLibrary ("psapi.dll"); if (hm) { - EnumProcessModules = (void *) - GetProcAddress (hm, "EnumProcessModules"); - GetModuleInformation = (void *) - GetProcAddress (hm, "GetModuleInformation"); - GetModuleFileNameEx = (void *) - GetProcAddress (hm, GetModuleFileNameEx_name); + GPA (hm, EnumProcessModules); + GPA (hm, GetModuleInformation); + GPA (hm, GetModuleFileNameEx); } if (!EnumProcessModules || !GetModuleInformation || !GetModuleFileNameEx) @@ -2843,15 +2862,15 @@ Use \"file\" or \"dll\" command to load executable/libraries directly.")); hm = LoadLibrary ("advapi32.dll"); if (hm) { - OpenProcessToken = (void *) GetProcAddress (hm, "OpenProcessToken"); - LookupPrivilegeValueA = (void *) - GetProcAddress (hm, "LookupPrivilegeValueA"); - AdjustTokenPrivileges = (void *) - GetProcAddress (hm, "AdjustTokenPrivileges"); + GPA (hm, OpenProcessToken); + GPA (hm, LookupPrivilegeValueA); + GPA (hm, AdjustTokenPrivileges); /* Only need to set one of these since if OpenProcessToken fails nothing else is needed. */ if (!OpenProcessToken || !LookupPrivilegeValueA || !AdjustTokenPrivileges) OpenProcessToken = bad_OpenProcessToken; } + +#undef GPA }