Commit 0e30a196 authored by ramiro's avatar ramiro

Add attribute that forces alignment of stack to functions that need it.

Necessary for systems that don't align by default to 16 bytes, required by some
SSE instructions.
Requires GCC >= 4.2.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@10106 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 6e70a6cc
...@@ -3833,7 +3833,8 @@ int ff_check_alignment(void){ ...@@ -3833,7 +3833,8 @@ int ff_check_alignment(void){
av_log(NULL, AV_LOG_ERROR, av_log(NULL, AV_LOG_ERROR,
"Compiler did not align stack variables. Libavcodec has been miscompiled\n" "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" "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 #endif
did_fail=1; did_fail=1;
} }
......
...@@ -42,7 +42,7 @@ typedef struct ThreadContext { ...@@ -42,7 +42,7 @@ typedef struct ThreadContext {
int done; int done;
} ThreadContext; } ThreadContext;
static void* worker(void *v) static void* attribute_align_arg worker(void *v)
{ {
AVCodecContext *avctx = v; AVCodecContext *avctx = v;
ThreadContext *c = avctx->thread_opaque; ThreadContext *c = avctx->thread_opaque;
......
...@@ -829,7 +829,7 @@ AVFrame *avcodec_alloc_frame(void){ ...@@ -829,7 +829,7 @@ AVFrame *avcodec_alloc_frame(void){
return pic; return pic;
} }
int avcodec_open(AVCodecContext *avctx, AVCodec *codec) int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
{ {
int ret= -1; int ret= -1;
...@@ -880,7 +880,7 @@ end: ...@@ -880,7 +880,7 @@ end:
return ret; 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) const short *samples)
{ {
if(buf_size < FF_MIN_BUFFER_SIZE && 0){ if(buf_size < FF_MIN_BUFFER_SIZE && 0){
...@@ -895,7 +895,7 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, ...@@ -895,7 +895,7 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
return 0; 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) const AVFrame *pict)
{ {
if(buf_size < FF_MIN_BUFFER_SIZE){ if(buf_size < FF_MIN_BUFFER_SIZE){
...@@ -923,7 +923,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, ...@@ -923,7 +923,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
return ret; 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, int *got_picture_ptr,
uint8_t *buf, int buf_size) uint8_t *buf, int buf_size)
{ {
...@@ -946,7 +946,7 @@ int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, ...@@ -946,7 +946,7 @@ int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
return ret; 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, int *frame_size_ptr,
uint8_t *buf, int buf_size) uint8_t *buf, int buf_size)
{ {
......
...@@ -36,7 +36,7 @@ typedef struct ThreadContext{ ...@@ -36,7 +36,7 @@ typedef struct ThreadContext{
}ThreadContext; }ThreadContext;
static unsigned __stdcall thread_func(void *v){ static unsigned __stdcall attribute_align_arg thread_func(void *v){
ThreadContext *c= v; ThreadContext *c= v;
for(;;){ for(;;){
......
...@@ -34,6 +34,14 @@ ...@@ -34,6 +34,14 @@
#include <stddef.h> #include <stddef.h>
#include <assert.h> #include <assert.h>
#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 #ifndef attribute_used
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
# define attribute_used __attribute__((used)) # define attribute_used __attribute__((used))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment