From 6b5b096ee25ccee6c784ddd0edef9e23160aac36 Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Tue, 15 Sep 2015 13:15:28 +0000 Subject: [PATCH] Fix a load of assumptions about default calling convention, a lot more remain. svn path=/trunk/; revision=69242 --- reactos/base/services/svchost/svchost.c | 1 + reactos/base/system/smss/smss.c | 1 + reactos/boot/freeldr/fdebug/fdebug.c | 4 ++-- reactos/include/crt/string.h | 1 + reactos/include/crt/time.h | 4 ++-- reactos/include/psdk/winddi.h | 2 +- .../3rdparty/freetype/include/config/ftconfig.h | 8 ++++---- .../crt/include/internal/mingw-w64/internal.h | 2 +- reactos/lib/sdk/crt/startup/atonexit.c | 2 +- reactos/lib/sdk/crt/startup/charmax.c | 4 ++-- reactos/lib/sdk/crt/startup/crt0_w.c | 4 ++-- reactos/lib/sdk/crt/startup/crt_handler.c | 4 ++-- reactos/lib/sdk/crt/startup/crtdll.c | 3 ++- reactos/lib/sdk/crt/startup/crtexe.c | 17 +++++++++-------- reactos/lib/sdk/crt/string/tcslen.h | 2 +- reactos/lib/sdk/crt/string/tcsnlen.h | 2 +- reactos/win32ss/gdi/gdi32/wine/rosglue.c | 1 + reactos/win32ss/gdi/ntgdi/gdidbg.c | 2 +- reactos/win32ss/pch.h | 4 ++++ 19 files changed, 39 insertions(+), 29 deletions(-) diff --git a/reactos/base/services/svchost/svchost.c b/reactos/base/services/svchost/svchost.c index e1085d08a79..73520c6a1db 100644 --- a/reactos/base/services/svchost/svchost.c +++ b/reactos/base/services/svchost/svchost.c @@ -1243,6 +1243,7 @@ CallPerInstanceInitFunctions ( } VOID +__cdecl wmainCRTStartup ( VOID ) diff --git a/reactos/base/system/smss/smss.c b/reactos/base/system/smss/smss.c index 02211514cbf..28bd66f22dc 100644 --- a/reactos/base/system/smss/smss.c +++ b/reactos/base/system/smss/smss.c @@ -445,6 +445,7 @@ SmpUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo) } NTSTATUS +__cdecl _main(IN INT argc, IN PCHAR argv[], IN PCHAR envp[], diff --git a/reactos/boot/freeldr/fdebug/fdebug.c b/reactos/boot/freeldr/fdebug/fdebug.c index 9bd764d16b5..9db43a879da 100644 --- a/reactos/boot/freeldr/fdebug/fdebug.c +++ b/reactos/boot/freeldr/fdebug/fdebug.c @@ -37,7 +37,7 @@ LRESULT CALLBACK ConnectionDialogProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK CaptureDialogProc(HWND, UINT, WPARAM, LPARAM); VOID EnableFileMenuItemByID(UINT Id, BOOL Enable); VOID CheckLocalEchoMenuItem(BOOL Checked); -VOID Rs232Thread(VOID* Parameter); +VOID __cdecl Rs232Thread(VOID* Parameter); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -437,7 +437,7 @@ VOID CheckLocalEchoMenuItem(BOOL Checked) CheckMenuItem(hFileMenu, IDM_FILE_LOCALECHO, MF_BYCOMMAND|(Checked ? MF_CHECKED : MF_UNCHECKED)); } -VOID Rs232Thread(VOID* Parameter) +VOID __cdecl Rs232Thread(VOID* Parameter) { BYTE Byte; TCHAR String[MAX_PATH]; diff --git a/reactos/include/crt/string.h b/reactos/include/crt/string.h index 3064aaca484..3249254c947 100644 --- a/reactos/include/crt/string.h +++ b/reactos/include/crt/string.h @@ -672,6 +672,7 @@ extern "C" { _CRTIMP wchar_t* + __cdecl wcsncat( wchar_t *_Dest, const wchar_t *_Source, diff --git a/reactos/include/crt/time.h b/reactos/include/crt/time.h index d332eb4ba84..d342ab30cc2 100644 --- a/reactos/include/crt/time.h +++ b/reactos/include/crt/time.h @@ -388,10 +388,10 @@ extern "C" { #ifdef _USE_32BIT_TIME_T /* Do it like this to be compatible to msvcrt.dll on 32 bit windows XP and before */ __CRT_INLINE wchar_t *__cdecl _wctime32(const time_t *_Time) { return _wctime(_Time); } -__CRT_INLINE errno_t _wctime32_s(wchar_t *_Buffer, size_t _SizeInWords,const __time32_t *_Time) { return _wctime32_s(_Buffer, _SizeInWords, _Time); } +__CRT_INLINE errno_t __cdecl _wctime32_s(wchar_t *_Buffer, size_t _SizeInWords,const __time32_t *_Time) { return _wctime32_s(_Buffer, _SizeInWords, _Time); } #else __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_Time); } -__CRT_INLINE errno_t _wctime_s(wchar_t *_Buffer, size_t _SizeInWords,const time_t *_Time) { return _wctime64_s(_Buffer, _SizeInWords, _Time); } +__CRT_INLINE errno_t __cdecl _wctime_s(wchar_t *_Buffer, size_t _SizeInWords,const time_t *_Time) { return _wctime64_s(_Buffer, _SizeInWords, _Time); } #endif #endif diff --git a/reactos/include/psdk/winddi.h b/reactos/include/psdk/winddi.h index 0b0814a9bb6..1d1019ae0db 100644 --- a/reactos/include/psdk/winddi.h +++ b/reactos/include/psdk/winddi.h @@ -2450,7 +2450,7 @@ EngSetPrinterData( _In_ DWORD cjPrinterData); #endif /* !USERMODE_DRIVER */ -typedef int (CDECL *SORTCOMP)(const void *pv1, const void *pv2); +typedef int (__cdecl /*CDECL*/ *SORTCOMP)(const void *pv1, const void *pv2); ENGAPI VOID diff --git a/reactos/lib/3rdparty/freetype/include/config/ftconfig.h b/reactos/lib/3rdparty/freetype/include/config/ftconfig.h index 086db76ab5b..e1b5c0619ea 100644 --- a/reactos/lib/3rdparty/freetype/include/config/ftconfig.h +++ b/reactos/lib/3rdparty/freetype/include/config/ftconfig.h @@ -387,9 +387,9 @@ FT_BEGIN_HEADER #ifndef FT_EXPORT #ifdef __cplusplus -#define FT_EXPORT( x ) extern "C" x +#define FT_EXPORT( x ) extern "C" x __cdecl #else -#define FT_EXPORT( x ) extern x +#define FT_EXPORT( x ) extern x __cdecl #endif #endif /* !FT_EXPORT */ @@ -398,9 +398,9 @@ FT_BEGIN_HEADER #ifndef FT_EXPORT_DEF #ifdef __cplusplus -#define FT_EXPORT_DEF( x ) extern "C" x +#define FT_EXPORT_DEF( x ) extern "C" x __cdecl #else -#define FT_EXPORT_DEF( x ) extern x +#define FT_EXPORT_DEF( x ) extern x __cdecl #endif #endif /* !FT_EXPORT_DEF */ diff --git a/reactos/lib/sdk/crt/include/internal/mingw-w64/internal.h b/reactos/lib/sdk/crt/include/internal/mingw-w64/internal.h index df3d76c4e3c..aeac86701ef 100644 --- a/reactos/lib/sdk/crt/include/internal/mingw-w64/internal.h +++ b/reactos/lib/sdk/crt/include/internal/mingw-w64/internal.h @@ -21,7 +21,7 @@ extern "C" { #ifdef __REACTOS__ #include "malloc.h" struct _exception; -__declspec(dllimport) void __setusermatherr(int (__cdecl *)(struct _exception *)); +__declspec(dllimport) void __cdecl __setusermatherr(int (__cdecl *)(struct _exception *)); #define __mingw_fprintf fprintf #define __mingw_vfprintf vfprintf #endif diff --git a/reactos/lib/sdk/crt/startup/atonexit.c b/reactos/lib/sdk/crt/startup/atonexit.c index 73eed2fd80a..e5fb98a2d63 100644 --- a/reactos/lib/sdk/crt/startup/atonexit.c +++ b/reactos/lib/sdk/crt/startup/atonexit.c @@ -24,7 +24,7 @@ _PVFV *__onexitbegin; _PVFV *__onexitend; -extern _CRTIMP _onexit_t __dllonexit (_onexit_t, _PVFV**, _PVFV**); +extern _CRTIMP _onexit_t __cdecl __dllonexit (_onexit_t, _PVFV**, _PVFV**); extern _onexit_t (__cdecl * __MINGW_IMP_SYMBOL(_onexit)) (_onexit_t func); /* Choose a different name to prevent name conflicts. The CRT one works fine. */ diff --git a/reactos/lib/sdk/crt/startup/charmax.c b/reactos/lib/sdk/crt/startup/charmax.c index fbd10c4b923..42debd4fe4b 100644 --- a/reactos/lib/sdk/crt/startup/charmax.c +++ b/reactos/lib/sdk/crt/startup/charmax.c @@ -7,13 +7,13 @@ #include #include -__declspec(dllimport) int __lconv_init (void); +__declspec(dllimport) int __cdecl __lconv_init (void); int mingw_initcharmax = 0; int _charmax = 255; -static int my_lconv_init(void) +static int __cdecl my_lconv_init(void) { return __lconv_init(); } diff --git a/reactos/lib/sdk/crt/startup/crt0_w.c b/reactos/lib/sdk/crt/startup/crt0_w.c index 8ee7ea79bbf..d55421fe7ee 100644 --- a/reactos/lib/sdk/crt/startup/crt0_w.c +++ b/reactos/lib/sdk/crt/startup/crt0_w.c @@ -14,10 +14,10 @@ extern HINSTANCE __mingw_winmain_hInstance; extern LPWSTR __mingw_winmain_lpCmdLine; extern DWORD __mingw_winmain_nShowCmd; -int wmain (int, wchar_t **, wchar_t **); +int __cdecl wmain (int, wchar_t **, wchar_t **); /*ARGSUSED*/ -int wmain (int __UNUSED_PARAM(flags), +int __cdecl wmain (int __UNUSED_PARAM(flags), wchar_t ** __UNUSED_PARAM(cmdline), wchar_t ** __UNUSED_PARAM(inst)) { diff --git a/reactos/lib/sdk/crt/startup/crt_handler.c b/reactos/lib/sdk/crt/startup/crt_handler.c index 84172172781..e1031ca53cc 100644 --- a/reactos/lib/sdk/crt/startup/crt_handler.c +++ b/reactos/lib/sdk/crt/startup/crt_handler.c @@ -40,7 +40,7 @@ PIMAGE_SECTION_HEADER _FindPESectionExec (size_t); PBYTE _GetPEImageBase (void); int __mingw_init_ehandler (void); -extern void _fpreset (void); +extern void __cdecl _fpreset (void); #if defined(_WIN64) && !defined(_MSC_VER) EXCEPTION_DISPOSITION __mingw_SEH_error_handler(struct _EXCEPTION_RECORD *, void *, struct _CONTEXT *, void *); @@ -90,7 +90,7 @@ __mingw_init_ehandler (void) return 1; } -extern void _fpreset (void); +extern void __cdecl _fpreset (void); EXCEPTION_DISPOSITION __mingw_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord, diff --git a/reactos/lib/sdk/crt/startup/crtdll.c b/reactos/lib/sdk/crt/startup/crtdll.c index f046705135f..e52f240f2c5 100644 --- a/reactos/lib/sdk/crt/startup/crtdll.c +++ b/reactos/lib/sdk/crt/startup/crtdll.c @@ -54,11 +54,12 @@ extern WINBOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreser extern WINBOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID); -static int pre_c_init (void); +static int __cdecl pre_c_init (void); _CRTALLOC(".CRT$XIAA") _PIFV pcinit = pre_c_init; static int +__cdecl pre_c_init (void) { _PVFV *onexitbegin; diff --git a/reactos/lib/sdk/crt/startup/crtexe.c b/reactos/lib/sdk/crt/startup/crtexe.c index 39904bf2c2f..1bd193bedff 100644 --- a/reactos/lib/sdk/crt/startup/crtexe.c +++ b/reactos/lib/sdk/crt/startup/crtexe.c @@ -39,7 +39,7 @@ extern char *** __MINGW_IMP_SYMBOL(__initenv); /* This symbol is defined by ld. */ extern IMAGE_DOS_HEADER __ImageBase; -extern void _fpreset (void); +extern void __cdecl _fpreset (void); #define SPACECHAR _T(' ') #define DQUOTECHAR _T('\"') @@ -147,11 +147,11 @@ pre_cpp_init (void) #endif } -static int __tmainCRTStartup (void); +static int __cdecl __tmainCRTStartup (void); -int WinMainCRTStartup (void); +int __cdecl WinMainCRTStartup (void); -int WinMainCRTStartup (void) +int __cdecl WinMainCRTStartup (void) { int ret = 255; #ifdef __SEH__ @@ -173,13 +173,13 @@ int WinMainCRTStartup (void) return ret; } -int mainCRTStartup (void); +int __cdecl mainCRTStartup (void); #ifdef _WIN64 int __mingw_init_ehandler (void); #endif -int mainCRTStartup (void) +int __cdecl mainCRTStartup (void) { int ret = 255; #ifdef __SEH__ @@ -202,7 +202,8 @@ int mainCRTStartup (void) } static -__declspec(noinline) int +__declspec(noinline) +int __cdecl __tmainCRTStartup (void) { _TCHAR *lpszCommandLine = NULL; @@ -410,7 +411,7 @@ static void duplicate_ppstrings (int ac, char ***av) #else #define __UNUSED_PARAM_1 __UNUSED_PARAM #endif -static void +static void __cdecl __mingw_invalidParameterHandler (const wchar_t * __UNUSED_PARAM_1(expression), const wchar_t * __UNUSED_PARAM_1(function), const wchar_t * __UNUSED_PARAM_1(file), diff --git a/reactos/lib/sdk/crt/string/tcslen.h b/reactos/lib/sdk/crt/string/tcslen.h index e8de5b2b179..c7ae4cfa59f 100644 --- a/reactos/lib/sdk/crt/string/tcslen.h +++ b/reactos/lib/sdk/crt/string/tcslen.h @@ -6,7 +6,7 @@ #pragma function(_tcslen) #endif /* _MSC_VER */ -size_t _tcslen(const _TCHAR * str) +size_t __cdecl _tcslen(const _TCHAR * str) { const _TCHAR * s; diff --git a/reactos/lib/sdk/crt/string/tcsnlen.h b/reactos/lib/sdk/crt/string/tcsnlen.h index 953b5adec86..de896136783 100644 --- a/reactos/lib/sdk/crt/string/tcsnlen.h +++ b/reactos/lib/sdk/crt/string/tcsnlen.h @@ -2,7 +2,7 @@ #include #include -size_t _tcsnlen(const _TCHAR * str, size_t count) +size_t __cdecl _tcsnlen(const _TCHAR * str, size_t count) { const _TCHAR * s; diff --git a/reactos/win32ss/gdi/gdi32/wine/rosglue.c b/reactos/win32ss/gdi/gdi32/wine/rosglue.c index 498ef103741..16da94ee630 100644 --- a/reactos/win32ss/gdi/gdi32/wine/rosglue.c +++ b/reactos/win32ss/gdi/gdi32/wine/rosglue.c @@ -511,6 +511,7 @@ SetWorldTransformForMetafile( } void +__cdecl _assert ( const char *exp, const char *file, diff --git a/reactos/win32ss/gdi/ntgdi/gdidbg.c b/reactos/win32ss/gdi/ntgdi/gdidbg.c index d9227f124cf..e3b3d0683cd 100644 --- a/reactos/win32ss/gdi/ntgdi/gdidbg.c +++ b/reactos/win32ss/gdi/ntgdi/gdidbg.c @@ -641,7 +641,7 @@ QueryEnvironmentVariable(PUNICODE_STRING Name, return(STATUS_VARIABLE_NOT_FOUND); } -static int +static int __cdecl DbgCompareChannels(const void * a, const void * b) { return wcscmp((WCHAR*)a, ((DBG_CHANNEL*)b)->Name); diff --git a/reactos/win32ss/pch.h b/reactos/win32ss/pch.h index ebedadc942d..b4bc1009038 100644 --- a/reactos/win32ss/pch.h +++ b/reactos/win32ss/pch.h @@ -43,6 +43,10 @@ typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; #include #include +// Needed because windef.h messes up CDECL for whatever +#undef CDECL +#define CDECL __cdecl + /* Avoid type casting, by defining RECT to RECTL */ #define RECT RECTL #define PRECT PRECTL