From 9aa26658bfc726f0f95dad6c9a07333d4d454fe0 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 25 Sep 2009 22:22:10 -0700 Subject: [PATCH] Simplify definitions of core object lengths and masks. Eliminate references to 8-bit types. Fix a couple of sign errors. --- src/microcode/object.h | 71 +++++++++++++----------------------------- 1 file changed, 21 insertions(+), 50 deletions(-) diff --git a/src/microcode/object.h b/src/microcode/object.h index cd403fe89..e86c76a92 100644 --- a/src/microcode/object.h +++ b/src/microcode/object.h @@ -38,17 +38,6 @@ USA. # include ";; inconsistency: TYPE_CODE_LENGTH < MIN_TYPE_CODE_LENGTH" #endif -#if (TYPE_CODE_LENGTH == 8) -# define N_TYPE_CODES (0x100) -#endif -#if (TYPE_CODE_LENGTH == 6) -# define N_TYPE_CODES (0x40) -#endif -#ifndef N_TYPE_CODES -# define N_TYPE_CODES (1U << TYPE_CODE_LENGTH) -#endif -#define __LOW_TYPE_MASK ((unsigned long) (N_TYPE_CODES - 1U)) - typedef unsigned long SCHEME_OBJECT; #define SIZEOF_SCHEME_OBJECT SIZEOF_UNSIGNED_LONG #define OBJECT_LENGTH ((unsigned int) (CHAR_BIT * SIZEOF_UNSIGNED_LONG)) @@ -56,73 +45,55 @@ typedef unsigned long SCHEME_OBJECT; /* A convenience definition since "unsigned char" is so verbose. */ typedef unsigned char byte_t; -#if (SIZEOF_UNSIGNED_LONG == 4) /* 32 bit word versions */ -# if (TYPE_CODE_LENGTH == 6) +#if (TYPE_CODE_LENGTH == 6U) +# define N_TYPE_CODES (0x40) +# if (SIZEOF_UNSIGNED_LONG == 4) /* 32 bit word versions */ # define DATUM_LENGTH (26U) -# define FIXNUM_LENGTH (25U) +# define DATUM_MASK (0x03FFFFFFL) +# define TYPE_CODE_MASK (0XFC000000L) +# define FIXNUM_LENGTH (25U) /* doesn't include sign */ +# define FIXNUM_MASK (0x01FFFFFFL) # define FIXNUM_SIGN_BIT (0x02000000L) # define SIGN_MASK (0xFE000000L) # define SMALLEST_FIXNUM (-33554432L) # define BIGGEST_FIXNUM (33554431L) # define HALF_DATUM_LENGTH (13U) # define HALF_DATUM_MASK (0x00001FFFL) -# define DATUM_MASK (0x03FFFFFFL) -# define TYPE_CODE_MASK (0XFC000000L) -# endif -# if (TYPE_CODE_LENGTH == 8) -# define DATUM_LENGTH (24U) -# define FIXNUM_LENGTH (23U) -# define FIXNUM_SIGN_BIT (0x00800000L) -# define SIGN_MASK (0xFF800000L) -# define SMALLEST_FIXNUM (-8388608) -# define BIGGEST_FIXNUM (8388607) -# define HALF_DATUM_LENGTH (12U) -# define HALF_DATUM_MASK (0x00000FFFL) -# define DATUM_MASK (0x00FFFFFFL) -# define TYPE_CODE_MASK (0xFF000000L) # endif -#endif - -#if (SIZEOF_UNSIGNED_LONG == 8) /* 64 bit word versions */ -# if (TYPE_CODE_LENGTH == 6) +# if (SIZEOF_UNSIGNED_LONG == 8) /* 64 bit word versions */ # define DATUM_LENGTH (58U) -# define FIXNUM_LENGTH (57U) +# define DATUM_MASK (0x03FFFFFFFFFFFFFFL) +# define TYPE_CODE_MASK (0XFC00000000000000L) +# define FIXNUM_LENGTH (57U) /* doesn't include sign */ +# define FIXNUM_MASK (0x01FFFFFFFFFFFFFFL) # define FIXNUM_SIGN_BIT (0x0200000000000000L) # define SIGN_MASK (0xFE00000000000000L) # define SMALLEST_FIXNUM (-144115188075855872L) # define BIGGEST_FIXNUM (144115188075855871L) # define HALF_DATUM_LENGTH (29U) # define HALF_DATUM_MASK (0x000000001FFFFFFFL) -# define DATUM_MASK (0x03FFFFFFFFFFFFFFL) -# define TYPE_CODE_MASK (0XFC00000000000000L) # endif #endif #ifndef DATUM_LENGTH /* Safe versions */ +# define N_TYPE_CODES (1U << TYPE_CODE_LENGTH) # define DATUM_LENGTH (OBJECT_LENGTH - TYPE_CODE_LENGTH) - /* FIXNUM_LENGTH does NOT include the sign bit! */ -# define FIXNUM_LENGTH (DATUM_LENGTH - 1U) +# define DATUM_MASK ((1UL << DATUM_LENGTH) - 1UL) +# define TYPE_CODE_MASK ((N_TYPE_CODES - 1U) << DATUM_LENGTH) +# define FIXNUM_LENGTH (DATUM_LENGTH - 1U) /* doesn't include sign */ +# define FIXNUM_MASK ((1UL << FIXNUM_LENGTH) - 1UL) # define FIXNUM_SIGN_BIT (1UL << FIXNUM_LENGTH) -# define __SIGN_MASK ((unsigned long) ((N_TYPE_CODES * 2U) - 1U)) -# define SIGN_MASK (__SIGN_MASK << FIXNUM_LENGTH) +# define SIGN_MASK \ + (((unsigned long) ((N_TYPE_CODES * 2U) - 1U)) << FIXNUM_LENGTH) # define SMALLEST_FIXNUM SIGN_MASK -# define BIGGEST_FIXNUM ((1UL << FIXNUM_LENGTH) - 1U) +# define BIGGEST_FIXNUM ((1UL << FIXNUM_LENGTH) - 1UL) # define HALF_DATUM_LENGTH (DATUM_LENGTH / 2U) # define HALF_DATUM_MASK ((1UL << HALF_DATUM_LENGTH) - 1UL) -# define DATUM_MASK ((1UL << DATUM_LENGTH) - 1UL) -# define TYPE_CODE_MASK (__LOW_TYPE_MASK << DATUM_LENGTH) #endif /* Basic object structure */ -#ifndef OBJECT_TYPE -# ifdef UNSIGNED_SHIFT_BUG -# define OBJECT_TYPE(object) (((object) >> DATUM_LENGTH) & __LOW_TYPE_MASK) -# else -# define OBJECT_TYPE(object) ((object) >> DATUM_LENGTH) -# endif -#endif - +#define OBJECT_TYPE(object) ((object) >> DATUM_LENGTH) #define OBJECT_DATUM(object) ((object) & DATUM_MASK) #define OBJECT_ADDRESS(object) (DATUM_TO_ADDRESS (OBJECT_DATUM (object))) -- 2.25.1