1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

(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.
This commit is contained in:
Marius Vollmer 2001-10-06 20:00:43 +00:00
parent dcb6a296dc
commit 801ba33101

View file

@ -79,16 +79,43 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller)
SCM SCM
INTEGRAL2NUM (ITYPE n) INTEGRAL2NUM (ITYPE n)
{ {
if (sizeof (ITYPE) < sizeof (scm_t_signed_bits) /* 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
#ifndef UNSIGNED the compiler (it can figure this out on its already), but to
SCM_FIXABLE (n) avoid a spurious warning.
*/
#ifdef NEED_CHECK
#undef NEED_CHECK
#endif
#ifdef NO_PREPRO_MAGIC
#define NEED_CHECK
#else #else
SCM_POSFIXABLE (n) #ifdef UNSIGNED
#endif #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); return SCM_MAKINUM ((scm_t_signed_bits) n);
#undef NEED_CHECK
#ifdef SCM_BIGDIG #ifdef SCM_BIGDIG
return INTEGRAL2BIG (n); return INTEGRAL2BIG (n);
#else #else
@ -152,6 +179,7 @@ INTEGRAL2BIG (ITYPE n)
#undef ITYPE #undef ITYPE
#undef MIN_VALUE #undef MIN_VALUE
#undef MAX_VALUE #undef MAX_VALUE
#undef NO_PREPRO_MAGIC
/* /*
Local Variables: Local Variables: