use inexact real SCM numbers for lisp floats
authorBT Templeton <bpt@hcoop.net>
Wed, 11 Jul 2012 20:58:12 +0000 (16:58 -0400)
committerRobin Templeton <robin@terpri.org>
Sat, 18 Apr 2015 22:49:08 +0000 (18:49 -0400)
* src/alloc.c (make_float): Use `scm_from_double'.n
* src/lisp.h (XFLOAT): Use `scm_to_double'.
  (lisp_float_tag, XSETFLOAT, XFLOAT_INIT): Remove.
  (FLOATP): Use `SCM_INEXACTP'.

src/alloc.c
src/lisp.h

index b229f7b..648e3f7 100644 (file)
@@ -142,13 +142,6 @@ extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE;
 /* Recording what needs to be marked for gc.  */
 
 struct gcpro *gcprolist;
-
-static void
-XFLOAT_INIT (Lisp_Object f, double n)
-{
-  XFLOAT (f)->data = n;
-}
-
 \f
 /************************************************************************
                                Malloc
@@ -790,17 +783,9 @@ make_formatted_string (char *buf, const char *format, ...)
 Lisp_Object
 make_float (double float_value)
 {
-  register Lisp_Object val;
-  struct Lisp_Float *p;
-
-  p = xmalloc (sizeof *p);
-  SCM_NEWSMOB (p->self, lisp_float_tag, p);
-  XSETFLOAT (val, p);
-  XFLOAT_INIT (val, float_value);
-  return val;
+  return scm_from_double (float_value);
 }
 
-
 \f
 /***********************************************************************
                           Cons Allocation
@@ -1677,7 +1662,6 @@ init_alloc_once (void)
   lisp_string_tag = scm_make_smob_type ("elisp-string", 0);
   lisp_vectorlike_tag = scm_make_smob_type ("elisp-vectorlike", 0);
   lisp_cons_tag = scm_make_smob_type ("elisp-cons", 0);
-  lisp_float_tag = scm_make_smob_type ("elisp-float", 0);
 
   /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet!  */
 
index 2f7c2f7..4888c27 100644 (file)
@@ -293,7 +293,7 @@ DEFINE_GDB_SYMBOL_END (USE_LSB_TAG)
    ((ok) ? (void) 0 : (void) wrong_type_argument (predicate, x))
 #define lisp_h_CONSP(x) (SMOB_TYPEP (x, lisp_cons_tag))
 #define lisp_h_EQ(x, y) (scm_is_eq (x, y))
-#define lisp_h_FLOATP(x) (SMOB_TYPEP (x, lisp_float_tag))
+#define lisp_h_FLOATP(x) (x && SCM_INEXACTP (x))
 #define lisp_h_INTEGERP(x) (SCM_I_INUMP (x))
 #define lisp_h_MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker)
 #define lisp_h_MISCP(x) (SMOB_TYPEP (x, lisp_misc_tag))
@@ -380,7 +380,6 @@ scm_t_bits lisp_misc_tag;
 scm_t_bits lisp_string_tag;
 scm_t_bits lisp_vectorlike_tag;
 scm_t_bits lisp_cons_tag;
-scm_t_bits lisp_float_tag;
 
 enum Lisp_Type
   {
@@ -689,13 +688,6 @@ XSTRING (Lisp_Object a)
 
 LISP_MACRO_DEFUN (XSYMBOL, struct Lisp_Symbol *, (Lisp_Object a), (a))
 
-INLINE struct Lisp_Float *
-XFLOAT (Lisp_Object a)
-{
-  eassert (FLOATP (a));
-  return SMOB_PTR (a);
-}
-
 /* Pseudovector types.  */
 
 INLINE struct Lisp_Process *
@@ -765,7 +757,6 @@ make_lisp_proc (struct Lisp_Process *p)
 #define XSETVECTOR(a, b) ((a) = (b)->header.self)
 #define XSETSTRING(a, b) ((a) = (b)->self)
 #define XSETSYMBOL(a, b) ((a) = (b)->self)
-#define XSETFLOAT(a, b) ((a) = (b)->self)
 #define XSETMISC(a, b) (a) = ((union Lisp_Misc *) (b))->u_any.self
 
 /* Pseudovector types.  */
@@ -2050,18 +2041,7 @@ XBUFFER_OBJFWD (union Lisp_Fwd *a)
   return &a->u_buffer_objfwd;
 }
 \f
-/* Lisp floating point type.  */
-struct Lisp_Float
-  {
-    Lisp_Object self;
-    double data;
-  };
-
-INLINE double
-XFLOAT_DATA (Lisp_Object f)
-{
-  return XFLOAT (f)->data;
-}
+#define XFLOAT_DATA(f)  (scm_to_double (f))
 
 /* Most hosts nowadays use IEEE floating point, so they use IEC 60559
    representations, have infinities and NaNs, and do not trap on