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

Måns Rullgård mans
Tue Jul 15 23:10:37 CEST 2008


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

> On Tue, 2008-07-15 at 21:48 +0100, M?ns Rullg?rd wrote:
>> Uoti Urpala <uoti.urpala at pp1.inet.fi> writes:
>> > 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.
>
> You seem to be reading outdated documentation. The 4.3 documentation
> says:
> When used on a struct, or struct member, the aligned attribute can only
> increase the alignment; in order to decrease it, the packed attribute
> must be specified as well. When used as part of a typedef, the aligned
> attribute can both increase and decrease alignment, and specifying the
> packed attribute will generate a warning.

I read the documentation for the compiler I use, and I don't trust gcc
4.3 just yet (if I ever will).  Furthermore, we can't rely on features
only present in gcc 4.3, so there's nothing to discuss.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list