* Squash round() commits

- Add check in roundx() functions for infinite or NaN cases
  - Add block to avoid style warnings
  - Define long double constants and macros for infinity and nan
  - Correct return syntax to match NuttX style
  - Make c89 compliant
  - Fix definitions of INFINITY_L/NAN_L

* include/nuttx/lib/math.h - match standard naming conventions
  - Rename isinf_l to isinfl
  - Rename isinf_f to isinff
  - Add finite()
  - Add finitel()
  - Add finitef()
  - Define isnanl and isnanf
  - Define isfinite() so that it uses the appropriate macro

* libs/libc/math/lib_asinf.c
  libs/libc/math/lib_asinl.c
  libs/libc/math/lib_roundf.c
  libs/libc/math/lib_roundl.c
  libs/libc/math/lib_sqrtf.c
  libs/libc/math/lib_sqrtl.c
  - Use renamed macros
  - Use correct NAN_x or INFINIT_x macro on returns
This commit is contained in:
Neale Ferguson
2022-09-07 11:37:15 +10:00
committed by Xiang Xiao
parent 5e22dcb73b
commit 213b954a90
10 changed files with 54 additions and 21 deletions
+16 -4
View File
@@ -81,11 +81,23 @@
#define INFINITY_F (1.0F/0.0F)
#define NAN_F (0.0F/0.0F)
#define isnan(x) ((x) != (x))
#define isinf(x) (((x) == INFINITY) || ((x) == -INFINITY))
#define isfinite(x) (!(isinf(x) || isnan(x)))
#define INFINITY_L (1.0L/0.0L)
#define NAN_L (0.0L/0.0L)
#define isinf_f(x) (((x) == INFINITY_F) || ((x) == -INFINITY_F))
#define isnan(x) ((x) != (x))
#define isnanf(x) ((x) != (x))
#define isnanl(x) ((x) != (x))
#define isinf(x) (((x) == INFINITY) || ((x) == -INFINITY))
#define isinff(x) (((x) == INFINITY_F) || ((x) == -INFINITY_F))
#define isinfl(x) (((x) == INFINITY_L) || ((x) == -INFINITY_L))
#define finite(x) (!(isinf(x) || isnan(x)))
#define finitef(x) (!(isinff(x) || isnanf(x)))
#define finitel(x) (!(isinfl(x) || isnanl(x)))
#define isfinite(x) \
(sizeof(x) == sizeof(float) ? finitef(x) : \
sizeof(x) == sizeof(double) ? finite(x) : finitel(x))
/* Exponential and Logarithmic constants ************************************/