This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] tr1/8.4 + configury


Hi,

the below adds the simple bits required for 8.4 and some configury: I'm
adding a separate procedure, checking the various headers for the
functions specifically required for TR1. For the moment, cannot be
disabled by a configure option, I think it's correct, because at
variance with the existing [GLIBCXX_ENABLE_C99] we are *not* "polluting"
(in the sense of C++03) namespace std anyway. But maybe the procedure
will become more complex, in the future...

Tested x86-linux, would commit later today.

Paolo.

////////////////
2006-01-25  Paolo Carlini  <pcarlini@suse.de>

	* include/tr1/cctype: New.
	* include/Makefile.am: Add.
	* testsuite/tr1/8_c_compatibility/cctype/functions.cc: New.
	* include/Makefile.in: Regenerate.

	* acinclude.m4 ([GLIBCXX_CHECK_C99_TR1]): New, check for C99
	support to TR1, Chapter 8.
	* configure.ac: Use it.
	* include/tr1/complex: Adjust.
	* config.h.in: Regenerate.
	* configure: Likewise.
Index: include/tr1/cctype
===================================================================
--- include/tr1/cctype	(revision 0)
+++ include/tr1/cctype	(revision 0)
@@ -0,0 +1,56 @@
+// 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_CCTYPE
+#define _TR1_CCTYPE 1
+
+#include <bits/c++config.h>
+#include <ctype.h>
+
+#if _GLIBCXX_USE_C99_CTYPE_TR1
+
+#undef isblank
+
+// namespace std::tr1
+namespace std
+{
+_GLIBCXX_BEGIN_NAMESPACE(tr1)
+
+  using ::isblank;
+
+_GLIBCXX_END_NAMESPACE
+}
+
+#endif
+
+#endif
Index: include/tr1/complex
===================================================================
--- include/tr1/complex	(revision 110173)
+++ include/tr1/complex	(working copy)
@@ -64,7 +64,7 @@
       return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag());
     }
 
-#if _GLIBCXX_USE_C99_COMPLEX
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
   inline __complex__ float
   __complex_acos(__complex__ float __z)
   { return __builtin_cacosf(__z); }
@@ -100,7 +100,7 @@
       return std::complex<_Tp>(__t.imag(), -__t.real());
     }
 
-#if _GLIBCXX_USE_C99_COMPLEX
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
   inline __complex__ float
   __complex_asin(__complex__ float __z)
   { return __builtin_casinf(__z); }
@@ -144,7 +144,7 @@
 			       _Tp(0.25) * log(__num / __den));
     }
 
-#if _GLIBCXX_USE_C99_COMPLEX
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
   inline __complex__ float
   __complex_atan(__complex__ float __z)
   { return __builtin_catanf(__z); }
@@ -183,7 +183,7 @@
       return std::log(__t + __z);
     }
 
-#if _GLIBCXX_USE_C99_COMPLEX
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
   inline __complex__ float
   __complex_acosh(__complex__ float __z)
   { return __builtin_cacoshf(__z); }
@@ -222,7 +222,7 @@
       return std::log(__t + __z);
     }
 
-#if _GLIBCXX_USE_C99_COMPLEX
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
   inline __complex__ float
   __complex_asinh(__complex__ float __z)
   { return __builtin_casinhf(__z); }
@@ -266,7 +266,7 @@
 			       _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
     }
 
-#if _GLIBCXX_USE_C99_COMPLEX
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
   inline __complex__ float
   __complex_atanh(__complex__ float __z)
   { return __builtin_catanhf(__z); }
Index: testsuite/tr1/8_c_compatibility/cctype/functions.cc
===================================================================
--- testsuite/tr1/8_c_compatibility/cctype/functions.cc	(revision 0)
+++ testsuite/tr1/8_c_compatibility/cctype/functions.cc	(revision 0)
@@ -0,0 +1,36 @@
+// 2006-01-25  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.4 Additions to header <cctype>
+
+#include <tr1/cctype>
+
+void test01(int r = 0)
+{
+#if _GLIBCXX_USE_C99_CTYPE_TR1
+  r = std::tr1::isblank(0);
+#endif
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
Index: configure.ac
===================================================================
--- configure.ac	(revision 110173)
+++ configure.ac	(working copy)
@@ -157,6 +157,9 @@
   # For LFS support.
   GLIBCXX_CHECK_LFS
 
+  # For C99 support to TR1.
+  GLIBCXX_CHECK_C99_TR1
+
   # For TLS support.
   GCC_CHECK_TLS
 
Index: acinclude.m4
===================================================================
--- acinclude.m4	(revision 110173)
+++ acinclude.m4	(working copy)
@@ -1048,6 +1048,71 @@
 
 
 dnl
+dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
+dnl facilities in Chapter 8, "C compatibility".
+dnl
+AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
+
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+
+  # Check for the existence of <complex.h> complex math functions used
+  # by tr1/complex.
+  AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
+  ac_c99_complex_tr1=no;
+  if test x"$ac_has_complex_h" = x"yes"; then
+    AC_MSG_CHECKING([for ISO C99 support to TR1 in <complex.h>])
+    AC_TRY_COMPILE([#include <complex.h>],
+	           [typedef __complex__ float float_type; float_type tmpf;
+	            cacosf(tmpf);
+	            casinf(tmpf);
+	            catanf(tmpf);
+	            cacoshf(tmpf);
+	            casinhf(tmpf);
+	            catanhf(tmpf);
+		    typedef __complex__ double double_type; double_type tmpd;
+	            cacos(tmpd);
+	            casin(tmpd);
+	            catan(tmpd);
+	            cacosh(tmpd);
+	            casinh(tmpd);
+	            catanh(tmpd);
+		    typedef __complex__ long double ld_type; ld_type tmpld;
+	            cacosl(tmpld);
+	            casinl(tmpld);
+	            catanl(tmpld);
+	            cacoshl(tmpld);
+	            casinhl(tmpld);
+	            catanhl(tmpld);
+		   ],[ac_c99_complex_tr1=yes], [ac_c99_complex_tr1=no])
+  fi
+  AC_MSG_RESULT($ac_c99_complex_tr1)
+  if test x"$ac_c99_complex_tr1" = x"yes"; then
+    AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_TR1, 1,
+              [Define if C99 functions in <complex.h> should be used in
+              <tr1/complex>. Using compiler builtins for these functions
+	      requires corresponding C99 library functions to be present.])
+  fi
+
+  # Check for the existence of <ctype.h> functions.
+  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);
+		 ],[ac_c99_ctype_tr1=yes], [ac_c99_ctype_tr1=no])
+  ])
+  AC_MSG_RESULT($ac_c99_ctype_tr1)
+  if test x"$ac_c99_ctype_tr1" = x"yes"; then
+    AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1,
+              [Define if C99 functions in <ctype.h> should be imported in
+	      <tr1/cctype> in namespace std::tr1.])
+  fi
+
+  AC_LANG_RESTORE
+])
+
+
+dnl
 dnl Check for what type of C headers to use.
 dnl
 dnl --enable-cheaders= [does stuff].

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]