]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add new templates for IEEE wrappers
authorGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Thu, 15 Dec 2016 18:41:58 +0000 (16:41 -0200)
committerGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Thu, 23 Feb 2017 14:28:50 +0000 (11:28 -0300)
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.

29 files changed:
ChangeLog
math/Makefile
math/w_acos_template.c [new file with mode: 0644]
math/w_acosh_template.c [new file with mode: 0644]
math/w_asin_template.c [new file with mode: 0644]
math/w_atan2_template.c [new file with mode: 0644]
math/w_atanh_template.c [new file with mode: 0644]
math/w_cosh_template.c [new file with mode: 0644]
math/w_exp10_template.c [new file with mode: 0644]
math/w_exp2_template.c [new file with mode: 0644]
math/w_exp_template.c [new file with mode: 0644]
math/w_fmod_template.c [new file with mode: 0644]
math/w_hypot_template.c [new file with mode: 0644]
math/w_j0_template.c [new file with mode: 0644]
math/w_j1_template.c [new file with mode: 0644]
math/w_jn_template.c [new file with mode: 0644]
math/w_lgamma_r_template.c [new file with mode: 0644]
math/w_lgamma_template.c [new file with mode: 0644]
math/w_log10_template.c [new file with mode: 0644]
math/w_log2_template.c [new file with mode: 0644]
math/w_log_template.c [new file with mode: 0644]
math/w_pow_template.c [new file with mode: 0644]
math/w_remainder_template.c [new file with mode: 0644]
math/w_sinh_template.c [new file with mode: 0644]
math/w_sqrt_template.c [new file with mode: 0644]
math/w_tgamma_template.c [new file with mode: 0644]
sysdeps/generic/math-type-macros-double.h
sysdeps/generic/math-type-macros-float.h
sysdeps/generic/math-type-macros-ldouble.h

index 0b368089469e54522bb2ec25969932c0fa4df813..f1bf7ca6a47b97e805f88b94b0590350ba55766f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2017-02-23 Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
+          Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
+
+       * 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.
+
 2017-02-22  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/unix/sysv/linux/sys/timerfd.h (TFD_TIMER_CANCEL_ON_SET):
index 1941abcafd929a2a070f9af3e45b384558325e6f..0cd3a4b4b93f11efcbae9516b16d772c77ffa2d0 100644 (file)
@@ -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 (file)
index 0000000..ea0e7d4
--- /dev/null
@@ -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 (file)
index 0000000..31f63db
--- /dev/null
@@ -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 (file)
index 0000000..41c6102
--- /dev/null
@@ -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 (file)
index 0000000..bfab6e8
--- /dev/null
@@ -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 (file)
index 0000000..771af5a
--- /dev/null
@@ -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 (file)
index 0000000..b912e6e
--- /dev/null
@@ -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 (file)
index 0000000..8f7997d
--- /dev/null
@@ -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 (file)
index 0000000..76577c7
--- /dev/null
@@ -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 (file)
index 0000000..c0a4ec5
--- /dev/null
@@ -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 (file)
index 0000000..06d7c75
--- /dev/null
@@ -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).
+       If x or y are nan, these conditions should not be considered.  */
+    __set_errno (EDOM);
+  return M_SUF (__ieee754_fmod) (x, y);
+}
+declare_mgen_alias (__fmod, fmod)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_hypot_template.c b/math/w_hypot_template.c
new file mode 100644 (file)
index 0000000..9298add
--- /dev/null
@@ -0,0 +1,39 @@
+/* Wrapper to set errno for hypot.
+   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 (__hypot) (FLOAT x, FLOAT y)
+{
+  FLOAT z = M_SUF (__ieee754_hypot) (x, y);
+  if (__glibc_unlikely (!isfinite (z)) && isfinite (x) && isfinite (y))
+    /* Overflow.  */
+    __set_errno (ERANGE);
+  return z;
+}
+declare_mgen_alias (__hypot, hypot)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_j0_template.c b/math/w_j0_template.c
new file mode 100644 (file)
index 0000000..f49874f
--- /dev/null
@@ -0,0 +1,51 @@
+/* Wrapper to set errno for j0 and y0.
+   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 (__j0) (FLOAT x)
+{
+  return M_SUF (__ieee754_j0) (x);
+}
+declare_mgen_alias (__j0, j0)
+
+FLOAT
+M_DECL_FUNC (__y0) (FLOAT x)
+{
+  if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
+    {
+      if (x < 0)
+       /* Domain error: y0(x<0).  */
+       __set_errno (EDOM);
+      else if (x == 0)
+       /* Pole error: y0(0).  */
+       __set_errno (ERANGE);
+    }
+  return M_SUF (__ieee754_y0) (x);
+}
+declare_mgen_alias (__y0, y0)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_j1_template.c b/math/w_j1_template.c
new file mode 100644 (file)
index 0000000..6d1058f
--- /dev/null
@@ -0,0 +1,51 @@
+/* Wrapper to set errno for j1 and y1.
+   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 (__j1) (FLOAT x)
+{
+  return M_SUF (__ieee754_j1) (x);
+}
+declare_mgen_alias (__j1, j1)
+
+FLOAT
+M_DECL_FUNC (__y1) (FLOAT x)
+{
+  if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
+    {
+      if (x < 0)
+       /* Domain error: y1(x<0).  */
+       __set_errno (EDOM);
+      else if (x == 0)
+       /* Pole error: y1(0).  */
+       __set_errno (ERANGE);
+    }
+  return M_SUF (__ieee754_y1) (x);
+}
+declare_mgen_alias (__y1, y1)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_jn_template.c b/math/w_jn_template.c
new file mode 100644 (file)
index 0000000..fd13835
--- /dev/null
@@ -0,0 +1,51 @@
+/* Wrapper to set errno for jn and yn.
+   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 (__jn) (int n, FLOAT x)
+{
+  return M_SUF (__ieee754_jn) (n, x);
+}
+declare_mgen_alias (__jn, jn)
+
+FLOAT
+M_DECL_FUNC (__yn) (int n, FLOAT x)
+{
+  if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
+    {
+      if (x < 0)
+       /* Domain error: yn(x<0).  */
+       __set_errno (EDOM);
+      else if (x == 0)
+       /* Pole error: yn(0).  */
+       __set_errno (ERANGE);
+    }
+  return M_SUF (__ieee754_yn) (n, x);
+}
+declare_mgen_alias (__yn, yn)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_lgamma_r_template.c b/math/w_lgamma_r_template.c
new file mode 100644 (file)
index 0000000..977d1b5
--- /dev/null
@@ -0,0 +1,53 @@
+/* Wrapper to set errno for lgamma_r.
+   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>
+
+#define M_DECL_FUNC_R_X(x) x ## _r
+#define M_DECL_FUNC_R_S(x) M_DECL_FUNC_R_X (x)
+#define M_DECL_FUNC_R(x) M_DECL_FUNC_R_S (M_SUF (x))
+
+#define M_CALL_FUNC_R_X(x) x ## _r
+#define M_CALL_FUNC_R_S(x) M_CALL_FUNC_R_X (x)
+#define M_CALL_FUNC_R(x) M_CALL_FUNC_R_S (M_SUF (x))
+
+#define declare_mgen_alias_r_x(from, to) weak_alias (from ## _r, to ## _r)
+#define declare_mgen_alias_r_s(from, to) \
+       declare_mgen_alias_r_x (from, to)
+#define declare_mgen_alias_r(from, to) \
+       declare_mgen_alias_r_s (M_SUF (from), M_SUF (to))
+
+FLOAT
+M_DECL_FUNC_R (__lgamma) (FLOAT x, int *signgamp)
+{
+  FLOAT y = M_CALL_FUNC_R (__ieee754_lgamma) (x, signgamp);
+  if (__glibc_unlikely (!isfinite (y)) && isfinite (x))
+    /* Pole error: lgamma_r(integer x<0).  Or overflow.  */
+    __set_errno (ERANGE);
+  return y;
+}
+declare_mgen_alias_r (__lgamma, lgamma)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_lgamma_template.c b/math/w_lgamma_template.c
new file mode 100644 (file)
index 0000000..a60413d
--- /dev/null
@@ -0,0 +1,42 @@
+/* Wrapper to set errno for lgamma.
+   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>
+
+#define M_CALL_FUNC_X(x) x ## _r
+#define M_CALL_FUNC(x) M_CALL_FUNC_X (x)
+
+FLOAT
+M_DECL_FUNC (__lgamma) (FLOAT x)
+{
+  FLOAT y = M_CALL_FUNC (M_SUF (__ieee754_lgamma)) (x, &__signgam);
+  if (__glibc_unlikely (!isfinite (y)) && isfinite (x))
+    /* Pole error: lgamma(integer x<0).  Or overflow.  */
+    __set_errno (ERANGE);
+  return y;
+}
+declare_mgen_alias (__lgamma, lgamma)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_log10_template.c b/math/w_log10_template.c
new file mode 100644 (file)
index 0000000..92735f0
--- /dev/null
@@ -0,0 +1,44 @@
+/* Wrapper to set errno for log10.
+   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 (__log10) (FLOAT x)
+{
+  if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
+    {
+      if (x == 0)
+       /* Pole error: log10(0).  */
+       __set_errno (ERANGE);
+      else
+       /* Domain error: log10(<0).  */
+       __set_errno (EDOM);
+    }
+  return M_SUF (__ieee754_log10) (x);
+}
+declare_mgen_alias (__log10, log10)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_log2_template.c b/math/w_log2_template.c
new file mode 100644 (file)
index 0000000..a80b287
--- /dev/null
@@ -0,0 +1,44 @@
+/* Wrapper to set errno for log2.
+   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 (__log2) (FLOAT x)
+{
+  if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
+    {
+      if (x == 0)
+       /* Pole error: log2(0).  */
+       __set_errno (ERANGE);
+      else
+       /* Domain error: log2(<0).  */
+       __set_errno (EDOM);
+    }
+  return M_SUF (__ieee754_log2) (x);
+}
+declare_mgen_alias (__log2, log2)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_log_template.c b/math/w_log_template.c
new file mode 100644 (file)
index 0000000..3f9830c
--- /dev/null
@@ -0,0 +1,44 @@
+/* Wrapper to set errno for log.
+   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 (__log) (FLOAT x)
+{
+  if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
+    {
+      if (x == 0)
+       /* Pole error: log(0).  */
+       __set_errno (ERANGE);
+      else
+       /* Domain error: log(<0).  */
+       __set_errno (EDOM);
+    }
+  return M_SUF (__ieee754_log) (x);
+}
+declare_mgen_alias (__log, log)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_pow_template.c b/math/w_pow_template.c
new file mode 100644 (file)
index 0000000..50431b9
--- /dev/null
@@ -0,0 +1,51 @@
+/* Wrapper to set errno for pow.
+   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 (__pow) (FLOAT x, FLOAT y)
+{
+  FLOAT z = M_SUF (__ieee754_pow) (x, y);
+  if (__glibc_unlikely (!isfinite (z)))
+    {
+      if (isfinite (x) && isfinite (y))
+       {
+         if (isnan (z))
+           /* Domain error: pow(x<0,y=non-integer).  */
+           __set_errno (EDOM);
+         else
+           /* Pole error: pow(x=0,y<0).  Or overflow.  */
+           __set_errno (ERANGE);
+       }
+    }
+  else if (__glibc_unlikely (z == 0) && isfinite (x) && x != 0 && isfinite (y))
+    /* Underflow.  */
+    __set_errno (ERANGE);
+  return z;
+}
+declare_mgen_alias (__pow, pow)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_remainder_template.c b/math/w_remainder_template.c
new file mode 100644 (file)
index 0000000..4ecf10d
--- /dev/null
@@ -0,0 +1,39 @@
+/* Wrapper to set errno for remainder.
+   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 (__remainder) (FLOAT x, FLOAT y)
+{
+  if (__glibc_unlikely (isinf (x) || y == 0) && !isnan (y) && !isnan (x))
+    /* Domain error: remainder(+-Inf,y) or remainder(x,0).
+       If x or y are nan, these conditions should not be considered.  */
+    __set_errno (EDOM);
+  return M_SUF (__ieee754_remainder) (x, y);
+}
+declare_mgen_alias (__remainder, remainder)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_sinh_template.c b/math/w_sinh_template.c
new file mode 100644 (file)
index 0000000..7a147de
--- /dev/null
@@ -0,0 +1,39 @@
+/* Wrapper to set errno for sinh.
+   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 (__sinh) (FLOAT x)
+{
+  FLOAT z = M_SUF (__ieee754_sinh) (x);
+  if (__glibc_unlikely (!isfinite (z)) && isfinite (x))
+    /* Overflow.  */
+    __set_errno (ERANGE);
+  return z;
+}
+declare_mgen_alias (__sinh, sinh)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_sqrt_template.c b/math/w_sqrt_template.c
new file mode 100644 (file)
index 0000000..f97074f
--- /dev/null
@@ -0,0 +1,38 @@
+/* Wrapper to set errno for sqrt.
+   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 (__sqrt) (FLOAT x)
+{
+  if (__glibc_unlikely (isless (x, M_LIT (0.0))))
+    /* Domain error: sqrt(x<-0).  */
+    __set_errno (EDOM);
+  return M_SUF (__ieee754_sqrt) (x);
+}
+declare_mgen_alias (__sqrt, sqrt)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_tgamma_template.c b/math/w_tgamma_template.c
new file mode 100644 (file)
index 0000000..277a837
--- /dev/null
@@ -0,0 +1,54 @@
+/* Wrapper to set errno for tgamma.
+   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>
+
+#define M_CALL_FUNC_X(x) x ## _r
+#define M_CALL_FUNC(x) M_CALL_FUNC_X (x)
+
+FLOAT
+M_DECL_FUNC (__tgamma) (FLOAT x)
+{
+  int local_signgam;
+  FLOAT y = M_CALL_FUNC (M_SUF (__ieee754_gamma)) (x, &local_signgam);
+
+  if (__glibc_unlikely (!isfinite (y) || y == 0)
+      && (isfinite (x) || (isinf (x) && x < 0)))
+    {
+      if (x == 0)
+       /* Pole error: tgamma(x=0).  */
+       __set_errno (ERANGE);
+      else if (M_SUF (__floor) (x) == x && x < 0)
+       /* Domain error: tgamma(integer x<0).  */
+       __set_errno (EDOM);
+      else
+       /* Overflow or underflow.  */
+       __set_errno (ERANGE);
+    }
+  return local_signgam < 0 ? -y : y;
+}
+declare_mgen_alias (__tgamma, tgamma)
+
+#endif /* __USE_WRAPPER_TEMPLATE.  */
index 8048d388197e1bdff53b0ce727675362cf76081b..6116f7f32f0bbc47b50600f432e43b4daf621423 100644 (file)
@@ -47,4 +47,7 @@
 /* Supply the generic macros.  */
 #include <math-type-macros.h>
 
+/* Do not use the type-generic wrapper templates.  */
+#define __USE_WRAPPER_TEMPLATE 0
+
 #endif
index 03079cef75058c8966f18575462ff475c0788d02..712e517a8112407745c614298e306acd8714c825 100644 (file)
@@ -33,4 +33,7 @@
 /* Supply the generic macros.  */
 #include <math-type-macros.h>
 
+/* Do not use the type-generic wrapper templates.  */
+#define __USE_WRAPPER_TEMPLATE 0
+
 #endif
index 31591a3a904bf65ae16e4dc169aced9a96694e2c..4e02e53f70d121e10e62b09834e2f9d6b73b6132 100644 (file)
@@ -30,4 +30,7 @@
 /* Supply the generic macros.  */
 #include <math-type-macros.h>
 
+/* Do not use the type-generic wrapper templates.  */
+#define __USE_WRAPPER_TEMPLATE 0
+
 #endif