Commit 3115f94f by Rainer Orth Committed by Rainer Orth

Don't define libstdc++-internal macros in Solaris 10+ <math.h>

	libstdc++-v3:
	* acinclude.m4 (GLIBCXX_CHECK_MATH11_PROTO): Update comments.
	(__CORRECT_ISO_CPP11_MATH_H_PROTO): Rename to ...
	(__CORRECT_ISO_CPP11_MATH_H_PROTO_FP): ... this.
	Add test for C++11 <math.h> integral overloads.
	* configure: Regenerate.
	* config.h.in: Regenerate.

	* include/c_global/cmath [__cplusplus >= 201103L]: Reflect
	__CORRECT_ISO_CPP11_MATH_H_PROTO to
	__CORRECT_ISO_CPP11_MATH_H_PROTO_FP rename.
	* include/c_global/cmath [_GLIBCXX_USE_C99_MATH &&
	!_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC && __cplusplus >= 201103L]
	(std::fpclassify): Wrap in !__CORRECT_ISO_CPP11_MATH_H_PROTO_INT.
	(std::isfinite): Likewise.
	(std::isinf): Likewise.
	(std::isnan): Likewise.
	(std::isnormal): Likewise.
	(std::signbit): Likewise.
	(std::isgreater): Likewise.
	(std::isgreaterequal): Likewise.
	(std::isless): Likewise.
	(std::islessequal): Likewise.
	(std::islessgreater): Likewise.
	(std::isunordered): Likewise.
	[__cplusplus >= 201103L && _GLIBCXX_USE_C99_MATH_TR1]
	(std::acosh): Likewise.
	(std::asinh): Likewise.
	(std::atanh): Likewise.
	(std::cbrt): Likewise.
	(std::copysign): Likewise.
	(std::erf): Likewise.
	(std::erfc): Likewise.
	(std::exp2): Likewise.
	(std::expm1): Likewise.
	(std::fdim): Likewise.
	(std::fma): Likewise.
	(std::fmax): Likewise.
	(std::fmin): Likewise.
	(std::hypot): Likewise.
	(std::ilogb): Likewise.
	(std::lgamma): Likewise.
	(std::llrint): Likewise.
	(std::llround): Likewise.
	(std::log1p): Likewise.
	(std::log2): Likewise.
	(std::logb): Likewise.
	(std::lrint): Likewise.
	(std::lround): Likewise.
	(std::nearbyint): Likewise.
	(std::nextafter): Likewise.
	(std::nexttoward): Likewise.
	(std::remainder): Likewise.
	(std::remquo): Likewise.
	(std::rint): Likewise.
	(std::round): Likewise.
	(std::scalbln): Likewise.
	(std::scalbn): Likewise.
	(std::tgamma): Likewise.
	(std::trunc): Likewise.
	* include/tr1/cmath [_GLIBCXX_USE_C99_MATH_TR1 && __cplusplus >=
	201103L]: Reflect __CORRECT_ISO_CPP11_MATH_H_PROTO to
	__CORRECT_ISO_CPP11_MATH_H_PROTO_FP rename.

	fixincludes:
	* inclhack.def (solaris_math_12): New fix.
	(hpux11_fabsf): Replace bypass by *-hp-hpux11* mach selector.
	* fixincl.x: Regenerate.
	* tests/base/math.h [SOLARIS_MATH_12_CHECK]: New test.

From-SVN: r242671
parent 6fce0013
2016-11-21 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* inclhack.def (solaris_math_12): New fix.
(hpux11_fabsf): Replace bypass by *-hp-hpux11* mach selector.
* fixincl.x: Regenerate.
* tests/base/math.h [SOLARIS_MATH_12_CHECK]: New test.
2016-11-20 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR sanitizer/78267
......
......@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
* It has been AutoGen-ed November 20, 2016 at 11:44:36 AM by AutoGen 5.16.2
* It has been AutoGen-ed November 20, 2016 at 12:02:46 PM by AutoGen 5.16.2
* From the definitions inclhack.def
* and the template file fixincl
*/
/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Nov 20 11:44:37 MET 2016
/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Nov 20 12:02:47 MET 2016
*
* You must regenerate it. Use the ./genfixes script.
*
......@@ -15,7 +15,7 @@
* certain ANSI-incompatible system header files which are fixed to work
* correctly with ANSI C and placed in a directory that GNU C will search.
*
* This file contains 241 fixup descriptions.
* This file contains 242 fixup descriptions.
*
* See README for more information.
*
......@@ -4507,7 +4507,9 @@ tSCC zHpux11_FabsfList[] =
/*
* Machine/OS name selection pattern
*/
#define apzHpux11_FabsfMachs (const char**)NULL
tSCC* apzHpux11_FabsfMachs[] = {
"*-hp-hpux11*",
(const char*)NULL };
/*
* content selection pattern - do fix if pattern found
......@@ -4515,15 +4517,8 @@ tSCC zHpux11_FabsfList[] =
tSCC zHpux11_FabsfSelect0[] =
"^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
/*
* content bypass pattern - skip fix if pattern found
*/
tSCC zHpux11_FabsfBypass0[] =
"__cplusplus";
#define HPUX11_FABSF_TEST_CT 2
#define HPUX11_FABSF_TEST_CT 1
static tTestDesc aHpux11_FabsfTests[] = {
{ TT_NEGREP, zHpux11_FabsfBypass0, (regex_t*)NULL },
{ TT_EGREP, zHpux11_FabsfSelect0, (regex_t*)NULL }, };
/*
......@@ -7583,6 +7578,42 @@ static const char* apzSolaris_Math_11Patch[] = {
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description of Solaris_Math_12 fix
*/
tSCC zSolaris_Math_12Name[] =
"solaris_math_12";
/*
* File name selection pattern
*/
tSCC zSolaris_Math_12List[] =
"math.h\0";
/*
* Machine/OS name selection pattern
*/
tSCC* apzSolaris_Math_12Machs[] = {
"*-*-solaris2*",
(const char*)NULL };
/*
* content selection pattern - do fix if pattern found
*/
tSCC zSolaris_Math_12Select0[] =
"#undef.*_GLIBCXX_USE_C99_MATH";
#define SOLARIS_MATH_12_TEST_CT 1
static tTestDesc aSolaris_Math_12Tests[] = {
{ TT_EGREP, zSolaris_Math_12Select0, (regex_t*)NULL }, };
/*
* Fix Command Arguments for Solaris_Math_12
*/
static const char* apzSolaris_Math_12Patch[] = { sed_cmd_z,
"-e", "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d",
(char*)NULL };
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Description of Solaris_Once_Init_1 fix
*/
tSCC zSolaris_Once_Init_1Name[] =
......@@ -9879,7 +9910,7 @@ static const char* apzX11_SprintfPatch[] = {
*/
#define REGEX_COUNT 279
#define MACH_LIST_SIZE_LIMIT 187
#define FIX_COUNT 241
#define FIX_COUNT 242
/*
* Enumerate the fixes
......@@ -10068,6 +10099,7 @@ typedef enum {
SOLARIS_MATH_8_FIXIDX,
SOLARIS_MATH_9_FIXIDX,
SOLARIS_MATH_11_FIXIDX,
SOLARIS_MATH_12_FIXIDX,
SOLARIS_ONCE_INIT_1_FIXIDX,
SOLARIS_POSIX_SPAWN_RESTRICT_FIXIDX,
SOLARIS_POW_INT_OVERLOAD_FIXIDX,
......@@ -11044,6 +11076,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
SOLARIS_MATH_11_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aSolaris_Math_11Tests, apzSolaris_Math_11Patch, 0 },
{ zSolaris_Math_12Name, zSolaris_Math_12List,
apzSolaris_Math_12Machs,
SOLARIS_MATH_12_TEST_CT, FD_MACH_ONLY,
aSolaris_Math_12Tests, apzSolaris_Math_12Patch, 0 },
{ zSolaris_Once_Init_1Name, zSolaris_Once_Init_1List,
apzSolaris_Once_Init_1Machs,
SOLARIS_ONCE_INIT_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
......
......@@ -2334,9 +2334,9 @@ fix = {
*/
fix = {
hackname = hpux11_fabsf;
mach = "*-hp-hpux11*";
files = math.h;
select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
bypass = "__cplusplus";
c_fix = format;
c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
......@@ -3868,6 +3868,23 @@ _EOText_;
};
/*
* Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
*/
fix = {
hackname = solaris_math_12;
files = math.h;
mach = '*-*-solaris2*';
select = '#undef.*_GLIBCXX_USE_C99_MATH';
sed = "/#undef[ \t]*_GLIBCXX_USE_C99_MATH/d";
test_text = << _EOText_
#if __cplusplus >= 201103L
#undef _GLIBCXX_USE_C99_MATH
#undef _GLIBCXX_USE_C99_MATH_TR1
#endif
_EOText_;
};
/*
* Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
* structure. As such, it need two levels of brackets, but only
* contains one. Wrap the macro definition in an extra layer.
......
......@@ -85,6 +85,12 @@ extern int class();
#endif /* RS6000_DOUBLE_CHECK */
#if defined( SOLARIS_MATH_12_CHECK )
#if __cplusplus >= 201103L
#endif
#endif /* SOLARIS_MATH_12_CHECK */
#if defined( STRICT_ANSI_NOT_CTD_CHECK )
#if 1 && \
&& defined(mumbling) |& ( !defined(__STRICT_ANSI__)) \
......
2016-11-21 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* acinclude.m4 (GLIBCXX_CHECK_MATH11_PROTO): Update comments.
(__CORRECT_ISO_CPP11_MATH_H_PROTO): Rename to ...
(__CORRECT_ISO_CPP11_MATH_H_PROTO_FP): ... this.
Add test for C++11 <math.h> integral overloads.
* configure: Regenerate.
* config.h.in: Regenerate.
* include/c_global/cmath [__cplusplus >= 201103L]: Reflect
__CORRECT_ISO_CPP11_MATH_H_PROTO to
__CORRECT_ISO_CPP11_MATH_H_PROTO_FP rename.
* include/c_global/cmath [_GLIBCXX_USE_C99_MATH &&
!_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC && __cplusplus >= 201103L]
(std::fpclassify): Wrap in !__CORRECT_ISO_CPP11_MATH_H_PROTO_INT.
(std::isfinite): Likewise.
(std::isinf): Likewise.
(std::isnan): Likewise.
(std::isnormal): Likewise.
(std::signbit): Likewise.
(std::isgreater): Likewise.
(std::isgreaterequal): Likewise.
(std::isless): Likewise.
(std::islessequal): Likewise.
(std::islessgreater): Likewise.
(std::isunordered): Likewise.
[__cplusplus >= 201103L && _GLIBCXX_USE_C99_MATH_TR1]
(std::acosh): Likewise.
(std::asinh): Likewise.
(std::atanh): Likewise.
(std::cbrt): Likewise.
(std::copysign): Likewise.
(std::erf): Likewise.
(std::erfc): Likewise.
(std::exp2): Likewise.
(std::expm1): Likewise.
(std::fdim): Likewise.
(std::fma): Likewise.
(std::fmax): Likewise.
(std::fmin): Likewise.
(std::hypot): Likewise.
(std::ilogb): Likewise.
(std::lgamma): Likewise.
(std::llrint): Likewise.
(std::llround): Likewise.
(std::log1p): Likewise.
(std::log2): Likewise.
(std::logb): Likewise.
(std::lrint): Likewise.
(std::lround): Likewise.
(std::nearbyint): Likewise.
(std::nextafter): Likewise.
(std::nexttoward): Likewise.
(std::remainder): Likewise.
(std::remquo): Likewise.
(std::rint): Likewise.
(std::round): Likewise.
(std::scalbln): Likewise.
(std::scalbn): Likewise.
(std::tgamma): Likewise.
(std::trunc): Likewise.
* include/tr1/cmath [_GLIBCXX_USE_C99_MATH_TR1 && __cplusplus >=
201103L]: Reflect __CORRECT_ISO_CPP11_MATH_H_PROTO to
__CORRECT_ISO_CPP11_MATH_H_PROTO_FP rename.
2016-11-15 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/59406
......
......@@ -2181,7 +2181,8 @@ AC_DEFUN([GLIBCXX_CHECK_STDIO_PROTO], [
])
dnl
dnl Check whether required C++11 overloads are present in <math.h>.
dnl Check whether required C++11 overloads for floating point and integral
dnl types are present in <math.h>.
dnl
AC_DEFUN([GLIBCXX_CHECK_MATH11_PROTO], [
......@@ -2192,10 +2193,10 @@ AC_DEFUN([GLIBCXX_CHECK_MATH11_PROTO], [
case "$host" in
*-*-solaris2.*)
# Solaris 12 introduced the C++11 <math.h> overloads. A backport to
# a Solaris 11.3 SRU is likely, maybe even a Solaris 10 patch.
AC_MSG_CHECKING([for C++11 <math.h> overloads])
AC_CACHE_VAL(glibcxx_cv_math11_overload, [
# Solaris 12 Build 86, Solaris 11.3 SRU 3.6, and Solaris 10 Patch
# 11996[67]-02 introduced the C++11 <math.h> floating point overloads.
AC_MSG_CHECKING([for C++11 <math.h> floating point overloads])
AC_CACHE_VAL(glibcxx_cv_math11_fp_overload, [
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[#include <math.h>
#undef isfinite
......@@ -2204,21 +2205,73 @@ AC_DEFUN([GLIBCXX_CHECK_MATH11_PROTO], [
{ return __builtin_isfinite(__x); }
}
])],
[glibcxx_cv_math11_overload=no],
[glibcxx_cv_math11_overload=yes]
[glibcxx_cv_math11_fp_overload=no],
[glibcxx_cv_math11_fp_overload=yes]
)])
# autoheader cannot handle indented templates.
AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO],
[/* Define if all C++11 overloads are available in <math.h>. */
AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO_FP],
[/* Define if all C++11 floating point overloads are available in <math.h>. */
#if __cplusplus >= 201103L
#undef __CORRECT_ISO_CPP11_MATH_H_PROTO
#undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
#endif])
if test $glibcxx_cv_math11_overload = yes; then
AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO)
if test $glibcxx_cv_math11_fp_overload = yes; then
AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO_FP)
fi
AC_MSG_RESULT([$glibcxx_cv_math11_overload])
AC_MSG_RESULT([$glibcxx_cv_math11_fp_overload])
# Solaris 12 Build 90, Solaris 11.3 SRU 5.6, and Solaris 10 Patch
# 11996[67]-02 introduced the C++11 <math.h> integral type overloads.
AC_MSG_CHECKING([for C++11 <math.h> integral type overloads])
AC_CACHE_VAL(glibcxx_cv_math11_int_overload, [
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[#include <math.h>
namespace std {
template<typename _Tp>
struct __is_integer;
template<>
struct __is_integer<int>
{
enum { __value = 1 };
};
}
namespace __gnu_cxx {
template<bool, typename>
struct __enable_if;
template<typename _Tp>
struct __enable_if<true, _Tp>
{ typedef _Tp __type; };
}
namespace std {
template<typename _Tp>
constexpr typename __gnu_cxx::__enable_if
<__is_integer<_Tp>::__value, double>::__type
log2(_Tp __x)
{ return __builtin_log2(__x); }
}
int
main (void)
{
int i = 1000;
return std::log2(i);
}
])],
[glibcxx_cv_math11_int_overload=no],
[glibcxx_cv_math11_int_overload=yes]
)])
# autoheader cannot handle indented templates.
AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO_INT],
[/* Define if all C++11 integral type overloads are available in <math.h>. */
#if __cplusplus >= 201103L
#undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
#endif])
if test $glibcxx_cv_math11_int_overload = yes; then
AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO_INT)
fi
AC_MSG_RESULT([$glibcxx_cv_math11_int_overload])
;;
*)
# If <math.h> defines the obsolete isinf(double) and isnan(double)
......
......@@ -977,9 +977,14 @@
/* Define to 1 if mutex_timedlock is available. */
#undef _GTHREAD_USE_MUTEX_TIMEDLOCK
/* Define if all C++11 overloads are available in <math.h>. */
/* Define if all C++11 floating point overloads are available in <math.h>. */
#if __cplusplus >= 201103L
#undef __CORRECT_ISO_CPP11_MATH_H_PROTO
#undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
#endif
/* Define if all C++11 integral type overloads are available in <math.h>. */
#if __cplusplus >= 201103L
#undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
#endif
#if defined (HAVE__ACOSF) && ! defined (HAVE_ACOSF)
......
......@@ -18236,11 +18236,11 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
case "$host" in
*-*-solaris2.*)
# Solaris 12 introduced the C++11 <math.h> overloads. A backport to
# a Solaris 11.3 SRU is likely, maybe even a Solaris 10 patch.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++11 <math.h> overloads" >&5
$as_echo_n "checking for C++11 <math.h> overloads... " >&6; }
if test "${glibcxx_cv_math11_overload+set}" = set; then :
# Solaris 12 Build 86, Solaris 11.3 SRU 3.6, and Solaris 10 Patch
# 11996[67]-02 introduced the C++11 <math.h> floating point overloads.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++11 <math.h> floating point overloads" >&5
$as_echo_n "checking for C++11 <math.h> floating point overloads... " >&6; }
if test "${glibcxx_cv_math11_fp_overload+set}" = set; then :
$as_echo_n "(cached) " >&6
else
......@@ -18255,9 +18255,9 @@ else
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
glibcxx_cv_math11_overload=no
glibcxx_cv_math11_fp_overload=no
else
glibcxx_cv_math11_overload=yes
glibcxx_cv_math11_fp_overload=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
......@@ -18267,12 +18267,74 @@ fi
# autoheader cannot handle indented templates.
if test $glibcxx_cv_math11_overload = yes; then
$as_echo "#define __CORRECT_ISO_CPP11_MATH_H_PROTO 1" >>confdefs.h
if test $glibcxx_cv_math11_fp_overload = yes; then
$as_echo "#define __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_math11_overload" >&5
$as_echo "$glibcxx_cv_math11_overload" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_math11_fp_overload" >&5
$as_echo "$glibcxx_cv_math11_fp_overload" >&6; }
# Solaris 12 Build 90, Solaris 11.3 SRU 5.6, and Solaris 10 Patch
# 11996[67]-02 introduced the C++11 <math.h> integral type overloads.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++11 <math.h> integral type overloads" >&5
$as_echo_n "checking for C++11 <math.h> integral type overloads... " >&6; }
if test "${glibcxx_cv_math11_int_overload+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <math.h>
namespace std {
template<typename _Tp>
struct __is_integer;
template<>
struct __is_integer<int>
{
enum { __value = 1 };
};
}
namespace __gnu_cxx {
template<bool, typename>
struct __enable_if;
template<typename _Tp>
struct __enable_if<true, _Tp>
{ typedef _Tp __type; };
}
namespace std {
template<typename _Tp>
constexpr typename __gnu_cxx::__enable_if
<__is_integer<_Tp>::__value, double>::__type
log2(_Tp __x)
{ return __builtin_log2(__x); }
}
int
main (void)
{
int i = 1000;
return std::log2(i);
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
glibcxx_cv_math11_int_overload=no
else
glibcxx_cv_math11_int_overload=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
# autoheader cannot handle indented templates.
if test $glibcxx_cv_math11_int_overload = yes; then
$as_echo "#define __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_math11_int_overload" >&5
$as_echo "$glibcxx_cv_math11_int_overload" >&6; }
;;
*)
# If <math.h> defines the obsolete isinf(double) and isnan(double)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment