[PATCH] test: only test for double alignment on 64 bit. (#36986)
Julien Cristau
jcristau at debian.org
Thu May 19 12:58:00 PDT 2011
On Thu, May 19, 2011 at 14:54:28 +1000, Peter Hutterer wrote:
> X.Org Bug 36986 <http://bugs.freedesktop.org/show_bug.cgi?id=36986>
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>
> On Wed, May 18, 2011 at 12:45:05AM -0700, Keith Packard wrote:
> > On Wed, 18 May 2011 13:30:44 +1000, Peter Hutterer
> > <peter.hutterer at who-t.net> wrote:
> >
> > > + const int sz_dbl = sizeof(double);
> > > /* force alignment with double */
> > > - union align_u { ValuatorClassRec valc; double d; } *align;
> > > + union align_u {
> > > + ValuatorClassRec valc;
> > > + double d[(sizeof(ValuatorClassRec) + sz_dbl - 1)/sz_dbl];
> > > + } *align;
> >
> > This doesn't make sense to me. The requirement for the union is that you
> > be able to allocate an array of them and store into each element:
> >
> > union align_u foo[12];
> >
> > foo[0].d = 0.0;
> > foo[1].d = 1.0;
> >
> > This should require double alignment for the entire union, even though
> > 'd' is far smaller than 'valc'.
> >
> > Of course, on a 32-bit x86 machine, doubles can be stored without
> > penalty on 4-byte boundaries, so the union is only aligned to 52 bytes.
> >
> > Can you explain why this alignment isn't acceptable in this context?
>
> because I naïvely thought that we needed double alignment on 32 bit too and
> the test was written that way. Oh well, how about this patch instead then.
> it just disables the alignment check on 32 bit.
>
Maybe check for __alignof__(double) instead of sizeof(double)?
Cheers,
Julien
More information about the xorg-devel
mailing list