summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>2004-07-29 14:03:40 +0000
committerMarius Vollmer <mvo@zagadka.de>2004-07-29 14:03:40 +0000
commite88d45aa731eae1c5742f100fdf0731202f7b434 (patch)
tree702a8f902716902fa04f32122b521f00e178913b /libguile
parentd0fefc7de59be16cdc6b08c08e76adbb0bc34a26 (diff)
downloadguile-e88d45aa731eae1c5742f100fdf0731202f7b434.tar.gz
* __scm.h (SCM_I_UTYPE_MAX, SCM_I_TYPE_MAX, SCM_I_TYPE_MIN,
SCM_I_SIZE_MAX, SCM_I_SSIZE_MIN, SCM_I_SSIZE_MAX): New. * __scm.h, gen-scmconfig.c (SCM_I_LLONG_MAX, SCM_I_LLONG_MIN, SCM_I_ULLONG_MAX, SCM_T_INT8_MIN, SCM_T_INT8_MAX, SCM_T_UINT8_MAX, SCM_T_INT16_MIN, SCM_T_INT16_MAX, SCM_T_UINT16_MAX, SCM_T_INT32_MIN, SCM_T_INT32_MAX, SCM_T_UINT32_MAX, SCM_T_INT64_MIN, SCM_T_INT64_MAX, SCM_T_UINT64_MAX, SCM_T_INTMAX_MIN, SCM_T_INTMAX_MAX, SCM_T_UINTMAX_MAX): Moved definition into __scm.h, using new SCM_I_TYPE_MIN, etc.
Diffstat (limited to 'libguile')
-rw-r--r--libguile/__scm.h36
-rw-r--r--libguile/gen-scmconfig.c30
2 files changed, 36 insertions, 30 deletions
diff --git a/libguile/__scm.h b/libguile/__scm.h
index 5448ff4fd..5581c8a4b 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -353,6 +353,42 @@
# define SCM_CHAR_CODE_LIMIT 256L
#endif
+#define SCM_I_UTYPE_MAX(type) ((type)-1)
+#define SCM_I_TYPE_MAX(type,umax) ((type)((umax)/2))
+#define SCM_I_TYPE_MIN(type,umax) (-((type)((umax)/2))-1)
+
+#define SCM_T_UINT8_MAX SCM_I_UTYPE_MAX(scm_t_uint8)
+#define SCM_T_INT8_MIN SCM_I_TYPE_MIN(scm_t_int8,SCM_T_UINT8_MAX)
+#define SCM_T_INT8_MAX SCM_I_TYPE_MAX(scm_t_int8,SCM_T_UINT8_MAX)
+
+#define SCM_T_UINT16_MAX SCM_I_UTYPE_MAX(scm_t_uint16)
+#define SCM_T_INT16_MIN SCM_I_TYPE_MIN(scm_t_int16,SCM_T_UINT16_MAX)
+#define SCM_T_INT16_MAX SCM_I_TYPE_MAX(scm_t_int16,SCM_T_UINT16_MAX)
+
+#define SCM_T_UINT32_MAX SCM_I_UTYPE_MAX(scm_t_uint32)
+#define SCM_T_INT32_MIN SCM_I_TYPE_MIN(scm_t_int32,SCM_T_UINT32_MAX)
+#define SCM_T_INT32_MAX SCM_I_TYPE_MAX(scm_t_int32,SCM_T_UINT32_MAX)
+
+#if SCM_HAVE_T_INT64
+#define SCM_T_UINT64_MAX SCM_I_UTYPE_MAX(scm_t_uint64)
+#define SCM_T_INT64_MIN SCM_I_TYPE_MIN(scm_t_int64,SCM_T_UINT64_MAX)
+#define SCM_T_INT64_MAX SCM_I_TYPE_MAX(scm_t_int64,SCM_T_UINT64_MAX)
+#endif
+
+#if SCM_SIZEOF_LONG_LONG
+#define SCM_I_ULLONG_MAX SCM_I_UTYPE_MAX(unsigned long long)
+#define SCM_I_LLONG_MIN SCM_I_TYPE_MIN(long long,SCM_I_ULLONG_MAX)
+#define SCM_I_LLONG_MAX SCM_I_TYPE_MAX(long long,SCM_I_ULLONG_MAX)
+#endif
+
+#define SCM_T_UINTMAX_MAX SCM_I_UTYPE_MAX(scm_t_uintmax)
+#define SCM_T_INTMAX_MIN SCM_I_TYPE_MIN(scm_t_intmax,SCM_T_UINTMAX_MAX)
+#define SCM_T_INTMAX_MAX SCM_I_TYPE_MAX(scm_t_intmax,SCM_T_UINTMAX_MAX)
+
+#define SCM_I_SIZE_MAX SCM_I_UTYPE_MAX(size_t)
+#define SCM_I_SSIZE_MIN SCM_I_TYPE_MIN(ssize_t,SCM_I_SIZE_MAX)
+#define SCM_I_SSIZE_MAX SCM_I_TYPE_MAX(ssize_t,SCM_I_SIZE_MAX)
+
#include "libguile/tags.h"
diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c
index 1dd87b844..3fd2df569 100644
--- a/libguile/gen-scmconfig.c
+++ b/libguile/gen-scmconfig.c
@@ -277,19 +277,6 @@ main (int argc, char *argv[])
pf ("#define SCM_SIZEOF_LONG_LONG %d\n", SIZEOF_LONG_LONG);
pf ("#define SCM_SIZEOF_UNSIGNED_LONG_LONG %d\n", SIZEOF_UNSIGNED_LONG_LONG);
- if (SIZEOF_LONG_LONG != 0)
- {
- pf ("\n");
- pf ("/* The limits of long long are not readily available without\n");
- pf (" defining _GNU_SOURCE (which we can't do in a header) or\n");
- pf (" being on a C99 system (which we can't rely on yet). Thus,\n");
- pf (" we define the limits on our own, assuming twos-complement.\n");
- pf ("*/\n");
- pf ("#define SCM_I_LLONG_MAX ((long long) (SCM_I_ULLONG_MAX >> 1))\n");
- pf ("#define SCM_I_LLONG_MIN (~SCM_I_LLONG_MAX)\n");
- pf ("#define SCM_I_ULLONG_MAX ((unsigned long long) (-1))\n");
- }
-
pf("\n");
pf("/* handling for the deprecated long_long and ulong_long types */\n");
pf("/* If anything suitable is available, it'll be defined here. */\n");
@@ -316,16 +303,6 @@ main (int argc, char *argv[])
pf ("typedef %s scm_t_intmax;\n", SCM_I_GSC_T_INTMAX);
pf ("typedef %s scm_t_uintmax;\n", SCM_I_GSC_T_UINTMAX);
- pf ("#define SCM_T_INT8_MIN %s_MIN\n", SCM_I_GSC_T_INT8_LIMITS);
- pf ("#define SCM_T_INT8_MAX %s_MAX\n", SCM_I_GSC_T_INT8_LIMITS);
- pf ("#define SCM_T_UINT8_MAX %s_MAX\n", SCM_I_GSC_T_UINT8_LIMITS);
- pf ("#define SCM_T_INT16_MIN %s_MIN\n", SCM_I_GSC_T_INT16_LIMITS);
- pf ("#define SCM_T_INT16_MAX %s_MAX\n", SCM_I_GSC_T_INT16_LIMITS);
- pf ("#define SCM_T_UINT16_MAX %s_MAX\n", SCM_I_GSC_T_UINT16_LIMITS);
- pf ("#define SCM_T_INT32_MIN %s_MIN\n", SCM_I_GSC_T_INT32_LIMITS);
- pf ("#define SCM_T_INT32_MAX %s_MAX\n", SCM_I_GSC_T_INT32_LIMITS);
- pf ("#define SCM_T_UINT32_MAX %s_MAX\n", SCM_I_GSC_T_UINT32_LIMITS);
-
pf ("\n");
pf ("/* 64-bit integer -- if available SCM_HAVE_T_INT64 will be 1 and\n"
" scm_t_int64 will be a suitable type, otherwise SCM_HAVE_T_INT64\n"
@@ -334,8 +311,6 @@ main (int argc, char *argv[])
{
pf ("#define SCM_HAVE_T_INT64 1 /* 0 or 1 */\n");
pf ("typedef %s scm_t_int64;\n", SCM_I_GSC_T_INT64);
- pf ("#define SCM_T_INT64_MIN %s_MIN\n", SCM_I_GSC_T_INT64_LIMITS);
- pf ("#define SCM_T_INT64_MAX %s_MAX\n", SCM_I_GSC_T_INT64_LIMITS);
}
else
pf ("#define SCM_HAVE_T_INT64 0 /* 0 or 1 */\n");
@@ -348,15 +323,10 @@ main (int argc, char *argv[])
{
pf ("#define SCM_HAVE_T_UINT64 1 /* 0 or 1 */\n");
pf ("typedef %s scm_t_uint64;\n", SCM_I_GSC_T_UINT64);
- pf ("#define SCM_T_UINT64_MAX %s_MAX\n", SCM_I_GSC_T_UINT64_LIMITS);
}
else
pf ("#define SCM_HAVE_T_UINT64 0 /* 0 or 1 */\n");
- pf ("#define SCM_T_INTMAX_MIN %s_MIN\n", SCM_I_GSC_T_INTMAX_LIMITS);
- pf ("#define SCM_T_INTMAX_MAX %s_MAX\n", SCM_I_GSC_T_INTMAX_LIMITS);
- pf ("#define SCM_T_UINTMAX_MAX %s_MAX\n", SCM_I_GSC_T_UINTMAX_LIMITS);
-
pf ("\n");
pf ("/* scm_t_ptrdiff_t and size, always defined -- defined to long if\n"
" platform doesn't have ptrdiff_t. */\n");