diff options
| -rw-r--r-- | libm/Makefile.in | 7 | ||||
| -rw-r--r-- | libm/float_wrappers.c | 13 | ||||
| -rw-r--r-- | libm/ldouble_wrappers.c | 25 | ||||
| -rw-r--r-- | test/Makefile | 1 | ||||
| -rw-r--r-- | test/math/Makefile | 10 | ||||
| -rw-r--r-- | test/math/basic-test.c | 1 | ||||
| -rw-r--r-- | test/math/compile_test.c | 140 | ||||
| -rw-r--r-- | test/math/libm-test.inc | 56 |
8 files changed, 214 insertions, 39 deletions
diff --git a/libm/Makefile.in b/libm/Makefile.in index b490ec8bf..fd36833b2 100644 --- a/libm/Makefile.in +++ b/libm/Makefile.in @@ -69,12 +69,13 @@ libm_CSRC := \ s_tanh.c s_trunc.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c \ w_cabs.c w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c \ w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \ - w_log.c w_log2.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \ + w_log.c w_log2.c w_log10.c w_pow.c w_remainder.c w_sinh.c \ w_sqrt.c nan.c carg.c s_llrint.c \ s_fpclassify.c s_fpclassifyf.c s_signbit.c s_signbitf.c \ s_isnan.c s_isnanf.c s_isinf.c s_isinff.c s_finitef.c \ s_fdim.c s_fma.c s_fmax.c s_fmin.c s_nearbyint.c \ s_remquo.c s_scalbln.c w_exp2.c w_tgamma.c +libm_CSRC += $(if $(UCLIBC_SUSV3_LEGACY),w_scalb.c) # REMOVED: w_gamma_r.c FL_MOBJ := \ acosf.o acoshf.o asinf.o asinhf.o atan2f.o atanf.o atanhf.o cbrtf.o \ @@ -84,9 +85,9 @@ FL_MOBJ := \ log1pf.o log2f.o logbf.o logf.o lrintf.o lroundf.o modff.o nearbyintf.o \ nextafterf.o powf.o remainderf.o remquof.o rintf.o roundf.o \ scalblnf.o scalbnf.o sinf.o sinhf.o sqrtf.o tanf.o tanhf.o \ - tgammaf.o truncf.o cargf.o llrintf.o + tgammaf.o truncf.o cabsf.o cargf.o llrintf.o -LD_MOBJ := acoshl.o acosl.o asinhl.o asinl.o atan2l.o atanhl.o atanl.o cargl.o cbrtl.o \ +LD_MOBJ := acoshl.o acosl.o asinhl.o asinl.o atan2l.o atanhl.o atanl.o cabsl.o cargl.o cbrtl.o \ ceill.o copysignl.o coshl.o cosl.o erfcl.o erfl.o exp2l.o expl.o \ expm1l.o fabsl.o finitel.o fdiml.o floorl.o fmal.o fmaxl.o fminl.o fmodl.o fpclassifyl.o \ frexpl.o gammal.o hypotl.o ilogbl.o isinfl.o isnanl.o ldexpl.o lgammal.o llrintl.o \ diff --git a/libm/float_wrappers.c b/libm/float_wrappers.c index 8efaeed1f..dc315e75c 100644 --- a/libm/float_wrappers.c +++ b/libm/float_wrappers.c @@ -24,8 +24,6 @@ #undef L_nearbyintf /*float nearbyintf(float);*/ #undef L_nexttowardf /*float nexttowardf(float, long double);*/ #undef L_remquof /*float remquof(float, float, int *);*/ -#undef L_scalblnf /*float scalblnf(float, long);*/ -#undef L_tgammaf /*float tgammaf(float);*/ /* Implement the following, as defined by SuSv3 */ #if 0 @@ -36,6 +34,7 @@ float asinhf(float); float atan2f(float, float); float atanf(float); float atanhf(float); +float cabsf(float complex); float cargf(float complex); float cbrtf(float); float ceilf(float); @@ -66,12 +65,14 @@ float powf(float, float); float remainderf(float, float); float rintf(float); float roundf(float); +float scalblnf(float, long); float scalbnf(float, int); float sinf(float); float sinhf(float); float sqrtf(float); float tanf(float); float tanhf(float); +float tgammaf(float); #endif @@ -131,6 +132,14 @@ float atanhf (float x) #endif +#ifdef L_cabsf +float cabsf (float complex x) +{ + return (float) cabs( (double complex)x ); +} +#endif + + #ifdef L_cargf float cargf (float complex x) { diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c index 3567c61aa..76365fc23 100644 --- a/libm/ldouble_wrappers.c +++ b/libm/ldouble_wrappers.c @@ -23,6 +23,7 @@ long double asinl(long double); long double atan2l(long double, long double); long double atanhl(long double); long double atanl(long double); +long double cabsl(long double complex); long double cargl(long double complex); long double cbrtl(long double); long double ceill(long double); @@ -131,6 +132,14 @@ long double atanl (long double x) #endif +#ifdef L_cabsl +long double cabsl (long double complex x) +{ + return (long double) cabs( (double complex)x ); +} +#endif + + #ifdef L_cargl long double cargl (long double complex x) { @@ -276,9 +285,9 @@ long double fmodl (long double x, long double y) #ifdef L_frexpl -long double frexpl (long double x, int *exp) +long double frexpl (long double x, int *exponent) { - return (long double) frexp( (double)x, exp ); + return (long double) frexp( (double)x, exponent ); } #endif @@ -300,9 +309,9 @@ int ilogbl (long double x) #ifdef L_ldexpl -long double ldexpl (long double x, int exp) +long double ldexpl (long double x, int exponent) { - return (long double) ldexp( (double)x, exp ); + return (long double) ldexp( (double)x, exponent ); } #endif @@ -463,17 +472,17 @@ long double roundl (long double x) #ifdef L_scalblnl -long double scalblnl (long double x, long exp) +long double scalblnl (long double x, long exponent) { - return (long double) scalbln( (double)x, exp ); + return (long double) scalbln( (double)x, exponent ); } #endif #ifdef L_scalbnl -long double scalbnl (long double x, int exp) +long double scalbnl (long double x, int exponent) { - return (long double) scalbn( (double)x, exp ); + return (long double) scalbn( (double)x, exponent ); } #endif diff --git a/test/Makefile b/test/Makefile index f38427e41..b8c3969e8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -38,7 +38,6 @@ endif ifeq ($(HAS_NO_THREADS),y) DIRS := $(filter-out pthread,$(DIRS)) endif -DIRS := $(filter-out math,$(DIRS)) test check all: run diff --git a/test/math/Makefile b/test/math/Makefile index 09f5425a5..8553e2a4c 100644 --- a/test/math/Makefile +++ b/test/math/Makefile @@ -1,9 +1,13 @@ # uClibc math tests # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +include ../../.config + TESTS := basic-test rint tst-definitions test-fpucw test-float test-ifloat test-double test-idouble -ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y) -TESTS += test-ldouble test-ildouble +ifeq ($(UCLIBC_HAS_LONG_DOUBLE_MATH),y) +TESTS += test-ldouble test-ildoubl compile_test +else +CFLAGS_basic-test := -DNO_LONG_DOUBLE endif include ../Test.mak @@ -13,7 +17,7 @@ DODIFF_rint := 1 # NOTE: For basic-test we must disable the floating point optimization. # Only for sh architecture because in the other architecture are disabled. ifeq ($(TARGET_ARCH),sh) -CFLAGS_basic-test := -mieee +CFLAGS_basic-test += -mieee endif EXTRA_CFLAGS := -fno-builtin EXTRA_LDFLAGS := -lm diff --git a/test/math/basic-test.c b/test/math/basic-test.c index e42c01457..477b274e0 100644 --- a/test/math/basic-test.c +++ b/test/math/basic-test.c @@ -17,6 +17,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#define _ISOC99_SOURCE #include <math.h> #include <float.h> #include <stdio.h> diff --git a/test/math/compile_test.c b/test/math/compile_test.c new file mode 100644 index 000000000..99905201e --- /dev/null +++ b/test/math/compile_test.c @@ -0,0 +1,140 @@ +#include <math.h> + +static int testf(float float_x, long double long_double_x, /*float complex float_complex_x,*/ int int_x, long long_x) +{ +int r = 0; +r += acosf(float_x); +r += acoshf(float_x); +r += asinf(float_x); +r += asinhf(float_x); +r += atan2f(float_x, float_x); +r += atanf(float_x); +r += atanhf(float_x); +/*r += cargf(float_complex_x); - will fight with complex numbers later */ +r += cbrtf(float_x); +r += ceilf(float_x); +r += copysignf(float_x, float_x); +r += cosf(float_x); +r += coshf(float_x); +r += erfcf(float_x); +r += erff(float_x); +/*r += exp2f(float_x); - uclibc does not have it (yet?) */ +r += expf(float_x); +r += expm1f(float_x); +r += fabsf(float_x); +/*r += fdimf(float_x, float_x); - uclibc does not have it (yet?) */ +r += floorf(float_x); +/*r += fmaf(float_x, float_x, float_x); - uclibc does not have it (yet?) */ +/*r += fmaxf(float_x, float_x); - uclibc does not have it (yet?) */ +/*r += fminf(float_x, float_x); - uclibc does not have it (yet?) */ +r += fmodf(float_x, float_x); +r += frexpf(float_x, &int_x); +/* r += gammaf(float_x); fux0red API; use tgamma */ +r += hypotf(float_x, float_x); +r += ilogbf(float_x); +r += ldexpf(float_x, int_x); +r += lgammaf(float_x); +r += llrintf(float_x); +r += llroundf(float_x); +r += log10f(float_x); +r += log1pf(float_x); +/*r += log2f(float_x); - uclibc does not have it (yet?) */ +r += logbf(float_x); +r += logf(float_x); +r += lrintf(float_x); +r += lroundf(float_x); +r += modff(float_x, &float_x); +/*r += nearbyintf(float_x); - uclibc does not have it (yet?) */ +r += nextafterf(float_x, float_x); +/*r += nexttowardf(float_x, long_double_x); - uclibc does not have it (yet?) */ +r += powf(float_x, float_x); +r += remainderf(float_x, float_x); +/*r += remquof(float_x, float_x, &int_x); - uclibc does not have it (yet?) */ +r += rintf(float_x); +r += roundf(float_x); +/* r += scalbf(float_x, float_x); */ +r += scalblnf(float_x, long_x); +r += scalbnf(float_x, int_x); +/* r += significandf(float_x); Remove support for significand or only for OBSCURE_754_TESTS. */ +r += sinf(float_x); +r += sinhf(float_x); +r += sqrtf(float_x); +r += tanf(float_x); +r += tanhf(float_x); +r += tgammaf(float_x); +r += truncf(float_x); +return r; +} + +static int testl(long double long_double_x, int int_x, long long_x) +{ +int r = 0; +r += __finitel(long_double_x); +r += __fpclassifyl(long_double_x); +r += __isinfl(long_double_x); +r += __isnanl(long_double_x); +r += __signbitl(long_double_x); +r += acoshl(long_double_x); +r += acosl(long_double_x); +r += asinhl(long_double_x); +r += asinl(long_double_x); +r += atan2l(long_double_x, long_double_x); +r += atanhl(long_double_x); +r += atanl(long_double_x); +r += cbrtl(long_double_x); +r += ceill(long_double_x); +r += copysignl(long_double_x, long_double_x); +r += coshl(long_double_x); +r += cosl(long_double_x); +r += erfcl(long_double_x); +r += erfl(long_double_x); +r += exp2l(long_double_x); +r += expl(long_double_x); +r += expm1l(long_double_x); +r += fabsl(long_double_x); +r += fdiml(long_double_x, long_double_x); +r += floorl(long_double_x); +r += fmal(long_double_x, long_double_x, long_double_x); +r += fmaxl(long_double_x, long_double_x); +r += fminl(long_double_x, long_double_x); +r += fmodl(long_double_x, long_double_x); +r += frexpl(long_double_x, &int_x); +r += hypotl(long_double_x, long_double_x); +r += ilogbl(long_double_x); +r += ldexpl(long_double_x, int_x); +r += lgammal(long_double_x); +r += llrintl(long_double_x); +r += llroundl(long_double_x); +r += log10l(long_double_x); +r += log1pl(long_double_x); +/* r += log2l(long_double_x); uclibc does not have it (yet?) */ +r += logbl(long_double_x); +r += logl(long_double_x); +r += lrintl(long_double_x); +r += lroundl(long_double_x); +r += modfl(long_double_x, &long_double_x); +r += nearbyintl(long_double_x); +r += nextafterl(long_double_x, long_double_x); +/* r += nexttowardl(long_double_x, long_double_x); - uclibc doesn't provide this [yet?] */ +r += powl(long_double_x, long_double_x); +r += remainderl(long_double_x, long_double_x); +r += remquol(long_double_x, long_double_x, &int_x); +r += rintl(long_double_x); +r += roundl(long_double_x); +r += scalblnl(long_double_x, long_x); +r += scalbnl(long_double_x, int_x); +r += sinhl(long_double_x); +r += sinl(long_double_x); +r += sqrtl(long_double_x); +r += tanhl(long_double_x); +r += tanl(long_double_x); +r += tgammal(long_double_x); +r += truncl(long_double_x); +return r; +} + +int main(int argc, char **argv) +{ + /* Always 0 but gcc hopefully won't be able to notice */ + return 5 & ((long)&testf) & ((long)&testl) & 2; +} diff --git a/test/math/libm-test.inc b/test/math/libm-test.inc index c9c2c8b41..0309e5a42 100644 --- a/test/math/libm-test.inc +++ b/test/math/libm-test.inc @@ -2883,6 +2883,7 @@ frexp_test (void) static void gamma_test (void) { +#if !defined TEST_DOUBLE && !defined TEST_FLOAT && !defined TEST_LDOUBLE errno = 0; FUNC(gamma) (1); @@ -2906,8 +2907,10 @@ gamma_test (void) TEST_f_f1 (gamma, -0.5, M_LOG_2_SQRT_PIl, -1); END (gamma); +#endif } + static void hypot_test (void) { @@ -3006,14 +3009,15 @@ isnormal_test (void) static void j0_test (void) { +#if !defined TEST_DOUBLE && !defined TEST_FLOAT && !defined TEST_LDOUBLE errno = 0; -#if 0 +# if 0 FLOAT s, c; FUNC (sincos) (0, &s, &c); if (errno == ENOSYS) /* Required function not implemented. */ return; -#endif +# endif FUNC(j0) (0); if (errno == ENOSYS) /* Function not implemented. */ @@ -3037,20 +3041,22 @@ j0_test (void) TEST_f_f (j0, -4.0, -3.9714980986384737228659076845169804197562E-1L); END (j0); +#endif } static void j1_test (void) { +#if !defined TEST_DOUBLE && !defined TEST_FLOAT && !defined TEST_LDOUBLE errno = 0; -#if 0 +# if 0 FLOAT s, c; FUNC (sincos) (0, &s, &c); if (errno == ENOSYS) /* Required function not implemented. */ return; -#endif +# endif FUNC(j1) (0); if (errno == ENOSYS) /* Function not implemented. */ @@ -3074,19 +3080,21 @@ j1_test (void) TEST_f_f (j1, 10.0, 0.0434727461688614366697487680258592883L); END (j1); +#endif } static void jn_test (void) { +#if !defined TEST_DOUBLE && !defined TEST_FLOAT && !defined TEST_LDOUBLE errno = 0; -#if 0 +# if 0 FLOAT s, c; FUNC (sincos) (0, &s, &c); if (errno == ENOSYS) /* Required function not implemented. */ return; -#endif +# endif FUNC(jn) (1, 1); if (errno == ENOSYS) /* Function not implemented. */ @@ -3148,6 +3156,7 @@ jn_test (void) TEST_ff_f (jn, 10, 10.0, 0.207486106633358857697278723518753428L); END (jn); +#endif } @@ -4231,8 +4240,9 @@ round_test (void) static void scalb_test (void) { - +#ifdef __UCLIBC_SUSV3_LEGACY__ START (scalb); +#ifndef TEST_LDOUBLE /* uclibc doesn't have scalbl */ TEST_ff_f (scalb, 2.0, 0.5, nan_value, INVALID_EXCEPTION); TEST_ff_f (scalb, 3.0, -2.5, nan_value, INVALID_EXCEPTION); @@ -4283,8 +4293,9 @@ scalb_test (void) TEST_ff_f (scalb, 0.8L, 4, 12.8L); TEST_ff_f (scalb, -0.854375L, 5, -27.34L); - +#endif END (scalb); +#endif } @@ -4310,7 +4321,6 @@ scalbn_test (void) } -#if 0 static void scalbln_test (void) { @@ -4331,7 +4341,6 @@ scalbln_test (void) END (scalbn); } -#endif static void @@ -4535,7 +4544,6 @@ tanh_test (void) END (tanh); } -#if 0 static void tgamma_test (void) { @@ -4567,7 +4575,6 @@ tgamma_test (void) END (tgamma); } -#endif #if 0 @@ -4650,14 +4657,15 @@ trunc_test (void) static void y0_test (void) { +#if !defined TEST_DOUBLE && !defined TEST_FLOAT && !defined TEST_LDOUBLE errno = 0; -#if 0 +# if 0 FLOAT s, c; FUNC (sincos) (0, &s, &c); if (errno == ENOSYS) /* Required function not implemented. */ return; -#endif +# endif FUNC(y0) (1); if (errno == ENOSYS) /* Function not implemented. */ @@ -4680,20 +4688,22 @@ y0_test (void) TEST_f_f (y0, 10.0, 0.0556711672835993914244598774101900481L); END (y0); +#endif } static void y1_test (void) { +#if !defined TEST_DOUBLE && !defined TEST_FLOAT && !defined TEST_LDOUBLE errno = 0; -#if 0 +# if 0 FLOAT s, c; FUNC (sincos) (0, &s, &c); if (errno == ENOSYS) /* Required function not implemented. */ return; -#endif +# endif FUNC(y1) (1); if (errno == ENOSYS) /* Function not implemented. */ @@ -4716,20 +4726,22 @@ y1_test (void) TEST_f_f (y1, 10.0, 0.249015424206953883923283474663222803L); END (y1); +#endif } static void yn_test (void) { +#if !defined TEST_DOUBLE && !defined TEST_FLOAT && !defined TEST_LDOUBLE errno = 0; -#if 0 +# if 0 FLOAT s, c; FUNC (sincos) (0, &s, &c); if (errno == ENOSYS) /* Required function not implemented. */ return; -#endif +# endif FUNC(yn) (1, 1); if (errno == ENOSYS) /* Function not implemented. */ @@ -4787,13 +4799,14 @@ yn_test (void) TEST_ff_f (yn, 10, 10.0, -0.359814152183402722051986577343560609L); END (yn); - +#endif } - +/* FIXME: Remove support for significand or only for OBSCURE_754_TESTS. */ static void significand_test (void) { +#if !defined TEST_DOUBLE && !defined TEST_FLOAT && !defined TEST_LDOUBLE /* significand returns the mantissa of the exponential representation. */ START (significand); @@ -4802,6 +4815,7 @@ significand_test (void) TEST_f_f (significand, 8.0, 1.0); END (significand); +#endif } @@ -5066,14 +5080,12 @@ main (int argc, char **argv) #endif /* Bessel functions: */ -#if 0 j0_test (); j1_test (); jn_test (); y0_test (); y1_test (); yn_test (); -#endif if (output_ulps) fclose (ulps_file); |
