diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-12-07 18:33:00 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-12-07 18:33:00 +0000 |
commit | 6dc7d5da70292edcd7c9b17706caa938f79b853b (patch) | |
tree | dbb01c66a047bc88e766d3f2f4acff66ea234d8e /libavcodec/dsputil.c | |
parent | f95778f80d27538b68c72858914bcccfbcda02cf (diff) | |
download | ffmpeg-6dc7d5da70292edcd7c9b17706caa938f79b853b.tar.gz |
ff_check_alignment to warn the user about a missaligned stack
Originally committed as revision 7249 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/dsputil.c')
-rw-r--r-- | libavcodec/dsputil.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 51eddbc601..0f5416ff64 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3801,11 +3801,31 @@ void dsputil_static_init(void) for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1; } +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, your code has been misscompiled\n" + "and may crash, this is not a bug in the application but in the compiler\n" + "so reporting it anywhere but to the compiler maintainers is senseless!\n"); +#endif + did_fail=1; + } + return -1; + } + return 0; +} void dsputil_init(DSPContext* c, AVCodecContext *avctx) { int i; + ff_check_alignment(); + #ifdef CONFIG_ENCODERS if(avctx->dct_algo==FF_DCT_FASTINT) { c->fdct = fdct_ifast; |