From: Guillermo J. Rozas Date: Thu, 6 Aug 1987 05:05:07 +0000 (+0000) Subject: - Make bitstr.c work on machines with "little indian" byte ordering X-Git-Tag: 20090517-FFI~13188 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=4555858979c0fead8a1bcac66ed8a6b76596de5e;p=mit-scheme.git - Make bitstr.c work on machines with "little indian" byte ordering convention by parameterizing bitstr.h according to byte order. - Make Wsize compute the byte ordering information. - Add changes for Alliant. --- diff --git a/v7/src/microcode/bitstr.h b/v7/src/microcode/bitstr.h index 0b8f44de5..c8977aaaf 100644 --- a/v7/src/microcode/bitstr.h +++ b/v7/src/microcode/bitstr.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/bitstr.h,v 1.2 1987/05/14 13:47:34 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/bitstr.h,v 1.3 1987/08/06 05:03:44 jinx Exp $ Copyright (c) 1987 Massachusetts Institute of Technology @@ -32,19 +32,128 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* Bit string macros. */ +/* Bit string macros. "Little indian" version. */ +#define BIT_STRING_LENGTH_OFFSET 1 +#define BIT_STRING_FIRST_WORD 2 + +#define bits_to_pointers(bits) \ +(((bits) + (POINTER_LENGTH - 1)) / POINTER_LENGTH) + +#define low_mask(nbits) ((1 << (nbits)) - 1) +#define any_mask(nbits, offset) ((low_mask (nbits)) << (offset)) + #define bit_string_length(bit_string) \ -(Fast_Vector_Ref (bit_string, NM_ENTRY_COUNT)) +(Fast_Vector_Ref (bit_string, BIT_STRING_LENGTH_OFFSET)) #define bit_string_start_ptr(bit_string) \ -(Nth_Vector_Loc (bit_string, NM_DATA)) +(Nth_Vector_Loc (bit_string, BIT_STRING_FIRST_WORD)) #define bit_string_end_ptr(bit_string) \ (Nth_Vector_Loc (bit_string, ((Vector_Length (bit_string)) + 1))) -#define any_mask(nbits, offset) ((low_mask (nbits)) << (offset)) -#define low_mask(nbits) ((1 << (nbits)) - 1) +#define bit_string_msw(bit_string) \ +(bit_string_word(bit_string_high_ptr(bit_string))) + +#define bit_string_lsw(bit_string) \ +(bit_string_word(Nth_Vector_Loc(bit_string, index_to_word(bit_string, 0)))) + +#define index_pair_to_bit_fixnum(string, word, bit) \ +(Make_Unsigned_Fixnum (index_pair_to_bit_number (string, word, bit))) + +/* Byte order dependencies. */ + +#ifdef VAX_BYTE_ORDER + +/* + +Memory layout of bit strings: + ++-------+-------+-------+-------+ +| NMV | GC size (longwords) | 0 ++-------+-------+-------+-------+ +| Size in bits | 1 ++-------+-------+-------+-------+ +| LSB| 2 ++-------+-------+-------+-------+ +| | 3 ++-------+-------+-------+-------+ +. . . +. . . +. . . ++-------+-------+-------+-------+ +|MSB | N ++-------+-------+-------+-------+ + +The last data word (marked as word "N" above) is where any excess +bits are kept. + +The "size in bits" is a C "long" integer. + +*/ + +#define bit_string_high_ptr bit_string_end_ptr + +#define bit_string_low_ptr bit_string_start_ptr + +#define bit_string_word(ptr) (*((ptr) - 1)) + +#define dec_bit_string_ptr(ptr) (--(ptr)) + +#define inc_bit_string_ptr(ptr) ((ptr)++) + +#define object_msw_ptr(object, length) \ +(Get_Pointer(object) + bits_to_pointers(length - 1)) + +/* This is off by one so bit_string_word will get the correct word. */ + +#define index_to_word(bit_string, index) \ +((BIT_STRING_FIRST_WORD + 1) + (index / POINTER_LENGTH)) + +#define index_pair_to_bit_number(string, word, bit) \ +(((word) * POINTER_LENGTH) + (bit)) + + + +#else /* not VAX_BYTE_ORDER */ + +/* + +Memory layout of bit strings: + ++-------+-------+-------+-------+ +| NMV | GC size (longwords) | 0 ++-------+-------+-------+-------+ +| Size in bits | 1 ++-------+-------+-------+-------+ +|MSB | 2 ++-------+-------+-------+-------+ +| | 3 ++-------+-------+-------+-------+ +. . . +. . . +. . . ++-------+-------+-------+-------+ +| LSB| N ++-------+-------+-------+-------+ + +The first data word (marked as word "2" above) is where any excess +bits are kept. + +The "size in bits" is a C "long" integer. +*/ + +#define bit_string_high_ptr bit_string_start_ptr + +#define bit_string_low_ptr bit_string_end_ptr + +#define bit_string_word(ptr) (*(ptr)) + +#define dec_bit_string_ptr(ptr) ((ptr)++) + +#define inc_bit_string_ptr(ptr) (--(ptr)) + +#define object_msw_ptr(object, length) (Get_Pointer(object)) /* This is especially clever. To understand it, note that the index of the last pointer of a vector is also the GC length of the @@ -54,11 +163,8 @@ MIT in each case. */ #define index_to_word(bit_string, index) \ ((Vector_Length (bit_string)) - (index / POINTER_LENGTH)) -#define bits_to_pointers(bits) \ -(((bits) + (POINTER_LENGTH - 1)) / POINTER_LENGTH) - #define index_pair_to_bit_number(string, word, bit) \ ((((Vector_Length (string)) - (word)) * POINTER_LENGTH) + (bit)) -#define index_pair_to_bit_fixnum(string, word, bit) \ -(Make_Unsigned_Fixnum (index_pair_to_bit_number (string, word, bit))) + +#endif /* VAX_BYTE_ORDER */ diff --git a/v7/src/microcode/config.h b/v7/src/microcode/config.h index a1e558f30..afac2cd1c 100644 --- a/v7/src/microcode/config.h +++ b/v7/src/microcode/config.h @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/config.h,v 9.29 1987/06/19 15:53:28 jinx Rel $ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/config.h,v 9.30 1987/08/06 05:05:07 jinx Exp $ * * This file contains the configuration information and the information * given on the command line on Unix. @@ -158,6 +158,11 @@ typedef unsigned long Pointer; (i.e. Pointer) results in a logical (vs. arithmetic) shift. Setting the flag allows faster type code extraction. + VAX_BYTE_ORDER is defined if the least significant byte of a + longword in memory lies at the lowest address, not defined if the + opposite convention holds (ie. Motorola MC6820), or the concept + does not apply (ie. DEC PDP-10). + BELL is the character which rings the terminal bell. The following switches are used to use the system provided library @@ -196,6 +201,7 @@ typedef unsigned long Pointer; #define FASL_HP_SPECTRUM 10 #define FASL_UMAX 11 #define FALS_PYR 12 +#define FASL_ALLIANT 13 /* These (pdp10 and nu) haven't worked in a while. * Should be upgraded or flushed some day. @@ -229,9 +235,12 @@ typedef unsigned long Pointer; #endif #ifdef vax + /* Amazingly unix and vms agree on all these */ + #define Heap_In_Low_Memory #define UNSIGNED_SHIFT +#define VAX_BYTE_ORDER #define CHAR_SIZE 8 #define USHORT_SIZE 16 #define ULONG_SIZE 32 @@ -449,6 +458,21 @@ longjmp(Exit_Point, NORMAL_EXIT) #define FLONUM_MANTISSA_BITS 52 #define MAX_FLONUM_EXPONENT 2047 #endif + +#ifdef alliant +#define Heap_In_Low_Memory +#define UNSIGNED_SHIFT +#define CHAR_SIZE 8 +#define USHORT_SIZE 16 +#define ULONG_SIZE 32 +#define BELL '\007' +#define FASL_INTERNAL_FORMAT FASL_ALLIANT +#define FLONUM_EXPT_SIZE 10 +#define FLONUM_MANTISSA_BITS 53 +#define MAX_FLONUM_EXPONENT 1023 +#define HAS_FLOOR +#define HAS_FREXP +#endif /* Make sure that some definition applies. If this error occurs, and the parameters of the diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index 24dbde900..cdbd4b985 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 9.92 1987/08/05 07:33:16 jinx Exp $ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 9.93 1987/08/06 05:04:11 jinx Exp $ This file contains version information for the microcode. */ @@ -46,7 +46,7 @@ This file contains version information for the microcode. */ #define VERSION 9 #endif #ifndef SUBVERSION -#define SUBVERSION 92 +#define SUBVERSION 93 #endif #ifndef UCODE_TABLES_FILENAME diff --git a/v7/src/microcode/wsize.c b/v7/src/microcode/wsize.c index 5cf7d076b..ac52ed56a 100644 --- a/v7/src/microcode/wsize.c +++ b/v7/src/microcode/wsize.c @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/wsize.c,v 9.22 1987/07/07 02:22:55 jinx Rel $ */ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/wsize.c,v 9.23 1987/08/06 05:04:42 jinx Rel $ */ #include #include @@ -78,6 +78,7 @@ main() int count, expt_size, char_size, mant_size; unsigned long to_be_shifted; unsigned bogus; + char buffer[sizeof(long)]; char *temp; setup_error(); @@ -87,17 +88,24 @@ main() count += 1) bogus >>= 1; - char_size = count/(sizeof(unsigned)); + char_size = count / (sizeof(unsigned)); + temp = malloc(MEM_SIZE*sizeof(long)); if (temp == NULL) + { printf("/%c Cannot allocate %d Pointers. %c/\n", '*', MEM_SIZE, '*'); - else count = free(temp); - - if (((unsigned long) temp) < (1 << ((char_size*sizeof(long))-8))) - printf("#define Heap_In_Low_Memory\n"); + printf("/%c Will not assume that the Heap is in Low Memory. %c\n", + '*', '*'); + } else - printf("/%c Heap is not in Low Memory. %c/\n", '*', '*'); + { + count = free(temp); + if (((unsigned long) temp) < (1 << ((char_size * sizeof(long)) - 8))) + printf("#define Heap_In_Low_Memory\n"); + else + printf("/%c Heap is not in Low Memory. %c/\n", '*', '*'); + } to_be_shifted = -1; if ((to_be_shifted >> 1) != to_be_shifted) @@ -106,6 +114,22 @@ main() printf("/%c unsigned longs use arithmetic shifting. %c/\n", '*', '*'); + if (sizeof(long) == sizeof(char)) + { + printf("/%c sizeof(long) == sizeof(char); no byte order problems! %c/\n", + '*', '*'); + } + else + { + buffer[0] = 1; + for (count = 1; count < sizeof(long); ) + buffer[count++] = 0; + if (*((long *) &buffer[0]) == 1) + printf("#define VAX_BYTE_ORDER\n"); + else + printf("/%c VAX_BYTE_ORDER not used. %c/\n", '*', '*'); + } + printf("#define CHAR_SIZE %d\n", char_size); @@ -139,8 +163,8 @@ main() printf("#define FLONUM_EXPT_SIZE %d\n", expt_size); printf("#define FLONUM_MANTISSA_BITS %d\n", mant_size); printf("#define MAX_FLONUM_EXPONENT %d\n", ((1 << expt_size) - 1)); - printf("/%c Representation %s hidden bit. %c/\n", '*', - (((2+expt_size+mant_size) > (char_size*sizeof(double))) ? + printf("/%c Floating point representation %s hidden bit. %c/\n", '*', + (((2 + expt_size + mant_size) > (char_size * sizeof(double))) ? "uses" : "does not use"), '*'); return; diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index 734da24d5..8f715f692 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 9.92 1987/08/05 07:33:16 jinx Exp $ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 9.93 1987/08/06 05:04:11 jinx Exp $ This file contains version information for the microcode. */ @@ -46,7 +46,7 @@ This file contains version information for the microcode. */ #define VERSION 9 #endif #ifndef SUBVERSION -#define SUBVERSION 92 +#define SUBVERSION 93 #endif #ifndef UCODE_TABLES_FILENAME