Skip to content

Commit

Permalink
Align stack of all threads created by libhb
Browse files Browse the repository at this point in the history
This is a preemptive measure to prevent any future crashes in SSE code
that requires 16 byte stack alignment.

git-svn-id: svn://localhost/HandBrake/trunk@4358 b64f7644-9d1e-0410-96f1-a4d463321fa5
  • Loading branch information
jstebbins committed Nov 18, 2011
1 parent 75f2586 commit ce3454b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions libhb/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
#include <sys/stat.h>
#include <dirent.h>

/*
* It seems WinXP doesn't align the stack of new threads to 16 bytes.
* To prevent crashes in SSE functions, we need to force stack alignement
* of new threads.
*/
#if defined( __GNUC__ ) && (defined( _WIN32 ) || defined( __MINGW32__ ))
# define attribute_align_thread __attribute__((force_align_arg_pointer))
#else
# define attribute_align_thread
#endif

#if defined( __GNUC__ ) && !(defined( _WIN32 ) || defined( __MINGW32__ ))
# define HB_WPRINTF(s,v) __attribute__((format(printf,s,v)))
#else
Expand Down
2 changes: 1 addition & 1 deletion libhb/ports.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static uint64_t hb_thread_to_integer( const hb_thread_t* t )
* + Get informed when the thread exits, so we know whether
* hb_thread_close() will block or not.
***********************************************************************/
static void hb_thread_func( void * _t )
static void attribute_align_thread hb_thread_func( void * _t )
{
hb_thread_t * t = (hb_thread_t *) _t;

Expand Down

0 comments on commit ce3454b

Please sign in to comment.