From 5e4c7ca224417902dd714f4f50500b36b8c89148 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Mon, 13 Aug 2007 15:28:29 +0000 Subject: [PATCH] =?UTF-8?q?Add=20attribute=20that=20forces=20alignment=20o?= =?UTF-8?q?f=20stack=20to=20functions=20that=20need=20it.=20Necessary=20fo?= =?UTF-8?q?r=20systems=20that=20don't=20align=20by=20default=20to=2016=20b?= =?UTF-8?q?ytes,=20required=20by=20some=20SSE=20instructions.=20Requires?= =?UTF-8?q?=20GCC=20>=3D=204.2.=20Based=20on=20patch=20by=20Ga=C3=ABl=20Ch?= =?UTF-8?q?ardon.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally committed as revision 10106 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/dsputil.c | 3 ++- libavcodec/pthread.c | 2 +- libavcodec/utils.c | 10 +++++----- libavcodec/w32thread.c | 2 +- libavutil/internal.h | 8 ++++++++ 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 93417823d9..e1a81a3fea 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3833,7 +3833,8 @@ int ff_check_alignment(void){ 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"); + "but in the compiler. You may try recompiling using gcc >= 4.2.\n" + "Do not report crashes to FFmpeg developers.\n"); #endif did_fail=1; } diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 244bb520dd..702adb533d 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -42,7 +42,7 @@ typedef struct ThreadContext { int done; } ThreadContext; -static void* worker(void *v) +static void* attribute_align_arg worker(void *v) { AVCodecContext *avctx = v; ThreadContext *c = avctx->thread_opaque; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index c381f03f20..e494baf965 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -829,7 +829,7 @@ AVFrame *avcodec_alloc_frame(void){ return pic; } -int avcodec_open(AVCodecContext *avctx, AVCodec *codec) +int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) { int ret= -1; @@ -880,7 +880,7 @@ end: return ret; } -int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, +int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples) { if(buf_size < FF_MIN_BUFFER_SIZE && 0){ @@ -895,7 +895,7 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, return 0; } -int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, +int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVFrame *pict) { if(buf_size < FF_MIN_BUFFER_SIZE){ @@ -923,7 +923,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, return ret; } -int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, +int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, uint8_t *buf, int buf_size) { @@ -946,7 +946,7 @@ int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, return ret; } -int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, +int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, uint8_t *buf, int buf_size) { diff --git a/libavcodec/w32thread.c b/libavcodec/w32thread.c index 12c9212945..fbc0a581e2 100644 --- a/libavcodec/w32thread.c +++ b/libavcodec/w32thread.c @@ -36,7 +36,7 @@ typedef struct ThreadContext{ }ThreadContext; -static unsigned __stdcall thread_func(void *v){ +static unsigned __stdcall attribute_align_arg thread_func(void *v){ ThreadContext *c= v; for(;;){ diff --git a/libavutil/internal.h b/libavutil/internal.h index e8dc72ef85..337f297083 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -34,6 +34,14 @@ #include #include +#ifndef attribute_align_arg +#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1) +# define attribute_align_arg __attribute__((force_align_arg_pointer)) +#else +# define attribute_align_arg +#endif +#endif + #ifndef attribute_used #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) # define attribute_used __attribute__((used))