summaryrefslogtreecommitdiff
path: root/libguile/numbers.h
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/numbers.h')
-rw-r--r--libguile/numbers.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/libguile/numbers.h b/libguile/numbers.h
index cfc2ba80d..38b25ca8b 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -71,25 +71,26 @@
/* shifts of more than one are done by a library call, single shifts are
* performed in registers
*/
-# define SCM_MAKINUM(x) ((((x)<<1)<<1)+2L)
+# define SCM_MAKINUM(x) ((SCM) (((SCM_ASWORD(x)<<1)<<1)+2L))
#else
-# define SCM_MAKINUM(x) (((x)<<2)+2L)
+# define SCM_MAKINUM(x) ((SCM)((SCM_ASWORD(x)<<2)+2L))
#endif /* def __TURBOC__ */
/* SCM_SRS is signed right shift */
+/* SCM_INUM makes a C int from an SCM immediate number. */
/* Turbo C++ v1.0 has a bug with right shifts of signed longs!
* It is believed to be fixed in Turbo C++ v1.01
*/
#if (-1==(((-1)<<2)+2)>>2) && (__TURBOC__ != 0x295)
-# define SCM_SRS(x, y) ((x)>>y)
+# define SCM_SRS(x, y) (SCM_ASWORD (x)>>y)
# ifdef __TURBOC__
-# define SCM_INUM(x) (((x)>>1)>>1)
+# define SCM_INUM(x) ((SCM_ASWORD(x) >>1) >>1)
# else
# define SCM_INUM(x) SCM_SRS(x, 2)
# endif /* def __TURBOC__ */
#else
-# define SCM_SRS(x, y) (((x)<0) ? ~((~(x))>>y) : (x)>>y)
+# define SCM_SRS(x, y) ((SCM_ASWORD(x) < 0) ? ~( (~SCM_ASWORD(x)) >>y) : (SCM_ASWORD (x)>>y))
# define SCM_INUM(x) SCM_SRS(x, 2)
#endif /* (-1==(((-1)<<2)+2)>>2) && (__TURBOC__ != 0x295) */
@@ -132,15 +133,15 @@
*/
#define SCM_INEXP(x) (SCM_NIMP(x) && (SCM_TYP16(x)==scm_tc16_flo))
-#define SCM_CPLXP(x) (SCM_NIMP(x) && (SCM_CAR(x)==scm_tc_dblc))
+#define SCM_CPLXP(x) (SCM_NIMP(x) && (SCM_CARW (x)==scm_tc_dblc))
#define SCM_REAL(x) (*(((scm_dbl *) (SCM2PTR(x)))->real))
#define SCM_IMAG(x) (*((double *)(SCM_CHARS(x)+sizeof(double))))
/* ((&SCM_REAL(x))[1]) */
#ifdef SCM_SINGLES
-#define SCM_REALP(x) (SCM_NIMP(x) && ((~SCM_REAL_PART & SCM_CAR(x))==scm_tc_flo))
-#define SCM_SINGP(x) (SCM_NIMP(x) && (SCM_CAR(x)==scm_tc_flo))
+#define SCM_REALP(x) (SCM_NIMP(x) && ((~SCM_REAL_PART & SCM_CARW (x))==scm_tc_flo))
+#define SCM_SINGP(x) (SCM_NIMP(x) && (SCM_CARW (x)==scm_tc_flo))
#define SCM_FLO(x) (((scm_flo *)(SCM2PTR(x)))->num)
#define SCM_REALPART(x) (SCM_SINGP(x)?0.0+SCM_FLO(x):SCM_REAL(x))
#else /* SCM_SINGLES */
@@ -216,7 +217,7 @@
#define SCM_BIGP(x) (SCM_NIMP(x) && SCM_TYP16S(x)==scm_tc16_bigpos)
#define SCM_BIGSIGN(x) (0x0100 & (int)SCM_CAR(x))
#define SCM_BDIGITS(x) ((SCM_BIGDIG *)(SCM_CDR(x)))
-#define SCM_NUMDIGS(x) ((scm_sizet)(SCM_CAR(x)>>16))
+#define SCM_NUMDIGS(x) ((scm_sizet)(SCM_CARW (x)>>16))
#define SCM_SETNUMDIGS(x, v, t) SCM_SETCAR(x, (((v)+0L)<<16)+(t))