1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 22:31:12 +02:00

* Cleaned up some limits-definitions.

This commit is contained in:
Dirk Herrmann 2001-01-18 13:35:45 +00:00
parent 339bfe47a1
commit 5c75b29f1d
3 changed files with 54 additions and 34 deletions

View file

@ -1,3 +1,18 @@
2001-01-18 Dirk Herrmann <D.Herrmann@tu-bs.de>
* __scm.h: Added comment about architecture and compiler
properties that are required by guile.
(SCM_FIXNUM_BIT, SCM_MOST_POSITIVE_FIXNUM,
SCM_MOST_NEGATIVE_FIXNUM): Moved to numbers.h.
(SCM_CHAR_BIT, SCM_LONG_BIT): Moved here from numbers.h.
* numbers.h (SCM_CHAR_BIT, SCM_LONG_BIT): Moved to __scm.h.
(SCM_FIXNUM_BIT, SCM_MOST_POSITIVE_FIXNUM,
SCM_MOST_NEGATIVE_FIXNUM): Moved here from __scm.h.
2001-01-17 Dirk Herrmann <D.Herrmann@tu-bs.de> 2001-01-17 Dirk Herrmann <D.Herrmann@tu-bs.de>
* __scm.h (SCM_FIXNUM_BIT): Added. The name is chosen in analogy * __scm.h (SCM_FIXNUM_BIT): Added. The name is chosen in analogy

View file

@ -203,37 +203,46 @@ typedef unsigned long long ulong_long;
/* Define /* {Architecture and compiler properties}
* *
* SCM_CHAR_CODE_LIMIT == UCHAR_MAX + 1 * Guile as of today can only work on systems which fulfill at least the
* SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2) * following requirements:
* SCM_MOST_NEGATIVE_FIXNUM == SCM_SRS((long)LONG_MIN, 2) * - long ints have at least 32 bits.
* Guile's type system is based on this assumption.
* - long ints consist of at least four characters.
* It is assumed that cells, i. e. pairs of long ints, are eight character
* aligned, because three bits of a cell pointer are used for type data.
* - sizeof (void*) == sizeof (long int)
* Pointers are stored in SCM objects, and sometimes SCM objects are passed
* as void*. Thus, there has to be a one-to-one correspondence.
* - numbers are encoded using two's complement.
* The implementation of the bitwise scheme level operations is based on
* this assumption.
* - ... add more
*/ */
#ifdef HAVE_LIMITS_H #ifdef HAVE_LIMITS_H
# include <limits.h> # include <limits.h>
# ifdef UCHAR_MAX #endif
# define SCM_CHAR_CODE_LIMIT (UCHAR_MAX+1L)
# else #ifdef CHAR_BIT
# define SCM_CHAR_CODE_LIMIT 256L # define SCM_CHAR_BIT CHAR_BIT
# endif /* def UCHAR_MAX */ #else
# define SCM_FIXNUM_BIT (LONG_BIT - 2) # define SCM_CHAR_BIT 8
# define SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2) #endif
# ifdef _UNICOS /* Stupid cray bug */
# define SCM_MOST_NEGATIVE_FIXNUM ((long)LONG_MIN/4) #ifdef LONG_BIT
# else # define SCM_LONG_BIT LONG_BIT
# define SCM_MOST_NEGATIVE_FIXNUM SCM_SRS((long)LONG_MIN, 2) #else
# endif /* UNICOS */ # define SCM_LONG_BIT (SCM_CHAR_BIT * sizeof (long) / sizeof (char))
#endif
#ifdef UCHAR_MAX
# define SCM_CHAR_CODE_LIMIT (UCHAR_MAX + 1L)
#else #else
# define SCM_CHAR_CODE_LIMIT 256L # define SCM_CHAR_CODE_LIMIT 256L
# define SCM_FIXNUM_BIT 30 #endif
# define SCM_MOST_POSITIVE_FIXNUM ((long)((unsigned long)~0L>>3))
# if (0 != ~0)
# define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1)
# else
# define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM)
# endif /* (0 != ~0) */
#endif /* def HAVE_LIMITS_H */
#ifdef STDC_HEADERS #ifdef STDC_HEADERS

View file

@ -52,7 +52,6 @@
/* Immediate Numbers /* Immediate Numbers
* *
* Inums are exact integer data that fits within an SCM word. * Inums are exact integer data that fits within an SCM word.
@ -63,6 +62,11 @@
* SCM_INUMP (SCM_CAR (x)) can give wrong answers. * SCM_INUMP (SCM_CAR (x)) can give wrong answers.
*/ */
#define SCM_FIXNUM_BIT (SCM_LONG_BIT - 2)
#define SCM_MOST_POSITIVE_FIXNUM ((1L << (SCM_FIXNUM_BIT - 1)) - 1)
#define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM - 1)
/* SCM_SRS is signed right shift */ /* SCM_SRS is signed right shift */
#if (-1 == (((-1) << 2) + 2) >> 2) #if (-1 == (((-1) << 2) + 2) >> 2)
# define SCM_SRS(x, y) ((x) >> (y)) # define SCM_SRS(x, y) ((x) >> (y))
@ -111,15 +115,7 @@
/* SCM_INTBUFLEN is the maximum number of characters neccessary for the /* SCM_INTBUFLEN is the maximum number of characters neccessary for the
* printed or scm_string representation of an exact immediate. * printed or scm_string representation of an exact immediate.
*/ */
#define SCM_INTBUFLEN (5 + SCM_LONG_BIT)
#ifndef SCM_CHAR_BIT
# define SCM_CHAR_BIT 8
#endif /* ndef SCM_CHAR_BIT */
#ifndef SCM_LONG_BIT
# define SCM_LONG_BIT (SCM_CHAR_BIT*sizeof(long)/sizeof(char))
#endif /* ndef SCM_LONG_BIT */
#define SCM_INTBUFLEN (5+SCM_LONG_BIT)