From 520025d9047ae470360e447e768fe35571ba6965 Mon Sep 17 00:00:00 2001 From: binary1248 Date: Sun, 13 Jul 2014 09:22:25 +0200 Subject: [PATCH] Fixed a crash caused by the stack being unaligned when entering ThreadImpl::entryPoint if compiled by GCC or clang and run on Windows XP 32-bit. (#412) --- src/SFML/System/Win32/ThreadImpl.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/SFML/System/Win32/ThreadImpl.hpp b/src/SFML/System/Win32/ThreadImpl.hpp index 49d7a671b..619d5c3ab 100644 --- a/src/SFML/System/Win32/ThreadImpl.hpp +++ b/src/SFML/System/Win32/ThreadImpl.hpp @@ -31,6 +31,17 @@ #include #include +// Fix for unaligned stack with clang and GCC on Windows XP 32-bit +#if defined(SFML_SYSTEM_WINDOWS) && (defined(__clang__) || defined(__GNUC__)) + + #define ALIGN_STACK __attribute__((__force_align_arg_pointer__)) + +#else + + #define ALIGN_STACK + +#endif + namespace sf { @@ -81,7 +92,7 @@ private : /// \return OS specific error code /// //////////////////////////////////////////////////////////// - static unsigned int __stdcall entryPoint(void* userData); + ALIGN_STACK static unsigned int __stdcall entryPoint(void* userData); //////////////////////////////////////////////////////////// // Member data