Fix clisp cross-compile
authorChristophe Rhodes <c.rhodes@gold.ac.uk>
Sat, 15 Sep 2012 17:39:23 +0000 (18:39 +0100)
committerChristophe Rhodes <c.rhodes@gold.ac.uk>
Sat, 15 Sep 2012 17:42:16 +0000 (18:42 +0100)
Problems:

* least-positive-long-float is unrepresentable in clisp, ending up
  with being zero
* clisp's decode-float returns a 0 exponent for a 0 float (rather
  than something large and negative)
* everything got constant-folded in the cross-compiler, thus using
  the host's runtime.

Solution: compute the value using sb!vm:double-float-digits/bias

src/code/reader.lisp

index 08a5286..8f885fa 100644 (file)
@@ -1415,17 +1415,17 @@ extended <package-name>::<form-in-package> syntax."
   ;; and convert to base-10 conservatively at the end.
   ;; Use the least positive float, because denormalized exponent
   ;; can be larger than normalized.
-  (let* ((max-exponent (- (nth-value
-                           1
-                           (decode-float least-positive-long-float))))
+  (let* ((max-exponent
+          #!-long-float
+          (+ sb!vm:double-float-digits sb!vm:double-float-bias))
          (number-magnitude (integer-length number))
          (divisor-magnitude (1- (integer-length divisor)))
          (magnitude (- number-magnitude divisor-magnitude)))
     (if (minusp exponent)
         (max exponent (ceiling (- (+ max-exponent magnitude))
-                               (floor (log 10 2))))
+                               #.(floor (log 10 2))))
         (min exponent (floor (- max-exponent magnitude)
-                             (floor (log 10 2)))))))
+                             #.(floor (log 10 2)))))))
 
 (defun make-float (stream)
   ;; Assume that the contents of *read-buffer* are a legal float, with nothing