From 6b07439dfe446be285ee5be9fabd03bf0e7957c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Fri, 18 Nov 2016 13:48:22 +0100 Subject: [PATCH] ieee-fp: remove si_infinity Our "new" way of defining infinity constants breaks on ARM. Remove unnecessary functions. IEEE-FP are a nightmare (honestly). --- src/c/num_pred.d | 12 ++++++++++++ src/c/number.d | 6 ------ src/c/symbols_list.h | 1 - src/c/symbols_list2.h | 1 - src/doc/new-doc/standards/index.txi | 1 - src/h/external.h | 1 - src/lsp/numlib.lsp | 30 ++++++++++++++++------------- src/tests/normal-tests/ieee-fp.lsp | 3 +-- 8 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/c/num_pred.d b/src/c/num_pred.d index d8468518b..7bfb6052d 100644 --- a/src/c/num_pred.d +++ b/src/c/num_pred.d @@ -65,6 +65,18 @@ bool ecl_float_nan_p(cl_object x) { return !ecl_number_equalp(x,x); +/* switch (ecl_t_of(x)) { */ +/* case t_singlefloat: */ +/* return !isnan(ecl_single_float(x)); */ +/* case t_doublefloat: */ +/* return !isnan(ecl_double_float(x)); */ +/* #ifdef ECL_LONG_FLOAT */ +/* case t_longfloat: */ +/* return !isnan(ecl_long_float(x)); */ +/* #endif */ +/* default: */ +/* return 0; */ +/* } */ } bool diff --git a/src/c/number.d b/src/c/number.d index 235469b2a..dac770193 100644 --- a/src/c/number.d +++ b/src/c/number.d @@ -923,10 +923,4 @@ si_nan() { cl_object x = ecl_alloc_object(t_doublefloat); ecl_double_float(x) = NAN; } - -cl_object -si_infinity() { - cl_object x = ecl_alloc_object(t_doublefloat); - ecl_double_float(x) = INFINITY; -} #endif /* ECL_IEEE_FP */ diff --git a/src/c/symbols_list.h b/src/c/symbols_list.h index 1651ab7bf..3dbabed55 100755 --- a/src/c/symbols_list.h +++ b/src/c/symbols_list.h @@ -1912,7 +1912,6 @@ cl_symbols[] = { #ifdef ECL_IEEE_FP {SYS_ "NAN", EXT_ORDINARY, si_nan, 0, OBJNULL}, -{SYS_ "INFINITY", EXT_ORDINARY, si_infinity, 0, OBJNULL}, {EXT_ "SHORT-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL}, {EXT_ "SINGLE-FLOAT-POSITIVE-INFINITY", EXT_CONSTANT, NULL, -1, OBJNULL}, diff --git a/src/c/symbols_list2.h b/src/c/symbols_list2.h index 719962b5b..364402544 100644 --- a/src/c/symbols_list2.h +++ b/src/c/symbols_list2.h @@ -1912,7 +1912,6 @@ cl_symbols[] = { #ifdef ECL_IEEE_FP {SYS_ "NAN","si_nan"}, -{SYS_ "INFINITY","si_infinity"}, {EXT_ "SHORT-FLOAT-POSITIVE-INFINITY",NULL}, {EXT_ "SINGLE-FLOAT-POSITIVE-INFINITY",NULL}, diff --git a/src/doc/new-doc/standards/index.txi b/src/doc/new-doc/standards/index.txi index 804e831d9..8b7c845fd 100644 --- a/src/doc/new-doc/standards/index.txi +++ b/src/doc/new-doc/standards/index.txi @@ -63,7 +63,6 @@ @c build option --with-ieee-fp={yes|no} @c si::trap-fpe @c si::nan -@c si::infinity @c ext:{short,single,double,long}-float-{positive,negative}-infinity @c ext:float-nan-p @c ext:float-infinity-p diff --git a/src/h/external.h b/src/h/external.h index 90c499959..df810c718 100755 --- a/src/h/external.h +++ b/src/h/external.h @@ -1119,7 +1119,6 @@ extern ECL_API cl_object ecl_make_long_float(long double f); #endif #ifdef ECL_IEEE_FP extern cl_object si_nan(); -extern cl_object si_infinity(); #endif /* ECL_IEEE_FP */ /* num_co.c */ diff --git a/src/lsp/numlib.lsp b/src/lsp/numlib.lsp index 1bd7c9d84..dc72a8f19 100644 --- a/src/lsp/numlib.lsp +++ b/src/lsp/numlib.lsp @@ -74,19 +74,23 @@ )) #+ieee-floating-point -(let ((bits (si:trap-fpe 'last nil))) - (unwind-protect - (locally (declare (notinline -)) - (let ((inf (si:infinity))) - (defconstant short-float-positive-infinity (coerce inf 'short-float)) - (defconstant short-float-negative-infinity (coerce (- inf) 'short-float)) - (defconstant single-float-positive-infinity (coerce inf 'single-float)) - (defconstant single-float-negative-infinity (coerce (- inf) 'single-float)) - (defconstant double-float-positive-infinity (coerce inf 'double-float)) - (defconstant double-float-negative-infinity (coerce (- inf) 'double-float)) - (defconstant long-float-positive-infinity (coerce inf 'long-float)) - (defconstant long-float-negative-infinity (coerce (- inf) 'long-float)))) - (si:trap-fpe bits t))) +(locally (declare (notinline -)) + (let ((bits (si::trap-fpe 'last nil))) + (unwind-protect + (progn + (let ((a (/ (coerce 1 'short-float) (coerce 0.0 'short-float)))) + (defconstant short-float-positive-infinity a) + (defconstant short-float-negative-infinity (- a))) + (let ((a (/ (coerce 1 'single-float) (coerce 0.0 'single-float)))) + (defconstant single-float-positive-infinity a) + (defconstant single-float-negative-infinity (- a))) + (let ((a (/ (coerce 1 'double-float) (coerce 0.0 'double-float)))) + (defconstant double-float-positive-infinity a) + (defconstant double-float-negative-infinity (- a))) + (let ((a (/ (coerce 1 'long-float) (coerce 0.0 'long-float)))) + (defconstant long-float-positive-infinity a) + (defconstant long-float-negative-infinity (- a)))) + (si::trap-fpe bits t)))) (defconstant imag-one #C(0.0 1.0)) diff --git a/src/tests/normal-tests/ieee-fp.lsp b/src/tests/normal-tests/ieee-fp.lsp index 3696913dc..c98d67199 100644 --- a/src/tests/normal-tests/ieee-fp.lsp +++ b/src/tests/normal-tests/ieee-fp.lsp @@ -25,8 +25,7 @@ ext:single-float-positive-infinity ext:double-float-negative-infinity ext:double-float-positive-infinity - (si:nan) - (si:infinity))) + (si:nan))) (*standard-output* (make-string-output-stream))) (dolist (i nums) (finishes