* __scm.h: Added section for debugging options.
authorDirk Herrmann <dirk@dirk-herrmanns-seiten.de>
Thu, 11 May 2000 16:03:32 +0000 (16:03 +0000)
committerDirk Herrmann <dirk@dirk-herrmanns-seiten.de>
Thu, 11 May 2000 16:03:32 +0000 (16:03 +0000)
* New debugging option SCM_DEBUG_DEPRECATED.
* numbers.c numbers.h:  Deprecated a lot of stuff.

libguile/ChangeLog
libguile/__scm.h
libguile/numbers.c
libguile/numbers.h

index 154bde0..808ab84 100644 (file)
@@ -1,3 +1,23 @@
+2000-05-11  Dirk Herrmann  <D.Herrmann@tu-bs.de>
+
+       * __scm.h:  Added new section for debugging options.
+
+       (SCM_DEBUG_DEPRECATED):  If 1, no deprecated code is included to
+       help developers to get rid of references to deprecated code.
+
+       * numbers.[ch] (SCM_POSFIXABLE, SCM_NEGFIXABLE, SCM_UNEGFIXABLE,
+       SCM_FIXABLE, SCM_FLOBUFLEN):  These macros are no longer provided
+       as part of the interface and are marked as deprecated in the
+       header file.
+
+       * numbers.c (scm_make_real, scm_make_complex):  Inlined the
+       corresponding macros SCM_NEWREAL and SCM_NEWCOMPLEX,
+       respectively.
+
+       * numbers.h (SCM_NEWREAL, SCM_NEWCOMPLEX, SCM_INEXP, SCM_CPLXP,
+       SCM_REAL, SCM_IMAG, SCM_REALPART, scm_makdbl, SCM_SINGP,
+       SCM_NO_BIGDIG, SCM_NUM2DBL, scm_dblproc):  Deprecated.
+
 2000-05-10  Dirk Herrmann  <D.Herrmann@tu-bs.de>
 
        * gc.h (scm_cell, SCM_CELL_WORD, SCM_CELL_OBJECT,
index 7ca2241..cb10c51 100644 (file)
 #undef NO_CEVAL_STACK_CHECKING
 
 \f
+
 /* What did the configure script discover about the outside world?  */
 #include "libguile/scmconfig.h"
 
+\f
+
+/* {Debugging Options}
+ *
+ * These compile time options determine whether to include code that is only
+ * useful for debugging guile itself or C level extensions to guile.  The
+ * common prefix for all option macros of this kind is "SCM_DEBUG_".  It is
+ * guaranteed that a macro named SCM_DEBUG_XXX is defined to be either 0 or 1,
+ * i. e. there is no need to test for the undefined case.  This allows to use
+ * these definitions comfortably in macro code, as in the following example:
+ *   #define FOO do { if (SCM_DEBUG_XXX) bar(); else baz(); } while (0)
+ * Any sane compiler will remove the unused branch without any performance
+ * penalty for the resulting code.
+ *
+ * Note:  Some SCM_DEBUG_XXX options are not settable at configure time.
+ * To change the value of such options you will have to edit this header
+ * file or give -DSCM_DEBUG_XXX options to make.
+ */
+
+
+/* If SCM_DEBUG_DEPRECATED is set to 1, deprecated code is not compiled.  This
+ * can be used by developers to get rid of references to deprecated code.
+ */
+#ifndef SCM_DEBUG_DEPRECATED
+#define SCM_DEBUG_DEPRECATED 0
+#endif
+
+\f
+
 #ifdef HAVE_LONG_LONGS
 
 /* Some auto-generated .h files contain unused prototypes
index 6b34515..0b08131 100644 (file)
@@ -70,6 +70,22 @@ static SCM scm_divbigint (SCM x, long z, int sgn, int mode);
 #define SCM_SWAP(x,y) do { SCM __t = x; x = y; y = __t; } while (0)
 
 
+#if (SCM_DEBUG_DEPRECATED == 1)  /* not defined in header yet? */
+/* SCM_FIXABLE is non-0 if its long argument can be encoded in an SCM_INUM.
+ */
+#define SCM_POSFIXABLE(n) ((n) <= SCM_MOST_POSITIVE_FIXNUM)
+#define SCM_NEGFIXABLE(n) ((n) >= SCM_MOST_NEGATIVE_FIXNUM)
+#define SCM_UNEGFIXABLE(n) ((n) <= -SCM_MOST_NEGATIVE_FIXNUM)
+#define SCM_FIXABLE(n) (SCM_POSFIXABLE(n) && SCM_NEGFIXABLE(n))
+
+
+/* SCM_FLOBUFLEN is the maximum number of characters neccessary for the
+ * printed or scm_string representation of an inexact number.
+ */
+#define SCM_FLOBUFLEN (10+2*(sizeof(double)/sizeof(char)*SCM_CHAR_BIT*3+9)/10)
+#endif
+
+
 /* IS_INF tests its floating point number for infiniteness
    Dirk:FIXME:: This test does not work if x == 0
  */
@@ -2803,7 +2819,9 @@ SCM
 scm_make_real (double x)
 {
   SCM z;
-  SCM_NEWREAL (z, x);
+  SCM_NEWCELL2 (z);
+  SCM_SET_CELL_TYPE (z, scm_tc16_real);
+  SCM_REAL_VALUE (z) = x;
   return z;
 }
 
@@ -2811,9 +2829,15 @@ scm_make_real (double x)
 SCM
 scm_make_complex (double x, double y)
 {
-  SCM z;
-  SCM_NEWCOMPLEX (z, x, y);
-  return z;
+  if (y == 0.0) {
+    return scm_make_real (x);
+  } else {
+    SCM z;
+    SCM_NEWSMOB (z, scm_tc16_complex, scm_must_malloc (2L * sizeof (double), "complex"));
+    SCM_COMPLEX_REAL (z) = x;
+    SCM_COMPLEX_IMAG (z) = y;
+    return z;
+  }
 }
 
 
index 723f144..b3922f8 100644 (file)
@@ -48,7 +48,6 @@
 \f
 
 #include "libguile/__scm.h"
-
 #include "libguile/print.h"
 
 \f
 #endif /* def FLT_MAX */
 
 
-/* SCM_FIXABLE is non-0 if its long argument can be encoded in an SCM_INUM.
- */
-#define SCM_POSFIXABLE(n) ((n) <= SCM_MOST_POSITIVE_FIXNUM)
-#define SCM_NEGFIXABLE(n) ((n) >= SCM_MOST_NEGATIVE_FIXNUM)
-#define SCM_UNEGFIXABLE(n) ((n) <= -SCM_MOST_NEGATIVE_FIXNUM)
-#define SCM_FIXABLE(n) (SCM_POSFIXABLE(n) && SCM_NEGFIXABLE(n))
-
 /* SCM_INTBUFLEN is the maximum number of characters neccessary for the
  * printed or scm_string representation of an exact immediate.
  */
 #endif /* ndef SCM_LONG_BIT */
 #define SCM_INTBUFLEN (5+SCM_LONG_BIT)
 
-/* SCM_FLOBUFLEN is the maximum number of characters neccessary for the
- * printed or scm_string representation of an inexact number.
- */
-
-#define SCM_FLOBUFLEN (10+2*(sizeof(double)/sizeof(char)*SCM_CHAR_BIT*3+9)/10)
-
 
 \f
 
 /* Numbers 
  */
 
-#define SCM_NEWREAL(z, x) \
-  do { \
-    SCM_NEWCELL2 (z); \
-    SCM_SET_CELL_TYPE (z, scm_tc16_real); \
-    SCM_REAL_VALUE (z) = (x); \
-  } while (0) \
-
-#define SCM_NEWCOMPLEX(z, x, y)        \
-  do { \
-    double __SCM_complex_tmp = (y); \
-    if (__SCM_complex_tmp == 0.0) \
-      SCM_NEWREAL (z, x); \
-    else \
-      { \
-        SCM_NEWSMOB (z, scm_tc16_complex, \
-                    scm_must_malloc (2L * sizeof (double), "complex")); \
-        SCM_COMPLEX_REAL (z) = (x); \
-        SCM_COMPLEX_IMAG (z) = __SCM_complex_tmp; \
-      } \
-  } while (0) \
-
 #define SCM_SLOPPY_INEXACTP(x) (SCM_TYP16S (x) == scm_tc16_real)
 #define SCM_SLOPPY_REALP(x) (SCM_TYP16 (x) == scm_tc16_real)
 #define SCM_SLOPPY_COMPLEXP(x) (SCM_TYP16 (x) == scm_tc16_complex)
 #define SCM_REALP(x) (SCM_NIMP (x) && SCM_TYP16 (x) == scm_tc16_real)
 #define SCM_COMPLEXP(x) (SCM_NIMP (x) && SCM_TYP16 (x) == scm_tc16_complex)
 
-#define SCM_INEXP(x) SCM_INEXACTP(x) /* Deprecated */
-#define SCM_CPLXP(x) SCM_COMPLEXP(x) /* Deprecated */
-
 #define SCM_REAL_VALUE(x) (((scm_double_t *) SCM2PTR (x))->real)
 #define SCM_COMPLEX_REAL(x) (((scm_complex_t *) SCM_CELL_WORD_1 (x))->real)
 #define SCM_COMPLEX_IMAG(x) (((scm_complex_t *) SCM_CELL_WORD_1 (x))->imag)
-#define SCM_REAL(x) \
- (SCM_SLOPPY_REALP (x) \
-  ? SCM_REAL_VALUE (x) \
-  : SCM_COMPLEX_REAL (x)) \
-
-#define SCM_IMAG(x) \
-  (SCM_SLOPPY_REALP (x) \
-   ? 0.0 \
-   : SCM_COMPLEX_IMAG (x)) \
-
-#define SCM_REALPART(x) \
-  (SCM_SLOPPY_REALP (x) ? SCM_REAL_VALUE (x) : SCM_COMPLEX_REAL (x))
-
-#define scm_makdbl scm_make_complex /* Deprecated */
-#define SCM_SINGP(x) 0 /* Deprecated */
 
 /* Define SCM_BIGDIG to an integer type whose size is smaller than long if
  * you want bignums.  SCM_BIGRAD is one greater than the biggest SCM_BIGDIG. 
 # define SCM_LONGLONGBIGUP(x) ((ulong_long)(x) << SCM_BITSPERDIG)
 # define SCM_BIGDN(x) ((x) >> SCM_BITSPERDIG)
 # define SCM_BIGLO(x) ((x) & (SCM_BIGRAD-1))
-
 #endif /* def BIGNUMS */
 
 #ifndef SCM_BIGDIG
  * prototypes to compile with conditionalization.
  */
 # define SCM_BIGDIG unsigned short
-# define SCM_NO_BIGDIG
 #endif /* ndef SCM_BIGDIG */
 
 #define SCM_NUMBERP(x) (SCM_INUMP(x) || SCM_NUMP(x))
-#ifdef SCM_BIGDIG
-#define SCM_NUM2DBL(x) (SCM_INUMP (x) \
-                       ? (double) SCM_INUM (x) \
-                       : (SCM_REALP (x) \
-                          ? SCM_REALPART (x) \
-                          : scm_big2dbl (x)))
-#else
-#define SCM_NUM2DBL(x) (SCM_INUMP (x) \
-                       ? (double) SCM_INUM (x) \
-                       : SCM_REALPART (x))
-#endif
 #define SCM_NUMP(x) \
   (SCM_NIMP(x) && (0xfcff & SCM_UNPACK (SCM_CAR(x))) == scm_tc7_smob)
 #define SCM_BIGP(x) SCM_SMOB_PREDICATE (scm_tc16_big, x)
 
 \f
 
-typedef struct scm_dblproc
-{
-  char *scm_string;
-  double (*cproc) ();
-} scm_dblproc;
-
 typedef struct scm_double_t
 {
   SCM type;
@@ -286,7 +214,6 @@ typedef struct scm_complex_t
   double imag;
 } scm_complex_t;
 
-
 \f
 
 extern SCM scm_exact_p (SCM x);
@@ -335,7 +262,6 @@ extern SCM scm_istring2number (char *str, long len, long radix);
 extern SCM scm_string_to_number (SCM str, SCM radix);
 extern SCM scm_make_real (double x);
 extern SCM scm_make_complex (double x, double y);
-extern SCM scm_makdbl (double x, double y); /* Deprecated */
 extern SCM scm_bigequal (SCM x, SCM y);
 extern SCM scm_real_equalp (SCM x, SCM y);
 extern SCM scm_complex_equalp (SCM x, SCM y);
@@ -386,6 +312,38 @@ extern unsigned long scm_num2ulong (SCM num, char *pos,
                                     const char *s_caller);
 extern void scm_init_numbers (void);
 
+\f
+
+#if (SCM_DEBUG_DEPRECATED == 0)
+
+typedef struct scm_dblproc
+{
+  char *scm_string;
+  double (*cproc) ();
+} scm_dblproc;
+
+#define SCM_NEWREAL(z, x) do { z = scm_make_real (x); } while (0)
+#define SCM_NEWCOMPLEX(z, x, y) do { z = scm_make_complex (x, y); } while (0)
+#define SCM_POSFIXABLE(n) ((n) <= SCM_MOST_POSITIVE_FIXNUM)
+#define SCM_NEGFIXABLE(n) ((n) >= SCM_MOST_NEGATIVE_FIXNUM)
+#define SCM_UNEGFIXABLE(n) ((n) <= -SCM_MOST_NEGATIVE_FIXNUM)
+#define SCM_FIXABLE(n) (SCM_POSFIXABLE(n) && SCM_NEGFIXABLE(n))
+#define SCM_FLOBUFLEN (10+2*(sizeof(double)/sizeof(char)*SCM_CHAR_BIT*3+9)/10)
+#define SCM_INEXP(x) SCM_INEXACTP(x)
+#define SCM_CPLXP(x) SCM_COMPLEXP(x)
+#define SCM_REAL(x) (SCM_SLOPPY_REALP (x) ? SCM_REAL_VALUE (x) : SCM_COMPLEX_REAL (x))
+#define SCM_IMAG(x) (SCM_SLOPPY_REALP (x) ? 0.0 : SCM_COMPLEX_IMAG (x))
+#define SCM_REALPART(x) (SCM_SLOPPY_REALP (x) ? SCM_REAL_VALUE (x) : SCM_COMPLEX_REAL (x))
+#define scm_makdbl scm_make_complex
+#define SCM_SINGP(x) 0
+#define SCM_NUM2DBL(x) scm_num2dbl(x, "SCM_NUM2DBL")
+
+#ifndef SCM_BIGDIG
+# define SCM_NO_BIGDIG
+#endif
+
+#endif  /* SCM_DEBUG_DEPRECATED == 0 */
+
 #endif  /* NUMBERSH */
 
 /*