diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-03-20 02:20:57 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-03-20 02:20:57 +0000 |
commit | c57abfa73560ac665e126a66081e1549bcd4645b (patch) | |
tree | ba69ca2329ef60f22093769ad45a227dd90dad7c /math | |
parent | e61abf83986463e263de965d487fac5cb083839a (diff) | |
download | glibc-c57abfa73560ac665e126a66081e1549bcd4645b.zip glibc-c57abfa73560ac665e126a66081e1549bcd4645b.tar.gz glibc-c57abfa73560ac665e126a66081e1549bcd4645b.tar.bz2 |
Update.cvs/libc20x-ud-970319
1997-03-20 01:49 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/libm-ieee754/s_tanhl.c (__tanhl): Correct handling of
-inf.
* Makeconfig: (rpath-link): Add math/ directory.
(math-objdir): New variable.
(link-extra-lib): Define to special version when
$(common-objpfx)!=$(objpfx) to allow libraries outside
$(common-objpfx) be linked to the application.
* math/Makefile: Add rules to build and run test programs.
* math/libm-test.c (_GNU_SOURCE): Define only if still undefined.
(check_equal): Correct check for error.
(ceil_test): Fix typo.
(log_test): Fix typo.
(floor_test): Fix typo.
(pow_test): Fix typos.
(log10_test): Allow slight incorrectness for `log10(e)'.
(modf_test): New functions to test `modf' et.al.
(hypot_test): Rewrite test completely.
Patch partly by Andreas Jaeger.
* math/test-double.h (__NO_MATH_INLINES): Define only if not
already defined.
* math/test-float.h: Likewise.
* math/test-logdouble.h: Likewise.
* setjmp/setjmp.h: Change references of ANSI C to ISO C.
* setjmp/tst-setjmp.c: Correct and extend test suite.
* sysdeps/i386/__longjmp.S: Update copyright.
* sysdeps/i386/bsd-_setjmp.S: Correct fatal bug in jump to
`__sigsetjmp' in PIC code.
* sysdeps/i386/bsd-setjmp.S: Likewise.
* sysdeps/libm-i387/e_pow.S: Correct recognition of mantissa
overflow.
* sysdeps/libm-i387/e_powf.S: Likewise.
* sysdeps/libm-i387/s_expm1.S: Handle x == +-0 as a special
case since expm1(-0) == -0.
* sysdeps/libm-i387/s_expm1f.S: Likewise.
* sysdeps/libm-i387/s_expm1l.S: Likewise.
* sysdeps/libm-ieee754/s_modf.c: Optimize code by avoiding unneeded
access to FP number.
* sysdeps/libm-ieee754/s_modff.c: Likewise.
* sysdeps/libm-ieee754/s_modfl.c: Correct former completely bogus
code. It never worked correctly.
* sysdeps/libm-ieee754/s_tanh.c: Handle x == +-0 as a special
case since tanh(-0) == -0.
* sysdeps/libm-ieee754/s_tanhf.c: Likewise.
1997-03-19 21:13 Ulrich Drepper <drepper@cygnus.com>
* stdlib/strtod.c (STRTOL): Use wchar_t as type for `decimal' and
`thousands' to support systems with sizeof(wchar_t) !=
sizeof(wint_t). Blargh.
* sysdeps/unix/sysv/linux/socketbits.h: Remove definition of
SOL_IP, SOL_TCP, SOL_UDP, and SOL_IPX as they are defined in
appropriate headers.
* sysdeps/unix/sysv/linux/writev.c: Don't use MAX_IOVEC. Test for
UIO_FASTIOV and set to 8 if not available.
* sysdeps/unix/sysv/linux/readv.c: Likewise.
Patch by HJ Lu.
* sysdeps/unix/sysv/linux/xstat.c: Include <kernel_stat.h>, not
"kernel_stat.h".
* sysdeps/unix/sysv/linux/lxstat.c: Likewise.
* sysdeps/unix/sysv/linux/fxstat.c: Likewise.
Reported by fabsoft@fabsoft2.zarm.uni-bremen.de.
Diffstat (limited to 'math')
-rw-r--r-- | math/Makefile | 14 | ||||
-rw-r--r-- | math/libm-test.c | 122 | ||||
-rw-r--r-- | math/test-double.c | 4 | ||||
-rw-r--r-- | math/test-float.c | 4 | ||||
-rw-r--r-- | math/test-longdouble.c | 4 |
5 files changed, 91 insertions, 57 deletions
diff --git a/math/Makefile b/math/Makefile index c4ed312..5b1f090 100644 --- a/math/Makefile +++ b/math/Makefile @@ -64,6 +64,20 @@ routines = $(calls) $(calls:=f) $(long-c-$(long-double-fcts)) long-c-yes = $(calls:=l) distribute += $(long-c-yes:=.c) +# Rules for the test suite. +tests = test-float test-double $(test-longdouble-$(long-double-fcts)) +# We do the `long double' tests only if this data type is available and +# distrinct from `double'. +# +# XXX This test is disabled for now since the functions are too buggy. +#test-longdouble-yes = test-longdouble + +LDLIBS-test-float = libm +LDLIBS-test-double = libm +LDLIBS-test-longdouble = libm + +distribute += libm-test.c + # The -lieee module sets the _LIB_VERSION_ switch to IEEE mode # for error handling in the -lm functions. diff --git a/math/libm-test.c b/math/libm-test.c index 98e3cba..a0482df 100644 --- a/math/libm-test.c +++ b/math/libm-test.c @@ -41,9 +41,9 @@ /* This program isn't finished yet. It has tests for acos, acosh, asin, asinh, atan, atan2, atanh, cbrt, ceil, cos, cosh, exp, exp2, expm1, fabs, floor, fpclassify, - frexp, ldexp, - log, log10, log1p, log2, logb, - pow, sin, sinh, tan, tanh, fabs, hypot. + frexp, hypot, ldexp, + log, log10, log1p, log2, logb, modf, + pow, sin, sinh, tan, tanh. Tests for the other libm-functions will come later. The routines using random variables are still under construction. I don't @@ -66,7 +66,9 @@ log2. */ #undef ISO_9X_IMPLEMENTED -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif #include <math.h> #include <float.h> @@ -192,7 +194,7 @@ check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff *diff = FUNC(fabs) (computed - supplied); - if (*diff <= eps || signbit (computed) != signbit (supplied)) + if (*diff <= eps && (signbit (computed) == signbit (supplied) || eps != 0.0)) return 1; return 0; @@ -211,7 +213,7 @@ output_result_bool (const char *test_name, int result) { if (verbose) printf ("Fail: %s\n", test_name); - noErrors++; + ++noErrors; } fpstack_test (test_name); @@ -592,7 +594,7 @@ ceil_test (void) check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty)); check ("ceil (pi) == 4", FUNC(ceil) (M_PI), 4.0); - check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), 3.0); + check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), -3.0); } @@ -802,7 +804,7 @@ log_test (void) check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty)); check_eps ("log (e) == 1", FUNC(log) (M_E), 1, CHOOSE (0, 0, 9e-8L)); - check ("log (1/e) == -1", FUNC(log) (1.0 / M_E), 1); + check ("log (1/e) == -1", FUNC(log) (1.0 / M_E), -1); check ("log (2) == M_LN2", FUNC(log) (2), M_LN2); check ("log (10) == M_LN10", FUNC(log) (10), M_LN10); } @@ -828,7 +830,7 @@ log10_test (void) check ("log10 (100) == 2", FUNC(log10) (100.0), 2); check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4); check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_E), M_LOG10E, - CHOOSE (0, 0, 9e-8)); + CHOOSE (9e-20, 0, 9e-8)); } @@ -896,6 +898,42 @@ logb_test (void) static void +modf_test (void) +{ + MATHTYPE result, intpart; + + result = FUNC(modf) (plus_infty, &intpart); + check ("modf (+inf, &x) returns +0", result, 0); + check_isinfp ("modf (+inf, &x) set x to +inf", intpart); + + result = FUNC(modf) (minus_infty, &intpart); + check ("modf (-inf, &x) returns -0", result, minus_zero); + check_isinfn ("modf (-inf, &x) sets x to -inf", intpart); + + result = FUNC(modf) (nan_value, &intpart); + check_isnan ("modf (NaN, &x) returns NaN", result); + check_isnan ("modf (-inf, &x) sets x to NaN", intpart); + + result = FUNC(modf) (0, &intpart); + check ("modf (0, &x) returns 0", result, 0); + check ("modf (0, &x) sets x to 0", intpart, 0); + + result = FUNC(modf) (minus_zero, &intpart); + check ("modf (-0, &x) returns -0", result, minus_zero); + check ("modf (-0, &x) sets x to -0", intpart, minus_zero); + + result = FUNC(modf) (2.5, &intpart); + check ("modf (2.5, &x) returns 0.5", result, 0.5); + check ("modf (2.5, &x) sets x to 2", intpart, 2); + + result = FUNC(modf) (-2.5, &intpart); + check ("modf (-2.5, &x) returns -0.5", result, -0.5); + check ("modf (-2.5, &x) sets x to -2", intpart, -2); + +} + + +static void sin_test (void) { check ("sin (+0) == +0", FUNC(sin) (0), 0); @@ -971,58 +1009,33 @@ floor_test (void) check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty)); check ("floor (pi) == 3", FUNC(floor) (M_PI), 3.0); - check ("floor (-pi) == -4", FUNC(floor) (-M_PI), 4.0); + check ("floor (-pi) == -4", FUNC(floor) (-M_PI), -4.0); } static void -hypot_report (const char *test_name, MATHTYPE computed, MATHTYPE expected) +hypot_test (void) { - MATHTYPE diff; - int result; - - result = check_equal (computed, expected, 0, &diff); - - if (result) - { - if (verbose > 2) - printf ("Pass: %s\n", test_name); - } - else - { - if (verbose) - printf ("Fail: %s\n", test_name); - if (verbose > 1) - { - printf ("Result:\n"); - printf (" is: %.20" PRINTF_EXPR, computed); - printf (" should be: %.20" PRINTF_EXPR, expected); - printf (" difference: %.20" PRINTF_EXPR "\n", diff); - } - noErrors++; - } - fpstack_test (test_name); - output_result (test_name, result, - computed, expected, diff, PRINT, PRINT); -} + MATHTYPE a; + a = random_greater (0); + check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a); + check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a); -static void -hypot_test (void) -{ - MATHTYPE a = FUNC(hypot) (12.4L, 0.7L); + check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value)); - hypot_report ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a); - hypot_report ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a); - hypot_report ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a); - hypot_report ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a); - hypot_report ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a); + a = FUNC(hypot) (12.4L, 0.7L); + check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a); + check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a); + check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a); + check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a); + check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a); check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L); check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L); check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L); - check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L); - check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L); + check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L); check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L); + check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L); } @@ -1084,9 +1097,9 @@ pow_test (void) check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1)); check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1)); - check ("pow (-inf, -1) == -0", FUNC(pow) (-minus_infty, -1), minus_zero); - check ("pow (-inf, -11) == -0", FUNC(pow) (-minus_infty, -11), minus_zero); - check ("pow (-inf, -1001) == -0", FUNC(pow) (-minus_infty, -1001), minus_zero); + check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero); + check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero); + check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero); check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0); check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0); @@ -1189,8 +1202,8 @@ pow_test (void) FUNC(pow) (minus_infty, x), minus_zero, x); x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */ - check_ext ("pow (-inf, y) == -0 for y < 0 and not an odd integer", - FUNC(pow) (minus_infty, x), minus_zero, x); + check_ext ("pow (-inf, y) == 0 for y < 0 and not an odd integer", + FUNC(pow) (minus_infty, x), 0.0, x); x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */ check_ext ("pow (+0, y) == +0 for y an odd integer > 0", @@ -1497,6 +1510,7 @@ main (int argc, char *argv[]) log2_test (); #endif logb_test (); + modf_test (); sin_test (); sinh_test (); tan_test (); diff --git a/math/test-double.c b/math/test-double.c index 5f562a0..1f4ff8e 100644 --- a/math/test-double.c +++ b/math/test-double.c @@ -24,6 +24,8 @@ #define CHOOSE(Clongdouble,Cdouble,Cfloat) Cdouble #define PRINTF_EXPR "e" -#define __NO_MATH_INLINES +#ifndef __NO_MATH_INLINES +# define __NO_MATH_INLINES +#endif #include "libm-test.c" diff --git a/math/test-float.c b/math/test-float.c index fa9f2bc..de918a3 100644 --- a/math/test-float.c +++ b/math/test-float.c @@ -24,6 +24,8 @@ #define CHOOSE(Clongdouble,Cdouble,Cfloat) Cfloat #define PRINTF_EXPR "e" -#define __NO_MATH_INLINES +#ifndef __NO_MATH_INLINES +# define __NO_MATH_INLINES +#endif #include "libm-test.c" diff --git a/math/test-longdouble.c b/math/test-longdouble.c index 9eebe5a..eb9b57a 100644 --- a/math/test-longdouble.c +++ b/math/test-longdouble.c @@ -24,6 +24,8 @@ #define CHOOSE(Clongdouble,Cdouble,Cfloat) Clongdouble #define PRINTF_EXPR "Le" -#define __NO_MATH_INLINES +#ifndef __NO_MATH_INLINES +# define __NO_MATH_INLINES +#endif #include "libm-test.c" |