[PATCH] makekeys: Fix build/target word size mismatch when cross-compiling
walter harms
wharms at bfs.de
Mon May 30 07:28:25 PDT 2011
Am 30.05.2011 15:37, schrieb Derek Buitenhuis:
> From: Derek Buitenhuis <dbuitenh at windriver.com>
>
> Since makekeys is built using build environment's gcc and
> run natively, we have to make sure that the size of the
> Signature type is the same on both the native build environment
> and the host, otherwise we get mismatches upon running X,
> and some LSB test failures (xts5).
>
> Have configure check the size of the host's unsigned long
> and typedef Signature in makekeys.c accordingly.
I have no clue how signature is used but i guess it would be
useful to have it the same size on all architectures.
The way it is printed does not take into account big/little endian,
is this adressed somewhere else ?
re,
wh
> ---
> configure.ac | 3 +++
> src/util/makekeys.c | 13 ++++++++++---
> 2 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index a39ab8d..81acb8f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -227,6 +227,9 @@ AC_CHECK_HEADERS([sys/select.h])
>
> # Checks for typedefs, structures, and compiler characteristics.
>
> +# Check the size of unsigned long for use in makekeys
> +AC_CHECK_SIZEOF([unsigned long])
> +
> # Checks for library functions.
> AC_CHECK_FUNCS([strtol])
> # Used in lcFile.c (see also --enable-xlocaledir settings below)
> diff --git a/src/util/makekeys.c b/src/util/makekeys.c
> index 8f88beb..6022f3b 100644
> --- a/src/util/makekeys.c
> +++ b/src/util/makekeys.c
> @@ -31,10 +31,17 @@ from The Open Group.
> #include <X11/X.h>
> #include <X11/Xos.h>
> #include <X11/keysymdef.h>
> +#include <stdint.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> -typedef unsigned long Signature;
> +#include "../config.h"
> +
> +#if SIZEOF_UNSIGNED_LONG == 4
> +typedef uint32_t Signature;
> +#else
> +typedef uint64_t Signature;
> +#endif
>
> #define KTNUM 4000
>
> @@ -212,8 +219,8 @@ next1: ;
> offsets[j] = k;
> indexes[i] = k;
> val = info[i].val;
> - printf("0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, ",
> - (sig >> 8) & 0xff, sig & 0xff,
> + printf("0x%.2jx, 0x%.2jx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, ",
> + (uintmax_t)((sig >> 8) & 0xff), (uintmax_t)(sig & 0xff),
> (val >> 24) & 0xff, (val >> 16) & 0xff,
> (val >> 8) & 0xff, val & 0xff);
> for (name = info[i].name, k += 7; (c = *name++); k++)
More information about the xorg-devel
mailing list