[FFmpeg-devel] Stack variables alignment check in libavcodec/dsputil.c

Michael Niedermayer michaelni
Tue Jul 31 02:00:55 CEST 2007


On Tue, Jul 31, 2007 at 02:47:59AM +0300, Uoti Urpala wrote:
> > On Mon, Jul 30, 2007 at 03:42:54PM -0700, Roman Shaposhnick wrote:
> > >   Not to start yet another gcc flame war, but I'm sick and tired
> > > of hearing what gcc is *supposed* to do and how much better it
> > > is supposed to be if it *works*. Well, it doesn't work, I'm sorry.
> > > Hence the efficiency becomes moot.
> In your earlier message you mentioned "gcc 3.4.5". gcc versions before 4
> are buggy and just ignore alignment for stack variables.
> On Tue, 2007-07-31 at 01:12 +0200, Michael Niedermayer wrote:
> > realign_stack() would check if the stack is aligned and if so just return 0
> > if not it would align the stack, copy the function arguments to the aligned
> > stack, call the function ptr, set ret to what the function returned and
> > return 1
> > 
> > yes you have to write realign_stack() in asm
> In gcc-4.2 or above you can use function attributes to add such forced
> stack realign code instead of writing asm. However since Roman mentioned
> pre-4 gcc versions the problem in this case most likely isn't the stack
> getting misaligned but gcc placing the variables at a bad offset from
> the stack frame.

ok, then my next idea would be to put the SSE/altivec code which needs an
aligned stack under #ifdef ALIGNED_STACK
its of course not a perfect solution but better than random crashes or
having to disable all mmx/sse/...

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070731/2324163f/attachment.pgp>

More information about the ffmpeg-devel mailing list