diff options
| author | Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com> | 2016-12-15 16:41:58 -0200 |
|---|---|---|
| committer | Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com> | 2017-02-23 11:28:50 -0300 |
| commit | aec0821ce78e5f006ed45c063b4a129292bb739a (patch) | |
| tree | fdbe3af878af58185d0fe0bb036d5876d2d521a6 /math | |
| parent | 63e1c3768dad1b6e1ea6b46108da236792228fe4 (diff) | |
| download | glibc-aec0821ce78e5f006ed45c063b4a129292bb739a.tar.xz glibc-aec0821ce78e5f006ed45c063b4a129292bb739a.zip | |
Add new templates for IEEE wrappers
Several wrappers for IEEE functions use _LIB_VERSION / matherr /
__kernel_standard functionality, which we want to obsolete. New
wrappers, such as for float128, must not use this functionality.
This patch adds new wrappers that only __set_errno and can be used by
the new float128 wrappers.
Tested for powerpc64le.
* math/Makefile: Add wrappers to gen-libm-calls.
* math/w_acos_template.c: New file.
* math/w_acosh_template.c: Likewise.
* math/w_asin_template.c: Likewise.
* math/w_atan2_template.c: Likewise.
* math/w_atanh_template.c: Likewise.
* math/w_cosh_template.c: Likewise.
* math/w_exp10_template.c: Likewise.
* math/w_exp2_template.c: Likewise.
* math/w_exp_template.c: Likewise.
* math/w_fmod_template.c: Likewise.
* math/w_hypot_template.c: Likewise.
* math/w_j0_template.c: Likewise.
* math/w_j1_template.c: Likewise.
* math/w_jn_template.c: Likewise.
* math/w_lgamma_r_template.c: Likewise.
* math/w_lgamma_template.c: Likewise.
* math/w_log10_template.c: Likewise.
* math/w_log2_template.c: Likewise.
* math/w_log_template.c: Likewise.
* math/w_pow_template.c: Likewise.
* math/w_remainder_template.c: Likewise.
* math/w_sinh_template.c: Likewise.
* math/w_sqrt_template.c: Likewise.
* math/w_tgamma_template.c: Likewise.: Likewise.
* sysdeps/generic/math-type-macros-double.h
(__USE_WRAPPER_TEMPLATE): New macro to control inclusion of
the new wrappers.
* sysdeps/generic/math-type-macros-float.h: Likewise.
* sysdeps/generic/math-type-macros-ldouble.h: Likewise.
Diffstat (limited to 'math')
| -rw-r--r-- | math/Makefile | 6 | ||||
| -rw-r--r-- | math/w_acos_template.c | 38 | ||||
| -rw-r--r-- | math/w_acosh_template.c | 38 | ||||
| -rw-r--r-- | math/w_asin_template.c | 38 | ||||
| -rw-r--r-- | math/w_atan2_template.c | 39 | ||||
| -rw-r--r-- | math/w_atanh_template.c | 44 | ||||
| -rw-r--r-- | math/w_cosh_template.c | 39 | ||||
| -rw-r--r-- | math/w_exp10_template.c | 39 | ||||
| -rw-r--r-- | math/w_exp2_template.c | 39 | ||||
| -rw-r--r-- | math/w_exp_template.c | 43 | ||||
| -rw-r--r-- | math/w_fmod_template.c | 39 | ||||
| -rw-r--r-- | math/w_hypot_template.c | 39 | ||||
| -rw-r--r-- | math/w_j0_template.c | 51 | ||||
| -rw-r--r-- | math/w_j1_template.c | 51 | ||||
| -rw-r--r-- | math/w_jn_template.c | 51 | ||||
| -rw-r--r-- | math/w_lgamma_r_template.c | 53 | ||||
| -rw-r--r-- | math/w_lgamma_template.c | 42 | ||||
| -rw-r--r-- | math/w_log10_template.c | 44 | ||||
| -rw-r--r-- | math/w_log2_template.c | 44 | ||||
| -rw-r--r-- | math/w_log_template.c | 44 | ||||
| -rw-r--r-- | math/w_pow_template.c | 51 | ||||
| -rw-r--r-- | math/w_remainder_template.c | 39 | ||||
| -rw-r--r-- | math/w_sinh_template.c | 39 | ||||
| -rw-r--r-- | math/w_sqrt_template.c | 38 | ||||
| -rw-r--r-- | math/w_tgamma_template.c | 54 |
25 files changed, 1041 insertions, 1 deletions
diff --git a/math/Makefile b/math/Makefile index 1941abcafd..0cd3a4b4b9 100644 --- a/math/Makefile +++ b/math/Makefile @@ -54,7 +54,11 @@ gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF \ s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF \ s_cpowF s_clog10F s_fdimF s_nextdownF s_fmaxF s_fminF \ s_nanF s_iseqsigF s_canonicalizeF w_ilogbF w_llogbF \ - w_log1pF w_scalblnF s_fmaxmagF s_fminmagF + w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF \ + w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F \ + w_exp2F w_fmodF w_hypotF w_j0F w_j1F w_jnF w_logF \ + w_log10F w_log2F w_powF w_remainderF w_sinhF w_sqrtF \ + w_tgammaF w_lgammaF w_lgammaF_r w_expF libm-calls = \ e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \ diff --git a/math/w_acos_template.c b/math/w_acos_template.c new file mode 100644 index 0000000000..ea0e7d4f02 --- /dev/null +++ b/math/w_acos_template.c @@ -0,0 +1,38 @@ +/* Wrapper to set errno for acos. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__acos) (FLOAT x) +{ + if (__glibc_unlikely (isgreater (M_SUF (fabs) (x), M_LIT (1.0)))) + /* Domain error: acos(|x|>1). */ + __set_errno (EDOM); + return M_SUF (__ieee754_acos) (x); +} +declare_mgen_alias (__acos, acos) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_acosh_template.c b/math/w_acosh_template.c new file mode 100644 index 0000000000..31f63dbd96 --- /dev/null +++ b/math/w_acosh_template.c @@ -0,0 +1,38 @@ +/* Wrapper to set errno for acosh. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__acosh) (FLOAT x) +{ + if (__glibc_unlikely (isless (x, M_LIT (1.0)))) + /* Domain error: acosh(x<1). */ + __set_errno (EDOM); + return M_SUF (__ieee754_acosh) (x); +} +declare_mgen_alias (__acosh, acosh) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_asin_template.c b/math/w_asin_template.c new file mode 100644 index 0000000000..41c610245f --- /dev/null +++ b/math/w_asin_template.c @@ -0,0 +1,38 @@ +/* Wrapper to set errno for asin. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__asin) (FLOAT x) +{ + if (__glibc_unlikely (isgreater (M_SUF (fabs) (x), M_LIT (1.0)))) + /* Domain error: asin(|x|>1). */ + __set_errno (EDOM); + return M_SUF (__ieee754_asin) (x); +} +declare_mgen_alias (__asin, asin) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_atan2_template.c b/math/w_atan2_template.c new file mode 100644 index 0000000000..bfab6e83b8 --- /dev/null +++ b/math/w_atan2_template.c @@ -0,0 +1,39 @@ +/* Wrapper to set errno for atan2. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <errno.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__atan2) (FLOAT y, FLOAT x) +{ + FLOAT z = M_SUF (__ieee754_atan2) (y, x); + if (__glibc_unlikely (z == 0 && y != 0 && isfinite (x))) + /* Underflow. */ + __set_errno (ERANGE); + return z; +} +declare_mgen_alias (__atan2, atan2) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_atanh_template.c b/math/w_atanh_template.c new file mode 100644 index 0000000000..771af5aff8 --- /dev/null +++ b/math/w_atanh_template.c @@ -0,0 +1,44 @@ +/* Wrapper to set errno for atanh. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__atanh) (FLOAT x) +{ + if (__glibc_unlikely (isgreaterequal (M_SUF (fabs) (x), M_LIT (1.0)))) + { + if (M_SUF (fabs) (x) == 1) + /* Pole error: atanh(|x|==1). */ + __set_errno (ERANGE); + else + /* Domain error: atanh(|x|>1). */ + __set_errno (EDOM); + } + return M_SUF (__ieee754_atanh) (x); +} +declare_mgen_alias (__atanh, atanh) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_cosh_template.c b/math/w_cosh_template.c new file mode 100644 index 0000000000..b912e6e6a5 --- /dev/null +++ b/math/w_cosh_template.c @@ -0,0 +1,39 @@ +/* Wrapper to set errno for cosh. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__cosh) (FLOAT x) +{ + FLOAT z = M_SUF (__ieee754_cosh) (x); + if (__glibc_unlikely (!isfinite (z)) && isfinite (x)) + /* Overflow. */ + __set_errno (ERANGE); + return z; +} +declare_mgen_alias (__cosh, cosh) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_exp10_template.c b/math/w_exp10_template.c new file mode 100644 index 0000000000..8f7997dd35 --- /dev/null +++ b/math/w_exp10_template.c @@ -0,0 +1,39 @@ +/* Wrapper to set errno for exp10. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__exp10) (FLOAT x) +{ + FLOAT z = M_SUF (__ieee754_exp10) (x); + if (__glibc_unlikely (!isfinite (z) || z == 0) && isfinite (x)) + /* Overflow or underflow. */ + __set_errno (ERANGE); + return z; +} +declare_mgen_alias (__exp10, exp10) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_exp2_template.c b/math/w_exp2_template.c new file mode 100644 index 0000000000..76577c7fca --- /dev/null +++ b/math/w_exp2_template.c @@ -0,0 +1,39 @@ +/* Wrapper to set errno for exp2. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__exp2) (FLOAT x) +{ + FLOAT z = M_SUF (__ieee754_exp2) (x); + if (__glibc_unlikely (!isfinite (z) || z == 0) && isfinite (x)) + /* Overflow or underflow. */ + __set_errno (ERANGE); + return z; +} +declare_mgen_alias (__exp2, exp2) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_exp_template.c b/math/w_exp_template.c new file mode 100644 index 0000000000..c0a4ec5be3 --- /dev/null +++ b/math/w_exp_template.c @@ -0,0 +1,43 @@ +/* Wrapper to set errno for exp. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +/* Provide an additional macro expansion for hidden_def. */ +#define hidden_def_x(name) hidden_def (name) + +FLOAT +M_DECL_FUNC (__exp) (FLOAT x) +{ + FLOAT z = M_SUF (__ieee754_exp) (x); + if (__glibc_unlikely (!isfinite (z) || z == 0) && isfinite (x)) + /* Overflow or underflow. */ + __set_errno (ERANGE); + return z; +} +hidden_def_x (M_SUF (__exp)) +declare_mgen_alias (__exp, exp) + +#endif /* __USE_WRAPPER_TEMPLATE. */ diff --git a/math/w_fmod_template.c b/math/w_fmod_template.c new file mode 100644 index 0000000000..06d7c75661 --- /dev/null +++ b/math/w_fmod_template.c @@ -0,0 +1,39 @@ +/* Wrapper to set errno for fmod. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* Only build wrappers from the templates for the types that define the macro + below. This macro is set in math-type-macros-<type>.h in sysdeps/generic + for each floating-point type. */ +#if __USE_WRAPPER_TEMPLATE + +# include <fenv.h> +# include <math.h> +# include <math_private.h> + +FLOAT +M_DECL_FUNC (__fmod) (FLOAT x, FLOAT y) +{ + if (__builtin_expect (isinf (x) || y == 0, 0) && !isnan (y) && !isnan (x)) + /* Domain error: fmod(+-Inf,y) or fmod(x,0). |
