summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2001-01-18 13:35:45 +0000
committerDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2001-01-18 13:35:45 +0000
commit5c75b29f1d3f318318a1645a268cd17d6452cbf5 (patch)
treee529e3bb84f4cbbd9096abf6a98492ddbdfc1e4c
parent339bfe47a1d2acee88f84e1ef5653b7b85d1d98a (diff)
downloadguile-5c75b29f1d3f318318a1645a268cd17d6452cbf5.tar.gz
* Cleaned up some limits-definitions.
-rw-r--r--libguile/ChangeLog15
-rw-r--r--libguile/__scm.h57
-rw-r--r--libguile/numbers.h16
3 files changed, 54 insertions, 34 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index f8ed2b5a2..c9250adca 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -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>
* __scm.h (SCM_FIXNUM_BIT): Added. The name is chosen in analogy
diff --git a/libguile/__scm.h b/libguile/__scm.h
index 7723396bc..75a01a934 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -203,37 +203,46 @@ typedef unsigned long long ulong_long;
-/* Define
+/* {Architecture and compiler properties}
*
- * SCM_CHAR_CODE_LIMIT == UCHAR_MAX + 1
- * SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2)
- * SCM_MOST_NEGATIVE_FIXNUM == SCM_SRS((long)LONG_MIN, 2)
+ * Guile as of today can only work on systems which fulfill at least the
+ * following requirements:
+ * - 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
# include <limits.h>
-# ifdef UCHAR_MAX
-# define SCM_CHAR_CODE_LIMIT (UCHAR_MAX+1L)
-# else
-# define SCM_CHAR_CODE_LIMIT 256L
-# endif /* def UCHAR_MAX */
-# define SCM_FIXNUM_BIT (LONG_BIT - 2)
-# define SCM_MOST_POSITIVE_FIXNUM (LONG_MAX>>2)
-# ifdef _UNICOS /* Stupid cray bug */
-# define SCM_MOST_NEGATIVE_FIXNUM ((long)LONG_MIN/4)
-# else
-# define SCM_MOST_NEGATIVE_FIXNUM SCM_SRS((long)LONG_MIN, 2)
-# endif /* UNICOS */
+#endif
+
+#ifdef CHAR_BIT
+# define SCM_CHAR_BIT CHAR_BIT
+#else
+# define SCM_CHAR_BIT 8
+#endif
+
+#ifdef LONG_BIT
+# define SCM_LONG_BIT LONG_BIT
+#else
+# define SCM_LONG_BIT (SCM_CHAR_BIT * sizeof (long) / sizeof (char))
+#endif
+
+#ifdef UCHAR_MAX
+# define SCM_CHAR_CODE_LIMIT (UCHAR_MAX + 1L)
#else
# define SCM_CHAR_CODE_LIMIT 256L
-# define SCM_FIXNUM_BIT 30
-# 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 */
+#endif
+
#ifdef STDC_HEADERS
diff --git a/libguile/numbers.h b/libguile/numbers.h
index 6a78c5910..d5b2809e7 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -52,7 +52,6 @@
-
/* Immediate Numbers
*
* Inums are exact integer data that fits within an SCM word.
@@ -63,6 +62,11 @@
* 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 */
#if (-1 == (((-1) << 2) + 2) >> 2)
# define SCM_SRS(x, y) ((x) >> (y))
@@ -111,15 +115,7 @@
/* SCM_INTBUFLEN is the maximum number of characters neccessary for the
* printed or scm_string representation of an exact immediate.
*/
-
-#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)
-
+#define SCM_INTBUFLEN (5 + SCM_LONG_BIT)