[PATCH] test/input: Replace negative architecture test by test for 64-bit

Michał Masłowski mtjm at mtjm.eu
Tue Feb 12 04:23:46 PST 2013


Geert Uytterhoeven <geert at linux-m68k.org> writes:

> The test for double-aligned members in dix_valuator_alloc() currently
> depends on "if !defined(__i386__) && !defined(__sh__)". This covers
> m68k, where it fails.
>
> According to the comment, the test should be limited to 64-bit
> platforms only. Hence check if sizeof(long) == 8 instead.

MIPS N32 needs doubles to be 8 byte aligned, while it has 32 bit longs
and pointers (the CPU registers are 64 bit).  libxi has a similar
conditional for structure padding which prevented sigbuses of all
GTK3-using programs there.

Should the comment be changed, or the negative test expanded?  I don't
know how it could be determined without checking specific architecture
names.

>
> Signed-off-by: Geert Uytterhoeven <geert at linux-m68k.org>
> ---
> Untested for now
>
>  test/input.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/test/input.c b/test/input.c
> index be988a4..ed29bdc 100644
> --- a/test/input.c
> +++ b/test/input.c
> @@ -1384,11 +1384,11 @@ dix_valuator_alloc(void)
>  
>          assert(v);
>          assert(v->numAxes == num_axes);
> -#if !defined(__i386__) && !defined(__sh__)
> -        /* must be double-aligned on 64 bit */
> -        assert(((void *) v->axisVal - (void *) v) % sizeof(double) == 0);
> -        assert(((void *) v->axes - (void *) v) % sizeof(double) == 0);
> -#endif
> +        if (sizeof(long) == 8) {
> +            /* must be double-aligned on 64 bit */
> +            assert(((void *) v->axisVal - (void *) v) % sizeof(double) == 0);
> +            assert(((void *) v->axes - (void *) v) % sizeof(double) == 0);
> +        }
>          num_axes++;
>      }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20130212/9369ef9d/attachment.pgp>


More information about the xorg-devel mailing list