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

Uoti Urpala uoti.urpala
Tue Jul 31 01:47:59 CEST 2007

> 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.

More information about the ffmpeg-devel mailing list