- Make bitstr.c work on machines with "little indian" byte ordering
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Thu, 6 Aug 1987 05:05:07 +0000 (05:05 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Thu, 6 Aug 1987 05:05:07 +0000 (05:05 +0000)
convention by parameterizing bitstr.h according to byte order.

- Make Wsize compute the byte ordering information.

- Add changes for Alliant.

v7/src/microcode/bitstr.h
v7/src/microcode/config.h
v7/src/microcode/version.h
v7/src/microcode/wsize.c
v8/src/microcode/version.h

index 0b8f44de580a28b6e6752b800811b70c4395d45b..c8977aaaffe31a11e63625ea137f86ea8088b802 100644 (file)
@@ -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. */
 \f
+#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)))
+\f
+/* 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))
+
+
+\f
+#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 */
index a1e558f308b98114c72362f0f8d7293f5f0f8354..afac2cd1c69c88071e79b1589f16260975f03a2e 100644 (file)
@@ -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
 \f
 /* 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
 \f
 #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
 \f
 /* Make sure that some definition applies. 
    If this error occurs, and the parameters of the
index 24dbde900f417f5dd15c93b8347c5005452c38d7..cdbd4b985c502e83136e262663f432872d7e0801 100644 (file)
@@ -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. */
 \f
@@ -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
index 5cf7d076be101fa3e275b04280239230e490cb13..ac52ed56a34f7d99c41eb2bb2096d7fa6eb5a9e1 100644 (file)
@@ -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 $ */
 \f
 #include <stdio.h>
 #include <math.h>
@@ -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;      
index 734da24d5326e81a99988d6048cff4d40790f16c..8f715f692d9f24ed98e3824813e5608d51db7126 100644 (file)
@@ -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. */
 \f
@@ -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