public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [v3] Handle different versions of Solaris 8 <iso/math_iso.h>, <iso/stdlib_iso.h>
@ 2011-08-26 13:04 Rainer Orth
  2011-08-26 13:22 ` Paolo Carlini
  0 siblings, 1 reply; 16+ messages in thread
From: Rainer Orth @ 2011-08-26 13:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++

[-- Attachment #1: Type: text/plain, Size: 2160 bytes --]

All my testing of the __cplusplus 199711L patches had been on Solaris
8+/x86.  During last weekend's bootstrap on the whole range of systems
(Solaris 8 to 11, SPARC and x86), it turned out that there are possible
variations of <iso/math_iso.h> and <iso/stdlib_iso.h> between Solaris 8
FCS and patches, so we cannot statically configure which overloads are
present, but need autoconf checks for that.

The situation is as follows:

* Solaris 8 FCS shipped rev. 1.1 of <iso/math_iso.h> which only had
  double std::abs(double).  Later, in patches 111721-04 (SPARC) and
  112757-01 (x86), rev. 1.3 whas shipped that has everything that's also
  present in Solaris 9 and up.

* Similarly, Solaris 8 FCS has rev. 1.1 of <iso/stdlib_iso.h> without
  any overloads.  Patches 109607-02 (SPARC) and 109608-02 (x86) added
  long std::abs(long) and ldiv_t div(lng, long) in rev. 1.3.

Since <bits/os_defines.h> is included before configure results,
configure needs to define the affected
__CORRECT_ISO_CPP_MATH_H_PROTO[12] and __CORRECT_ISO_CPP_STDLIB_H_PROTO
directly.  The following patch does just that.

Bootstrapped without regressions on x86_64-unknown-linux-gnu and
i386-pc-solaris2.11, bootstraps on i386-pc-solaris2.8 (with the old
rev. 1.1 headers) and sparc-sun-solaris2.8 (with the the rev. 1.3
headers) are still in progress, but I've verified that the
__CORRECT_ISO_CPP_* macros are all defined correctly..  Since errors in
previous versions of the patch manifested themselves in build failures
immediately, I'm pretty certain that there are no errors.

Ok for mainline if bootstraps pass?

Thanks.
        Rainer


2011-08-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* acinclude.m4 (GLIBCXX_CHECK_MATH_PROTO)
	(GLIBCXX_CHECK_STDLIB_PROTO): New tests.
	* configure.ac (GLIBCXX_CHECK_MATH_PROTO)
	(GLIBCXX_CHECK_STDLIB_PROTO): Call them.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* config/os/solaris/solaris2.8/os_defines.h
	(__CORRECT_ISO_CPP_MATH_H_PROTO2): Don't define.
	* config/os/solaris/solaris2.9: Remove.
	* configure.host (solaris2.8): Merge with ...
	(solaris2.9, solaris2.1[0-9]): ... this.
	Always use os/solaris/solaris2.8.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol8-v3-math_iso.patch --]
[-- Type: text/x-patch, Size: 5180 bytes --]

# HG changeset patch
# Parent b3524f20d0077532a567b222d37ef05976af2743
Handle different versions of Solaris 8 <iso/math_iso.h>

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1693,6 +1693,100 @@ AC_DEFUN([GLIBCXX_COMPUTE_STDIO_INTEGER_
 ])
 
 dnl
+dnl Check whether required C++ overloads are present in <math.h>.
+dnl
+
+AC_DEFUN([GLIBCXX_CHECK_MATH_PROTO], [
+
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+
+  case "$host" in
+    *-*-solaris2.*)
+      # Solaris 8 FCS only had an overload for double std::abs(double) in
+      # <iso/math_iso.h>.  Patches 111721-04 (SPARC) and 112757-01 (x86)
+      # introduced the full set also found from Solaris 9 onwards.
+      AC_MSG_CHECKING([for float std::abs(float) overload])
+      AC_CACHE_VAL(glibcxx_cv_abs_float, [
+	AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+	  [#include <math.h>
+	   namespace std {
+	     inline float abs(float __x)
+	     {  return __builtin_fabsf(__x); }
+	   }
+	])],
+        [glibcxx_cv_abs_float=no],
+        [glibcxx_cv_abs_float=yes]
+      )])
+
+      # autoheader cannot handle indented templates.
+      AH_VERBATIM([__CORRECT_ISO_CPP_MATH_H_PROTO1],
+        [/* Define if all C++ overloads are available in <math.h>.  */
+#if __cplusplus >= 199711L
+#undef __CORRECT_ISO_CPP_MATH_H_PROTO1
+#endif])
+      AH_VERBATIM([__CORRECT_ISO_CPP_MATH_H_PROTO2],
+        [/* Define if only double std::abs(double) is available in <math.h>.  */
+#if __cplusplus >= 199711L
+#undef __CORRECT_ISO_CPP_MATH_H_PROTO2
+#endif])
+
+      if test $glibcxx_cv_abs_float = yes; then
+        AC_DEFINE(__CORRECT_ISO_CPP_MATH_H_PROTO1)
+      else
+        AC_DEFINE(__CORRECT_ISO_CPP_MATH_H_PROTO2)
+      fi
+      AC_MSG_RESULT($glibcxx_cv_abs_float)
+      ;;
+  esac
+
+  AC_LANG_RESTORE
+])
+
+dnl
+dnl Check whether required C++ overloads are present in <stdlib.h>.
+dnl
+
+AC_DEFUN([GLIBCXX_CHECK_STDLIB_PROTO], [
+
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+
+  case "$host" in
+    *-*-solaris2.*)
+      # Solaris 8 FCS lacked the overloads for long std::abs(long) and
+      # ldiv_t std::div(long, long) in <iso/stdlib_iso.h>.  Patches 109607-02
+      # (SPARC) and 109608-02 (x86) introduced them.
+      AC_MSG_CHECKING([for long std::abs(long) overload])
+      AC_CACHE_VAL(glibcxx_cv_abs_long, [
+	AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+	  [#include <stdlib.h>
+	   namespace std {
+	     inline long
+	     abs(long __i) { return labs(__i); }
+	   }
+        ])],
+        [glibcxx_cv_abs_long=no],
+        [glibcxx_cv_abs_long=yes]
+      )])
+
+      # autoheader cannot handle indented templates.
+      AH_VERBATIM([__CORRECT_ISO_CPP_STDLIB_H_PROTO],
+        [/* Define if all C++ overloads are available in <stdlib.h>.  */
+#if __cplusplus >= 199711L
+#undef __CORRECT_ISO_CPP_STDLIB_H_PROTO
+#endif])
+      if test $glibcxx_cv_abs_long = yes; then
+        AC_DEFINE(__CORRECT_ISO_CPP_STDLIB_H_PROTO, 1)
+      fi
+      AC_MSG_RESULT($glibcxx_cv_abs_long)
+      ;;
+  esac
+
+  AC_LANG_RESTORE
+])
+
+dnl
 dnl Check whether macros, etc are present for <system_error>
 dnl
 AC_DEFUN([GLIBCXX_CHECK_SYSTEM_ERROR], [
diff --git a/libstdc++-v3/config/os/solaris/solaris2.8/os_defines.h b/libstdc++-v3/config/os/solaris/solaris2.8/os_defines.h
--- a/libstdc++-v3/config/os/solaris/solaris2.8/os_defines.h
+++ b/libstdc++-v3/config/os/solaris/solaris2.8/os_defines.h
@@ -1,4 +1,4 @@
-// Specific definitions for Solaris 8  -*- C++ -*-
+// Specific definitions for Solaris 8+  -*- C++ -*-
 
 // Copyright (C) 2000, 2002, 2005, 2009, 2011 Free Software Foundation, Inc.
 //
@@ -28,9 +28,12 @@
 // System-specific #define, typedefs, corrections, etc, go here.  This
 // file will come before all others.
 
-// FIXME: Autoconf if possible.
 #if __cplusplus >= 199711L
-#define __CORRECT_ISO_CPP_MATH_H_PROTO2
+// Overloads in <iso/math_iso.h> and <iso/stdlib_iso.h> changed with
+// Solaris 8 patches.  Since <bits/c++config.h> includes
+// <bits/os_defines.h> before configure results,
+// __CORRECT_ISO_CPP_MATH_H_PROTO[12] and __CORRECT_ISO_CPP_STDLIB_H_PROTO
+// must be defined via acinclude.m4.
 #define __CORRECT_ISO_CPP_STRING_H_PROTO
 #define __CORRECT_ISO_CPP_WCHAR_H_PROTO
 #endif
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -135,6 +135,8 @@ GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING([no]
 GLIBCXX_ENABLE_EXTERN_TEMPLATE([yes])
 
 # Checks for operating systems support that doesn't require linking.
+GLIBCXX_CHECK_MATH_PROTO
+GLIBCXX_CHECK_STDLIB_PROTO
 GLIBCXX_CHECK_SYSTEM_ERROR
 
 # For the streamoff typedef.
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -288,12 +288,9 @@ case "${host_os}" in
     echo "Please specify the full version of Solaris, ie. solaris2.9 " 1>&2
     exit 1
     ;;
-  solaris2.8)
+  solaris2.[89] | solaris2.1[0-9])
     os_include_dir="os/solaris/solaris2.8"
     ;;
-  solaris2.9 | solaris2.1[0-9])
-    os_include_dir="os/solaris/solaris2.9"
-    ;;
   tpf)
     os_include_dir="os/tpf"
     ;;

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]


-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-08-29 15:13 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26 13:04 [v3] Handle different versions of Solaris 8 <iso/math_iso.h>, <iso/stdlib_iso.h> Rainer Orth
2011-08-26 13:22 ` Paolo Carlini
2011-08-26 13:45   ` Rainer Orth
2011-08-26 13:54     ` Paolo Carlini
2011-08-26 14:33       ` Rainer Orth
2011-08-26 16:04         ` Paolo Carlini
2011-08-26 16:13           ` Rainer Orth
2011-08-26 16:19             ` Paolo Carlini
2011-08-26 17:45               ` Rainer Orth
2011-08-27 19:35                 ` Paolo Carlini
2011-08-29 13:31                   ` Rainer Orth
2011-08-29 13:49                     ` Paolo Carlini
2011-08-29 16:38                       ` Rainer Orth
2011-08-28 20:37                 ` Paolo Carlini
2011-08-26 18:54       ` Jonathan Wakely
2011-08-26 19:11         ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).