This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.25-65-gaec0821


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  aec0821ce78e5f006ed45c063b4a129292bb739a (commit)
      from  63e1c3768dad1b6e1ea6b46108da236792228fe4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=aec0821ce78e5f006ed45c063b4a129292bb739a

commit aec0821ce78e5f006ed45c063b4a129292bb739a
Author: Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Date:   Thu Dec 15 16:41:58 2016 -0200

    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.

diff --git a/ChangeLog b/ChangeLog
index 0b36808..f1bf7ca 100644
--- 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):
diff --git a/math/Makefile b/math/Makefile
index 1941abc..0cd3a4b 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/sysdeps/generic/math-type-macros-ldouble.h b/math/w_acos_template.c
similarity index 52%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_acos_template.c
index 31591a3..ea0e7d4 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_acos_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/math/w_acosh_template.c
similarity index 53%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_acosh_template.c
index 31591a3..31f63db 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_acosh_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/math/w_asin_template.c
similarity index 52%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_asin_template.c
index 31591a3..41c6102 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_asin_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/math/w_atan2_template.c
similarity index 52%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_atan2_template.c
index 31591a3..bfab6e8 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_atan2_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,24 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <errno.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_atanh_template.c b/math/w_atanh_template.c
new file mode 100644
index 0000000..771af5a
--- /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/sysdeps/generic/math-type-macros-ldouble.h b/math/w_cosh_template.c
similarity index 53%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_cosh_template.c
index 31591a3..b912e6e 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_cosh_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,24 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/math/w_exp10_template.c
similarity index 52%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_exp10_template.c
index 31591a3..8f7997d 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_exp10_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,24 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/math/w_exp2_template.c
similarity index 52%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_exp2_template.c
index 31591a3..76577c7 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_exp2_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,24 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_exp_template.c b/math/w_exp_template.c
new file mode 100644
index 0000000..c0a4ec5
--- /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 0000000..06d7c75
--- /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).
+       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/sysdeps/generic/math-type-macros-ldouble.h b/math/w_hypot_template.c
similarity index 52%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_hypot_template.c
index 31591a3..9298add 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_hypot_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,24 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_j0_template.c b/math/w_j0_template.c
new file mode 100644
index 0000000..f49874f
--- /dev/null
+++ b/math/w_j0_template.c
@@ -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
index 0000000..6d1058f
--- /dev/null
+++ b/math/w_j1_template.c
@@ -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
index 0000000..fd13835
--- /dev/null
+++ b/math/w_jn_template.c
@@ -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
index 0000000..977d1b5
--- /dev/null
+++ b/math/w_lgamma_r_template.c
@@ -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
index 0000000..a60413d
--- /dev/null
+++ b/math/w_lgamma_template.c
@@ -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/sysdeps/generic/math-type-macros-ldouble.h b/math/w_log10_template.c
similarity index 50%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_log10_template.c
index 31591a3..92735f0 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_log10_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,29 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/math/w_log2_template.c
similarity index 50%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_log2_template.c
index 31591a3..a80b287 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_log2_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,29 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/math/w_log_template.c
similarity index 50%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_log_template.c
index 31591a3..3f9830c 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_log_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,29 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_pow_template.c b/math/w_pow_template.c
new file mode 100644
index 0000000..50431b9
--- /dev/null
+++ b/math/w_pow_template.c
@@ -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
index 0000000..4ecf10d
--- /dev/null
+++ b/math/w_remainder_template.c
@@ -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/sysdeps/generic/math-type-macros-ldouble.h b/math/w_sinh_template.c
similarity index 53%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_sinh_template.c
index 31591a3..7a147de 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_sinh_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,24 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/math/w_sqrt_template.c
similarity index 53%
copy from sysdeps/generic/math-type-macros-ldouble.h
copy to math/w_sqrt_template.c
index 31591a3..f97074f 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/math/w_sqrt_template.c
@@ -1,5 +1,5 @@
-/* Helper macros for long double variants of type generic functions of libm.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* 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
@@ -16,18 +16,23 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _MATH_TYPE_MACROS_LDOUBLE
-#define _MATH_TYPE_MACROS_LDOUBLE
+/* 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
 
-#define M_LIT(c) c ## L
-#define M_MLIT(c) c ## l
-#define M_PFX LDBL
-#define M_SUF(c) c ## l
-#define FLOAT long double
-#define CFLOAT _Complex long double
-#define M_STRTO_NAN __strtold_nan
+# include <fenv.h>
+# include <math.h>
+# include <math_private.h>
 
-/* Supply the generic macros.  */
-#include <math-type-macros.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
+#endif /* __USE_WRAPPER_TEMPLATE.  */
diff --git a/math/w_tgamma_template.c b/math/w_tgamma_template.c
new file mode 100644
index 0000000..277a837
--- /dev/null
+++ b/math/w_tgamma_template.c
@@ -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.  */
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
index 8048d38..6116f7f 100644
--- a/sysdeps/generic/math-type-macros-double.h
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -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
diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h
index 03079ce..712e517 100644
--- a/sysdeps/generic/math-type-macros-float.h
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -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
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/sysdeps/generic/math-type-macros-ldouble.h
index 31591a3..4e02e53 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -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

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                  |   34 +++++++++++++++++
 math/Makefile                              |    6 +++-
 math/w_acos_template.c                     |   38 +++++++++++++++++++
 math/w_acosh_template.c                    |   38 +++++++++++++++++++
 math/w_asin_template.c                     |   38 +++++++++++++++++++
 math/w_atan2_template.c                    |   39 ++++++++++++++++++++
 math/w_atanh_template.c                    |   44 ++++++++++++++++++++++
 math/w_cosh_template.c                     |   39 ++++++++++++++++++++
 math/w_exp10_template.c                    |   39 ++++++++++++++++++++
 math/w_exp2_template.c                     |   39 ++++++++++++++++++++
 math/w_exp_template.c                      |   43 ++++++++++++++++++++++
 math/w_fmod_template.c                     |   39 ++++++++++++++++++++
 math/w_hypot_template.c                    |   39 ++++++++++++++++++++
 math/w_j0_template.c                       |   51 ++++++++++++++++++++++++++
 math/w_j1_template.c                       |   51 ++++++++++++++++++++++++++
 math/w_jn_template.c                       |   51 ++++++++++++++++++++++++++
 math/w_lgamma_r_template.c                 |   53 +++++++++++++++++++++++++++
 math/w_lgamma_template.c                   |   42 +++++++++++++++++++++
 math/w_log10_template.c                    |   44 ++++++++++++++++++++++
 math/w_log2_template.c                     |   44 ++++++++++++++++++++++
 math/w_log_template.c                      |   44 ++++++++++++++++++++++
 math/w_pow_template.c                      |   51 ++++++++++++++++++++++++++
 math/w_remainder_template.c                |   39 ++++++++++++++++++++
 math/w_sinh_template.c                     |   39 ++++++++++++++++++++
 math/w_sqrt_template.c                     |   38 +++++++++++++++++++
 math/w_tgamma_template.c                   |   54 ++++++++++++++++++++++++++++
 sysdeps/generic/math-type-macros-double.h  |    3 ++
 sysdeps/generic/math-type-macros-float.h   |    3 ++
 sysdeps/generic/math-type-macros-ldouble.h |    3 ++
 29 files changed, 1084 insertions(+), 1 deletions(-)
 create mode 100644 math/w_acos_template.c
 create mode 100644 math/w_acosh_template.c
 create mode 100644 math/w_asin_template.c
 create mode 100644 math/w_atan2_template.c
 create mode 100644 math/w_atanh_template.c
 create mode 100644 math/w_cosh_template.c
 create mode 100644 math/w_exp10_template.c
 create mode 100644 math/w_exp2_template.c
 create mode 100644 math/w_exp_template.c
 create mode 100644 math/w_fmod_template.c
 create mode 100644 math/w_hypot_template.c
 create mode 100644 math/w_j0_template.c
 create mode 100644 math/w_j1_template.c
 create mode 100644 math/w_jn_template.c
 create mode 100644 math/w_lgamma_r_template.c
 create mode 100644 math/w_lgamma_template.c
 create mode 100644 math/w_log10_template.c
 create mode 100644 math/w_log2_template.c
 create mode 100644 math/w_log_template.c
 create mode 100644 math/w_pow_template.c
 create mode 100644 math/w_remainder_template.c
 create mode 100644 math/w_sinh_template.c
 create mode 100644 math/w_sqrt_template.c
 create mode 100644 math/w_tgamma_template.c


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]