[2/5] Make common nextdown implementation generic.
diff mbox

Message ID f999b76a4609e802938e4f79b90027ebe5823946.1472599898.git.murphyp@linux.vnet.ibm.com
State New
Headers show

Commit Message

Paul E. Murphy Aug. 30, 2016, 11:39 p.m. UTC
With the exception of those machines using the ldbl-opt in
an Implies file, this is a trivial transformation.

nextdownl is not subject to the non-trivial versioning rules
of the other generated functions, so to keep things simple,
it is handled as a one-off case in ldbl-opt to preserve the
existing behavior.

	* math/Makefile: (gen-libm-calls): Add s_nextdown.
	(libm-calls): Remove above.

	* math/s_nextdown.c: Refactor into ...
	* math/s_nextdown_template.c: New file.
	* math/s_nextdownf.c: Removed.
	* math/s_nextdownl.c: Removed.

	* sysdeps/ieee754/ldbl-opt/s_nextdownl.c: New file.
---
 math/Makefile                          |  4 ++--
 math/s_nextdown.c                      | 33 ---------------------------------
 math/s_nextdown_template.c             | 29 +++++++++++++++++++++++++++++
 math/s_nextdownf.c                     | 29 -----------------------------
 math/s_nextdownl.c                     | 29 -----------------------------
 sysdeps/ieee754/ldbl-opt/s_nextdownl.c |  5 +++++
 6 files changed, 36 insertions(+), 93 deletions(-)
 delete mode 100644 math/s_nextdown.c
 create mode 100644 math/s_nextdown_template.c
 delete mode 100644 math/s_nextdownf.c
 delete mode 100644 math/s_nextdownl.c
 create mode 100644 sysdeps/ieee754/ldbl-opt/s_nextdownl.c

Comments

Joseph Myers Aug. 31, 2016, 4:54 p.m. UTC | #1
On Tue, 30 Aug 2016, Paul E. Murphy wrote:

> With the exception of those machines using the ldbl-opt in
> an Implies file, this is a trivial transformation.
> 
> nextdownl is not subject to the non-trivial versioning rules
> of the other generated functions, so to keep things simple,
> it is handled as a one-off case in ldbl-opt to preserve the
> existing behavior.
> 
> 	* math/Makefile: (gen-libm-calls): Add s_nextdown.
> 	(libm-calls): Remove above.
> 
> 	* math/s_nextdown.c: Refactor into ...
> 	* math/s_nextdown_template.c: New file.
> 	* math/s_nextdownf.c: Removed.
> 	* math/s_nextdownl.c: Removed.
> 
> 	* sysdeps/ieee754/ldbl-opt/s_nextdownl.c: New file.

OK.
Paul E. Murphy Sept. 1, 2016, 3:34 p.m. UTC | #2
On 08/31/2016 11:54 AM, Joseph Myers wrote:
> On Tue, 30 Aug 2016, Paul E. Murphy wrote:
> 
>> With the exception of those machines using the ldbl-opt in
>> an Implies file, this is a trivial transformation.
>>
>> nextdownl is not subject to the non-trivial versioning rules
>> of the other generated functions, so to keep things simple,
>> it is handled as a one-off case in ldbl-opt to preserve the
>> existing behavior.
>>
>> 	* math/Makefile: (gen-libm-calls): Add s_nextdown.
>> 	(libm-calls): Remove above.
>>
>> 	* math/s_nextdown.c: Refactor into ...
>> 	* math/s_nextdown_template.c: New file.
>> 	* math/s_nextdownf.c: Removed.
>> 	* math/s_nextdownl.c: Removed.
>>
>> 	* sysdeps/ieee754/ldbl-opt/s_nextdownl.c: New file.
> 
> OK.
> 

Committed as ee8a490.

Patch
diff mbox

diff --git a/math/Makefile b/math/Makefile
index d4b6d98..be6b8ac 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -49,7 +49,7 @@  gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF		  \
 	         s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF	  \
 		 k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
 		 s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF	  \
-		 s_cpowF s_clog10F s_fdimF
+		 s_cpowF s_clog10F s_fdimF s_nextdownF
 
 libm-calls =								  \
 	e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -70,7 +70,7 @@  libm-calls =								  \
 	s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F w_log2F	  \
 	s_issignalingF $(calls:s_%=m_%) x2y2m1F				  \
 	gamma_productF lgamma_negF lgamma_productF			  \
-	s_nextupF s_nextdownF $(gen-libm-calls)
+	s_nextupF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
diff --git a/math/s_nextdown.c b/math/s_nextdown.c
deleted file mode 100644
index 06fd1c9..0000000
--- a/math/s_nextdown.c
+++ /dev/null
@@ -1,33 +0,0 @@ 
-/* Return the greatest floating-point number less than X.
-   Copyright (C) 2016 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/>.  */
-
-#include <math.h>
-#include <math_private.h>
-
-/* Return the greatest floating-point number less than X.  */
-double
-__nextdown (double x)
-{
-  return -__nextup (-x);
-}
-
-weak_alias (__nextdown, nextdown)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__nextdown, __nextdownl)
-weak_alias (__nextdown, nextdownl)
-#endif
diff --git a/math/s_nextdown_template.c b/math/s_nextdown_template.c
new file mode 100644
index 0000000..f286dfd
--- /dev/null
+++ b/math/s_nextdown_template.c
@@ -0,0 +1,29 @@ 
+/* Return the greatest floating-point number less than X.
+   Copyright (C) 2016 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/>.  */
+
+#include <math.h>
+#include <math_private.h>
+
+/* Return the greatest floating-point number less than X.  */
+FLOAT
+M_DECL_FUNC (__nextdown) (FLOAT x)
+{
+  return -M_SUF (__nextup) (-x);
+}
+
+declare_mgen_alias (__nextdown, nextdown);
diff --git a/math/s_nextdownf.c b/math/s_nextdownf.c
deleted file mode 100644
index c0d4585..0000000
--- a/math/s_nextdownf.c
+++ /dev/null
@@ -1,29 +0,0 @@ 
-/* Return the greatest floating-point number less than X.
-   Copyright (C) 2016 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/>.  */
-
-#include <math.h>
-#include <math_private.h>
-
-/* Return the greatest floating-point number less than X.  */
-float
-__nextdownf (float x)
-{
-  return -__nextupf (-x);
-}
-
-weak_alias (__nextdownf, nextdownf)
diff --git a/math/s_nextdownl.c b/math/s_nextdownl.c
deleted file mode 100644
index e7607f5..0000000
--- a/math/s_nextdownl.c
+++ /dev/null
@@ -1,29 +0,0 @@ 
-/* Return the greatest floating-point number less than X.
-   Copyright (C) 2016 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/>.  */
-
-#include <math.h>
-#include <math_private.h>
-
-/* Return the greatest floating-point number less than X.  */
-long double
-__nextdownl (long double x)
-{
-  return -__nextupl (-x);
-}
-
-weak_alias (__nextdownl, nextdownl)
diff --git a/sysdeps/ieee754/ldbl-opt/s_nextdownl.c b/sysdeps/ieee754/ldbl-opt/s_nextdownl.c
new file mode 100644
index 0000000..c92c02e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/s_nextdownl.c
@@ -0,0 +1,5 @@ 
+/* nextdownl is not subject to complex aliasing rules.  It was
+   added in glibc 2.24.  */
+#define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#include <math-type-macros-ldouble.h>
+#include <s_nextdown_template.c>