On Wed, 18 May 2011 13:30:44 +1000, Peter Hutterer <[email protected]> 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?
--
[email protected]
pgpcHaS2PPDAa.pgp
Description: PGP signature
_______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
