]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Move LDBL_CLASSIFY_COMPAT to its own header.
authorJoseph Myers <joseph@codesourcery.com>
Thu, 1 Feb 2018 21:01:00 +0000 (21:01 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 1 Feb 2018 21:01:00 +0000 (21:01 +0000)
The general rule in glibc is that it's better for a macro to be always
defined, and tested with #if, than for it to be tested with #ifdef,
because the latter is prone to typos in the macro name as well as to
the header with the macro accidentally not being included in a file
testing it.  (Testing with an "if" statement is even better, in those
cases where it's possible to do things that way, as it then means both
cases in the code get checked for syntax in glibc builds with either
value of the condition.)

math_private.h has several different groups of macros, meaning that
architectures wanting to override some of them need to define those
then include the generic version, which then defines macros if not
already defined.  It's hard to avoid that arrangement completely, but
various cases can be improved by splitting out macros or groups of
macros into separate files.

This patch splits out the LDBL_CLASSIFY_COMPAT macro into a separate
ldbl-classify-compat.h header.  This macro is tested with #ifdef; this
patch changes it to testing with #if, with a default definition to 0
in the generic header and then architecture-specific headers defining
it to 1.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by the patch.

* sysdeps/generic/ldbl-classify-compat.h: New file.
* sysdeps/arm/ldbl-classify-compat.h: Likewise.
* sysdeps/m68k/coldfire/ldbl-classify-compat.h: Likewise.
* sysdeps/microblaze/ldbl-classify-compat.h: Likewise.
* sysdeps/mips/ldbl-classify-compat.h: Likewise.
* sysdeps/nios2/ldbl-classify-compat.h: Likewise.
* sysdeps/sh/ldbl-classify-compat.h: Likewise.
* sysdeps/ieee754/dbl-64/s_finite.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/s_isinf.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/s_isnan.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/arm/math_private.h (LDBL_CLASSIFY_COMPAT): Remove macro.
* sysdeps/mips/math_private.h (LDBL_CLASSIFY_COMPAT): Likewise.
* sysdeps/m68k/coldfire/math_private.h: Remove file.
* sysdeps/microblaze/math_private.h: Likewise.
* sysdeps/nios2/math_private.h: Likewise.
* sysdeps/sh/math_private.h: Likewise.

16 files changed:
ChangeLog
sysdeps/arm/ldbl-classify-compat.h [moved from sysdeps/sh/math_private.h with 64% similarity]
sysdeps/arm/math_private.h
sysdeps/generic/ldbl-classify-compat.h [new file with mode: 0644]
sysdeps/ieee754/dbl-64/s_finite.c
sysdeps/ieee754/dbl-64/s_isinf.c
sysdeps/ieee754/dbl-64/s_isnan.c
sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c
sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c
sysdeps/m68k/coldfire/ldbl-classify-compat.h [moved from sysdeps/nios2/math_private.h with 63% similarity]
sysdeps/microblaze/ldbl-classify-compat.h [moved from sysdeps/m68k/coldfire/math_private.h with 61% similarity]
sysdeps/mips/ldbl-classify-compat.h [moved from sysdeps/microblaze/math_private.h with 60% similarity]
sysdeps/mips/math_private.h
sysdeps/nios2/ldbl-classify-compat.h [new file with mode: 0644]
sysdeps/sh/ldbl-classify-compat.h [new file with mode: 0644]

index 735090ef57f5f633515bd741fddd8622100132a2..1453e9cc9d0d2ee9303fbfa3cc20cec5260c627a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,37 @@
 2018-02-01  Joseph Myers  <joseph@codesourcery.com>
 
+       * sysdeps/generic/ldbl-classify-compat.h: New file.
+       * sysdeps/arm/ldbl-classify-compat.h: Likewise.
+       * sysdeps/m68k/coldfire/ldbl-classify-compat.h: Likewise.
+       * sysdeps/microblaze/ldbl-classify-compat.h: Likewise.
+       * sysdeps/mips/ldbl-classify-compat.h: Likewise.
+       * sysdeps/nios2/ldbl-classify-compat.h: Likewise.
+       * sysdeps/sh/ldbl-classify-compat.h: Likewise.
+       * sysdeps/ieee754/dbl-64/s_finite.c: Include
+       <ldbl-classify-compat.h>.
+       [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
+       * sysdeps/ieee754/dbl-64/s_isinf.c: Include
+       <ldbl-classify-compat.h>.
+       [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
+       * sysdeps/ieee754/dbl-64/s_isnan.c: Include
+       <ldbl-classify-compat.h>.
+       [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
+       * sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c: Include
+       <ldbl-classify-compat.h>.
+       [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
+       * sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c: Include
+       <ldbl-classify-compat.h>.
+       [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
+       * sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c: Include
+       <ldbl-classify-compat.h>.
+       [LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
+       * sysdeps/arm/math_private.h (LDBL_CLASSIFY_COMPAT): Remove macro.
+       * sysdeps/mips/math_private.h (LDBL_CLASSIFY_COMPAT): Likewise.
+       * sysdeps/m68k/coldfire/math_private.h: Remove file.
+       * sysdeps/microblaze/math_private.h: Likewise.
+       * sysdeps/nios2/math_private.h: Likewise.
+       * sysdeps/sh/math_private.h: Likewise.
+
        * sysdeps/m68k/coldfire/fpu/math_private.h: Move to ....
        * sysdeps/m68k/coldfire/math_private.h: ... here.
        * sysdeps/m68k/coldfire/nofpu/math_private.h: Remove file.
similarity index 64%
rename from sysdeps/sh/math_private.h
rename to sysdeps/arm/ldbl-classify-compat.h
index d13f2d49d3eee99c9da8bdf6d6add4ebfaef6179..f3f10607cadf07e4d7cfc6d7bdcfbd9abbf8d052 100644 (file)
@@ -1,10 +1,8 @@
-#ifndef SH_MATH_PRIVATE_H
-#define SH_MATH_PRIVATE_H 1
+#ifndef ARM_LDBL_CLASSIFY_COMPAT_H
+#define ARM_LDBL_CLASSIFY_COMPAT_H 1
 
 /* Enable __finitel, __isinfl, and __isnanl for binary compatibility
    when built without long double support. */
 #define LDBL_CLASSIFY_COMPAT 1
 
-#include_next <math_private.h>
-
 #endif
index d39e9ee24a162833ab24c6152c922e180df01c4b..c175b15601f88f712620839250b79bd1fbd6c877 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef ARM_MATH_PRIVATE_H
 #define ARM_MATH_PRIVATE_H 1
 
-/* Enable __finitel, __isinfl, and __isnanl for binary compatibility
-   when built without long double support. */
-#define LDBL_CLASSIFY_COMPAT 1
-
 #include "fenv_private.h"
 #include_next <math_private.h>
 
diff --git a/sysdeps/generic/ldbl-classify-compat.h b/sysdeps/generic/ldbl-classify-compat.h
new file mode 100644 (file)
index 0000000..d77ca18
--- /dev/null
@@ -0,0 +1,33 @@
+/* Specify whether there should be compat symbol aliases for some
+   classification functions.  Generic version.
+   Copyright (C) 2015-2018 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/>.  */
+
+#ifndef _LDBL_CLASSIFY_COMPAT_H
+#define _LDBL_CLASSIFY_COMPAT_H        1
+
+/* If defined to 1, enable __finitel, __isinfl, and __isnanl function
+   aliases for binary compatibility when built without long double
+   support.  If defined to 0, or if long double does not have the same
+   format as double, there are no such aliases.  New ports should use
+   the default definition of this as 0, as such
+   implementation-namespace functions should only have one exported
+   name per floating-point format, not one per floating-point
+   type.  */
+#define LDBL_CLASSIFY_COMPAT 0
+
+#endif /* ldbl-classify-compat.h */
index eed80c64493d84bb2fc0eaad829f7e9de92986dc..da1519b1d066b89a27250657be8d612aaeecfbed 100644 (file)
@@ -21,6 +21,7 @@ static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
 
 #include <math.h>
 #include <math_private.h>
+#include <ldbl-classify-compat.h>
 #include <shlib-compat.h>
 
 #undef __finite
@@ -38,7 +39,7 @@ int FINITE(double x)
 hidden_def (__finite)
 weak_alias (__finite, finite)
 #ifdef NO_LONG_DOUBLE
-# ifdef LDBL_CLASSIFY_COMPAT
+# if LDBL_CLASSIFY_COMPAT
 #  if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
 compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
 #  endif
index c0ad54538a1697174686b58e81a604b4fa419354..93eb65c1479c2e8caf27576e07889492c59ab226 100644 (file)
@@ -15,6 +15,7 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
 
 #include <math.h>
 #include <math_private.h>
+#include <ldbl-classify-compat.h>
 #include <shlib-compat.h>
 
 int
@@ -29,7 +30,7 @@ __isinf (double x)
 hidden_def (__isinf)
 weak_alias (__isinf, isinf)
 #ifdef NO_LONG_DOUBLE
-# if defined LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+# if LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
 compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
 # endif
 weak_alias (__isinf, isinfl)
index 642ec3a494ec06c001d3b0ace0700034cb7efb2e..82723eeb8a7a1fb6565498af7d2812021386902a 100644 (file)
@@ -21,6 +21,7 @@ static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
 
 #include <math.h>
 #include <math_private.h>
+#include <ldbl-classify-compat.h>
 #include <shlib-compat.h>
 
 #undef __isnan
@@ -37,7 +38,7 @@ __isnan (double x)
 hidden_def (__isnan)
 weak_alias (__isnan, isnan)
 #ifdef NO_LONG_DOUBLE
-# if defined LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+# if LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
 compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
 # endif
 weak_alias (__isnan, isnanl)
index ef51608f6eeb792a55e25c0c16a9458a36ceb9aa..40676924fe4dc6052b43dfa6d4aeada56fcc09d8 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <math.h>
 #include <math_private.h>
+#include <ldbl-classify-compat.h>
 #include <shlib-compat.h>
 #include <stdint.h>
 
@@ -30,7 +31,7 @@ __finite(double x)
 hidden_def (__finite)
 weak_alias (__finite, finite)
 #ifdef NO_LONG_DOUBLE
-# ifdef LDBL_CLASSIFY_COMPAT
+# if LDBL_CLASSIFY_COMPAT
 #  if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
 compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
 #  endif
index 951fb732391fb3a9abb95970f33ce04569801682..2b427a8b4cc7fcdbbcaaff2bd2d1dc8ab8eedff5 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <math.h>
 #include <math_private.h>
+#include <ldbl-classify-compat.h>
 #include <shlib-compat.h>
 
 int
@@ -26,7 +27,7 @@ __isinf (double x)
 hidden_def (__isinf)
 weak_alias (__isinf, isinf)
 #ifdef NO_LONG_DOUBLE
-# if defined LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+# if LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
 compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
 # endif
 weak_alias (__isinf, isinfl)
index bcff9e3b67e34544522642f8018c4c7759a5bee5..cd805d157ba65cf1c38758c5bd0a55b2b559fb6c 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <math.h>
 #include <math_private.h>
+#include <ldbl-classify-compat.h>
 #include <shlib-compat.h>
 #include <stdint.h>
 
@@ -32,7 +33,7 @@ int __isnan(double x)
 hidden_def (__isnan)
 weak_alias (__isnan, isnan)
 #ifdef NO_LONG_DOUBLE
-# if defined LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+# if LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
 compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
 # endif
 weak_alias (__isnan, isnanl)
similarity index 63%
rename from sysdeps/nios2/math_private.h
rename to sysdeps/m68k/coldfire/ldbl-classify-compat.h
index bc7f9c8e90333e0b022a1f4d57c4fdbd3ddb601e..c1ec4d4ffa0b0cfa7b9366a47e20ee2defa8af2b 100644 (file)
@@ -1,10 +1,8 @@
-#ifndef NIO2_MATH_PRIVATE_H
-#define NIO2_MATH_PRIVATE_H 1
+#ifndef COLDFIRE_LDBL_CLASSIFY_COMPAT_H
+#define COLDFIRE_LDBL_CLASSIFY_COMPAT_H 1
 
 /* Enable __finitel, __isinfl, and __isnanl for binary compatibility
    when built without long double support. */
 #define LDBL_CLASSIFY_COMPAT 1
 
-#include_next <math_private.h>
-
 #endif
similarity index 61%
rename from sysdeps/m68k/coldfire/math_private.h
rename to sysdeps/microblaze/ldbl-classify-compat.h
index d306a508b4d169009483bf58c1fd3c56cb56e3e4..38c5c99949baa75b7a45b2f6df02dce18ea3a404 100644 (file)
@@ -1,10 +1,8 @@
-#ifndef COLDFIRE_MATH_PRIVATE_H
-#define COLDFIRE_MATH_PRIVATE_H 1
+#ifndef MICROBLAZE_LDBL_CLASSIFY_COMPAT_H
+#define MICROBLAZE_LDBL_CLASSIFY_COMPAT_H 1
 
 /* Enable __finitel, __isinfl, and __isnanl for binary compatibility
    when built without long double support. */
 #define LDBL_CLASSIFY_COMPAT 1
 
-#include_next <math_private.h>
-
 #endif
similarity index 60%
rename from sysdeps/microblaze/math_private.h
rename to sysdeps/mips/ldbl-classify-compat.h
index 64dc18133fa664ad8b998c61d7173a93feae3230..547ac7b53a187817bffe3e0e88f014d9304fe722 100644 (file)
@@ -1,10 +1,8 @@
-#ifndef MICROBLAZE_MATH_PRIVATE_H
-#define MICROBLAZE_MATH_PRIVATE_H 1
+#ifndef MIPS_LDBL_CLASSIFY_COMPAT_H
+#define MIPS_LDBL_CLASSIFY_COMPAT_H 1
 
 /* Enable __finitel, __isinfl, and __isnanl for binary compatibility
    when built without long double support. */
 #define LDBL_CLASSIFY_COMPAT 1
 
-#include_next <math_private.h>
-
 #endif
index a3c25138c7a866724afc3e05379b71dd1194eb80..01ae8b18fd7356c862ff6310cd447feea395df45 100644 (file)
@@ -240,10 +240,6 @@ libc_feholdsetround_mips_ctx (struct rm_ctx *ctx, int round)
 
 #endif
 
-/* Enable __finitel, __isinfl, and __isnanl for binary compatibility
-   when built without long double support. */
-#define LDBL_CLASSIFY_COMPAT 1
-
 #include_next <math_private.h>
 
 #endif
diff --git a/sysdeps/nios2/ldbl-classify-compat.h b/sysdeps/nios2/ldbl-classify-compat.h
new file mode 100644 (file)
index 0000000..a9614de
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef NIOS2_LDBL_CLASSIFY_COMPAT_H
+#define NIOS2_LDBL_CLASSIFY_COMPAT_H 1
+
+/* Enable __finitel, __isinfl, and __isnanl for binary compatibility
+   when built without long double support. */
+#define LDBL_CLASSIFY_COMPAT 1
+
+#endif
diff --git a/sysdeps/sh/ldbl-classify-compat.h b/sysdeps/sh/ldbl-classify-compat.h
new file mode 100644 (file)
index 0000000..d3b978c
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef SH_LDBL_CLASSIFY_COMPAT_H
+#define SH_LDBL_CLASSIFY_COMPAT_H 1
+
+/* Enable __finitel, __isinfl, and __isnanl for binary compatibility
+   when built without long double support. */
+#define LDBL_CLASSIFY_COMPAT 1
+
+#endif