From 1e41a98ca56a9641f356d6f4233b3237fe518b04 Mon Sep 17 00:00:00 2001
From: Paolo Carlini <pcarlini@suse.de>
Date: Sun, 26 Feb 2006 18:42:29 +0000
Subject: [PATCH] cmath: Add templates (8.16.3).

2006-02-26  Paolo Carlini  <pcarlini@suse.de>

	* include/tr1/cmath: Add templates (8.16.3).
	* include/tr1/cstbool: New.
	* include/tr1/stdbool.h: Likewise.
	* include/Makefile.am: Add.
	* testsuite/tr1/8_c_compatibility/cmath/templates.cc: New.
	* testsuite/tr1/headers.cc: Update.
	* acinclude.m4 ([GLIBCXX_CHECK_C99_TR1]): Add <stdbool.h> check.
	* docs/html/ext/tr1.html: Update.
	* include/Makefile.in: Regenerate.
	* config.h.in: Likewise.
	* configure: Likewise.

From-SVN: r111456
---
 libstdc++-v3/ChangeLog                        |  14 ++
 libstdc++-v3/acinclude.m4                     |   3 +
 libstdc++-v3/config.h.in                      |   3 +
 libstdc++-v3/configure                        | 152 ++++++++++++++++++
 libstdc++-v3/docs/html/ext/tr1.html           |  12 +-
 libstdc++-v3/include/Makefile.am              |   2 +
 libstdc++-v3/include/Makefile.in              |   2 +
 libstdc++-v3/include/tr1/cmath                |  28 ++++
 .../tr1/8_c_compatibility/cmath/templates.cc  |  63 ++++++++
 libstdc++-v3/testsuite/tr1/headers.cc         |   2 +
 10 files changed, 275 insertions(+), 6 deletions(-)
 create mode 100644 libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 66f57c7f1eb8..96bce8c66553 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+2006-02-26  Paolo Carlini  <pcarlini@suse.de>
+
+	* include/tr1/cmath: Add templates (8.16.3).	
+	* include/tr1/cstbool: New.
+	* include/tr1/stdbool.h: Likewise.
+	* include/Makefile.am: Add.
+	* testsuite/tr1/8_c_compatibility/cmath/templates.cc: New.
+	* testsuite/tr1/headers.cc: Update.
+	* acinclude.m4 ([GLIBCXX_CHECK_C99_TR1]): Add <stdbool.h> check.
+	* docs/html/ext/tr1.html: Update.
+	* include/Makefile.in: Regenerate.
+	* config.h.in: Likewise.
+	* configure: Likewise.
+
 2006-02-24  Paolo Carlini  <pcarlini@suse.de>
 
 	* include/tr1/array (array<>::swap, assign): Implement.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index c8055eba7ce4..4dc38b883ac8 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1330,6 +1330,9 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
               <tr1/cinttypes> in namespace std::tr1.])
   fi
 
+  # Check for the existence of the <stdbool.h> header.	
+  AC_CHECK_HEADERS(stdbool.h)
+
   AC_LANG_RESTORE
 ])
 
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index b112aca8c688..5c373f53fedd 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -286,6 +286,9 @@
 /* Define to 1 if you have the `sqrtl' function. */
 #undef HAVE_SQRTL
 
+/* Define to 1 if you have the <stdbool.h> header file. */
+#undef HAVE_STDBOOL_H
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index e02b4ad52624..11d3cdacb083 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -30873,6 +30873,158 @@ _ACEOF
 
   fi
 
+  # Check for the existence of the <stdbool.h> header.
+
+for ac_header in stdbool.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_cxx_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ----------------------------------------- ##
+## Report this to the package-unused lists.  ##
+## ----------------------------------------- ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
   ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff --git a/libstdc++-v3/docs/html/ext/tr1.html b/libstdc++-v3/docs/html/ext/tr1.html
index 69dd2daaaac2..dcce47327c4a 100644
--- a/libstdc++-v3/docs/html/ext/tr1.html
+++ b/libstdc++-v3/docs/html/ext/tr1.html
@@ -1971,25 +1971,25 @@ release.
     <tr>
       <td>8.16.1</td>
       <td>Synopsis</td>
+      <td>done</td>
       <td></td>
       <td></td>
-      <td>missing</td>
       <td></td>
     </tr>
     <tr>
       <td>8.16.2</td>
       <td>Definitions</td>
+      <td>done</td>
       <td></td>
       <td></td>
-      <td>missing</td>
       <td></td>
     </tr>
     <tr>
       <td>8.16.3</td>
       <td>Function template definitions</td>
+      <td>done</td>
       <td></td>
       <td></td>
-      <td>missing</td>
       <td></td>
     </tr>
     <tr>
@@ -2027,17 +2027,17 @@ release.
     <tr>
       <td>8.20</td>
       <td>The header <code>&lt;cstdbool&gt;</code></td>
+      <td>done</td>
       <td></td>
       <td></td>
-      <td>missing</td>
       <td></td>
     </tr>
     <tr>
       <td>8.21</td>
       <td>The header <code>&lt;stdbool.h&gt;</code></td>
+      <td>done</td>
       <td></td>
       <td></td>
-      <td>missing</td>
       <td></td>
     </tr>
     <tr>
@@ -2307,7 +2307,7 @@ permitted in any medium, provided this notice is preserved.
 <table width="100%" border="0">
 <tr>
   <td>
-    <!-- IGNORE DIFF -->Last modified 2006-02-07
+    <!-- IGNORE DIFF -->Last modified 2006-02-26
   </td>
   <td align="right" valign="bottom">
     <a href="http://validator.w3.org/check/referer">
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 23b94a3aa0ef..0d179c9bfbd7 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -493,6 +493,7 @@ tr1_headers = \
 	${tr1_srcdir}/common.h \
 	${tr1_srcdir}/complex \
 	${tr1_srcdir}/cstdarg \
+	${tr1_srcdir}/cstdbool \
 	${tr1_srcdir}/cstdint \
 	${tr1_srcdir}/cstdio \
 	${tr1_srcdir}/cstdlib \
@@ -514,6 +515,7 @@ tr1_headers = \
 	${tr1_srcdir}/ref_wrap_iterate.h \
 	${tr1_srcdir}/repeat.h \
 	${tr1_srcdir}/stdarg.h \
+	${tr1_srcdir}/stdbool.h \
 	${tr1_srcdir}/stdint.h \
 	${tr1_srcdir}/stdio.h \
 	${tr1_srcdir}/stdlib.h \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index c04a598d88d5..c749a2c9a422 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -712,6 +712,7 @@ tr1_headers = \
 	${tr1_srcdir}/common.h \
 	${tr1_srcdir}/complex \
 	${tr1_srcdir}/cstdarg \
+	${tr1_srcdir}/cstdbool \
 	${tr1_srcdir}/cstdint \
 	${tr1_srcdir}/cstdio \
 	${tr1_srcdir}/cstdlib \
@@ -733,6 +734,7 @@ tr1_headers = \
 	${tr1_srcdir}/ref_wrap_iterate.h \
 	${tr1_srcdir}/repeat.h \
 	${tr1_srcdir}/stdarg.h \
+	${tr1_srcdir}/stdbool.h \
 	${tr1_srcdir}/stdint.h \
 	${tr1_srcdir}/stdio.h \
 	${tr1_srcdir}/stdlib.h \
diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath
index ec11b26adc56..3549868cd4d9 100644
--- a/libstdc++-v3/include/tr1/cmath
+++ b/libstdc++-v3/include/tr1/cmath
@@ -295,4 +295,32 @@ _GLIBCXX_END_NAMESPACE
 
 #endif
 
+// namespace std::tr1
+namespace std
+{
+_GLIBCXX_BEGIN_NAMESPACE(tr1)
+
+#if _GLIBCXX_USE_C99_MATH
+#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
+  using std::signbit;
+  
+  using std::fpclassify;
+
+  using std::isfinite;
+  using std::isinf;
+  using std::isnan;
+  using std::isnormal;
+
+  using std::isgreater;
+  using std::isgreaterequal;
+  using std::isless;
+  using std::islessequal;
+  using std::islessgreater;
+  using std::isunordered;
+#endif
+#endif
+
+_GLIBCXX_END_NAMESPACE
+}
+
 #endif
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
new file mode 100644
index 000000000000..31542894ef2e
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc
@@ -0,0 +1,63 @@
+// { dg-do compile }
+
+// 2006-02-26  Paolo Carlini  <pcarlini@suse.de>
+//
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 8.16 Additions to header <cmath>
+
+#include <tr1/cmath>
+
+#if _GLIBCXX_USE_C99
+#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
+
+template<typename T>
+  void test01_do()
+  {
+    T x = T();
+    
+    bool ret;
+    int iret;
+
+    ret = std::tr1::signbit(x);
+    
+    iret = std::tr1::fpclassify(x);
+    
+    ret = std::tr1::isfinite(x);
+    ret = std::tr1::isinf(x);
+    ret = std::tr1::isnan(x);
+    ret = std::tr1::isnormal(x);
+    
+    ret = std::tr1::isgreater(x, x);
+    ret = std::tr1::isgreaterequal(x, x);
+    ret = std::tr1::isless(x, x);
+    ret = std::tr1::islessequal(x, x);
+    ret = std::tr1::islessgreater(x, x);
+    ret = std::tr1::isunordered(x, x);
+  }
+
+void test01()
+{
+  test01_do<float>();
+  test01_do<double>();
+  test01_do<long double>();
+}
+
+#endif
+#endif
diff --git a/libstdc++-v3/testsuite/tr1/headers.cc b/libstdc++-v3/testsuite/tr1/headers.cc
index 4be96e020b77..ad77006a7c2c 100644
--- a/libstdc++-v3/testsuite/tr1/headers.cc
+++ b/libstdc++-v3/testsuite/tr1/headers.cc
@@ -29,6 +29,7 @@
 #include <tr1/cmath>
 #include <tr1/complex>
 #include <tr1/cstdarg>
+#include <tr1/cstdbool>
 #include <tr1/cstdint>
 #include <tr1/cstdio>
 #include <tr1/cstdlib>
@@ -44,6 +45,7 @@
 #include <tr1/math.h>
 #include <tr1/memory>
 #include <tr1/stdarg.h>
+#include <tr1/stdbool.h>
 #include <tr1/stdint.h>
 #include <tr1/stdio.h>
 #include <tr1/stdlib.h>
-- 
GitLab