From 054f2fe7cebe6ef7a519e94636a14492a701a11b Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Wed, 30 Nov 2011 22:04:54 +0000 Subject: [PATCH] [CRT] Fix error handling for j0, j1, y0, y1 Bessel functions. Remove useless defines svn path=/trunk/; revision=54552 --- reactos/lib/sdk/crt/math/j0_y0.c | 11 +++++++---- reactos/lib/sdk/crt/math/j1_y1.c | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/reactos/lib/sdk/crt/math/j0_y0.c b/reactos/lib/sdk/crt/math/j0_y0.c index c656e210b33..8d918a8269f 100644 --- a/reactos/lib/sdk/crt/math/j0_y0.c +++ b/reactos/lib/sdk/crt/math/j0_y0.c @@ -2,8 +2,6 @@ #include #include "ieee754/ieee754.h" -typedef int fpclass_t; -fpclass_t _fpclass(double __d); int *_errno(void); /* @@ -11,7 +9,7 @@ int *_errno(void); */ double _j0(double num) { - /* FIXME: errno handling */ + if (!_finite(num)) *_errno() = EDOM; return __ieee754_j0(num); } @@ -21,7 +19,12 @@ double _j0(double num) double _y0(double num) { double retval; - if (!_finite(num)) *_errno() = EDOM; + int fpclass = _fpclass(num); + + if (!_finite(num) || fpclass == _FPCLASS_NN || + fpclass == _FPCLASS_ND || fpclass == _FPCLASS_NZ) + *_errno() = EDOM; + retval = __ieee754_y0(num); if (_fpclass(retval) == _FPCLASS_NINF) { diff --git a/reactos/lib/sdk/crt/math/j1_y1.c b/reactos/lib/sdk/crt/math/j1_y1.c index 7a2bc2a8645..c179513d575 100644 --- a/reactos/lib/sdk/crt/math/j1_y1.c +++ b/reactos/lib/sdk/crt/math/j1_y1.c @@ -2,8 +2,6 @@ #include #include "ieee754/ieee754.h" -typedef int fpclass_t; -fpclass_t _fpclass(double __d); int *_errno(void); /* @@ -11,7 +9,7 @@ int *_errno(void); */ double _j1(double num) { - /* FIXME: errno handling */ + if (!_finite(num)) *_errno() = EDOM; return __ieee754_j1(num); } @@ -21,7 +19,12 @@ double _j1(double num) double _y1(double num) { double retval; - if (!_finite(num)) *_errno() = EDOM; + int fpclass = _fpclass(num); + + if (!_finite(num) || fpclass == _FPCLASS_NN || + fpclass == _FPCLASS_ND || fpclass == _FPCLASS_NZ) + *_errno() = EDOM; + retval = __ieee754_y1(num); if (_fpclass(retval) == _FPCLASS_NINF) {