[PATCH 1/4] ldbl-128: refactor nexttoward alias using new macro

Paul E. Murphy murphyp@linux.vnet.ibm.com
Mon May 4 22:23:50 GMT 2020


A new macro, libm_alias_exclusive_ldouble, is added to
expose an aliased symbol which should only be defined for
the long double type.

This enables a more controlled mechanism to define aliases
when long double may be aliased from _Float128, and the
removal of the almost trivial s_nextafterf128.c sitting in
ldbl-128ibm-compat.
---
 sysdeps/generic/libm-alias-ldouble.h          |  6 ++++++
 sysdeps/ieee754/float128/float128_private.h   |  4 ++++
 sysdeps/ieee754/ldbl-128/s_nextafterl.c       |  3 +--
 .../ldbl-128ibm-compat/libm-alias-float128.h  |  5 +++++
 .../ldbl-128ibm-compat/s_nextafterf128.c      | 20 -------------------
 5 files changed, 16 insertions(+), 22 deletions(-)
 delete mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c

diff --git a/sysdeps/generic/libm-alias-ldouble.h b/sysdeps/generic/libm-alias-ldouble.h
index 724a121792..8cd454dc9b 100644
--- a/sysdeps/generic/libm-alias-ldouble.h
+++ b/sysdeps/generic/libm-alias-ldouble.h
@@ -62,4 +62,10 @@
 /* Likewise, but without the R suffix.  */
 #define libm_alias_ldouble(from, to) libm_alias_ldouble_r (from, to, )
 
+/* Generate symbols which are defined for long double types, but are
+   not defined for _FloatX types.  e.g nextafterl and nexttowardl. */
+#define libm_alias_exclusive_ldouble(from, to) \
+	strong_alias (from ## l, __ ## to ## l) \
+	weak_alias (__ ## to ## l, to ## l)
+
 #endif
diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h
index f97463d9dc..5e5f9cc009 100644
--- a/sysdeps/ieee754/float128/float128_private.h
+++ b/sysdeps/ieee754/float128/float128_private.h
@@ -128,6 +128,10 @@
 
 
 #include <libm-alias-ldouble.h>
+/* Define here to allow float128 to ldbl redirects to redefine. */
+#undef libm_alias_exclusive_ldouble
+#define libm_alias_exclusive_ldouble(from, to)
+
 #include <libm-alias-float128.h>
 #undef libm_alias_ldouble_r
 #define libm_alias_ldouble_r(from, to, r) libm_alias_float128_r (from, to, r)
diff --git a/sysdeps/ieee754/ldbl-128/s_nextafterl.c b/sysdeps/ieee754/ldbl-128/s_nextafterl.c
index 60fdae648f..8d4abacb0d 100644
--- a/sysdeps/ieee754/ldbl-128/s_nextafterl.c
+++ b/sysdeps/ieee754/ldbl-128/s_nextafterl.c
@@ -84,5 +84,4 @@ _Float128 __nextafterl(_Float128 x, _Float128 y)
 	return x;
 }
 libm_alias_ldouble (__nextafter, nextafter)
-strong_alias (__nextafterl, __nexttowardl)
-weak_alias (__nextafterl, nexttowardl)
+libm_alias_exclusive_ldouble (__nextafter, nexttoward)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h b/sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h
index 48c6f9e729..66d2771291 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h
@@ -61,4 +61,9 @@
 /* Likewise, but without the R suffix.  */
 #define libm_alias_float128(from, to) libm_alias_float128_r (from, to, )
 
+/* Generate symbols for exclusive ldouble symbols not defined for _Float128. */
+#undef libm_alias_exclusive_ldouble
+#define libm_alias_exclusive_ldouble(from, to) \
+    libm_alias_float128_other_r_ldbl(from, to,)
+
 #endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c b/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c
deleted file mode 100644
index cc30ae02d7..0000000000
--- a/sysdeps/ieee754/ldbl-128ibm-compat/s_nextafterf128.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Provide nexttowardl and nextafterl implementations for IEEE long double.
-   Copyright (C) 2020 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 "../float128/s_nextafterf128.c"
-
-strong_alias (__nextafterieee128, __nexttowardieee128)
-- 
2.21.1



More information about the Libc-alpha mailing list