Commit 60e7eeeba1d6c1b17cc71c36381251e633d6716e

Daniel Stone 2010-06-17T03:16:09

Use CARD32 instead of Atom, drag in XkbClientMapRec On 64-bit architectures, XID varies in size between the server (always 32 bits), and non-server (always unsigned long) for some inexplicable reason. Use CARD32 instead to avoid this horrible trap. This involves dragging in XkbClientMapRec so we don't get stuck in the KeySym trap. Signed-off-by: Daniel Stone <daniel@fooishbar.org>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
diff --git a/include/X11/extensions/XKBcommon.h b/include/X11/extensions/XKBcommon.h
index 2c17304..3d451f8 100644
--- a/include/X11/extensions/XKBcommon.h
+++ b/include/X11/extensions/XKBcommon.h
@@ -34,6 +34,9 @@ authorization from the authors.
 #include <X11/extensions/XKBstrcommon.h>
 #include <X11/extensions/XKBrulescommon.h>
 
+#define KeySym CARD32
+#define Atom CARD32
+
 /* Action structures used in the server */
 
 #define XkbcAnyActionDataSize 18
@@ -121,6 +124,35 @@ typedef union _XkbcAction {
     unsigned char           type;
 } XkbcAction;
 
+typedef struct _XkbcSymInterpretRec {
+    CARD32          sym;
+    unsigned char   flags;
+    unsigned char   match;
+    unsigned char   mods;
+    unsigned char   virtual_mod;
+    XkbcAnyAction    act;
+} XkbcSymInterpretRec,*XkbcSymInterpretPtr;
+
+typedef struct _XkbcCompatMapRec {
+    XkbcSymInterpretPtr      sym_interpret;
+    XkbModsRec               groups[XkbNumKbdGroups];
+    unsigned short           num_si;
+    unsigned short           size_si;
+} XkbcCompatMapRec, *XkbcCompatMapPtr;
+
+typedef struct _XkbcClientMapRec {
+    unsigned char            size_types;
+    unsigned char            num_types;
+    XkbKeyTypePtr            types;
+
+    unsigned short           size_syms;
+    unsigned short           num_syms;
+    uint32_t                *syms;
+    XkbSymMapPtr             key_sym_map;
+
+    unsigned char           *modmap;
+} XkbcClientMapRec, *XkbcClientMapPtr;
+
 typedef struct _XkbcServerMapRec {
     unsigned short      num_acts;
     unsigned short      size_acts;
@@ -150,7 +182,7 @@ typedef struct _XkbcDesc {
 
     XkbControlsPtr      ctrls;
     XkbcServerMapPtr    server;
-    XkbClientMapPtr     map;
+    XkbcClientMapPtr    map;
     XkbIndicatorPtr     indicators;
     XkbNamesPtr         names;
     XkbCompatMapPtr     compat;
@@ -199,17 +231,23 @@ XkbcCanonicaliseComponents(XkbComponentNamesPtr names,
  * The string returned may become invalidated after the next call to
  * XkbcKeysymToString: if you need to preserve it, then you must
  * duplicate it.
+ *
+ * This is CARD32 rather than KeySym, as KeySym changes size between
+ * client and server (no, really).
  */
 extern char *
-XkbcKeysymToString(KeySym ks);
+XkbcKeysymToString(CARD32 ks);
 
 /*
  * See XkbcKeysymToString comments: this function will accept any string
  * from that function.
  */
-extern KeySym
+extern CARD32
 XkbcStringToKeysym(const char *s);
 
 _XFUNCPROTOEND
 
+#undef KeySym
+#undef Atom
+
 #endif /* _XKBCOMMON_H_ */
diff --git a/src/alloc.c b/src/alloc.c
index fce6b8c..173a4c2 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -136,7 +136,7 @@ XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases)
         type = xkb->map->types;
         for (i = 0; i < xkb->map->num_types; i++, type++) {
             if (!type->level_names) {
-                type->level_names = _XkbTypedCalloc(type->num_levels, Atom);
+                type->level_names = _XkbTypedCalloc(type->num_levels, CARD32);
                 if (!type->level_names)
                     return BadAlloc;
             }
@@ -181,15 +181,15 @@ XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases)
 
     if ((which & XkbRGNamesMask) && (nTotalRG > 0)) {
         if (!names->radio_groups)
-            names->radio_groups = _XkbTypedCalloc(nTotalRG, Atom);
+            names->radio_groups = _XkbTypedCalloc(nTotalRG, CARD32);
         else if (nTotalRG > names->num_rg) {
-            Atom *prev_radio_groups = names->radio_groups;
+            CARD32 *prev_radio_groups = names->radio_groups;
 
             names->radio_groups = _XkbTypedRealloc(names->radio_groups,
-                                                   nTotalRG, Atom);
+                                                   nTotalRG, CARD32);
             if (names->radio_groups)
                 _XkbClearElems(names->radio_groups, names->num_rg,
-                               nTotalRG - 1, Atom);
+                               nTotalRG - 1, CARD32);
             else
                 _XkbFree(prev_radio_groups);
         }
@@ -216,7 +216,7 @@ XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap)
         which = XkbAllNamesMask;
 
     if (which & XkbKTLevelNamesMask) {
-        XkbClientMapPtr map = xkb->map;
+        XkbcClientMapPtr map = xkb->map;
 
         if (map && map->types) {
             int i;
diff --git a/src/keysym.c b/src/keysym.c
index 1b33151..42a91f5 100644
--- a/src/keysym.c
+++ b/src/keysym.c
@@ -38,7 +38,7 @@ authorization from the authors.
 #include "ks_tables.h"
 
 char *
-XkbcKeysymToString(KeySym ks)
+XkbcKeysymToString(CARD32 ks)
 {
     int i, n, h, idx;
     const unsigned char *entry;
@@ -91,7 +91,7 @@ XkbcKeysymToString(KeySym ks)
     return ret;
 }
 
-KeySym
+CARD32
 XkbcStringToKeysym(const char *s)
 {
     int i, n, h, c, idx;
@@ -99,7 +99,7 @@ XkbcStringToKeysym(const char *s)
     const char *p = s;
     const unsigned char *entry;
     unsigned char sig1, sig2;
-    KeySym val;
+    CARD32 val;
 
     while ((c = *p++))
         sig = (sig << 1) + c;
diff --git a/src/malloc.c b/src/malloc.c
index 1f814a0..9b842a5 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -32,7 +32,7 @@ int
 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes)
 {
     int i;
-    XkbClientMapPtr map;
+    XkbcClientMapPtr map;
 
     if (!xkb || ((nTotalTypes > 0) && (nTotalTypes < XkbNumRequiredTypes)))
         return BadValue;
@@ -49,7 +49,7 @@ XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes)
     }
 
     if (!xkb->map) {
-        map = _XkbTypedCalloc(1, XkbClientMapRec);
+        map = _XkbTypedCalloc(1, XkbcClientMapRec);
         if (!map)
             return BadAlloc;
         xkb->map = map;
@@ -88,7 +88,7 @@ XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes)
 
         if (!map->syms) {
             map->size_syms = (nKeys * 15) / 10;
-            map->syms = _XkbTypedCalloc(map->size_syms, KeySym);
+            map->syms = _XkbTypedCalloc(map->size_syms, uint32_t);
             if (!map->syms) {
                 map->size_syms = 0;
                 return BadAlloc;
@@ -268,11 +268,11 @@ XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into)
     }
 
     if (from->level_names && (into->num_levels > 0)) {
-        into->level_names = _XkbTypedCalloc(into->num_levels, Atom);
+        into->level_names = _XkbTypedCalloc(into->num_levels, CARD32);
         if (!into->level_names)
             return BadAlloc;
         memcpy(into->level_names, from->level_names,
-               into->num_levels * sizeof(Atom));
+               into->num_levels * sizeof(CARD32));
     }
 
     return Success;
@@ -362,10 +362,10 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
     }
 
     if ((new_num_lvls > type->num_levels) || !type->level_names) {
-        Atom *prev_level_names = type->level_names;
+        CARD32 *prev_level_names = type->level_names;
 
         type->level_names = _XkbTypedRealloc(type->level_names, new_num_lvls,
-                                             Atom);
+                                             CARD32);
         if (!type->level_names) {
             if (prev_level_names)
                 _XkbFree(prev_level_names);
@@ -398,7 +398,7 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
     nMatchingKeys = 0;
     if (new_num_lvls > type->num_levels) {
         int nTotal;
-        KeySym *newSyms;
+        CARD32 *newSyms;
         int width, match, nResize = 0;
         int i, g, nSyms;
 
@@ -427,7 +427,7 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
             int nextMatch;
 
             xkb->map->size_syms = (nTotal * 12) / 10;
-            newSyms = _XkbTypedCalloc(xkb->map->size_syms, KeySym);
+            newSyms = _XkbTypedCalloc(xkb->map->size_syms, CARD32);
             if (!newSyms)
                 return BadAlloc;
             nextMatch = 0;
@@ -435,20 +435,20 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
 
             for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
                 if (matchingKeys[nextMatch] == i) {
-                    KeySym *pOld;
+                    CARD32 *pOld;
 
                     nextMatch++;
                     width = XkbKeyGroupsWidth(xkb, i);
                     pOld = XkbKeySymsPtr(xkb, i);
                     for (g = XkbKeyNumGroups(xkb, i) - 1; g >= 0; g--)
                         memcpy(&newSyms[nSyms+(new_num_lvls * g)],
-                               &pOld[width * g], width * sizeof(KeySym));
+                               &pOld[width * g], width * sizeof(CARD32));
                     xkb->map->key_sym_map[i].offset = nSyms;
                     nSyms += XkbKeyNumGroups(xkb, i) * new_num_lvls;
                 }
                 else {
                     memcpy(&newSyms[nSyms], XkbKeySymsPtr(xkb, i),
-                           XkbKeyNumSyms(xkb, i) * sizeof(KeySym));
+                           XkbKeyNumSyms(xkb, i) * sizeof(CARD32));
                     xkb->map->key_sym_map[i].offset = nSyms;
                     nSyms += XkbKeyNumSyms(xkb,i);
                 }
@@ -491,7 +491,7 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
             firstClear = new_num_lvls;
 
         for (i = 0; i < nMatchingKeys; i++) {
-            KeySym *pSyms;
+            CARD32 *pSyms;
             int width, nClear;
 
             key = matchingKeys[i];
@@ -502,7 +502,7 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
                 if (XkbKeyKeyTypeIndex(xkb, key, g) == type_ndx) {
                     if (nClear>0)
                         bzero(&pSyms[g * width + firstClear],
-                              nClear * sizeof(KeySym));
+                              nClear * sizeof(CARD32));
                 }
             }
         }
@@ -513,12 +513,12 @@ XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
     return Success;
 }
 
-KeySym *
+CARD32 *
 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed)
 {
     int i, nSyms, nKeySyms;
     unsigned nOldSyms;
-    KeySym *newSyms;
+    CARD32 *newSyms;
 
     if (needed == 0) {
         xkb->map->key_sym_map[key].offset = 0;
@@ -532,11 +532,11 @@ XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed)
     if (xkb->map->size_syms - xkb->map->num_syms >= (unsigned)needed) {
         if (nOldSyms > 0)
             memcpy(&xkb->map->syms[xkb->map->num_syms],
-                   XkbKeySymsPtr(xkb, key), nOldSyms * sizeof(KeySym));
+                   XkbKeySymsPtr(xkb, key), nOldSyms * sizeof(CARD32));
 
         if ((needed - nOldSyms) > 0)
             bzero(&xkb->map->syms[xkb->map->num_syms + XkbKeyNumSyms(xkb, key)],
-                  (needed - nOldSyms) * sizeof(KeySym));
+                  (needed - nOldSyms) * sizeof(CARD32));
 
         xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
         xkb->map->num_syms += needed;
@@ -545,7 +545,7 @@ XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed)
     }
 
     xkb->map->size_syms += (needed > 32 ? needed : 32);
-    newSyms = _XkbTypedCalloc(xkb->map->size_syms, KeySym);
+    newSyms = _XkbTypedCalloc(xkb->map->size_syms, CARD32);
     if (!newSyms)
         return NULL;
 
@@ -562,9 +562,9 @@ XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed)
             nKeySyms = needed;
         if (nCopy != 0)
            memcpy(&newSyms[nSyms], XkbKeySymsPtr(xkb, i),
-                  nCopy * sizeof(KeySym));
+                  nCopy * sizeof(CARD32));
         if (nKeySyms > nCopy)
-            bzero(&newSyms[nSyms+nCopy], (nKeySyms - nCopy) * sizeof(KeySym));
+            bzero(&newSyms[nSyms+nCopy], (nKeySyms - nCopy) * sizeof(CARD32));
 
         xkb->map->key_sym_map[i].offset = nSyms;
         nSyms += nKeySyms;
@@ -878,7 +878,7 @@ XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed)
 void
 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap)
 {
-    XkbClientMapPtr map;
+    XkbcClientMapPtr map;
 
     if (!xkb || !xkb->map)
         return;
diff --git a/src/misc.c b/src/misc.c
index e49921a..d568fc8 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -86,7 +86,7 @@ static XkbKeyTypeRec canonicalTypes[XkbNumRequiredTypes] = {
 int
 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod)
 {
-    XkbClientMapPtr map;
+    XkbcClientMapPtr map;
     XkbKeyTypePtr from,to;
     int rtrn;
 
@@ -190,7 +190,7 @@ XkbcEnsureSafeMapName(char *name)
 }
 
 unsigned
-_XkbcKSCheckCase(KeySym ks)
+_XkbcKSCheckCase(CARD32 ks)
 {
     unsigned set = (ks & (~0xff)) >> 8;
     unsigned rtrn = 0;
diff --git a/src/text.c b/src/text.c
index 0c641a5..b6318e3 100644
--- a/src/text.c
+++ b/src/text.c
@@ -60,7 +60,7 @@ char *
 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx)
 {
     int len;
-    Atom *vmodNames;
+    CARD32 *vmodNames;
     char *rtrn, *tmp = NULL;
 
     if (xkb && xkb->names)
@@ -280,7 +280,7 @@ XkbcActionTypeText(unsigned type)
 }
 
 char *
-XkbcKeysymText(KeySym sym)
+XkbcKeysymText(CARD32 sym)
 {
     return XkbcKeysymToString(sym);
 }
diff --git a/src/xkballoc.h b/src/xkballoc.h
index 3d28843..0decf87 100644
--- a/src/xkballoc.h
+++ b/src/xkballoc.h
@@ -82,7 +82,7 @@ extern int
 XkbcResizeKeyType(XkbcDescPtr xkb, int type_ndx, int map_count,
                   Bool want_preserve, int new_num_lvls);
 
-extern KeySym *
+extern CARD32 *
 XkbcResizeKeySyms(XkbcDescPtr xkb, int key, int needed);
 
 extern int
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 1a0f8d3..6d67d08 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -1049,7 +1049,7 @@ ExprResolveKeySym(ExprDef * expr,
                   IdentLookupFunc lookup, char * lookupPriv)
 {
     int ok = 0;
-    KeySym sym;
+    CARD32 sym;
 
     if (expr->op == ExprIdent)
     {
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index b15fc3e..dec9893 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -1180,12 +1180,12 @@ CopyDefToKeyType(XkbcDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
     type->name = (Atom) def->name;
     if (def->szNames > 0)
     {
-        type->level_names = uTypedCalloc(def->numLevels, Atom);
+        type->level_names = uTypedCalloc(def->numLevels, CARD32);
 
         /* assert def->szNames<=def->numLevels */
         for (i = 0; i < def->szNames; i++)
         {
-            type->level_names[i] = (Atom) def->lvlNames[i];
+            type->level_names[i] = (CARD32) def->lvlNames[i];
         }
     }
     else
diff --git a/src/xkbcomp/misc.c b/src/xkbcomp/misc.c
index a847f6c..73766d5 100644
--- a/src/xkbcomp/misc.c
+++ b/src/xkbcomp/misc.c
@@ -258,8 +258,8 @@ AddCommonInfo(CommonInfo * old, CommonInfo * new)
 
 typedef struct _KeyNameDesc
 {
-    KeySym level1;
-    KeySym level2;
+    CARD32 level1;
+    CARD32 level2;
     char name[5];
     Bool used;
 } KeyNameDesc;
@@ -379,7 +379,7 @@ ComputeKbdDefaults(XkbcDescPtr xkb)
     int rtrn;
     register int i, tmp, nUnknown;
     KeyNameDesc *name;
-    KeySym *syms;
+    uint32_t *syms;
 
     if ((xkb->names == NULL) || (xkb->names->keys == NULL))
     {
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index 9f6c0e4..cea1572 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -219,7 +219,7 @@ BoolVarCreate(Atom nameToken, unsigned set)
 }
 
 InterpDef *
-InterpCreate(KeySym sym, ExprDef * match)
+InterpCreate(CARD32 sym, ExprDef * match)
 {
     InterpDef *def;
 
@@ -621,9 +621,9 @@ AppendKeysymList(ExprDef * list, char *sym)
 }
 
 int
-LookupKeysym(char *str, KeySym * sym_rtrn)
+LookupKeysym(char *str, CARD32 * sym_rtrn)
 {
-    KeySym sym;
+    CARD32 sym;
 
     if ((!str) || (uStrCaseCmp(str, "any") == 0)
         || (uStrCaseCmp(str, "nosymbol") == 0))
diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h
index 0fecb42..9bc0a6b 100644
--- a/src/xkbcomp/parseutils.h
+++ b/src/xkbcomp/parseutils.h
@@ -88,7 +88,7 @@ extern VarDef *BoolVarCreate(Atom /* nameToken */ ,
                              unsigned   /* set */
     );
 
-extern InterpDef *InterpCreate(KeySym /* sym */ ,
+extern InterpDef *InterpCreate(CARD32 /* sym */ ,
                                ExprDef *        /* match */
     );
 
@@ -165,7 +165,7 @@ extern ExprDef *AppendKeysymList(ExprDef * /* list */ ,
     );
 
 extern int LookupKeysym(char * /* str */ ,
-                        KeySym *        /* sym_rtrn */
+                        CARD32 *        /* sym_rtrn */
     );
 
 extern IncludeStmt *IncludeCreate(char * /* str */ ,
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index ce97a6f..db64977 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -70,7 +70,7 @@ typedef struct _KeyInfo
     unsigned char symsDefined;
     unsigned char actsDefined;
     short numLevels[XkbNumKbdGroups];
-    KeySym *syms[XkbNumKbdGroups];
+    CARD32 *syms[XkbNumKbdGroups];
     XkbcAction *acts[XkbNumKbdGroups];
     Atom types[XkbNumKbdGroups];
     unsigned repeat;
@@ -178,7 +178,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
             width = new->numLevels[i];
             if (old->syms[i] != NULL)
             {
-                new->syms[i] = uTypedCalloc(width, KeySym);
+                new->syms[i] = uTypedCalloc(width, CARD32);
                 if (!new->syms[i])
                 {
                     new->syms[i] = NULL;
@@ -186,7 +186,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
                     return False;
                 }
                 memcpy((char *) new->syms[i], (char *) old->syms[i],
-                       width * sizeof(KeySym));
+                       width * sizeof(CARD32));
             }
             if (old->acts[i] != NULL)
             {
@@ -214,7 +214,7 @@ typedef struct _ModMapEntry
     union
     {
         unsigned long keyName;
-        KeySym keySym;
+        CARD32 keySym;
     } u;
 } ModMapEntry;
 
@@ -315,7 +315,7 @@ ResizeKeyGroup(KeyInfo * key,
     {
         key->syms[group] = uTypedRecalloc(key->syms[group],
                                           key->numLevels[group], newWidth,
-                                          KeySym);
+                                          CARD32);
         if (!key->syms[group])
             return False;
     }
@@ -336,7 +336,7 @@ static Bool
 MergeKeyGroups(SymbolsInfo * info,
                KeyInfo * into, KeyInfo * from, unsigned group)
 {
-    KeySym *resultSyms;
+    CARD32 *resultSyms;
     XkbcAction *resultActs;
     int resultWidth;
     register int i;
@@ -359,7 +359,7 @@ MergeKeyGroups(SymbolsInfo * info,
     }
     if (resultSyms == NULL)
     {
-        resultSyms = uTypedCalloc(resultWidth, KeySym);
+        resultSyms = uTypedCalloc(resultWidth, CARD32);
         if (!resultSyms)
         {
             WSGO("Could not allocate symbols for group merge\n");
@@ -381,7 +381,7 @@ MergeKeyGroups(SymbolsInfo * info,
     }
     for (i = 0; i < resultWidth; i++)
     {
-        KeySym fromSym, toSym;
+        CARD32 fromSym, toSym;
         if (from->syms[group] && (i < from->numLevels[group]))
             fromSym = from->syms[group][i];
         else
@@ -396,7 +396,7 @@ MergeKeyGroups(SymbolsInfo * info,
             resultSyms[i] = fromSym;
         else
         {
-            KeySym use, ignore;
+            CARD32 use, ignore;
             if (clobber)
             {
                 use = fromSym;
@@ -1565,7 +1565,7 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
             key->numLevels[i] = 0;
             if (key->syms[i] != NULL)
                 uFree(key->syms[i]);
-            key->syms[i] = (KeySym *) NULL;
+            key->syms[i] = (CARD32 *) NULL;
             if (key->acts[i] != NULL)
                 uFree(key->acts[i]);
             key->acts[i] = (XkbcAction *) NULL;
@@ -1577,7 +1577,7 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
     key->numLevels[group] = key->numLevels[0];
     key->numLevels[0] = 0;
     key->syms[group] = key->syms[0];
-    key->syms[0] = (KeySym *) NULL;
+    key->syms[0] = (CARD32 *) NULL;
     key->acts[group] = key->acts[0];
     key->acts[0] = (XkbcAction *) NULL;
     key->types[group] = key->types[0];
@@ -1720,7 +1720,7 @@ HandleSymbolsFile(XkbFile * file,
 }
 
 static Bool
-FindKeyForSymbol(XkbcDescPtr xkb, KeySym sym, unsigned int *kc_rtrn)
+FindKeyForSymbol(XkbcDescPtr xkb, CARD32 sym, unsigned int *kc_rtrn)
 {
     register int i, j;
     register Bool gotOne;
@@ -1791,7 +1791,7 @@ FindNamedType(XkbcDescPtr xkb, Atom name, unsigned *type_rtrn)
  * @returns True if a type could be found, False otherwise.
  */
 static Bool
-FindAutomaticType(int width, KeySym * syms, Atom * typeNameRtrn,
+FindAutomaticType(int width, CARD32 * syms, Atom * typeNameRtrn,
                   Bool * autoType)
 {
     *autoType = False;
@@ -1885,11 +1885,11 @@ PrepareKeyDef(KeyInfo * key)
         }
         if ((key->symsDefined & 1) && key->syms[0])
         {
-            key->syms[i] = uTypedCalloc(width, KeySym);
+            key->syms[i] = uTypedCalloc(width, CARD32);
             if (key->syms[i] == NULL)
                 continue;
             memcpy((void *) key->syms[i], (void *) key->syms[0],
-                   width * sizeof(KeySym));
+                   width * sizeof(CARD32));
             key->symsDefined |= 1 << i;
         }
         if (defined & 1)
@@ -1911,7 +1911,7 @@ PrepareKeyDef(KeyInfo * key)
         if ((key->syms[i] != key->syms[0]) &&
             (key->syms[i] == NULL || key->syms[0] == NULL ||
              memcmp((void *) key->syms[i], (void *) key->syms[0],
-                    sizeof(KeySym) * key->numLevels[0])))
+                    sizeof(CARD32) * key->numLevels[0])))
         {
             identical = False;
             break;
@@ -1932,7 +1932,7 @@ PrepareKeyDef(KeyInfo * key)
             key->numLevels[i] = 0;
             if (key->syms[i] != NULL)
                 uFree(key->syms[i]);
-            key->syms[i] = (KeySym *) NULL;
+            key->syms[i] = (CARD32 *) NULL;
             if (key->acts[i] != NULL)
                 uFree(key->acts[i]);
             key->acts[i] = (XkbcAction *) NULL;
@@ -1957,7 +1957,7 @@ CopySymbolsDef(XkbcDescPtr xkb, KeyInfo *key, int start_from)
     unsigned okc, kc, width, tmp, nGroups;
     XkbKeyTypePtr type;
     Bool haveActions, autoType, useAlias;
-    KeySym *outSyms;
+    CARD32 *outSyms;
     XkbcAction *outActs;
     unsigned types[XkbNumKbdGroups];
 
diff --git a/src/xkbcomp/xkbcomp.h b/src/xkbcomp/xkbcomp.h
index c120e24..d44f989 100644
--- a/src/xkbcomp/xkbcomp.h
+++ b/src/xkbcomp/xkbcomp.h
@@ -242,7 +242,7 @@ typedef struct _InterpDef
 {
     ParseCommon common;
     unsigned merge;
-    KeySym sym;
+    CARD32 sym;
     ExprDef *match;
     VarDef *def;
 } InterpDef;
diff --git a/src/xkbmisc.h b/src/xkbmisc.h
index 324a648..21c970d 100644
--- a/src/xkbmisc.h
+++ b/src/xkbmisc.h
@@ -52,7 +52,7 @@ extern void
 XkbcEnsureSafeMapName(char *name);
 
 extern unsigned
-_XkbcKSCheckCase(KeySym sym);
+_XkbcKSCheckCase(CARD32 sym);
 
 #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbKSLower)
 #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbKSUpper)
@@ -95,7 +95,7 @@ extern char *
 XkbcActionTypeText(unsigned type);
 
 extern char *
-XkbcKeysymText(KeySym sym);
+XkbcKeysymText(CARD32 sym);
 
 extern char *
 XkbcKeyNameText(char *name);