]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add C++11 header <cuchar>.
authorEdward Smith-Rowland <3dw4rd@verizon.net>
Fri, 4 Sep 2015 11:13:34 +0000 (11:13 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 4 Sep 2015 11:13:34 +0000 (12:13 +0100)
2015-09-04  Edward Smith-Rowland  <3dw4rd@verizon.net>
    Jonathan Wakely  <jwakely@redhat.com>

* acinclude.m4 (GLIBCXX_CHECK_UCHAR_H): Define.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check for <uchar.h>.
* include/Makefile.am: Add new headers.
* include/Makefile.in: Regenerate.
* include/c/cuchar: New.
* include/c_compatibility/uchar.h: New.
* include/c_global/cuchar: New.
* include/c_std/cuchar: New.
* include/precompiled/stdc++.h: Include <cuchar>.
* testsuite/17_intro/headers/c++200x/stdc++.cc: Include <uchar.h>.
* testsuite/17_intro/headers/c++200x/stdc++_multiple_inclusion.cc:
Include <uchar.h>.

Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>
From-SVN: r227488

14 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/acinclude.m4
libstdc++-v3/config.h.in
libstdc++-v3/configure
libstdc++-v3/configure.ac
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/include/c/cuchar [new file with mode: 0644]
libstdc++-v3/include/c_compatibility/uchar.h [new file with mode: 0644]
libstdc++-v3/include/c_global/cuchar [new file with mode: 0644]
libstdc++-v3/include/c_std/cuchar [new file with mode: 0644]
libstdc++-v3/include/precompiled/stdc++.h
libstdc++-v3/testsuite/17_intro/headers/c++200x/stdc++.cc
libstdc++-v3/testsuite/17_intro/headers/c++200x/stdc++_multiple_inclusion.cc

index 68464ead640de199c4bb992877f78233e58589ac..03fd3be590de0142f66a8eb859d7b560456ce698 100644 (file)
@@ -1,3 +1,22 @@
+2015-09-04  Edward Smith-Rowland  <3dw4rd@verizon.net>
+           Jonathan Wakely  <jwakely@redhat.com>
+
+       Add C++11 header <cuchar>.
+       * acinclude.m4 (GLIBCXX_CHECK_UCHAR_H): Define.
+       * config.h.in: Regenerate.
+       * configure: Regenerate.
+       * configure.ac: Check for <uchar.h>.
+       * include/Makefile.am: Add new headers.
+       * include/Makefile.in: Regenerate.
+       * include/c/cuchar: New.
+       * include/c_compatibility/uchar.h: New.
+       * include/c_global/cuchar: New.
+       * include/c_std/cuchar: New.
+       * include/precompiled/stdc++.h: Include <cuchar>.
+       * testsuite/17_intro/headers/c++200x/stdc++.cc: Include <uchar.h>.
+       * testsuite/17_intro/headers/c++200x/stdc++_multiple_inclusion.cc:
+       Include <uchar.h>.
+
 2015-09-04  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/65473
index 789bc5894a0fea96cc8ef8a07350836713e9ba95..64c9b7e32cf9901d4f61e72a09cc29bd43db31e7 100644 (file)
@@ -1808,6 +1808,52 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
   AC_LANG_RESTORE
 ])
 
+dnl
+dnl Check for uchar.h and usability.
+dnl
+AC_DEFUN([GLIBCXX_CHECK_UCHAR_H], [
+
+  # Test uchar.h.
+  AC_CHECK_HEADERS(uchar.h, ac_has_uchar_h=yes, ac_has_uchar_h=no)
+
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -std=c++11"
+
+  if test x"$ac_has_uchar_h" = x"yes"; then
+    AC_MSG_CHECKING([for ISO C11 support for <uchar.h>])
+    AC_TRY_COMPILE([#include <uchar.h>
+                   #ifdef __STDC_UTF_16__
+                   long i = __STDC_UTF_16__;
+                   #endif
+                   #ifdef __STDC_UTF_32__
+                   long j = __STDC_UTF_32__;
+                   #endif
+                   namespace test
+                   {
+                     using ::c16rtomb;
+                     using ::c32rtomb;
+                     using ::mbrtoc16;
+                     using ::mbrtoc32;
+                   }
+                  ],
+                  [], [ac_c11_uchar_cxx11=yes], [ac_c11_uchar_cxx11=no])
+  else
+    ac_c11_uchar_cxx11=no
+  fi
+  AC_MSG_RESULT($ac_c11_uchar_cxx11)
+  if test x"$ac_c11_uchar_cxx11" = x"yes"; then
+    AC_DEFINE(_GLIBCXX_USE_C11_UCHAR_CXX11, 1,
+             [Define if C11 functions in <uchar.h> should be imported into
+             namespace std in <cuchar>.])
+  fi
+
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  AC_LANG_RESTORE
+])
+
+
 dnl
 dnl Check whether "/dev/random" and "/dev/urandom" are available for the
 dnl random_device of "TR1" (Chapter 5.1, "Random number generation").
index 337f61440a9d72af1c519d8d4fa1cee593e97801..cc7a21e820c7cc6c7f1e3a03f6517427122ccd65 100644 (file)
 /* Define to 1 if the target supports thread-local storage. */
 #undef HAVE_TLS
 
+/* Define to 1 if you have the <uchar.h> header file. */
+#undef HAVE_UCHAR_H
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
 /* Define to use Sun versioning in the shared library. */
 #undef _GLIBCXX_SYMVER_SUN
 
+/* Define if C11 functions in <uchar.h> should be imported into namespace std
+   in <cuchar>. */
+#undef _GLIBCXX_USE_C11_UCHAR_CXX11
+
 /* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>,
    <stdio.h>, and <stdlib.h> can be used or exposed. */
 #undef _GLIBCXX_USE_C99
index 8646465fbbee75f0b870c631e1da64f3d834bfd9..6d35f30a18ad2bbbc770dc63b1fb726667769954 100755 (executable)
 
 
 
+
+  # Test uchar.h.
+  for ac_header in uchar.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "uchar.h" "ac_cv_header_uchar_h" "$ac_includes_default"
+if test "x$ac_cv_header_uchar_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UCHAR_H 1
+_ACEOF
+ ac_has_uchar_h=yes
+else
+  ac_has_uchar_h=no
+fi
+
+done
+
+
+
+  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -std=c++11"
+
+  if test x"$ac_has_uchar_h" = x"yes"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO C11 support for <uchar.h>" >&5
+$as_echo_n "checking for ISO C11 support for <uchar.h>... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <uchar.h>
+                   #ifdef __STDC_UTF_16__
+                   long i = __STDC_UTF_16__;
+                   #endif
+                   #ifdef __STDC_UTF_32__
+                   long j = __STDC_UTF_32__;
+                   #endif
+                   namespace test
+                   {
+                     using ::c16rtomb;
+                     using ::c32rtomb;
+                     using ::mbrtoc16;
+                     using ::mbrtoc32;
+                   }
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_c11_uchar_cxx11=yes
+else
+  ac_c11_uchar_cxx11=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  else
+    ac_c11_uchar_cxx11=no
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_c11_uchar_cxx11" >&5
+$as_echo "$ac_c11_uchar_cxx11" >&6; }
+  if test x"$ac_c11_uchar_cxx11" = x"yes"; then
+
+$as_echo "#define _GLIBCXX_USE_C11_UCHAR_CXX11 1" >>confdefs.h
+
+  fi
+
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
 # For the streamoff typedef.
 
 
index 96ff16f3f3e01699646817febde22ca55087d08e..34563480634a37b97716c55d37d2ea43738f2b13 100644 (file)
@@ -181,6 +181,7 @@ GLIBCXX_ENABLE_VTABLE_VERIFY([no])
 # Checks for operating systems support that doesn't require linking.
 GLIBCXX_CHECK_STDIO_PROTO
 GLIBCXX_CHECK_SYSTEM_ERROR
+GLIBCXX_CHECK_UCHAR_H
 
 # For the streamoff typedef.
 GLIBCXX_CHECK_INT64_T
index 41fc4af6d3067c99844e629e6019f303743047f8..e579b22f1b1a1c4153a5c7a131d6fdecd5a49693 100644 (file)
@@ -710,6 +710,7 @@ c_base_headers = \
        ${c_base_srcdir}/cstring \
        ${c_base_srcdir}/ctgmath \
        ${c_base_srcdir}/ctime \
+       ${c_base_srcdir}/cuchar \
        ${c_base_srcdir}/cwchar \
        ${c_base_srcdir}/cwctype
 
@@ -752,6 +753,7 @@ c_compatibility_headers = \
        ${c_compatibility_srcdir}/string.h \
        ${c_compatibility_srcdir}/tgmath.h \
        ${c_compatibility_srcdir}/time.h \
+       ${c_compatibility_srcdir}/uchar.h \
        ${c_compatibility_srcdir}/wchar.h \
        ${c_compatibility_srcdir}/wctype.h
 endif
index 6470d0173d53ee8be75f48288a29790034e5d044..47066705d23c17eca9b4c074f8831ac48ffb4bc8 100644 (file)
@@ -997,6 +997,7 @@ c_base_headers = \
        ${c_base_srcdir}/cstring \
        ${c_base_srcdir}/ctgmath \
        ${c_base_srcdir}/ctime \
+       ${c_base_srcdir}/cuchar \
        ${c_base_srcdir}/cwchar \
        ${c_base_srcdir}/cwctype
 
@@ -1033,6 +1034,7 @@ c_compatibility_builddir = .
 @GLIBCXX_C_HEADERS_C_TRUE@     ${c_compatibility_srcdir}/string.h \
 @GLIBCXX_C_HEADERS_C_TRUE@     ${c_compatibility_srcdir}/tgmath.h \
 @GLIBCXX_C_HEADERS_C_TRUE@     ${c_compatibility_srcdir}/time.h \
+@GLIBCXX_C_HEADERS_C_TRUE@     ${c_compatibility_srcdir}/uchar.h \
 @GLIBCXX_C_HEADERS_C_TRUE@     ${c_compatibility_srcdir}/wchar.h \
 @GLIBCXX_C_HEADERS_C_TRUE@     ${c_compatibility_srcdir}/wctype.h
 
diff --git a/libstdc++-v3/include/c/cuchar b/libstdc++-v3/include/c/cuchar
new file mode 100644 (file)
index 0000000..dd50c47
--- /dev/null
@@ -0,0 +1,47 @@
+// -*- C++ -*- forwarding header.
+
+// Copyright (C) 2015 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 3, 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882:2011 21.8
+//
+
+#ifndef _GLIBCXX_CUCHAR
+#define _GLIBCXX_CUCHAR 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <bits/c++config.h>
+#include <cwchar>
+
+#if _GLIBCXX_USE_C11_UCHAR_CXX11
+# include_next <uchar.h>
+#endif
+
+#endif // C++11
+
+#endif // _GLIBCXX_CUCHAR
diff --git a/libstdc++-v3/include/c_compatibility/uchar.h b/libstdc++-v3/include/c_compatibility/uchar.h
new file mode 100644 (file)
index 0000000..746f4af
--- /dev/null
@@ -0,0 +1,45 @@
+// -*- C++ -*- compatibility header.
+
+// Copyright (C) 2015 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 3, 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file uchar.h
+ *  This is a Standard C++ Library header.
+ */
+
+#include <cuchar>
+
+#ifndef _GLIBCXX_UCHAR_H
+#define _GLIBCXX_UCHAR_H 1
+
+#ifdef _GLIBCXX_NAMESPACE_C
+
+#if _GLIBCXX_USE_C11_UCHAR_CXX11
+using std::mbrtoc16;
+using std::c16rtomb;
+using std::mbrtoc32;
+using std::c32rtomb;
+#endif // _GLIBCXX_USE_C11_UCHAR_CXX11
+
+#endif // _GLIBCXX_NAMESPACE_C
+
+#endif // _GLIBCXX_UCHAR_H
diff --git a/libstdc++-v3/include/c_global/cuchar b/libstdc++-v3/include/c_global/cuchar
new file mode 100644 (file)
index 0000000..3b30c6a
--- /dev/null
@@ -0,0 +1,77 @@
+// -*- C++ -*- forwarding header.
+
+// Copyright (C) 2015 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 3, 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file include/cuchar
+ *  This is a Standard C++ Library file.  You should @c \#include this file
+ *  in your programs, rather than any of the @a *.h implementation files.
+ *
+ *  This is the C++ version of the Standard C Library header @c uchar.h,
+ *  and its contents are (mostly) the same as that header, but are all
+ *  contained in the namespace @c std (except for names which are defined
+ *  as macros in C).
+ */
+
+//
+// ISO C++ 14882:2011 21.8
+//
+
+#ifndef _GLIBCXX_CUCHAR
+#define _GLIBCXX_CUCHAR 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <bits/c++config.h>
+#include <cwchar>
+
+#if _GLIBCXX_USE_C11_UCHAR_CXX11
+
+#include <uchar.h>
+
+// Get rid of those macros defined in <uchar.h> in lieu of real functions.
+#undef mbrtoc16
+#undef c16rtomb
+#undef mbrtoc32
+#undef c32rtomb
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  using ::mbrtoc16;
+  using ::c16rtomb;
+  using ::mbrtoc32;
+  using ::c32rtomb;
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+
+#endif // _GLIBCXX_USE_C11_UCHAR_CXX11
+
+#endif // C++11
+
+#endif // _GLIBCXX_CUCHAR
diff --git a/libstdc++-v3/include/c_std/cuchar b/libstdc++-v3/include/c_std/cuchar
new file mode 100644 (file)
index 0000000..7d5eedb
--- /dev/null
@@ -0,0 +1,77 @@
+// -*- C++ -*- forwarding header.
+
+// Copyright (C) 2015 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 3, 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file include/cuchar
+ *  This is a Standard C++ Library file.  You should @c #include this file
+ *  in your programs, rather than any of the @a *.h implementation files.
+ *
+ *  This is the C++ version of the Standard C Library header @c uchar.h,
+ *  and its contents are (mostly) the same as that header, but are all
+ *  contained in the namespace @c std (except for names which are defined
+ *  as macros in C).
+ */
+
+//
+// ISO C++ 14882:2011 21.8
+//
+
+#ifndef _GLIBCXX_CUCHAR
+#define _GLIBCXX_CUCHAR 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <bits/c++config.h>
+#include <cwchar>
+
+#if _GLIBCXX_USE_C11_UCHAR_CXX11
+
+#include <uchar.h>
+
+// Get rid of those macros defined in <uchar.h> in lieu of real functions.
+#undef mbrtoc16
+#undef c16rtomb
+#undef mbrtoc32
+#undef c32rtomb
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  using ::mbrtoc16;
+  using ::c16rtomb;
+  using ::mbrtoc32;
+  using ::c32rtomb;
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+
+#endif // _GLIBCXX_USE_C11_UCHAR_CXX11
+
+#endif // C++11
+
+#endif // _GLIBCXX_CUCHAR
index 693391adffbabc8602b289b41830c5faf64519a6..ab119fecd2f46ca282059ebe21023f91fb005c55 100644 (file)
@@ -56,6 +56,7 @@
 #include <cstdbool>
 #include <cstdint>
 #include <ctgmath>
+#include <cuchar>
 #include <cwchar>
 #include <cwctype>
 #endif
index 50c32744732a587447dcb51ff1accd48d1eedc13..d1c64b190a8a9dc4a6f8c834215dfb937a1cba0e 100644 (file)
@@ -59,6 +59,9 @@
 #include <tgmath.h>
 #endif
 #include <time.h>
+#if __has_include(<uchar.h>)
+#include <uchar.h>
+#endif
 #ifdef _GLIBCXX_HAVE_WCHAR_H
 #include <wchar.h>
 #endif
index 9fa919f21c57fa49e47b9aeaa76cdb01586859e8..e51bdee70f6e175ef4930cb219cc542c268cd979 100644 (file)
@@ -59,6 +59,9 @@
 #include <tgmath.h>
 #endif
 #include <time.h>
+#if __has_include(<uchar.h>)
+#include <uchar.h>
+#endif
 #ifdef _GLIBCXX_HAVE_WCHAR_H
 #include <wchar.h>
 #endif
 #include <tgmath.h>
 #endif
 #include <time.h>
+#if __has_include(<uchar.h>)
+#include <uchar.h>
+#endif
 #ifdef _GLIBCXX_HAVE_WCHAR_H
 #include <wchar.h>
 #endif