[FFmpeg-devel] [PATCH] Make HAVE_FAST_UNALIGNED allow unaligned memory accesses

Måns Rullgård mans
Tue Jul 15 22:48:31 CEST 2008

Uoti Urpala <uoti.urpala at pp1.inet.fi> writes:

> On Tue, 2008-07-15 at 20:55 +0100, M?ns Rullg?rd wrote:
>> Reimar D?ffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> writes:
>> > can the current __GNUC__ be checked reliably? That
>> > __attribute__((packed)) acts as "unaligned marker" for structs with only
>> > one element is something that on first sight I would consider a compiler
>> > bug, in which case it would be really hard to check for...
>> GCC has always behaved like this.  However, the documentation for the
>> 'packed' attribute makes no mention of this.
> The documentation of 'packed' does not directly address its use on a
> struct definition, but the documentation of 'aligned' does mention that
> use of 'packed'.
> A more straightforward implementation of AV_RN32 etc would be (at least
> if the documentation of "align" is correct):
> typedef uint32_t av_unaligned_32 __attribute__((aligned(1)));
> #define AV_RN32(a) (*(const av_unaligned_32 *)a)

That won't work:

     The `aligned' attribute can only increase the alignment; but you
     can decrease it by specifying `packed' as well.

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list