diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-11-14 15:36:27 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-11-14 15:36:27 +0000 |
commit | bce9ff7ece912d18f1d92e6759b82ef5b8ad20aa (patch) | |
tree | b7a1b6118ffbb7c34e5e63c9785942ba81e0c1be /externals | |
parent | 745e354b19a00dba9fd6d058036ce412ba30e23a (diff) |
* Use the patched ATerm library.
Diffstat (limited to 'externals')
-rw-r--r-- | externals/Makefile.am | 12 | ||||
-rw-r--r-- | externals/aterm-64-bit.patch | 661 | ||||
-rw-r--r-- | externals/aterm-aliasing.patch | 224 |
3 files changed, 5 insertions, 892 deletions
diff --git a/externals/Makefile.am b/externals/Makefile.am index 0eb229954..937e095a3 100644 --- a/externals/Makefile.am +++ b/externals/Makefile.am @@ -35,19 +35,17 @@ endif # CWI ATerm -ATERM = aterm-2.4.2 +ATERM = aterm-2.4.2-fixes $(ATERM).tar.gz: @echo "Nix requires the CWI ATerm library to build." - @echo "Please download version 2.4.2 from" - @echo " http://www.cwi.nl/projects/MetaEnv/aterm/aterm-2.4.2.tar.gz" + @echo "Please download version 2.4.2-fixes from" + @echo " http://losser.st-lab.cs.uu.nl/~eelco/dist/aterm-2.4.2-fixes.tar.bz2" @echo "and place it in the externals/ directory." false -$(ATERM): $(ATERM).tar.gz - gunzip < $(srcdir)/$(ATERM).tar.gz | tar xvf - - (cd $(ATERM) && $(patch) -p1) < $(srcdir)/aterm-aliasing.patch -# (cd $(ATERM) && $(patch) -p1) < $(srcdir)/aterm-64-bit.patch +$(ATERM): $(ATERM).tar.bz2 + bunzip2 < $(srcdir)/$(ATERM).tar.bz2 | tar xvf - have-aterm: $(MAKE) $(ATERM) diff --git a/externals/aterm-64-bit.patch b/externals/aterm-64-bit.patch deleted file mode 100644 index 4618d0883..000000000 --- a/externals/aterm-64-bit.patch +++ /dev/null @@ -1,661 +0,0 @@ -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); diff --git a/externals/aterm-aliasing.patch b/externals/aterm-aliasing.patch deleted file mode 100644 index c1dfc3e0e..000000000 --- a/externals/aterm-aliasing.patch +++ /dev/null @@ -1,224 +0,0 @@ -diff -rc aterm-1142707243.10633/aterm/aterm.c aterm/aterm/aterm.c -*** aterm-1142707243.10633/aterm/aterm.c 2006-02-08 11:35:28.000000000 +0100 ---- aterm/aterm/aterm.c 2006-04-25 17:10:52.000000000 +0200 -*************** -*** 193,198 **** ---- 193,199 ---- - /* that have char == 2 bytes, and sizeof(header_type) == 2 */ - assert(sizeof(header_type) == sizeof(ATerm *)); - assert(sizeof(header_type) >= 4); -+ assert(sizeof(ATerm) == sizeof(MachineWord)); - - /*}}} */ - /*{{{ Initialize buffer */ -diff -rc aterm-1142707243.10633/aterm/memory.c aterm/aterm/memory.c -*** aterm-1142707243.10633/aterm/memory.c 2006-03-09 15:02:56.000000000 +0100 ---- aterm/aterm/memory.c 2006-04-25 18:22:00.000000000 +0200 -*************** -*** 119,130 **** - hash_number(tmp,3)) - */ - - #define HASHNUMBER3(t)\ -! FINISH(COMBINE(START(((MachineWord*)t)[0]), ((MachineWord*)t)[2])) - - #define HASHNUMBER4(t)\ -! FINISH(COMBINE(COMBINE(START(((MachineWord*)t)[0]), \ -! ((MachineWord*)t)[2]),((MachineWord*)t)[3])) - - #define HASHINT(val) \ - FINISH(COMBINE(START( (AT_INT<<SHIFT_TYPE) ), val)) ---- 119,171 ---- - hash_number(tmp,3)) - */ - -+ /* The ATerm library use some heavy aliasing. For instance, the -+ various ATermXXX structures are referenced through MachineWord -+ arrays. This is not generally allowed by the C standard --- see -+ C99, section 6.5, clause 7. In particular, this means that you -+ cannot assign something through an ATermXXX pointer, e.g., -+ -+ protoAppl->header = header; -+ -+ and then read it through a MachineWord*, e.g., -+ -+ hnr = hash_number((ATerm) protoAppl, 2); -+ -+ (hash_number walks over the term by casting it to a MachineWord*). -+ -+ However, the same clause of the C standard also specifies that you -+ *can* read the memory location through a union type that contains -+ both the original type (e.g. ATermAppl) and the type used to read -+ the memory location (e.g. MachineWord). That's what we do -+ below: we have a union of all the types that occur in the various -+ ATerm types. We then read the "w" element of the union. The -+ compiler is not allowed to assume absence of aliasing with the -+ other types in the union. -+ -+ A better solution would be to hash the term through a character -+ pointer (since *any* memory location can be legally read as a -+ character), but I'm too lazy right now. Performance might also -+ suffer if we do that. */ -+ -+ typedef union -+ { -+ MachineWord w; -+ header_type header; -+ ATerm term; -+ ATermList list; -+ int i; -+ double d; -+ void* p; -+ } Aliaser; -+ -+ #define GET_WORD(t, n) (((Aliaser*) (((MachineWord*) t) + n))->w) -+ - #define HASHNUMBER3(t)\ -! FINISH(COMBINE(START(GET_WORD(t, 0)), GET_WORD(t, 2))) - - #define HASHNUMBER4(t)\ -! FINISH(COMBINE(COMBINE(START(GET_WORD(t, 0)), \ -! GET_WORD(t, 2)), GET_WORD(t, 3))) - - #define HASHINT(val) \ - FINISH(COMBINE(START( (AT_INT<<SHIFT_TYPE) ), val)) -*************** -*** 132,144 **** - - #endif /* HASHPEM */ - -! #define PROTO_APPL_ARGS ((ATerm *) (protoTerm + ARG_OFFSET)) - - #define SET_PROTO_APPL_ARG(i, a) \ -! (PROTO_APPL_ARGS[(i)] = (a)) - - #define GET_PROTO_APPL_ARG(i) \ -! (PROTO_APPL_ARGS[(i)]) - - #define CHECK_TERM(t) \ - assert((t) != NULL \ ---- 173,185 ---- - - #endif /* HASHPEM */ - -! #define PROTO_APPL_ARGS (protoTerm + ARG_OFFSET) - - #define SET_PROTO_APPL_ARG(i, a) \ -! (PROTO_APPL_ARGS[(i)] = (MachineWord) (a)) - - #define GET_PROTO_APPL_ARG(i) \ -! ((ATerm) PROTO_APPL_ARGS[(i)]) - - #define CHECK_TERM(t) \ - assert((t) != NULL \ -*************** -*** 323,336 **** - #else - static HashNumber hash_number(ATerm t, int size) - { -- MachineWord *words = (MachineWord *) t; - int i; - HashNumber hnr; - -! hnr = START(HIDE_AGE_MARK(words[0])); - - for (i=2; i<size; i++) { -! hnr = COMBINE(hnr, words[i]); - } - - return FINISH(hnr); ---- 364,376 ---- - #else - static HashNumber hash_number(ATerm t, int size) - { - int i; - HashNumber hnr; - -! hnr = START(HIDE_AGE_MARK(GET_WORD(t, 0))); - - for (i=2; i<size; i++) { -! hnr = COMBINE(hnr, GET_WORD(t, i)); - } - - return FINISH(hnr); -*************** -*** 338,351 **** - - static HashNumber hash_number_anno(ATerm t, int size, ATerm anno) - { -- MachineWord *words = (MachineWord *) t; - int i; - HashNumber hnr; - -! hnr = START(HIDE_AGE_MARK(words[0])); - - for (i=2; i<size; i++) { -! hnr = COMBINE(hnr, words[i]); - } - hnr = COMBINE(hnr, (MachineWord)anno); - ---- 378,390 ---- - - static HashNumber hash_number_anno(ATerm t, int size, ATerm anno) - { - int i; - HashNumber hnr; - -! hnr = START(HIDE_AGE_MARK(GET_WORD(t, 0))); - - for (i=2; i<size; i++) { -! hnr = COMBINE(hnr, GET_WORD(t, i)); - } - hnr = COMBINE(hnr, (MachineWord)anno); - -*************** -*** 1639,1645 **** - protoAppl->header = header; - CHECK_HEADER(protoAppl->header); - -! if (args != PROTO_APPL_ARGS) { - for (i=0; i<arity; i++) { - CHECK_TERM(args[i]); - SET_PROTO_APPL_ARG(i, args[i]); ---- 1678,1684 ---- - protoAppl->header = header; - CHECK_HEADER(protoAppl->header); - -! if (args != (ATerm *) PROTO_APPL_ARGS) { - for (i=0; i<arity; i++) { - CHECK_TERM(args[i]); - SET_PROTO_APPL_ARG(i, args[i]); -*************** -*** 1680,1686 **** - hashtable[hnr] = cur; - } - -! if (args != PROTO_APPL_ARGS) { - for (i=0; i<arity; i++) { - protected_buffer[i] = NULL; - } ---- 1719,1725 ---- - hashtable[hnr] = cur; - } - -! if (args != (ATerm *) PROTO_APPL_ARGS) { - for (i=0; i<arity; i++) { - protected_buffer[i] = NULL; - } -*************** -*** 2144,2150 **** - } - SET_PROTO_APPL_ARG(n, arg); - -! result = ATmakeApplArray(sym, PROTO_APPL_ARGS); - annos = AT_getAnnotations((ATerm)appl); - if (annos != NULL) { - result = (ATermAppl)AT_setAnnotations((ATerm)result, annos); ---- 2183,2189 ---- - } - SET_PROTO_APPL_ARG(n, arg); - -! result = ATmakeApplArray(sym, (ATerm *) PROTO_APPL_ARGS); - annos = AT_getAnnotations((ATerm)appl); - if (annos != NULL) { - result = (ATermAppl)AT_setAnnotations((ATerm)result, annos); |