[Ffmpeg-devel] DECLARE_ALIGNED_16 not honoured correctly in MinGW
Tue Nov 7 14:26:10 CET 2006
> >Yes, and this assumption is highly broken on gcc's part. All
> it has to
> >do is insert an instruction "and $~15, %esp" before it sets
> up the new
> >frame and some other minor support. Flame the gcc developers
> for being
> >#$&(#$ idiots, yet again...
> So if we move a stack variable so it aligns the struct is it going to
> work then? Then it would still work properly on Unix while it could be
> considered a hack on mingw.
So was there any solution figured out for this? Gcc apperently assumes the
stack is aligned at the point of the call to the function, after any
parameters have been pushed onto stack, wich makes it very uggly to fix. One
have to write special assembly rutines to call a function.
In ms style assembly for a function with one parameter, something like this.
( this is for calling a function in mplayer built as a dll, wich then will
call lavc )
int mplayer_open_file(const char* szFile)
sub esp,4; /* make room for paramteres */
and esp,~15; /* align stack */
add esp,4; /* for parameters */
mov eax,dword ptr [szFile];
call dword ptr [pOpenFile];
mov result, eax;
mov esp,esi; /* restore stack */
Doing that for every potential function that could be needing aligned stack
is really uggly.
The patch suggested by steve would probably work, and I think aslong as the
memory that get's used for a struct is aligned properly, any property of
that struct seem to be correctly aligned if it has the aligned keyword on
it. Thus aslong as av_malloc or av_calloc is used, it should be fine. Just
making sure any variable on stack that needs to be aligned uses _alloca.
More information about the ffmpeg-devel