diff options
Diffstat (limited to 'math')
-rw-r--r-- | math/Makefile | 12 | ||||
-rw-r--r-- | math/bits/cmathcalls.h (renamed from math/cmathcalls.h) | 2 | ||||
-rw-r--r-- | math/bits/mathcalls.h (renamed from math/mathcalls.h) | 2 | ||||
-rw-r--r-- | math/complex.h | 14 | ||||
-rw-r--r-- | math/fenv.h | 4 | ||||
-rw-r--r-- | math/libm-test.c | 58 | ||||
-rw-r--r-- | math/libm.map | 105 | ||||
-rw-r--r-- | math/math.h | 22 | ||||
-rw-r--r-- | math/math_private.h | 10 |
9 files changed, 190 insertions, 39 deletions
diff --git a/math/Makefile b/math/Makefile index bd4506b99e..4f2537d680 100644 --- a/math/Makefile +++ b/math/Makefile @@ -21,15 +21,17 @@ subdir := math # Installed header files. -headers := math.h mathcalls.h __math.h huge_val.h nan.h \ - fpu_control.h complex.h cmathcalls.h fenv.h \ - fenvbits.h mathbits.h +headers := math.h bits/mathcalls.h bits/mathinline.h bits/huge_val.h \ + bits/nan.h fpu_control.h complex.h bits/cmathcalls.h \ + fenv.h bits/fenv.h bits/mathdef.h # Internal header files. distribute := math_private.h machine/asm.h machine/endian.h # FPU support code. -aux := fpu_control setfpucw +aux := fpu_control setfpucw s_matherr + +static-only-routines := s_matherr # Build the -lm library. @@ -38,7 +40,7 @@ extra-libs-others = $(extra-libs) libm-map := libm.map -libm-support = k_standard s_lib_version s_matherr s_signgam \ +libm-support = k_standard s_lib_version s_signgam \ s_lrint s_llrint s_lround s_llround \ fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg \ ftestexcept fegetround fesetround fegetenv feholdexcpt \ diff --git a/math/cmathcalls.h b/math/bits/cmathcalls.h index 1f74f56e0b..d94e764930 100644 --- a/math/cmathcalls.h +++ b/math/bits/cmathcalls.h @@ -42,7 +42,7 @@ both a `NAME' and a `NAMEf' that takes `float' arguments. */ #ifndef _COMPLEX_H - #error "Never include cmathcalls.h directly; include <complex.h> instead." +#error "Never use <bits/cmathcalls.h> directly; include <complex.h> instead." #endif #define _Mdouble_complex_ _Mdouble_ complex diff --git a/math/mathcalls.h b/math/bits/mathcalls.h index 735b5953a7..e0bf1008d3 100644 --- a/math/mathcalls.h +++ b/math/bits/mathcalls.h @@ -41,7 +41,7 @@ both a `NAME' and a `NAMEf' that takes `float' arguments. */ #ifndef _MATH_H - #error "Never include mathcalls.h directly; include <math.h> instead." + #error "Never include <bits/mathcalls.h> directly; include <math.h> instead." #endif diff --git a/math/complex.h b/math/complex.h index 938823b5fb..fe4c4ce545 100644 --- a/math/complex.h +++ b/math/complex.h @@ -21,8 +21,8 @@ */ #ifndef _COMPLEX_H - #define _COMPLEX_H 1 + #include <features.h> __BEGIN_DECLS @@ -52,9 +52,9 @@ __BEGIN_DECLS #define CX_LIMITED_RANGE_DEFAULT -/* The file <cmathcalls.h> contains the prototypes for all the actual - math functions. These macros are used for those prototypes, so - we can easily declare each function as both `name' and `__name', +/* The file <bits/cmathcalls.h> contains the prototypes for all the + actual math functions. These macros are used for those prototypes, + so we can easily declare each function as both `name' and `__name', and can declare the float versions `namef' and `__namef'. */ #define __MATHCALL(function, args) \ @@ -67,7 +67,7 @@ __BEGIN_DECLS #define _Mdouble_ double #define __MATH_PRECNAME(name) name -#include <cmathcalls.h> +#include <bits/cmathcalls.h> #undef _Mdouble_ #undef __MATH_PRECNAME @@ -81,7 +81,7 @@ __BEGIN_DECLS #else #define __MATH_PRECNAME(name) name/**/f #endif -#include <cmathcalls.h> +#include <bits/cmathcalls.h> #undef _Mdouble_ #undef __MATH_PRECNAME @@ -96,7 +96,7 @@ __BEGIN_DECLS #else #define __MATH_PRECNAME(name) name/**/l #endif -#include <cmathcalls.h> +#include <bits/cmathcalls.h> #undef _Mdouble_ #undef __MATH_PRECNAME #undef __MATHDECL_1 diff --git a/math/fenv.h b/math/fenv.h index e4dff29a2e..aa524b7a16 100644 --- a/math/fenv.h +++ b/math/fenv.h @@ -21,8 +21,8 @@ */ #ifndef _FENV_H - #define _FENV_H 1 + #include <features.h> /* Get the architecture dependend definitions. The following definitions @@ -55,7 +55,7 @@ FE_DOWNWARD round toward -Inf FE_TOWARDZERO round toward 0 */ -#include <fenvbits.h> +#include <bits/fenv.h> __BEGIN_DECLS diff --git a/math/libm-test.c b/math/libm-test.c index 5bf968f844..2b149f739a 100644 --- a/math/libm-test.c +++ b/math/libm-test.c @@ -56,7 +56,7 @@ ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctanh. At the moment the following functions aren't tested: - cabs, carg, conj, cproj, cimag, creal, drem, + cabs, carg, conj, cproj, cimag, creal, ctan, drem, j0, j1, jn, y0, y1, yn, significand, nan, comparison macros (isless,isgreater,...). @@ -814,6 +814,14 @@ check_isinfn_exc (const char *test_name, MATHTYPE computed, } +/* This is to prevent messages from the SVID libm emulation. */ +int +matherr (struct exception *x __attribute__ ((unused))) +{ + return 1; +} + + /**************************************************************************** Test for single functions of libm ****************************************************************************/ @@ -1298,10 +1306,15 @@ signbit_test (void) } - +/* + gamma has different semantics depending on _LIB_VERSION: + if _LIB_VERSION is _SVID, gamma is just an alias for lgamma, + otherwise gamma is the real gamma function as definied in ISO C 9X. +*/ static void gamma_test (void) { + int save_lib_version = _LIB_VERSION; errno = 0; FUNC(gamma) (0); if (errno == ENOSYS) @@ -1309,6 +1322,40 @@ gamma_test (void) return; feclearexcept (FE_ALL_EXCEPT); + + _LIB_VERSION = _SVID_; + + check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty)); + check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception", + FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION); + + check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0", + FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION); + check_isnan_exc ("gamma (-inf) == NaN plus invalid exception", + FUNC(gamma) (minus_infty), INVALID_EXCEPTION); + + signgam = 0; + check ("gamma (1) == 0", FUNC(gamma) (1), 0); + check_int ("gamma (0) sets signgam to 1", signgam, 1); + + signgam = 0; + check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2); + check_int ("gamma (3) sets signgam to 1", signgam, 1); + + signgam = 0; + check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma) (0.5), + FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7)); + check_int ("gamma (0.5) sets signgam to 1", signgam, 1); + + signgam = 0; + check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma) (-0.5), + FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0)); + + check_int ("gamma (-0.5) sets signgam to -1", signgam, -1); + + + _LIB_VERSION = _IEEE_; + check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty)); check_isnan_exc ("gamma (0) == NaN plus invalid exception", FUNC(gamma) (0), INVALID_EXCEPTION); @@ -1326,6 +1373,7 @@ gamma_test (void) check ("gamma (1) == 1", FUNC(gamma) (1), 1); check ("gamma (4) == 6", FUNC(gamma) (4), 6); + _LIB_VERSION = save_lib_version; } @@ -1348,16 +1396,20 @@ lgamma_test (void) check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception", FUNC(lgamma) (minus_infty), INVALID_EXCEPTION); + signgam = 0; check ("lgamma (1) == 0", FUNC(lgamma) (1), 0); check_int ("lgamma (0) sets signgam to 1", signgam, 1); + signgam = 0; check ("lgamma (3) == M_LN2", FUNC(lgamma) (3), M_LN2); check_int ("lgamma (3) sets signgam to 1", signgam, 1); + signgam = 0; check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma) (0.5), FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7)); check_int ("lgamma (0.5) sets signgam to 1", signgam, 1); + signgam = 0; check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma) (-0.5), FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0)); @@ -4725,7 +4777,7 @@ basic_tests (void) check_bool ("NaN != NaN", NaN_var != NaN_var); /* - the same tests but this time with NAN from <nan.h> + the same tests but this time with NAN from <bits/nan.h> NAN is a double const */ check_bool ("isnan (NAN)", isnan (NAN)); diff --git a/math/libm.map b/math/libm.map index b7c9b363d9..aff0ccd73f 100644 --- a/math/libm.map +++ b/math/libm.map @@ -1,16 +1,111 @@ GLIBC_2.0 { global: - # all functions and variables in the normal name space - a*; b*; c*; d*; e*; f*; g*; h*; i*; j*; k*; l*; m*; - n*; o*; p*; q*; r*; s*; t*; u*; v*; w*; x*; y*; z*; + # mathematical functions + acos; acosf; acosl; + acosh; acoshf; acoshl; + asin; asinf; asinl; + asinh; asinhf; asinhl; + atan2; atan2f; atan2l; + atan; atanf; atanl; + atanh; atanhf; atanhl; + cbrt; cbrtf; cbrtl; + ceil; ceilf; ceill; + copysign; copysignf; copysignl; + cos; cosf; cosl; + coshf; cosh; coshl; + drem; dremf; dreml; + erf; erff; erfl; + erfc; erfcf; erfcl; + exp2; exp2f; exp2l; + exp; expf; expl; + expm1; expm1f; expm1l; + fabs; fabsf; fabsl; + fdim; fdimf; fdiml; + finite; finitef; finitel; + floor; floorf; floorl; + fmax; fmaxf; fmaxl; + fmin; fminf; fminl; + fmod; fmodf; fmodl; + frexp; frexpf; frexpl; + gamma; gammaf; gammal; + gamma_r; gammaf_r; gammal_r; + hypot; hypotf; hypotl; + ilogb; ilogbf; ilogbl; + j0; j0f; j0l; + j1; j1f; j1l; + jn; jnf; jnl; + ldexp; ldexpf; ldexpl; + lgamma; lgammaf; lgammal; + lgamma_r; lgammaf_r; lgammal_r; + log10; log10f; log10l; + log1p; log1pf; log1pl; + log2; log2f; log2l; + log; logf; logl; + logb; logbf; logbl; + matherr; + modf; modff; modfl; + nan; nanf; nanl; + nearbyint; nearbyintf; nearbyintl; + nextafter; nextafterf; nextafterl; + pow; powf; powl; + remainder; remainderf; remainderl; + remquo; remquof; remquol; + rint; rintf; rintl; + lrint; llrint; + round; roundf; roundl; + lround; llround; + scalb; scalbf; scalbl; + scalbn; scalbnf; scalbnl; + significand; significandf; significandl; + sin; sinf; sinl; + sincos; sincosf; sincosl; + sinh; sinhf; sinhl; + sqrt; sqrtf; sqrtl; + tan; tanf; tanl; + tanh; tanhf; tanhl; + trunc; truncf; truncl; + y0; y0f; y0l; + y1; y1f; y1l; + yn; ynf; ynl; + + # complex functions + cabs; cabsf; cabsl; + cacos; cacosf; cacosl; + cacosh; cacoshf; cacoshl; + carg; cargf; cargl; + casin; casinf; casinl; + casinh; casinhf; casinhl; + catan; catanf; catanl; + catanh; catanhf; catanhl; + ccos; ccosf; ccosl; + ccosh; ccoshf; ccoshl; + cexp; cexpf; cexpl; + cimag; cimagf; cimagl; + clog; clogf; clogl; + conj; conjf; conjl; + cpow; cpowf; cpowl; + cproj; cprojf; cprojl; + creal; crealf; creall; + csin; csinf; csinl; + csinh; csinhf; csinhl; + csqrt; csqrtf; csqrtl; + ctan; ctanf; ctanl; + ctanh; ctanhf; ctanhl; + + # fp environment functions + feclearexcept; fegetenv; fegetexceptflag; + fegetround; feholdexcept; feraiseexcept; + fesetenv; fesetexceptflag; fesetround; + fetestexcept; feupdateenv; + # global variables - _LIB_VERSION; + _LIB_VERSION; signgam; # functions used in inline functions or macros __fpclassify; __fpclassifyf; __fpclassifyl; __signbit; __signbitf; __signbitl; - __finite; __finitef; __fintitel; + __finite; __finitef; __finitel; __log1p; diff --git a/math/math.h b/math/math.h index aa37f71f3c..2007509035 100644 --- a/math/math.h +++ b/math/math.h @@ -22,25 +22,25 @@ */ #ifndef _MATH_H - #define _MATH_H 1 + #include <features.h> __BEGIN_DECLS /* Get machine-dependent HUGE_VAL value (returned on overflow). On all IEEE754 machines, this is +Infinity. */ -#include <huge_val.h> +#include <bits/huge_val.h> /* Get machine-dependent NAN value (returned for some domain errors). */ #ifdef __USE_GNU -#include <nan.h> +#include <bits/nan.h> #endif -/* The file <mathcalls.h> contains the prototypes for all the actual - math functions. These macros are used for those prototypes, so - we can easily declare each function as both `name' and `__name', +/* The file <bits/mathcalls.h> contains the prototypes for all the + actual math functions. These macros are used for those prototypes, + so we can easily declare each function as both `name' and `__name', and can declare the float versions `namef' and `__namef'. */ #define __MATHCALL(function,suffix, args) \ @@ -58,7 +58,7 @@ __BEGIN_DECLS #define _Mdouble_ double #define __MATH_PRECNAME(name,r) __CONCAT(name,r) -#include <mathcalls.h> +#include <bits/mathcalls.h> #undef _Mdouble_ #undef __MATH_PRECNAME @@ -77,7 +77,7 @@ __BEGIN_DECLS #else #define __MATH_PRECNAME(name,r) name/**/f/**/r #endif -#include <mathcalls.h> +#include <bits/mathcalls.h> #undef _Mdouble_ #undef __MATH_PRECNAME @@ -94,7 +94,7 @@ __BEGIN_DECLS #else #define __MATH_PRECNAME(name,r) name/**/l/**/r #endif -#include <mathcalls.h> +#include <bits/mathcalls.h> #undef _Mdouble_ #undef __MATH_PRECNAME @@ -132,7 +132,7 @@ extern int signgam; INFINITY representation of the infinity value of type `float_t' */ -#include <mathbits.h> +#include <bits/mathdef.h> /* All floating-point numbers can be put in one of these categories. */ enum @@ -318,7 +318,7 @@ extern int matherr __P ((struct exception *)); /* Get machine-dependent inline versions (if there are any). */ #if (!defined __NO_MATH_INLINES && defined __OPTIMIZE__) \ || defined __LIBC_M81_MATH_INLINES -#include <__math.h> +#include <bits/mathinline.h> #endif diff --git a/math/math_private.h b/math/math_private.h index a7a4f3d74e..74b729d419 100644 --- a/math/math_private.h +++ b/math/math_private.h @@ -269,7 +269,7 @@ extern double __ieee754_y1 __P((double)); extern double __ieee754_jn __P((int,double)); extern double __ieee754_yn __P((int,double)); extern double __ieee754_remainder __P((double,double)); -extern int __ieee754_rem_pio2 __P((double,double*)); +extern int32_t __ieee754_rem_pio2 __P((double,double*)); extern double __ieee754_scalb __P((double,double)); /* fdlibm kernel function */ @@ -277,7 +277,8 @@ extern double __kernel_standard __P((double,double,int)); extern double __kernel_sin __P((double,double,int)); extern double __kernel_cos __P((double,double)); extern double __kernel_tan __P((double,double,int)); -extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*)); +extern int __kernel_rem_pio2 __P((double*,double*,int,int,int, + const int32_t*)); /* ieee style elementary float functions */ @@ -306,14 +307,15 @@ extern float __ieee754_y1f __P((float)); extern float __ieee754_jnf __P((int,float)); extern float __ieee754_ynf __P((int,float)); extern float __ieee754_remainderf __P((float,float)); -extern int __ieee754_rem_pio2f __P((float,float*)); +extern int32_t __ieee754_rem_pio2f __P((float,float*)); extern float __ieee754_scalbf __P((float,float)); /* float versions of fdlibm kernel functions */ extern float __kernel_sinf __P((float,float,int)); extern float __kernel_cosf __P((float,float)); extern float __kernel_tanf __P((float,float,int)); -extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int*)); +extern int __kernel_rem_pio2f __P((float*,float*,int,int,int, + const int32_t*)); /* ieee style elementary long double functions */ |