[FFmpeg-devel] [PATCH] Make HAVE_FAST_UNALIGNED allow unaligned memory accesses
Uoti Urpala
uoti.urpala
Tue Jul 15 22:56:23 CEST 2008
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.
Even though the 4.2 documentation does not distinguish the uses the
compiler still accepts the typedef (at least as shown by __alignof__). I
don't have older versions available to test with.
More information about the ffmpeg-devel
mailing list