shithub: libvpx

Download patch

ref: 343b6b09a121f5106281ac3fe9052b2f2c670491
parent: 4916a87bfc58b96882db3a9e978e604384821d92
author: Aleksey Vasenev <margtu-fivt@ya.ru>
date: Fri Jul 29 07:28:50 EDT 2016

Align thread entry point stack

_beginthreadex does not align the stack on 16-byte boundary as expected
by gcc.

On x86 targets, the force_align_arg_pointer attribute may be applied to
individual function definitions, generating an alternate prologue and
epilogue that realigns the run-time stack if necessary. This supports
mixing legacy codes that run with a 4-byte aligned stack with modern
codes that keep a 16-byte stack for SSE compatibility.
https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html

Change-Id: Ie4e4ab32948c238fa87054d5664189972ca6708e
Signed-off-by: Aleksey Vasenev <margtu-fivt@ya.ru>

--- a/vp8/common/threading.h
+++ b/vp8/common/threading.h
@@ -24,7 +24,13 @@
 /* Win32 */
 #include <process.h>
 #include <windows.h>
+#if defined(__GNUC__) && \
+    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
+#define THREAD_FUNCTION \
+  __attribute__((force_align_arg_pointer)) unsigned int __stdcall
+#else
 #define THREAD_FUNCTION unsigned int __stdcall
+#endif
 #define THREAD_FUNCTION_RETURN DWORD
 #define THREAD_SPECIFIC_INDEX DWORD
 #define pthread_t HANDLE
--- a/vpx_util/vpx_thread.h
+++ b/vpx_util/vpx_thread.h
@@ -58,7 +58,12 @@
 // simplistic pthread emulation layer
 
 // _beginthreadex requires __stdcall
+#if defined(__GNUC__) && \
+    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
+#define THREADFN __attribute__((force_align_arg_pointer)) unsigned int __stdcall
+#else
 #define THREADFN unsigned int __stdcall
+#endif
 #define THREAD_RETURN(val) (unsigned int)((DWORD_PTR)val)
 
 #if _WIN32_WINNT >= 0x0501  // Windows XP or greater