Question about signature computation performance

Brett Ciphery brett.ciphery at windriver.com
Thu Oct 14 10:32:15 PDT 2010


I'm wondering if someone can comment on the performance loss for the
below patch and whether it is significant enough to warrant a
full signature computation/hashing algorithm rewrite.

The below was patched to libX11-1.1.3 to fix an issue with the
keysym-tables ks_tables.h in a cross compile environment.  makekeys
generates this file according to signatures it computes from keysymdef.h
and it is used further in the building process. Though during runtime,
the signature is again computed for lookup into the keysym-table.
Problems can occur if there is a host-target mismatch (e.g.
32bit<->64bit) as for some strings, e.g. Greek_upsilonaccentdieresis, the
signature which gets computed will overflow a 32bit register and the
mapping will not be the same as decided during compile.

My proposed solution is below.  I'm wondering about performance loss by
forcing an 'unsigned long long' onto a 32bit arch.

===================BEGIN====================

--- a/src/util/makekeys.c       2007-05-16 11:34:44.000000000 -0400
+++ a/src/util/makekeys.c               2010-10-04 18:15:10.147648964
-0400
@@ -40,7 +40,7 @@
 char *malloc();
 #endif /* macII */
 
-typedef unsigned long Signature;
+typedef unsigned long long Signature;
 
 #define KTNUM 3000
 
@@ -175,7 +175,7 @@
        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%.2llx, 0x%.2llx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx,
",
               (sig >> 8) & 0xff, sig & 0xff,
               (val >> 24) & 0xff, (val >> 16) & 0xff,
               (val >> 8) & 0xff, val & 0xff);

--- a/src/KeysymStr.c
+++ b/src/KeysymStr.c
@@ -36,7 +36,7 @@

 #include <stdio.h> /* sprintf */

-typedef unsigned long Signature;
+typedef unsigned long long Signature;

 #define NEEDVTABLE
 #include "ks_tables.h"
--- a/src/Xresinternal.h
+++ b/src/Xresinternal.h
@@ -4,7 +4,7 @@
 #define _XRESINTERNAL_H_

 /* type defines */
-typedef unsigned long Signature;
+typedef unsigned long long Signature;

 /* prototypes */
 extern XrmQuark _XrmInternalStringToQuark(

======================EOF=======================

Thanks,
Brett


More information about the xorg-devel mailing list