[Ffmpeg-devel] about ff_check_alignment()

yubing trueice
Tue Jan 30 06:20:24 CET 2007


Hi, all

Recently, I updated my mencoder from the svn trunk, and compiled it with gcc
under my ia32 box, however, I got the message below when running it:

"Compiler did not align stack variables. Libavcodec has been miscompiled
and may be very slow or crash. This is not a bug in libavcodec,
but in the compiler. Do not report crashes to FFmpeg developers."

The source of this message resides in libavcodec/dsputil.c

#define DECLARE_ALIGNED_16(t,v)       t v __attribute__ ((aligned (16)))

int ff_check_alignment(void){
    static int did_fail=0;
    DECLARE_ALIGNED_16(int, aligned);

    if((int)&aligned & 15){
        if(!did_fail){
#if defined(HAVE_MMX) || defined(HAVE_ALTIVEC)
            av_log(NULL, AV_LOG_ERROR,
                "Compiler did not align stack variables. Libavcodec has been
miscompiled\n"
                "and may be very slow or crash. This is not a bug in
libavcodec,\n"
                "but in the compiler. Do not report crashes to FFmpeg
developers.\n");
#endif
            did_fail=1;
        }
        return -1;
    }
    return 0;
}
As we know, gcc does not align local variables (ever since the
2.95version), the DECLARE_XXX macro may only work for global vars like
this:

DECLARE_ALIGNED_16(int, aligned);
int ff_check_alignment(void) {
    static int did_fail=0;
    if((int)&aligned & 15) {
       ................
    }
}

I wonder which compiler the developers are using, would you refer an
appropriate compiler to me?

-- 
truly yours
ice




More information about the ffmpeg-devel mailing list