This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] tr1/c_compatibilty, cfenv + minor tweaks
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 26 Jan 2006 12:33:32 +0100
- Subject: [v3] tr1/c_compatibilty, cfenv + minor tweaks
Hi,
tested x86-linux, committed to mainline.
Paolo.
/////////////////
2006-01-26 Paolo Carlini <pcarlini@suse.de>
* include/tr1/cfenv: New.
* include/Makefile.am: Add.
* testsuite/tr1/8_c_compatibility/cfenv/functions.cc: New.
* testsuite/tr1/8_c_compatibility/cfenv/types.cc: Likewise.
* acinclude.m4 ([GLIBCXX_CHECK_C99_TR1]): Add <fenv.h> checks.
* docs/html/ext/tr1.html: Update; add note.
* include/Makefile.in: Regenerate.
* config.h.in: Likewise.
* configure: Likewise.
* testsuite/tr1/8_c_compatibility/complex/functions.cc: Tweak.
* testsuite/tr1/8_c_compatibility/cctype/functions.cc: Likewise.
* docs/html/faq/index.html: Fix link to tr1.html text; fix
formatting.
Index: include/tr1/cfenv
===================================================================
--- include/tr1/cfenv (revision 0)
+++ include/tr1/cfenv (revision 0)
@@ -0,0 +1,86 @@
+// TR1 cctype -*- C++ -*-
+
+// 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+/** @file
+ * This is a TR1 C++ Library header.
+ */
+
+#ifndef _TR1_CFENV
+#define _TR1_CFENV 1
+
+#include <bits/c++config.h>
+
+#if _GLIBCXX_HAVE_FENV_H
+#include <fenv.h>
+#endif
+
+#if _GLIBCXX_USE_C99_FENV_TR1
+
+#undef feclearexcept
+#undef fegetexceptflag
+#undef feraiseexcept
+#undef fesetexceptflag
+#undef fetestexcept
+#undef fegetround
+#undef fesetround
+#undef fegetenv
+#undef feholdexcept
+#undef fesetenv
+#undef feupdateenv
+
+// namespace std::tr1
+namespace std
+{
+_GLIBCXX_BEGIN_NAMESPACE(tr1)
+
+ // types
+ using ::fenv_t;
+ using ::fexcept_t;
+
+ // functions
+ using ::feclearexcept;
+ using ::fegetexceptflag;
+ using ::feraiseexcept;
+ using ::fesetexceptflag;
+ using ::fetestexcept;
+
+ using ::fegetround;
+ using ::fesetround;
+
+ using ::fegetenv;
+ using ::feholdexcept;
+ using ::fesetenv;
+ using ::feupdateenv;
+
+_GLIBCXX_END_NAMESPACE
+}
+
+#endif
+
+#endif
Index: include/Makefile.am
===================================================================
--- include/Makefile.am (revision 110221)
+++ include/Makefile.am (working copy)
@@ -485,6 +485,7 @@
${tr1_srcdir}/bind_iterate.h \
${tr1_srcdir}/boost_shared_ptr.h \
${tr1_srcdir}/cctype \
+ ${tr1_srcdir}/cfenv \
${tr1_srcdir}/common.h \
${tr1_srcdir}/complex \
${tr1_srcdir}/functional \
Index: docs/html/ext/tr1.html
===================================================================
--- docs/html/ext/tr1.html (revision 110220)
+++ docs/html/ext/tr1.html (working copy)
@@ -30,9 +30,16 @@
</p>
<p>
-This page describes the TR1 support in mainline GCC CVS, not in any particular release.
+In this implementation the header names are prefixed by
+<code>tr1/</code>, for instance <code><tr1/functional></code>,
+<code><tr1/memory></code>, and so on.
</p>
+<p>
+This page describes the TR1 support in mainline GCC CVS, not in any particular
+release.
+</p>
+
<table border="1">
<thead>
<tr>
@@ -1796,25 +1803,25 @@
<tr>
<td>8.4</td>
<td>Additions to header <code><cctype></code></td>
+ <td>done</td>
<td></td>
<td></td>
- <td>missing</td>
<td></td>
</tr>
<tr>
<td>8.4.1</td>
<td>Synopsis</td>
+ <td>done</td>
<td></td>
<td></td>
- <td>missing</td>
<td></td>
</tr>
<tr>
<td>8.4.2</td>
<td>Function <code>isblank</code></td>
+ <td>done</td>
<td></td>
<td></td>
- <td>missing</td>
<td></td>
</tr>
<tr>
@@ -1828,25 +1835,25 @@
<tr>
<td>8.6</td>
<td>Header <code><cfenv></code></td>
+ <td>done</td>
<td></td>
<td></td>
- <td>missing</td>
<td></td>
</tr>
<tr>
<td>8.6.1</td>
<td>Synopsis</td>
+ <td>done</td>
<td></td>
<td></td>
- <td>missing</td>
<td></td>
</tr>
<tr>
<td>8.6.2</td>
<td>Definitions</td>
+ <td>done</td>
<td></td>
<td></td>
- <td>missing</td>
<td></td>
</tr>
<tr>
@@ -2259,7 +2266,8 @@
<li>
<a name="1"/>
The shared_ptr implementation uses some code from the
- <a href="http://www.boost.org/libs/smart_ptr/shared_ptr.htm">Boost shared_ptr</a> library.
+ <a href="http://www.boost.org/libs/smart_ptr/shared_ptr.htm">Boost
+ shared_ptr</a> library.
</li>
</ol>
Index: docs/html/faq/index.html
===================================================================
--- docs/html/faq/index.html (revision 110220)
+++ docs/html/faq/index.html (working copy)
@@ -982,64 +982,73 @@
<hr />
<h2><a name="5_5">5.5 Does libstdc++ support TR1?</a></h2>
- <p>The C++ Standard Library Technical Report adds many new features to the library.
- The latest version of this effort is described in
- <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">
+ <p>The C++ Standard Library Technical Report adds many new features to
+ the library. The latest version of this effort is described in
+ <a href=
+ "http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">
Technical Report 1</a>.
</p>
<p>libstdc++ strives to implement all of TR1.
- The libstdc++ implementation status of the TR1 draft is listed in
- <a href="../ext/tr1.html">this page</a>.
+ An <a href="../ext/tr1.html">overview</a> of the implementation status
+ is available.
</p>
<p>Briefly, the features of TR1 and the current status are:
</p>
<p><strong>Unordered containers - Complete -</strong>
- The unordered_set, unordered_map, unordered_multiset, and unordered_multimap containers
- are hashed versions of the map, set, multimap, and multiset containers respectively.
- These classes are suitable replacements for the SGI STL hash_map and hash_set extensions.
+ The unordered_set, unordered_map, unordered_multiset, and
+ unordered_multimap containers are hashed versions of the map, set,
+ multimap, and multiset containers respectively. These classes are
+ suitable replacements for the SGI STL hash_map and hash_set
+ extensions.
</p>
<p><strong>Reference-counted smart pointers - Complete -</strong>
- The shared_ptr and weak_ptr allow several object to know about a pointer and whether it is valid.
- When the last reference to the pointer is destroyed the pointer is freed.
+ The shared_ptr and weak_ptr allow several object to know about a
+ pointer and whether it is valid. When the last reference to the
+ pointer is destroyed the pointer is freed.
</p>
<p><strong>Type traits - Complete -</strong>
- The type_traits class gives templates the ability to probe information about the input type
- and enable type-dependent logic to be performed without the need of template specializations.
+ The type_traits class gives templates the ability to probe
+ information about the input type and enable type-dependent logic
+ to be performed without the need of template specializations.
</p>
<p><strong>Fixed-size arrays - Complete -</strong>
- The array class implements small fixed-sized arrays with container semantics.
+ The array class implements small fixed-sized arrays with container
+ semantics.
</p>
<p><strong>Tuples - Complete -</strong>
- The tuple class implements small heterogeneous arrays. This is an enhanced pair.
- In fact, the standard pair is enhanced with a tuple interface.
+ The tuple class implements small heterogeneous arrays. This is an
+ enhanced pair. In fact, the standard pair is enhanced with a tuple
+ interface.
</p>
<p><strong>A regular expression engine</strong>
- This library provides for regular expression objects with traversal of
- text with return of subexpressions.
+ This library provides for regular expression objects with traversal
+ of text with return of subexpressions.
</p>
<p><strong>A random number engine</strong>
- This library contains randow number generators with several different choices
- of distribution.
+ This library contains randow number generators with several different
+ choices of distribution.
</p>
<p><strong>Special functions - Under construction - </strong>
- Twenty-three mathematical functions familiar to physicists and engineers are included:
- cylindrical and spherical Bessel and Neumann functions, hypergeometric functions,
- Laguerre polynomials, Legendre functions, elliptic integrals, exponential integrals
- and the Riemann zeta function all for your computing pleasure.
+ Twenty-three mathematical functions familiar to physicists and
+ engineers are included: cylindrical and spherical Bessel and Neumann
+ functions, hypergeometric functions, Laguerre polynomials, Legendre
+ functions, elliptic integrals, exponential integrals and the Riemann
+ zeta function all for your computing pleasure.
</p>
<p><strong>C99 compatibility - Under construction - </strong>
- There are many features designed to minimize the divergence of the C and the C++ languages.
+ There are many features designed to minimize the divergence of the C
+ and the C++ languages.
</p>
<hr />
Index: testsuite/tr1/8_c_compatibility/cfenv/types.cc
===================================================================
--- testsuite/tr1/8_c_compatibility/cfenv/types.cc (revision 0)
+++ testsuite/tr1/8_c_compatibility/cfenv/types.cc (revision 0)
@@ -0,0 +1,36 @@
+// { dg-do compile }
+
+// 2006-01-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.6 Header <cfenv>
+
+#include <tr1/cfenv>
+
+void test01()
+{
+#if _GLIBCXX_USE_C99_FENV_TR1
+
+ // Check for required typedefs
+ typedef std::tr1::fenv_t fenv_t_type;
+ typedef std::tr1::fexcept_t fexcept_t_type;
+
+#endif
+}
Index: testsuite/tr1/8_c_compatibility/cfenv/functions.cc
===================================================================
--- testsuite/tr1/8_c_compatibility/cfenv/functions.cc (revision 0)
+++ testsuite/tr1/8_c_compatibility/cfenv/functions.cc (revision 0)
@@ -0,0 +1,52 @@
+// { dg-do compile }
+
+// 2006-01-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.6 Header <cfenv>
+
+#include <tr1/cfenv>
+
+void test01()
+{
+#if _GLIBCXX_USE_C99_FENV_TR1
+
+ int except = 0, mode = 0;
+ std::tr1::fexcept_t* pflag = 0;
+ std::tr1::fenv_t* penv = 0;
+
+ int r;
+
+ r = std::tr1::feclearexcept(except);
+ r = std::tr1::fegetexceptflag(pflag, except);
+ r = std::tr1::feraiseexcept(except);
+ r = std::tr1::fesetexceptflag(pflag, except);
+ r = std::tr1::fetestexcept(except);
+
+ r = std::tr1::fegetround();
+ r = std::tr1::fesetround(mode);
+
+ r = std::tr1::fegetenv(penv);
+ r = std::tr1::feholdexcept(penv);
+ r = std::tr1::fesetenv(penv);
+ r = std::tr1::feupdateenv(penv);
+
+#endif
+}
Index: testsuite/tr1/8_c_compatibility/complex/functions.cc
===================================================================
--- testsuite/tr1/8_c_compatibility/complex/functions.cc (revision 110220)
+++ testsuite/tr1/8_c_compatibility/complex/functions.cc (working copy)
@@ -1,3 +1,5 @@
+// { dg-do compile }
+
// 2006-01-10 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2006 Free Software Foundation, Inc.
@@ -25,19 +27,18 @@
template<typename T>
void test01_do()
{
- using namespace std::tr1;
typedef std::complex<T> cmplx_type;
cmplx_type ans;
- ans = acos(cmplx_type(1.0, 1.0));
- ans = asin(cmplx_type(1.0, 1.0));
- ans = atan(cmplx_type(1.0, 1.0));
+ ans = std::tr1::acos(cmplx_type(1.0, 1.0));
+ ans = std::tr1::asin(cmplx_type(1.0, 1.0));
+ ans = std::tr1::atan(cmplx_type(1.0, 1.0));
- ans = acosh(cmplx_type(1.0, 1.0));
- ans = asinh(cmplx_type(1.0, 1.0));
- ans = atanh(cmplx_type(1.0, 1.0));
- ans = fabs(cmplx_type(1.0, 1.0));
+ ans = std::tr1::acosh(cmplx_type(1.0, 1.0));
+ ans = std::tr1::asinh(cmplx_type(1.0, 1.0));
+ ans = std::tr1::atanh(cmplx_type(1.0, 1.0));
+ ans = std::tr1::fabs(cmplx_type(1.0, 1.0));
}
void test01()
@@ -46,9 +47,3 @@
test01_do<double>();
test01_do<long double>();
}
-
-int main()
-{
- test01();
- return 0;
-}
Index: testsuite/tr1/8_c_compatibility/cctype/functions.cc
===================================================================
--- testsuite/tr1/8_c_compatibility/cctype/functions.cc (revision 110221)
+++ testsuite/tr1/8_c_compatibility/cctype/functions.cc (working copy)
@@ -1,3 +1,5 @@
+// { dg-do compile }
+
// 2006-01-25 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2006 Free Software Foundation, Inc.
@@ -22,17 +24,12 @@
#include <tr1/cctype>
-void test01(int r = 0)
+void test01()
{
#if _GLIBCXX_USE_C99_CTYPE_TR1
- r = std::tr1::isblank(0);
-#else
- r = 0;
+
+ int ch = 0, r;
+ r = std::tr1::isblank(ch);
+
#endif
}
-
-int main()
-{
- test01();
- return 0;
-}
Index: acinclude.m4
===================================================================
--- acinclude.m4 (revision 110221)
+++ acinclude.m4 (working copy)
@@ -1098,7 +1098,8 @@
AC_MSG_CHECKING([for ISO C99 support to TR1 in <ctype.h>])
AC_CACHE_VAL(ac_c99_ctype_tr1, [
AC_TRY_COMPILE([#include <ctype.h>],
- [isblank(0);
+ [int ch;
+ isblank(ch);
],[ac_c99_ctype_tr1=yes], [ac_c99_ctype_tr1=no])
])
AC_MSG_RESULT($ac_c99_ctype_tr1)
@@ -1108,6 +1109,35 @@
<tr1/cctype> in namespace std::tr1.])
fi
+ # Check for the existence of <fenv.h> functions.
+ AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
+ ac_c99_fenv_tr1=no;
+ if test x"$ac_has_fenv_h" = x"yes"; then
+ AC_MSG_CHECKING([for ISO C99 support to TR1 in <fenv.h>])
+ AC_TRY_COMPILE([#include <fenv.h>],
+ [int except, mode;
+ fexcept_t* pflag;
+ fenv_t* penv;
+ feclearexcept(except);
+ fegetexceptflag(pflag, except);
+ feraiseexcept(except);
+ fesetexceptflag(pflag, except);
+ fetestexcept(except);
+ fegetround();
+ fesetround(mode);
+ fegetenv(penv);
+ feholdexcept(penv);
+ fesetenv(penv);
+ feupdateenv(penv);
+ ],[ac_c99_fenv_tr1=yes], [ac_c99_fenv_tr1=no])
+ fi
+ AC_MSG_RESULT($ac_c99_fenv_tr1)
+ if test x"$ac_c99_fenv_tr1" = x"yes"; then
+ AC_DEFINE(_GLIBCXX_USE_C99_FENV_TR1, 1,
+ [Define if C99 functions in <fenv.h> should be imported in
+ <tr1/cfenv> in namespace std::tr1.])
+ fi
+
AC_LANG_RESTORE
])