summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>2001-10-06 20:00:43 +0000
committerMarius Vollmer <mvo@zagadka.de>2001-10-06 20:00:43 +0000
commit801ba33101a882fc1146823f3c805b966cf2e31d (patch)
tree1d11b758dbb7de19a05674969b4a73082cdcc050
parentdcb6a296dcf019c431076fc37375f30797ea38e9 (diff)
downloadguile-801ba33101a882fc1146823f3c805b966cf2e31d.tar.gz
(INTEGRAL2NUM): Let the preprocessor test
whether the integral type fits in a fixnum, not the compiler. This removes a spurious compiler warning. Also, honor the NO_PREPRO_MAGIC flag to suppress any preprocessor tests. This is needed for `long long's.
-rw-r--r--libguile/num2integral.i.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c
index 29e7effc0..acba57d1d 100644
--- a/libguile/num2integral.i.c
+++ b/libguile/num2integral.i.c
@@ -79,16 +79,43 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller)
SCM
INTEGRAL2NUM (ITYPE n)
{
- if (sizeof (ITYPE) < sizeof (scm_t_signed_bits)
- ||
-#ifndef UNSIGNED
- SCM_FIXABLE (n)
+ /* Determine at compile time whether we need to porferm the FIXABLE
+ test or not. This is not done to get more optimal code out of
+ the compiler (it can figure this out on its already), but to
+ avoid a spurious warning.
+ */
+
+#ifdef NEED_CHECK
+#undef NEED_CHECK
+#endif
+
+#ifdef NO_PREPRO_MAGIC
+#define NEED_CHECK
#else
- SCM_POSFIXABLE (n)
-#endif
- )
+#ifdef UNSIGNED
+#if MAX_VALUE > SCM_MOST_POSITIVE_FIXNUM
+#define NEED_CHECK
+#endif
+#else
+#if MIN_VALUE<SCM_MOST_NEGATIVE_FIXNUM || MAX_VALUE>SCM_MOST_POSITIVE_FIXNUM
+#define NEED_CHECK
+#endif
+#endif
+#endif
+
+#ifndef UNSIGNED
+#ifdef NEED_CHECK
+ if (SCM_FIXABLE (n))
+#endif
+#else
+#ifdef NEED_CHECK
+ if (SCM_FIXABLE (n))
+#endif
+#endif
return SCM_MAKINUM ((scm_t_signed_bits) n);
+#undef NEED_CHECK
+
#ifdef SCM_BIGDIG
return INTEGRAL2BIG (n);
#else
@@ -152,6 +179,7 @@ INTEGRAL2BIG (ITYPE n)
#undef ITYPE
#undef MIN_VALUE
#undef MAX_VALUE
+#undef NO_PREPRO_MAGIC
/*
Local Variables: