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

Derek Buitenhuis derek.buitenhuis at gmail.com
Thu Sep 22 15:44:13 PDT 2011


Since makekeys is built using build environment's gcc and
runs natively, we have to make sure that the size of the
Signature type is the same on both the native environment
and the target, otherwise we get mismatches upon running X,
and some LSB test failures (xts5).

Use an unsigned 32-bit integer on all platforms. Also,
eliminate the redundant multiple typedefs for the
Signature type.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
 src/KeysymStr.c      |    3 +--
 src/Xresinternal.h   |    4 +++-
 src/util/Makefile.am |    3 +++
 src/util/makekeys.c  |    5 +++--
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/KeysymStr.c b/src/KeysymStr.c
index 486b5d1..101f297 100644
--- a/src/KeysymStr.c
+++ b/src/KeysymStr.c
@@ -31,11 +31,10 @@ in this Software without prior written authorization from The Open Group.
 #include "Xlibint.h"
 #include <X11/Xresource.h>
 #include <X11/keysymdef.h>
+#include "Xresinternal.h"
 
 #include <stdio.h> /* sprintf */
 
-typedef unsigned long Signature;
-
 #define NEEDVTABLE
 #include "ks_tables.h"
 #include "Key.h"
diff --git a/src/Xresinternal.h b/src/Xresinternal.h
index b4b1b00..c2f355f 100644
--- a/src/Xresinternal.h
+++ b/src/Xresinternal.h
@@ -2,8 +2,10 @@
 #ifndef _XRESINTERNAL_H_
 #define _XRESINTERNAL_H_
 
+#include <inttypes.h>
+
 /* type defines */
-typedef unsigned long Signature;
+typedef uint32_t Signature;
 
 /* prototypes */
 extern XrmQuark _XrmInternalStringToQuark(
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 3b100e0..dfe91f1 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -5,6 +5,9 @@ makekeys_CFLAGS = \
 	$(X11_CFLAGS) \
 	$(CWARNFLAGS)
 
+makekeys_CPPFLAGS = \
+	-I$(top_srcdir)/include
+
 CC = @CC_FOR_BUILD@
 CPPFLAGS = @CPPFLAGS_FOR_BUILD@
 CFLAGS = @CFLAGS_FOR_BUILD@
diff --git a/src/util/makekeys.c b/src/util/makekeys.c
index 8f88beb..36d4d4b 100644
--- a/src/util/makekeys.c
+++ b/src/util/makekeys.c
@@ -30,11 +30,12 @@ from The Open Group.
 
 #include <X11/X.h>
 #include <X11/Xos.h>
+#include <X11/Xresource.h>
 #include <X11/keysymdef.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-typedef unsigned long Signature;
+#include "../Xresinternal.h"
 
 #define KTNUM 4000
 
@@ -212,7 +213,7 @@ next1:	;
 	offsets[j] = k;
 	indexes[i] = k;
 	val = info[i].val;
-	printf("0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, ",
+	printf("0x%.2"PRIx32", 0x%.2"PRIx32", 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, ",
 	       (sig >> 8) & 0xff, sig & 0xff,
 	       (val >> 24) & 0xff, (val >> 16) & 0xff,
 	       (val >> 8) & 0xff, val & 0xff);
-- 
1.7.7


--------------050507080101090305050306--


More information about the xorg-devel mailing list