Fix math.h, tgmath.h XSI POSIX namespace (gamma, isnan, scalb) (bug 18967).
authorJoseph Myers <joseph@codesourcery.com>
Tue, 15 Sep 2015 22:12:40 +0000 (22:12 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 15 Sep 2015 22:12:40 +0000 (22:12 +0000)
math.h incorrectly declares various functions for XSI POSIX 2001 and
2008 editions.  gamma was removed in the 2001 edition but is still
declared, along with gammaf and gammal which were never standard
functions.  isnan is still declared as a function, along with isnanf
and isnanl which were never standard functions, although in 2001 the
function was replaced by the type-generic macro.  scalbf and scalbl
are declared although never standard, and scalb was removed in the
2008 edition but is still declared.  The scalb type-generic macro in
tgmath.h shouldn't be present for any POSIX version, since POSIX never
had such a type-generic macro.

This patch disables all those declarations in the relevant cases (as a
minimal fix, it leaves them enabled for __USE_MISC).  For the matter
of declaring scalb but not scalbf or scalbl for the 2001 edition, a
new macro __MATH_DECLARING_DOUBLE is added, defined by math.h around
includes of bits/mathcalls.h, for bits/mathcalls.h to use to test
which type's functions are being declared.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

[BZ #18967]
* math/math.h (__MATH_DECLARING_DOUBLE): New macro.  Define and
undefine around includes of <bits/mathcalls.h>.
* math/bits/mathcalls.h [!__USE_MISC && __USE_XOPEN2K] (isnan): Do
not declare function.
[!__USE_MISC && __USE_XOPEN2K] (gamma): Likewise.
[!__USE_MISC && (!__MATH_DECLARING_DOUBLE || __USE_XOPEN2K8)]
(scalb): Likewise.
* math/tgmath.h [!__USE_MISC && __USE_XOPEN_EXTENDED] (scalb): Do
not define macro.
* conform/Makefile (test-xfail-XOPEN2K/math.h/conform): Remove
variable.
(test-xfail-XOPEN2K/tgmath.h/conform): Likewise.
(test-xfail-XOPEN2K8/math.h/conform): Likewise.
(test-xfail-XOPEN2K8/tgmath.h/conform): Likewise.

ChangeLog
NEWS
conform/Makefile
math/bits/mathcalls.h
math/math.h
math/tgmath.h

index 5053bf3..c3dafcf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2015-09-15  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #18967]
+       * math/math.h (__MATH_DECLARING_DOUBLE): New macro.  Define and
+       undefine around includes of <bits/mathcalls.h>.
+       * math/bits/mathcalls.h [!__USE_MISC && __USE_XOPEN2K] (isnan): Do
+       not declare function.
+       [!__USE_MISC && __USE_XOPEN2K] (gamma): Likewise.
+       [!__USE_MISC && (!__MATH_DECLARING_DOUBLE || __USE_XOPEN2K8)]
+       (scalb): Likewise.
+       * math/tgmath.h [!__USE_MISC && __USE_XOPEN_EXTENDED] (scalb): Do
+       not define macro.
+       * conform/Makefile (test-xfail-XOPEN2K/math.h/conform): Remove
+       variable.
+       (test-xfail-XOPEN2K/tgmath.h/conform): Likewise.
+       (test-xfail-XOPEN2K8/math.h/conform): Likewise.
+       (test-xfail-XOPEN2K8/tgmath.h/conform): Likewise.
+
        [BZ #18857]
        * sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c (__nearbyintl): Just
        return non-finite argument without doing ordered comparisons on
diff --git a/NEWS b/NEWS
index 5db57a2..702b118 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,7 +14,7 @@ Version 2.23
   18240, 18265, 18370, 18421, 18480, 18525, 18595, 18610, 18618, 18647,
   18661, 18674, 18675, 18681, 18757, 18778, 18781, 18787, 18789, 18790,
   18795, 18796, 18820, 18823, 18824, 18857, 18863, 18870, 18873, 18875,
-  18887, 18921, 18952, 18961, 18966.
+  18887, 18921, 18952, 18961, 18966, 18967.
 
 * The obsolete header <regexp.h> has been removed.  Programs that require
   this header must be updated to use <regex.h> instead.
index 7d0a3dd..1a76369 100644 (file)
@@ -217,7 +217,6 @@ test-xfail-UNIX98/utmpx.h/conform = yes
 test-xfail-XOPEN2K/aio.h/conform = yes
 test-xfail-XOPEN2K/fcntl.h/conform = yes
 test-xfail-XOPEN2K/langinfo.h/conform = yes
-test-xfail-XOPEN2K/math.h/conform = yes
 test-xfail-XOPEN2K/mqueue.h/conform = yes
 test-xfail-XOPEN2K/semaphore.h/conform = yes
 test-xfail-XOPEN2K/signal.h/conform = yes
@@ -225,7 +224,6 @@ test-xfail-XOPEN2K/stdarg.h/conform = yes
 test-xfail-XOPEN2K/stdio.h/conform = yes
 test-xfail-XOPEN2K/sys/wait.h/conform = yes
 test-xfail-XOPEN2K/termios.h/conform = yes
-test-xfail-XOPEN2K/tgmath.h/conform = yes
 test-xfail-XOPEN2K/ucontext.h/conform = yes
 test-xfail-POSIX2008/arpa/inet.h/conform = yes
 test-xfail-POSIX2008/netdb.h/conform = yes
@@ -234,12 +232,10 @@ test-xfail-POSIX2008/signal.h/conform = yes
 test-xfail-POSIX2008/sys/socket.h/conform = yes
 test-xfail-POSIX2008/sys/wait.h/conform = yes
 test-xfail-XOPEN2K8/limits.h/conform = yes
-test-xfail-XOPEN2K8/math.h/conform = yes
 test-xfail-XOPEN2K8/signal.h/conform = yes
 test-xfail-XOPEN2K8/stdio.h/conform = yes
 test-xfail-XOPEN2K8/sys/wait.h/conform = yes
 test-xfail-XOPEN2K8/termios.h/conform = yes
-test-xfail-XOPEN2K8/tgmath.h/conform = yes
 
 conformtest-cc-flags = -I../include $(+sysdep-includes) $(sysincludes) -I..
 $(conformtest-header-tests): $(objpfx)%/conform.out: \
index a881b7d..7ffe040 100644 (file)
@@ -229,10 +229,12 @@ __END_NAMESPACE_C99
 /* Return nonzero if VALUE is not a number.  */
 __MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
 
-#if defined __USE_MISC || defined __USE_XOPEN
+#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
 /* Return nonzero if VALUE is not a number.  */
 __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
+#endif
 
+#if defined __USE_MISC || defined __USE_XOPEN
 /* Bessel functions.  */
 __MATHCALL (j0,, (_Mdouble_));
 __MATHCALL (j1,, (_Mdouble_));
@@ -259,7 +261,7 @@ __MATHCALL (tgamma,, (_Mdouble_));
 __END_NAMESPACE_C99
 #endif
 
-#if defined __USE_MISC || defined __USE_XOPEN
+#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
 /* Obsolete alias for `lgamma'.  */
 __MATHCALL (gamma,, (_Mdouble_));
 #endif
@@ -366,7 +368,9 @@ __MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value))
      __attribute__ ((__const__));
 #endif
 
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
+#if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
+                          && __MATH_DECLARING_DOUBLE   \
+                          && !defined __USE_XOPEN2K8)
 /* Return X times (2 to the Nth power).  */
 __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
 #endif
index c5115d7..63511a6 100644 (file)
@@ -77,6 +77,7 @@ __BEGIN_DECLS
 
 #define _Mdouble_              double
 #define __MATH_PRECNAME(name,r)        __CONCAT(name,r)
+#define __MATH_DECLARING_DOUBLE  1
 #define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
 #define _Mdouble_END_NAMESPACE   __END_NAMESPACE_STD
 #include <bits/mathcalls.h>
@@ -84,6 +85,7 @@ __BEGIN_DECLS
 #undef _Mdouble_BEGIN_NAMESPACE
 #undef _Mdouble_END_NAMESPACE
 #undef __MATH_PRECNAME
+#undef __MATH_DECLARING_DOUBLE
 
 #ifdef __USE_ISOC99
 
@@ -96,6 +98,7 @@ __BEGIN_DECLS
 # endif
 # define _Mdouble_             _Mfloat_
 # define __MATH_PRECNAME(name,r) name##f##r
+# define __MATH_DECLARING_DOUBLE  0
 # define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
 # define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
 # include <bits/mathcalls.h>
@@ -103,6 +106,7 @@ __BEGIN_DECLS
 # undef _Mdouble_BEGIN_NAMESPACE
 # undef _Mdouble_END_NAMESPACE
 # undef        __MATH_PRECNAME
+# undef __MATH_DECLARING_DOUBLE
 
 # if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
      || defined __LDBL_COMPAT \
@@ -140,6 +144,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  endif
 #  define _Mdouble_            _Mlong_double_
 #  define __MATH_PRECNAME(name,r) name##l##r
+#  define __MATH_DECLARING_DOUBLE  0
 #  define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
 #  define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
 #  define __MATH_DECLARE_LDOUBLE   1
@@ -148,6 +153,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
 #  undef _Mdouble_BEGIN_NAMESPACE
 #  undef _Mdouble_END_NAMESPACE
 #  undef __MATH_PRECNAME
+#  undef __MATH_DECLARING_DOUBLE
 
 # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
 
index 3e1fb02..610a421 100644 (file)
 #define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder)
 
 /* Return X times (2 to the Nth power).  */
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
+#ifdef __USE_MISC
 # define scalb(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, scalb)
 #endif