From: Derek Buitenhuis <dbuit...@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.
---
 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++)
-- 
1.7.4.1

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to