mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-11 22:38:38 +00:00
Unaligned stacks on i686-w64-mingw32, may lead to crashes (#7607)
Co-authored-by: Ozkan Sezer <sezeroz@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0ad822eb70
commit
8231278817
@@ -631,9 +631,9 @@ SDL_bool SDL_IsTablet(void)
|
||||
#if defined(__WIN32__)
|
||||
|
||||
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
||||
/* Need to include DllMain() on Watcom C for some reason.. */
|
||||
/* FIXME: Still need to include DllMain() on Watcom C ? */
|
||||
|
||||
BOOL APIENTRY _DllMainCRTStartup(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
|
||||
@@ -76,6 +76,19 @@
|
||||
#define WINVER _WIN32_WINNT
|
||||
#endif
|
||||
|
||||
/* See https://github.com/libsdl-org/SDL/pull/7607 */
|
||||
/* force_align_arg_pointer attribute requires gcc >= 4.2.x. */
|
||||
#if defined(__clang__)
|
||||
#define HAVE_FORCE_ALIGN_ARG_POINTER
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
|
||||
#define HAVE_FORCE_ALIGN_ARG_POINTER
|
||||
#endif
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(HAVE_FORCE_ALIGN_ARG_POINTER)
|
||||
#define MINGW32_FORCEALIGN __attribute__((force_align_arg_pointer))
|
||||
#else
|
||||
#define MINGW32_FORCEALIGN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <basetyps.h> /* for REFIID with broken mingw.org headers */
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ int console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp)
|
||||
#endif
|
||||
|
||||
/* This is where execution begins [windowed apps] */
|
||||
int WINAPI
|
||||
int WINAPI MINGW32_FORCEALIGN
|
||||
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) /* NOLINT(readability-inconsistent-declaration-parameter-name) */
|
||||
{
|
||||
return main_getcmdline();
|
||||
|
||||
@@ -55,12 +55,12 @@ static DWORD RunThread(void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DWORD WINAPI RunThreadViaCreateThread(LPVOID data)
|
||||
static DWORD WINAPI MINGW32_FORCEALIGN RunThreadViaCreateThread(LPVOID data)
|
||||
{
|
||||
return RunThread(data);
|
||||
}
|
||||
|
||||
static unsigned __stdcall RunThreadViaBeginThreadEx(void *data)
|
||||
static unsigned __stdcall MINGW32_FORCEALIGN RunThreadViaBeginThreadEx(void *data)
|
||||
{
|
||||
return (unsigned)RunThread(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user