[PATCH] makekeys: Fix build/target word size mismatch when cross-compiling

Derek Buitenhuis derek.buitenhuis at windriver.com
Fri May 20 08:05:44 PDT 2011


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.
---
  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..16108a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -192,6 +192,9 @@ else
  fi
  AC_MSG_RESULT($HAVE_LOADABLE_MODULES)

+#Check the size of unsigned long for use in makekeys
+AC_CHECK_SIZEOF([unsigned long])
+
  AC_MSG_CHECKING([if loadable i18n module support should be enabled])
  AC_ARG_ENABLE(loadable-i18n,
            AS_HELP_STRING([--enable-loadable-i18n],
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++)
-- 
1.7.4.1




More information about the xorg-devel mailing list