summary refs log tree commit diff
path: root/externals/aterm-64-bit.patch
blob: 4618d0883ca3087adf87aa574e45bbbc3522aeac (plain) (blame)
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
diff -rc aterm-2.4.2-orig/aterm/bafio.c aterm-2.4.2/aterm/bafio.c
*** aterm-2.4.2-orig/aterm/bafio.c	2004-02-02 12:24:34.000000000 +0100
--- aterm-2.4.2/aterm/bafio.c	2006-09-22 13:39:07.000000000 +0200
***************
*** 222,227 ****
--- 222,229 ----
      }
    }
  
+   if (val) return -1;
+ 
    /* Ok */
    return 0;
  }
***************
*** 544,551 ****
    * terms have been sorted by symbol.
  	*/
  
! void gather_top_symbols(sym_entry *cur_entry, int cur_arg, 
! 			int total_top_symbols)
  {
    int index;
    unsigned int hnr;
--- 546,553 ----
    * terms have been sorted by symbol.
  	*/
  
! static void gather_top_symbols(sym_entry *cur_entry, int cur_arg, 
! 			       int total_top_symbols)
  {
    int index;
    unsigned int hnr;
***************
*** 899,905 ****
    } else {
      switch(ATgetType(t)) {
      case AT_INT:
!       if(writeBits(ATgetInt((ATermInt)t), HEADER_BITS, writer) < 0) {
  	return ATfalse;
        }
  #if 0
--- 901,908 ----
    } else {
      switch(ATgetType(t)) {
      case AT_INT:
!       /* If ATerm integers are > 32 bits, then this can fail. */
!       if(writeBits(ATgetInt((ATermInt)t), INT_SIZE_IN_BAF, writer) < 0) {
  	return ATfalse;
        }
  #if 0
***************
*** 1033,1039 ****
  /*}}}  */
  /*{{{  ATbool write_baf(ATerm t, byte_writer *writer) */
  
! ATbool
  write_baf(ATerm t, byte_writer *writer)
  {
    int nr_unique_terms = 0;
--- 1036,1042 ----
  /*}}}  */
  /*{{{  ATbool write_baf(ATerm t, byte_writer *writer) */
  
! static ATbool
  write_baf(ATerm t, byte_writer *writer)
  {
    int nr_unique_terms = 0;
***************
*** 1233,1239 ****
  	* Read a single symbol from file.
  	*/
  
! Symbol read_symbol(byte_reader *reader)
  {
    unsigned int arity, quoted;
    int len;
--- 1236,1242 ----
  	* Read a single symbol from file.
  	*/
  
! static Symbol read_symbol(byte_reader *reader)
  {
    unsigned int arity, quoted;
    int len;
***************
*** 1260,1266 ****
   * Read all symbols from file.
   */
  
! ATbool read_all_symbols(byte_reader *reader)
  {
    unsigned int val;
    int i, j, k, arity;
--- 1263,1269 ----
   * Read all symbols from file.
   */
  
! static ATbool read_all_symbols(byte_reader *reader)
  {
    unsigned int val;
    int i, j, k, arity;
***************
*** 1280,1293 ****
      /*}}}  */
      /*{{{  Read term count and allocate space */
  
!     if(readInt(&val, reader) < 0)
        return ATfalse;
      read_symbols[i].nr_terms = val;
      read_symbols[i].term_width = bit_width(val);
!     if(val == 0)
!       read_symbols[i].terms = NULL;
!     else
!       read_symbols[i].terms = (ATerm *)calloc(val, sizeof(ATerm));
      if(!read_symbols[i].terms)
        ATerror("read_symbols: could not allocate space for %d terms.\n", val);
      ATprotectArray(read_symbols[i].terms, val);
--- 1283,1293 ----
      /*}}}  */
      /*{{{  Read term count and allocate space */
  
!     if(readInt(&val, reader) < 0 || val == 0)
        return ATfalse;
      read_symbols[i].nr_terms = val;
      read_symbols[i].term_width = bit_width(val);
!     read_symbols[i].terms = (ATerm *)calloc(val, sizeof(ATerm));
      if(!read_symbols[i].terms)
        ATerror("read_symbols: could not allocate space for %d terms.\n", val);
      ATprotectArray(read_symbols[i].terms, val);
***************
*** 1351,1357 ****
  /*}}}  */
  /*{{{  ATerm read_term(sym_read_entry *sym, byte_reader *reader) */
  
! ATerm read_term(sym_read_entry *sym, byte_reader *reader)
  {
    unsigned int val;
    int i, arity = sym->arity;
--- 1351,1357 ----
  /*}}}  */
  /*{{{  ATerm read_term(sym_read_entry *sym, byte_reader *reader) */
  
! static ATerm read_term(sym_read_entry *sym, byte_reader *reader)
  {
    unsigned int val;
    int i, arity = sym->arity;
***************
*** 1365,1370 ****
--- 1365,1371 ----
      ATprotectArray(args, arity);
      if(!args)
        ATerror("could not allocate space for %d arguments.\n", arity);
+     /* !!! leaks memory on the "return NULL" paths */
    }
  
    /*ATfprintf(stderr, "reading term over symbol %y\n", sym->sym);*/
***************
*** 1372,1377 ****
--- 1373,1380 ----
      /*ATfprintf(stderr, "  reading argument %d (%d)", i, sym->sym_width[i]);*/
      if(readBits(&val, sym->sym_width[i], reader) < 0)
        return NULL;
+     if(val >= sym->nr_topsyms[i])
+       return NULL;
      arg_sym = &read_symbols[sym->topsyms[i][val]];
      /*		ATfprintf(stderr, "argument %d, symbol index = %d, symbol = %y\n", 
  		i, val, arg_sym->sym);*/
***************
*** 1381,1386 ****
--- 1384,1391 ----
      if(readBits(&val, arg_sym->term_width, reader) < 0)
        return NULL;
      /*		ATfprintf(stderr, "arg term index = %d\n", val);*/
+     if(val >= arg_sym->nr_terms)
+       return NULL;
      if(!arg_sym->terms[val]) {
        arg_sym->terms[val] = read_term(arg_sym, reader);
        if(!arg_sym->terms[val])
***************
*** 1396,1402 ****
    case AS_INT:
      /*{{{  Read an integer */
  
!     if(readBits(&val, HEADER_BITS, reader) < 0)
        return NULL;
  
      result = (ATerm)ATmakeInt((int)val);
--- 1401,1407 ----
    case AS_INT:
      /*{{{  Read an integer */
  
!     if(readBits(&val, INT_SIZE_IN_BAF, reader) < 0)
        return NULL;
  
      result = (ATerm)ATmakeInt((int)val);
***************
*** 1494,1502 ****
    for(i=0; i<nr_unique_symbols; i++) {
      sym_read_entry *entry = &read_symbols[i];
  
!     ATunprotectArray(entry->terms);
!     if(entry->terms)
        free(entry->terms);
      if(entry->nr_topsyms)
        free(entry->nr_topsyms);
      if(entry->sym_width)
--- 1499,1508 ----
    for(i=0; i<nr_unique_symbols; i++) {
      sym_read_entry *entry = &read_symbols[i];
  
!     if(entry->terms) {
!       ATunprotectArray(entry->terms);
        free(entry->terms);
+     }
      if(entry->nr_topsyms)
        free(entry->nr_topsyms);
      if(entry->sym_width)
Only in aterm-2.4.2/aterm: config.h.in
diff -rc aterm-2.4.2-orig/aterm/encoding.h aterm-2.4.2/aterm/encoding.h
*** aterm-2.4.2-orig/aterm/encoding.h	2004-06-01 10:29:02.000000000 +0200
--- aterm-2.4.2/aterm/encoding.h	2006-09-22 13:39:07.000000000 +0200
***************
*** 10,15 ****
--- 10,17 ----
  {
  #endif/* __cplusplus */
  
+ #include "config.h"
+ 
  /*
   |--------------------------------|
   |info|type |arity|quoted|mark|age|
***************
*** 31,37 ****
  #define SHIFT_REMOVE_MARK_AGE 3
  #define MASK_AGE_MARK   (MASK_AGE|MASK_MARK)
  
! #if AT_64BIT
  #define SHIFT_LENGTH  34
  #define HEADER_BITS 64
  typedef unsigned long header_type;
--- 33,39 ----
  #define SHIFT_REMOVE_MARK_AGE 3
  #define MASK_AGE_MARK   (MASK_AGE|MASK_MARK)
  
! #ifdef AT_64BIT
  #define SHIFT_LENGTH  34
  #define HEADER_BITS 64
  typedef unsigned long header_type;
***************
*** 137,142 ****
--- 139,150 ----
  #define AT_TABLE_SIZE(table_class)  (1<<(table_class))
  #define AT_TABLE_MASK(table_class)  (AT_TABLE_SIZE(table_class)-1)
  
+ 
+ /* Integers in BAF are always exactly 32 bits.  The size must be fixed so that
+  * BAF terms can be exchanged between platforms. */
+ #define INT_SIZE_IN_BAF 32
+ 
+ 
  #ifdef __cplusplus
  }
  #endif/* __cplusplus */ 
diff -rc aterm-2.4.2-orig/aterm/gc.c aterm-2.4.2/aterm/gc.c
*** aterm-2.4.2-orig/aterm/gc.c	2004-06-01 10:29:02.000000000 +0200
--- aterm-2.4.2/aterm/gc.c	2006-09-22 13:39:07.000000000 +0200
***************
*** 154,166 ****
      }
  
  #ifdef AT_64BIT
!     odd_term = *((ATerm *)((MachineWord)cur)+4);
      real_term = AT_isInsideValidTerm(odd_term);
      if (real_term != NULL) {
        AT_markTerm(odd_term);
      }
  
!     odd_sym = *((AFun *)((MachineWord)cur)+4);
      if (AT_isValidSymbol(odd_sym)) {
          /*fprintf(stderr,"mark_memory: AT_markSymbol(%d)\n",odd_sym);*/
        AT_markSymbol(odd_sym);
--- 154,166 ----
      }
  
  #ifdef AT_64BIT
!     odd_term = *((ATerm *)(((MachineWord)cur)+4));
      real_term = AT_isInsideValidTerm(odd_term);
      if (real_term != NULL) {
        AT_markTerm(odd_term);
      }
  
!     odd_sym = *((AFun *)(((MachineWord)cur)+4));
      if (AT_isValidSymbol(odd_sym)) {
          /*fprintf(stderr,"mark_memory: AT_markSymbol(%d)\n",odd_sym);*/
        AT_markSymbol(odd_sym);
***************
*** 198,210 ****
      }
  
  #ifdef AT_64BIT
!     odd_term = *((ATerm *)((MachineWord)cur)+4);
      real_term = AT_isInsideValidTerm(odd_term);
      if (real_term != NULL) {
        AT_markTerm_young(odd_term);
      }
  
!     odd_sym = *((AFun *)((MachineWord)cur)+4);
      if (AT_isValidSymbol(odd_sym)) {
          /*fprintf(stderr,"mark_memory_young: AT_markSymbol_young(%d)\n",odd_sym);*/
        AT_markSymbol_young(odd_sym);
--- 198,210 ----
      }
  
  #ifdef AT_64BIT
!     odd_term = *((ATerm *)(((MachineWord)cur)+4));
      real_term = AT_isInsideValidTerm(odd_term);
      if (real_term != NULL) {
        AT_markTerm_young(odd_term);
      }
  
!     odd_sym = *((AFun *)(((MachineWord)cur)+4));
      if (AT_isValidSymbol(odd_sym)) {
          /*fprintf(stderr,"mark_memory_young: AT_markSymbol_young(%d)\n",odd_sym);*/
        AT_markSymbol_young(odd_sym);
***************
*** 225,235 ****
    ATerm *start, *stop;
    ProtEntry *prot;
  
- #ifdef AT_64BIT
-   ATerm oddTerm;
-   AFun oddSym;
- #endif
- 
  #ifdef WIN32
  
    unsigned int r_eax, r_ebx, r_ecx, r_edx, \
--- 225,230 ----
***************
*** 287,293 ****
    /* Traverse possible register variables */
    sigsetjmp(env,0);
  
!   start = (ATerm *)env;
    stop  = ((ATerm *)(((char *)env) + sizeof(sigjmp_buf)));
    mark_memory(start, stop);
  #endif
--- 282,288 ----
    /* Traverse possible register variables */
    sigsetjmp(env,0);
  
!   start = (ATerm *)env; /* !!! illegal aliasing  */
    stop  = ((ATerm *)(((char *)env) + sizeof(sigjmp_buf)));
    mark_memory(start, stop);
  #endif
***************
*** 338,348 ****
    ATerm *start, *stop;
    ProtEntry *prot;
  
- #ifdef AT_64BIT
-   ATerm oddTerm;
-   AFun oddSym;
- #endif
- 
  #ifdef WIN32
  
    unsigned int r_eax, r_ebx, r_ecx, r_edx, \
--- 333,338 ----
***************
*** 400,406 ****
      /* Traverse possible register variables */
    sigsetjmp(env,0);
  
!   start = (ATerm *)env;
    stop  = ((ATerm *)(((char *)env) + sizeof(sigjmp_buf)));
    mark_memory_young(start, stop);
  #endif
--- 390,396 ----
      /* Traverse possible register variables */
    sigsetjmp(env,0);
  
!   start = (ATerm *)env; /* !!! illegal aliasing  */
    stop  = ((ATerm *)(((char *)env) + sizeof(sigjmp_buf)));
    mark_memory_young(start, stop);
  #endif
***************
*** 1047,1053 ****
        /*fprintf(stderr,"minor_sweep_phase_young: ensure empty freelist[%d]\n",size);*/
        for(data = at_freelist[size] ; data ; data=data->next) {
          if(!EQUAL_HEADER(data->header,FREE_HEADER)) {
!           fprintf(stderr,"data = %x header = %x\n",(unsigned int)data,data->header);
          }
          assert(EQUAL_HEADER(data->header,FREE_HEADER)); 
          assert(ATgetType(data) == AT_FREE);   
--- 1037,1043 ----
        /*fprintf(stderr,"minor_sweep_phase_young: ensure empty freelist[%d]\n",size);*/
        for(data = at_freelist[size] ; data ; data=data->next) {
          if(!EQUAL_HEADER(data->header,FREE_HEADER)) {
!           fprintf(stderr,"data = %p header = %x\n",data,(unsigned int) data->header);
          }
          assert(EQUAL_HEADER(data->header,FREE_HEADER)); 
          assert(ATgetType(data) == AT_FREE);   
diff -rc aterm-2.4.2-orig/aterm/Makefile.am aterm-2.4.2/aterm/Makefile.am
*** aterm-2.4.2-orig/aterm/Makefile.am	2005-08-03 11:45:19.000000000 +0200
--- aterm-2.4.2/aterm/Makefile.am	2006-09-22 13:39:07.000000000 +0200
***************
*** 37,43 ****
    aterm2.h \
    atypes.h \
    deprecated.h \
!   encoding.h
  
  PRIVATE_INCL = \
    _afun.h \
--- 37,44 ----
    aterm2.h \
    atypes.h \
    deprecated.h \
!   encoding.h \
!   config.h
  
  PRIVATE_INCL = \
    _afun.h \
diff -rc aterm-2.4.2-orig/aterm/md5.h aterm-2.4.2/aterm/md5.h
*** aterm-2.4.2-orig/aterm/md5.h	2003-09-02 15:32:46.000000000 +0200
--- aterm-2.4.2/aterm/md5.h	2006-09-22 13:39:07.000000000 +0200
***************
*** 24,29 ****
--- 24,31 ----
  documentation and/or software.
   */
  
+ #include <stdint.h>
+ 
  /* GLOBAL.H - RSAREF types and constants
   */
  
***************
*** 46,55 ****
  typedef unsigned char *POINTER;
  
  /* UINT2 defines a two byte word */
! typedef unsigned short int UINT2;
  
  /* UINT4 defines a four byte word */
! typedef unsigned long int UINT4;
  
  /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
  If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
--- 48,57 ----
  typedef unsigned char *POINTER;
  
  /* UINT2 defines a two byte word */
! typedef uint16_t UINT2;
  
  /* UINT4 defines a four byte word */
! typedef uint32_t UINT4;
  
  /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
  If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
diff -rc aterm-2.4.2-orig/aterm/memory.c aterm-2.4.2/aterm/memory.c
*** aterm-2.4.2-orig/aterm/memory.c	2005-10-11 13:19:25.000000000 +0200
--- aterm-2.4.2/aterm/memory.c	2006-09-22 13:39:16.000000000 +0200
***************
*** 96,102 ****
  #define HASHNUMBER4(t) hash_number(t,4)
  #define HASHINT(val)   (tmp[0]=(MachineWord)(AT_INT<<SHIFT_TYPE),\
                          tmp[1]=(MachineWord)0,\
!                         tmp[2]=(MachineWord)val,\
                          hash_number(tmp,3)) 
  
  #else
--- 96,102 ----
  #define HASHNUMBER4(t) hash_number(t,4)
  #define HASHINT(val)   (tmp[0]=(MachineWord)(AT_INT<<SHIFT_TYPE),\
                          tmp[1]=(MachineWord)0,\
!                         tmp[2]=(MachineWord)((unsigned int) val),\
                          hash_number(tmp,3)) 
  
  #else
***************
*** 127,133 ****
  		       ((MachineWord*)t)[2]),((MachineWord*)t)[3]))
  
  #define HASHINT(val) \
! FINISH(COMBINE(START( (AT_INT<<SHIFT_TYPE) ), val))
  
  
  #endif /* HASHPEM */
--- 127,133 ----
  		       ((MachineWord*)t)[2]),((MachineWord*)t)[3]))
  
  #define HASHINT(val) \
! FINISH(COMBINE(START( (AT_INT<<SHIFT_TYPE) ), (unsigned int) val))
  
  
  #endif /* HASHPEM */
***************
*** 708,714 ****
    at_blocks[size] = newblock;
    top_at_blocks[size] = newblock->data;
    assert(at_blocks[size] != NULL);
!   assert(((int)top_at_blocks[size] % MAX(sizeof(double), sizeof(void *))) == 0);
    
      /* [pem: Feb 14 02] TODO: fast allocation */
    assert(at_freelist[size] == NULL);
--- 708,714 ----
    at_blocks[size] = newblock;
    top_at_blocks[size] = newblock->data;
    assert(at_blocks[size] != NULL);
!   assert(((long)top_at_blocks[size] % MAX(sizeof(double), sizeof(void *))) == 0);
    
      /* [pem: Feb 14 02] TODO: fast allocation */
    assert(at_freelist[size] == NULL);
***************
*** 1009,1018 ****
    do {
      if(!cur) {
          /*printf("freeterm = %d\n",t);*/
!       fprintf(stderr,"### cannot find term %x in hashtable at pos %d header = %x\n", (unsigned int)t, hnr, t->header);
! 
!       ATabort("### cannot find term %n at %p in hashtable at pos %d"
! 	      ", header = %d\n", t, t, hnr, t->header);
      }
      if (cur == t) {
        if(prev)
--- 1009,1016 ----
    do {
      if(!cur) {
          /*printf("freeterm = %d\n",t);*/
!       ATabort("### cannot find term %p in hashtable at pos %d"
! 	      ", header = %x\n", t, hnr, t->header);
      }
      if (cur == t) {
        if(prev)
***************
*** 1728,1733 ****
--- 1726,1733 ----
      hashtable[hnr] = cur;
    }
  
+   assert((hnr & table_mask) == (hash_number(cur, TERM_SIZE_INT) & table_mask));
+ 
    return (ATermInt)cur;  
  }
  
diff -rc aterm-2.4.2-orig/aterm.m4 aterm-2.4.2/aterm.m4
*** aterm-2.4.2-orig/aterm.m4	2005-08-03 11:45:19.000000000 +0200
--- aterm-2.4.2/aterm.m4	2006-09-22 13:39:07.000000000 +0200
***************
*** 8,15 ****
      [AS_HELP_STRING([--with-sharing],[create libraries that do term sharing @<:@yes@:>@])],
      [if test "$withval" = "no"; then
         AC_MSG_RESULT([no])
!        AC_DEFINE([NO_SHARING])
!        AC_DEFINE([WITH_STATS])
       else
         if test "$withval" != "yes"; then
           AC_MSG_RESULT([unknown value specified for --with-sharing.])
--- 8,15 ----
      [AS_HELP_STRING([--with-sharing],[create libraries that do term sharing @<:@yes@:>@])],
      [if test "$withval" = "no"; then
         AC_MSG_RESULT([no])
!        AC_DEFINE([NO_SHARING], [], [Whether terms are shared.])
!        AC_DEFINE([WITH_STATS], [], [Whether to keep statistics.])
       else
         if test "$withval" != "yes"; then
           AC_MSG_RESULT([unknown value specified for --with-sharing.])
***************
*** 73,78 ****
--- 73,102 ----
    AC_SUBST([OPTIMIZECFLAGS])
  ])
  
+ # ATERM_64_BIT
+ # ------------
+ # Enable 64-bit mode if pointers are 8 bytes large.
+ AC_DEFUN([ATERM_64_BIT], [
+   AC_CHECK_SIZEOF(void *)
+   AC_CHECK_SIZEOF(int)
+   AC_CHECK_SIZEOF(long)
+ 
+   AC_MSG_CHECKING([what kind of platform this is])
+ 
+   AC_SUBST([AT_64BIT], [0])
+   if test "$ac_cv_sizeof_void_p" = "8" -a "$ac_cv_sizeof_int" = "4" -a "$ac_cv_sizeof_long" = "8"; then
+     AC_MSG_RESULT([LP64])
+     AC_SUBST([AT_64BIT], [1])
+   elif test "$ac_cv_sizeof_void_p" = "8" -a "$ac_cv_sizeof_int" = "8" -a "$ac_cv_sizeof_long" = "8"; then
+     AC_MSG_RESULT([ILP64 - warning, untested])
+     AC_SUBST([AT_64BIT], [1])
+   elif test "$ac_cv_sizeof_void_p" = "4" -a "$ac_cv_sizeof_int" = "4" -a "$ac_cv_sizeof_long" = "4"; then
+     AC_MSG_RESULT([32 bits])
+   else
+     AC_MSG_RESULT([something weird - warning, untested])
+   fi
+ ])
+ 
  # XT_SVN_REVISION
  # ---------------
  AC_DEFUN([XT_SVN_REVISION],
diff -rc aterm-2.4.2-orig/configure.ac aterm-2.4.2/configure.ac
*** aterm-2.4.2-orig/configure.ac	2005-08-03 11:45:19.000000000 +0200
--- aterm-2.4.2/configure.ac	2006-09-22 13:39:07.000000000 +0200
***************
*** 30,35 ****
--- 30,38 ----
  # Add a configuration option to allow users to control sharing.
  ATERM_WITH_SHARING
  
+ # Enable 64-bit mode if pointers are 8 bytes large.
+ ATERM_64_BIT
+ 
  CURDATE=`date`
  AC_SUBST([CURDATE])
  
***************
*** 45,49 ****
--- 48,53 ----
    doc/spec/Makefile
    aterm.spec
    aterm.pc
+   aterm/config.h
  ])
  AC_OUTPUT
diff -rc aterm-2.4.2-orig/utils/dicttoc.c aterm-2.4.2/utils/dicttoc.c
*** aterm-2.4.2-orig/utils/dicttoc.c	2003-10-07 13:57:40.000000000 +0200
--- aterm-2.4.2/utils/dicttoc.c	2006-09-22 13:39:07.000000000 +0200
***************
*** 69,74 ****
--- 69,75 ----
    fprintf(file, "#ifndef __%s_H\n", code_prefix);
    fprintf(file, "#define __%s_H\n\n", code_prefix);
    fprintf(file, "#include <aterm2.h>\n\n");
+   fprintf(file, "#include <assert.h>\n\n");
  
    while (!ATisEmpty(afuns)) {
      ATerm afun, alias, pair = ATgetFirst(afuns);
***************
*** 244,251 ****
    ATfprintf(file, "{\n");
    ATfprintf(file, "  ATermList afuns, terms;\n\n");
  
!   ATfprintf(file, "  _%s = ATreadFromBinaryString(_%s_baf, _%s_LEN);\n\n", 
  	    code_prefix, code_prefix, code_prefix);
    ATfprintf(file, "  ATprotect(&_%s);\n\n", code_prefix);
  
    ATfprintf(file, "  afuns = (ATermList)ATelementAt((ATermList)_%s, 0);\n\n", code_prefix);
--- 245,253 ----
    ATfprintf(file, "{\n");
    ATfprintf(file, "  ATermList afuns, terms;\n\n");
  
!   ATfprintf(file, "  _%s = ATreadFromBinaryString(_%s_baf, _%s_LEN);\n", 
  	    code_prefix, code_prefix, code_prefix);
+   ATfprintf(file, "  assert(_%s);\n\n", code_prefix);
    ATfprintf(file, "  ATprotect(&_%s);\n\n", code_prefix);
  
    ATfprintf(file, "  afuns = (ATermList)ATelementAt((ATermList)_%s, 0);\n\n", code_prefix);