about summary refs log tree commit diff
path: root/sysdeps/ieee754
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-11-10 21:41:56 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-11-10 21:41:56 +0000
commitb4e75104b432e86dc8e308e8f58391bee6b33d78 (patch)
treef455315a1673abfb980439d8152280e81825e561 /sysdeps/ieee754
parent0a557c105cad94758543e18b4834c15da2c39eb8 (diff)
downloadglibc-b4e75104b432e86dc8e308e8f58391bee6b33d78.tar.gz
glibc-b4e75104b432e86dc8e308e8f58391bee6b33d78.tar.xz
glibc-b4e75104b432e86dc8e308e8f58391bee6b33d78.zip
Refactor some libm type-generic macros.
This patch refactors some type-generic libm macros, in both math.h and
math_private.h, to be based on a common __MATH_TG macro rather than
all replicating similar logic to choose a function to call based on
the type of the argument.

This should serve to illustrate what I think float128 support for such
macros should look like: common macros such as __MATH_TG may need
different definitions depending on whether float128 is supported in
glibc, so that the individual macros themselves do not need
conditionals on float128 support.

Tested for x86_64, x86, mips64 and powerpc.

	* math/math.h (__MATH_TG): New macro.
	[__USE_ISOC99] (fpclassify): Define using __MATH_TG.
	[__USE_ISOC99] (signbit): Likewise.
	[__USE_ISOC99] (isfinite): Likewise.
	[__USE_ISOC99] (isnan): Likewise.
	[__USE_ISOC99] (isinf): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (issignaling): Likewise.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (__MATH_EVAL_FMT2): New macro.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (iseqsig): Define using
	__MATH_TG and __MATH_EVAL_FMT2.
	* sysdeps/generic/math_private.h (fabs_tg): Define using
	__MATH_TG.
	* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
	[!__NO_LONG_DOUBLE_MATH] (__iscanonicalf): New macro.
	[!__NO_LONG_DOUBLE_MATH] (__iscanonical): Likewise.
	[!__NO_LONG_DOUBLE_MATH] (iscanonical): Define using __MATH_TG.
	* sysdeps/ieee754/ldbl-96/bits/iscanonical.h (__iscanonicalf): New
	macro.
	(__iscanonical): Likewise.
	(iscanonical): Define using __MATH_TG.
Diffstat (limited to 'sysdeps/ieee754')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h7
-rw-r--r--sysdeps/ieee754/ldbl-96/bits/iscanonical.h7
2 files changed, 6 insertions, 8 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
index c7b7c63f95..d613cde4d3 100644
--- a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
+++ b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
@@ -25,6 +25,8 @@
 #else
 extern int __iscanonicall (long double __x)
      __THROW __attribute__ ((__const__));
+# define __iscanonicalf(x) ((void) (__typeof (x)) (x), 1)
+# define __iscanonical(x) ((void) (__typeof (x)) (x), 1)
 
 /* Return nonzero value if X is canonical.  In IEEE interchange binary
    formats, all values are canonical, but the argument must still be
@@ -32,8 +34,5 @@ extern int __iscanonicall (long double __x)
    conversion, before being discarded; in IBM long double, there are
    encodings that are not consistently handled as corresponding to any
    particular value of the type, and we return 0 for those.  */
-# define iscanonical(x)				\
-  (sizeof (x) == sizeof (long double)		\
-   ? __iscanonicall (x)				\
-   : ((void) (__typeof (x)) (x), 1))
+# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x))
 #endif
diff --git a/sysdeps/ieee754/ldbl-96/bits/iscanonical.h b/sysdeps/ieee754/ldbl-96/bits/iscanonical.h
index af0c72cc7f..8638db8903 100644
--- a/sysdeps/ieee754/ldbl-96/bits/iscanonical.h
+++ b/sysdeps/ieee754/ldbl-96/bits/iscanonical.h
@@ -22,6 +22,8 @@
 
 extern int __iscanonicall (long double __x)
      __THROW __attribute__ ((__const__));
+#define __iscanonicalf(x) ((void) (__typeof (x)) (x), 1)
+#define __iscanonical(x) ((void) (__typeof (x)) (x), 1)
 
 /* Return nonzero value if X is canonical.  In IEEE interchange binary
    formats, all values are canonical, but the argument must still be
@@ -29,7 +31,4 @@ extern int __iscanonicall (long double __x)
    conversion, before being discarded; in extended precision, there
    are encodings that are not consistently handled as corresponding to
    any particular value of the type, and we return 0 for those.  */
-#define iscanonical(x)				\
-  (sizeof (x) == sizeof (long double)		\
-   ? __iscanonicall (x)				\
-   : ((void) (__typeof (x)) (x), 1))
+#define iscanonical(x) __MATH_TG ((x), __iscanonical, (x))