mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-04-27 11:40:45 -07:00
ieee-floats: fix builds with --with-ieee-fp=no
Functions to print (nan,float)-to-string and and predicates are still available, but ext:*-float-*-infinity aren't available if ECL is built with option `--with-ieee-fp=no`.
This commit is contained in:
parent
873be229d0
commit
ed5ecd03eb
7 changed files with 60 additions and 26 deletions
|
|
@ -43,6 +43,7 @@ infinity(cl_index exp_char, int sign)
|
|||
{
|
||||
cl_object var;
|
||||
switch (exp_char) {
|
||||
#ifdef ECL_IEEE_FP
|
||||
case 'e': case 'E':
|
||||
return infinity(ecl_current_read_default_float_format(), sign);
|
||||
case 's': case 'S':
|
||||
|
|
@ -52,17 +53,18 @@ infinity(cl_index exp_char, int sign)
|
|||
@'ext::single-float-positive-infinity';
|
||||
break;
|
||||
case 'l': case 'L':
|
||||
#ifdef ECL_LONG_FLOAT
|
||||
# ifdef ECL_LONG_FLOAT
|
||||
var = (sign<0)?
|
||||
@'ext::long-float-negative-infinity' :
|
||||
@'ext::long-float-positive-infinity';
|
||||
break;
|
||||
#endif
|
||||
# endif
|
||||
case 'd': case 'D':
|
||||
var = (sign<0)?
|
||||
@'ext::double-float-negative-infinity' :
|
||||
@'ext::double-float-positive-infinity';
|
||||
break;
|
||||
#endif /* ECL_IEEE_FP */
|
||||
default:
|
||||
return OBJNULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1900,22 +1900,25 @@ cl_symbols[] = {
|
|||
|
||||
{EXT_ "*BYTECODES-COMPILER*", EXT_SPECIAL, NULL, -1, ECL_NIL},
|
||||
|
||||
#ifdef ECL_IEEE_FP
|
||||
{EXT_ "SHORT-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL},
|
||||
{EXT_ "SINGLE-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL},
|
||||
{EXT_ "DOUBLE-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL},
|
||||
{EXT_ "LONG-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL},
|
||||
|
||||
{EXT_ "SHORT-FLOAT-NEGATIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL},
|
||||
{EXT_ "SINGLE-FLOAT-NEGATIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL},
|
||||
{EXT_ "DOUBLE-FLOAT-NEGATIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL},
|
||||
{EXT_ "LONG-FLOAT-NEGATIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL},
|
||||
#endif /* ECL_IEEE_FP */
|
||||
|
||||
{EXT_ "FLOAT-NAN-P", EXT_ORDINARY, si_float_nan_p, 1, OBJNULL},
|
||||
{EXT_ "FLOAT-INFINITY-P", EXT_ORDINARY, si_float_infinity_p, 1, OBJNULL},
|
||||
|
||||
{SYS_ "READ-OBJECT-OR-IGNORE", EXT_ORDINARY, si_read_object_or_ignore, 2, OBJNULL},
|
||||
|
||||
{EXT_ "FLOAT-NAN-STRING", EXT_ORDINARY, NULL, 1, OBJNULL},
|
||||
{EXT_ "FLOAT-INFINITY-STRING", EXT_ORDINARY, NULL, 1, OBJNULL},
|
||||
|
||||
{SYS_ "READ-OBJECT-OR-IGNORE", EXT_ORDINARY, si_read_object_or_ignore, 2, OBJNULL},
|
||||
|
||||
{EXT_ "READTABLE-LOCK", EXT_ORDINARY, si_readtable_lock, -1, OBJNULL},
|
||||
|
||||
{SYS_ "+IO-SYNTAX-PROGV-LIST+", SI_CONSTANT, NULL, -1, OBJNULL},
|
||||
|
|
|
|||
|
|
@ -1900,22 +1900,25 @@ cl_symbols[] = {
|
|||
|
||||
{EXT_ "*BYTECODES-COMPILER*",NULL},
|
||||
|
||||
#ifdef ECL_IEEE_FP
|
||||
{EXT_ "SHORT-FLOAT-POSITIVE-INFINITY",NULL},
|
||||
{EXT_ "SINGLE-FLOAT-POSITIVE-INFINITY",NULL},
|
||||
{EXT_ "DOUBLE-FLOAT-POSITIVE-INFINITY",NULL},
|
||||
{EXT_ "LONG-FLOAT-POSITIVE-INFINITY",NULL},
|
||||
|
||||
{EXT_ "SHORT-FLOAT-NEGATIVE-INFINITY",NULL},
|
||||
{EXT_ "SINGLE-FLOAT-NEGATIVE-INFINITY",NULL},
|
||||
{EXT_ "DOUBLE-FLOAT-NEGATIVE-INFINITY",NULL},
|
||||
{EXT_ "LONG-FLOAT-NEGATIVE-INFINITY",NULL},
|
||||
#endif /* ECL_IEEE_FP */
|
||||
|
||||
{EXT_ "FLOAT-NAN-P","si_float_nan_p"},
|
||||
{EXT_ "FLOAT-INFINITY-P","si_float_infinity_p"},
|
||||
|
||||
{SYS_ "READ-OBJECT-OR-IGNORE","si_read_object_or_ignore"},
|
||||
|
||||
{EXT_ "FLOAT-NAN-STRING",NULL},
|
||||
{EXT_ "FLOAT-INFINITY-STRING",NULL},
|
||||
|
||||
{SYS_ "READ-OBJECT-OR-IGNORE","si_read_object_or_ignore"},
|
||||
|
||||
{EXT_ "READTABLE-LOCK","si_readtable_lock"},
|
||||
|
||||
{SYS_ "+IO-SYNTAX-PROGV-LIST+",NULL},
|
||||
|
|
|
|||
|
|
@ -217,24 +217,41 @@ printer and we should rather use MAKE-LOAD-FORM."
|
|||
(short-float . "#<short-float quiet NaN>")))))
|
||||
|
||||
(defun ext::float-infinity-string (x)
|
||||
(when (and *print-readably* (null *read-eval*))
|
||||
(when (and *print-readably*
|
||||
#+ieee-floating-point (null *read-eval*))
|
||||
(error 'print-not-readable :object x))
|
||||
(let* ((negative-infinities '((single-float .
|
||||
"#.ext::single-float-negative-infinity")
|
||||
#.(if (member :ieee-floating-point *features*)
|
||||
"#.ext::single-float-negative-infinity"
|
||||
"#<single-float negative infinity>"))
|
||||
(double-float .
|
||||
"#.ext::double-float-negative-infinity")
|
||||
#.(if (member :ieee-floating-point *features*)
|
||||
"#.ext::double-float-negative-infinity"
|
||||
"#<double-float negative infinity>"))
|
||||
(long-float .
|
||||
"#.ext::long-float-negative-infinity")
|
||||
#.(if (member :ieee-floating-point *features*)
|
||||
"#.ext::long-float-negative-infinity"
|
||||
"<long-float negative infinity>"))
|
||||
(short-float .
|
||||
"#.ext::short-float-negative-infinity")))
|
||||
#.(if (member :ieee-floating-point *features*)
|
||||
"#.ext::short-float-negative-infinity"
|
||||
"<short-float negative infinity>"))))
|
||||
(positive-infinities '((single-float .
|
||||
"#.ext::single-float-positive-infinity")
|
||||
#.(if (member :ieee-floating-point *features*)
|
||||
"#.ext::single-float-positive-infinity"
|
||||
"#<single-float positive infinity>"))
|
||||
(double-float .
|
||||
"#.ext::double-float-positive-infinity")
|
||||
#.(if (member :ieee-floating-point *features*)
|
||||
"#.ext::double-float-positive-infinity"
|
||||
"#<double-float positive infinity>"))
|
||||
(long-float .
|
||||
"#.ext::long-float-positive-infinity")
|
||||
#.(if (member :ieee-floating-point *features*)
|
||||
"#.ext::long-float-positive-infinity"
|
||||
"<long-float positive infinity>"))
|
||||
(short-float .
|
||||
"#.ext::short-float-positive-infinity")))
|
||||
#.(if (member :ieee-floating-point *features*)
|
||||
"#.ext::short-float-positive-infinity"
|
||||
"<short-float positive infinity>"))))
|
||||
(record (assoc (type-of x)
|
||||
(if (plusp x) positive-infinities negative-infinities))))
|
||||
(unless record
|
||||
|
|
|
|||
|
|
@ -152,22 +152,24 @@
|
|||
(LEAST-NEGATIVE-DOUBLE-FLOAT "-DBL_MIN")
|
||||
(LEAST-NEGATIVE-NORMALIZED-DOUBLE-FLOAT "-DBL_MIN")
|
||||
|
||||
(SHORT-FLOAT-POSITIVE-INFINITY "INFINITY")
|
||||
(SINGLE-FLOAT-POSITIVE-INFINITY "INFINITY")
|
||||
(DOUBLE-FLOAT-POSITIVE-INFINITY "INFINITY")
|
||||
#+ieee-floating-point
|
||||
,@'((SHORT-FLOAT-POSITIVE-INFINITY "INFINITY")
|
||||
(SINGLE-FLOAT-POSITIVE-INFINITY "INFINITY")
|
||||
(DOUBLE-FLOAT-POSITIVE-INFINITY "INFINITY")
|
||||
|
||||
(SHORT-FLOAT-NEGATIVE-INFINITY "-INFINITY")
|
||||
(SINGLE-FLOAT-NEGATIVE-INFINITY "-INFINITY")
|
||||
(DOUBLE-FLOAT-NEGATIVE-INFINITY "-INFINITY")
|
||||
(SHORT-FLOAT-NEGATIVE-INFINITY "-INFINITY")
|
||||
(SINGLE-FLOAT-NEGATIVE-INFINITY "-INFINITY")
|
||||
(DOUBLE-FLOAT-NEGATIVE-INFINITY "-INFINITY"))
|
||||
|
||||
#+long-float
|
||||
,@'(
|
||||
(MOST-POSITIVE-LONG-FLOAT "LDBL_MAX")
|
||||
,@'((MOST-POSITIVE-LONG-FLOAT "LDBL_MAX")
|
||||
(MOST-NEGATIVE-LONG-FLOAT "-LDBL_MAX")
|
||||
(LEAST-POSITIVE-LONG-FLOAT "LDBL_MIN")
|
||||
(LEAST-POSITIVE-NORMALIZED-LONG-FLOAT" LDBL_MIN")
|
||||
(LEAST-NEGATIVE-LONG-FLOAT "-LDBL_MIN")
|
||||
(LEAST-NEGATIVE-NORMALIZED-LONG-FLOAT "-LDBL_MIN")
|
||||
#+ieee-floating-point
|
||||
(LONG-FLOAT-POSITIVE-INFINITY "INFINITY")
|
||||
#+ieee-floating-point
|
||||
(LONG-FLOAT-NEGATIVE-INFINITY "-INFINITY")
|
||||
)))))
|
||||
|
|
|
|||
|
|
@ -60,6 +60,13 @@
|
|||
|
||||
@node Numbers
|
||||
@section Numbers
|
||||
|
||||
@c ext:{short,single,double,long}-float-{positive,negative}-infinity
|
||||
@c ext:float-nan-p
|
||||
@c ext:float-infinity-p
|
||||
@c ext:float-nan-string
|
||||
@c ext:float-infinity-string
|
||||
|
||||
@c make-random-state fixnum|array
|
||||
@c ext:random-state-array
|
||||
@c #$ macro
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
(not (= (float 1 E) (- (float 1 E) E)))")
|
||||
))
|
||||
|
||||
#+IEEE-FLOATING-POINT
|
||||
#+ieee-floating-point
|
||||
(locally
|
||||
(declare (notinline -))
|
||||
(let* ((bits (si::trap-fpe 'last nil)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue