This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[v3] mbstate_t, size_t checks
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Subject: [v3] mbstate_t, size_t checks
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Mon, 1 Jan 2001 23:32:16 -0800
...new regressions (fixed) plus tests found during conformance testing.
2001-01-01 Benjamin Kosnik <bkoz@fillmore.redhat.com>
* include/c_std/bits/std_cwchar.h: Same.
* testsuite/17_intro/header_cwchar.cc: Same.
* include/c_std/bits/std_ctime.h: Same.
* testsuite/17_intro/header_ctime.cc: Same.
* include/c_std/bits/std_cstdlib.h: Same.
Clean up undefs, make consistent with cwchar and cmath, etc.
* testsuite/17_intro/header_cstdlib.cc: Same.
* include/c_std/bits/std_cstdio.h: Same here.
* testsuite/17_intro/header_cstring.cc: Same.
* include/c_std/bits/std_cstring.h: Include std_cstddef.h for size_t.
* testsuite/17_intro/header_cstring.cc: New file. Check for
size_t in namespace std.
* include/c_std/bits/std_cwchar.h: Explicit checks for mbstate_t.
* acconfig.h (HAVE_MBSTATE_T): Add.
* config.h.in: Regenerate.
* acinclude.m4(GLIBCPP_CHECK_WCHAR_T_SUPPORT): Always test for
mbstate_t.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/17_intro/headers_c++.cc: New file.
* testsuite/17_intro/headers_c.cc: Small changes.
Index: include/c_std/bits/std_cwchar.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_cwchar.h,v
retrieving revision 1.3
diff -c -p -r1.3 std_cwchar.h
*** std_cwchar.h 2000/12/22 00:27:01 1.3
--- std_cwchar.h 2001/01/02 07:31:37
***************
*** 1,6 ****
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000 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
--- 1,6 ----
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001 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
***************
*** 37,56 ****
#define _CPP_CWCHAR 1
#include <bits/c++config.h>
#include <bits/std_cstdio.h>
#include <bits/std_cstdarg.h>
! #if _GLIBCPP_USE_WCHAR_T
#pragma GCC system_header
#include <wchar.h>
// Get rid of those macros defined in <wchar.h> in lieu of real functions.
#undef getwchar
namespace std
{
using ::wint_t;
- using ::mbstate_t;
extern "C" wint_t btowc(int);
extern "C" int wctob(wint_t);
--- 37,75 ----
#define _CPP_CWCHAR 1
#include <bits/c++config.h>
+ #include <bits/std_cstddef.h>
#include <bits/std_cstdio.h>
#include <bits/std_cstdarg.h>
! #if _GLIBCPP_HAVE_WCHAR_H
#pragma GCC system_header
#include <wchar.h>
+ #endif
+
+ // Need to do a bit of trickery here with mbstate_t as char_traits
+ // assumes it is in wchar.h, regardless of wchar_t specializations.
+ #ifndef _GLIBCPP_HAVE_MBSTATE_T
+ extern "C"
+ {
+ typedef struct
+ {
+ int __fill[6];
+ } mbstate_t;
+ }
+ #endif
+
+ namespace std
+ {
+ using ::mbstate_t;
+ }
// Get rid of those macros defined in <wchar.h> in lieu of real functions.
#undef getwchar
+ #if _GLIBCPP_USE_WCHAR_T
namespace std
{
using ::wint_t;
extern "C" wint_t btowc(int);
extern "C" int wctob(wint_t);
*************** namespace std
*** 117,157 ****
extern "C" unsigned long long int wcstoull(const wchar_t*, wchar_t**, int);
#endif
}
-
- #else
- extern "C"
- {
- typedef struct
- {
- int __fill[6];
- } mbstate_t;
- }
-
- namespace std
- {
- using ::mbstate_t;
- }
#endif //_GLIBCPP_USE_WCHAR_T
-
#endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
--- 136,141 ----
Index: include/c_std/bits/std_cstdio.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_cstdio.h,v
retrieving revision 1.5
diff -c -p -r1.5 std_cstdio.h
*** std_cstdio.h 2000/12/22 00:27:01 1.5
--- std_cstdio.h 2001/01/02 07:31:37
***************
*** 1,6 ****
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997-1999, 2000 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
--- 1,6 ----
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001 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
***************
*** 36,42 ****
--- 36,44 ----
#ifndef _CPP_CSTDIO
#define _CPP_CSTDIO 1
+ #include <bits/c++config.h>
#include <bits/std_cstdarg.h>
+ #include <bits/std_cstddef.h>
#pragma GCC system_header
#include <stdio.h>
Index: include/c_std/bits/std_cstdlib.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_cstdlib.h,v
retrieving revision 1.5
diff -c -p -r1.5 std_cstdlib.h
*** std_cstdlib.h 2001/01/01 00:06:50 1.5
--- std_cstdlib.h 2001/01/02 07:31:37
***************
*** 1,6 ****
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997-1999, 2000 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
--- 1,6 ----
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001 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
***************
*** 37,46 ****
--- 37,50 ----
#define _CPP_CSTDLIB 1
#include <bits/c++config.h>
+ #include <bits/std_cstddef.h>
#pragma GCC system_header
#include <stdlib.h>
+ // Get rid of those macros defined in <stdio.h> in lieu of real functions.
+ #undef mblen
+
namespace std
{
using ::div_t;
*************** namespace std
*** 85,93 ****
extern "C" long int labs(long int);
extern "C" div_t div(int, int);
extern "C" ldiv_t ldiv(long int, long int);
- #ifdef mblen
- #undef mblen
- #endif
extern "C" int mblen(const char*, size_t);
extern "C" int mbtowc(wchar_t*, const char*, size_t);
extern "C" int wctomb(char*, wchar_t);
--- 89,94 ----
Index: include/c_std/bits/std_cstring.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_cstring.h,v
retrieving revision 1.3
diff -c -p -r1.3 std_cstring.h
*** std_cstring.h 2000/12/22 00:27:01 1.3
--- std_cstring.h 2001/01/02 07:31:38
***************
*** 1,6 ****
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997-1999, 2000 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
--- 1,6 ----
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001 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
***************
*** 37,42 ****
--- 37,43 ----
#define _CPP_CSTRING 1
#include <bits/c++config.h>
+ #include <bits/std_cstddef.h>
#pragma GCC system_header
#include <string.h>
Index: include/c_std/bits/std_ctime.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_ctime.h,v
retrieving revision 1.3
diff -c -p -r1.3 std_ctime.h
*** std_ctime.h 2000/12/22 00:27:01 1.3
--- std_ctime.h 2001/01/02 07:31:38
***************
*** 1,6 ****
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997-1999, 2000 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
--- 1,6 ----
// -*- C++ -*- forwarding header.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001 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
***************
*** 35,40 ****
--- 35,43 ----
#ifndef _CPP_CTIME
#define _CPP_CTIME 1
+
+ #include <bits/c++config.h>
+ #include <bits/std_cstddef.h>
#pragma GCC system_header
#include <time.h>
Index: acconfig.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/acconfig.h,v
retrieving revision 1.14
diff -c -p -r1.14 acconfig.h
*** acconfig.h 2000/12/13 09:25:42 1.14
--- acconfig.h 2001/01/02 07:31:39
***************
*** 1,5 ****
--- 1,11 ----
// acconfig.h symbols and macros for libstdc++ v3 -*- C++ -*-
+ // Define if GCC support for __complex__ float is buggy.
+ #undef _GLIBCPP_BUGGY_FLOAT_COMPLEX
+
+ // Define if GCC support for __complex__ is buggy.
+ #undef _GLIBCPP_BUGGY_COMPLEX
+
// Include support for multiple threads, e.g., in the I/O package.
#undef _GLIBCPP_USE_THREADS
***************
*** 15,36 ****
// Define if code specialized for wchar_t should be used.
#undef _GLIBCPP_USE_WCHAR_T
! // Define if lldiv_t exists in stdlib.h.
! #undef HAVE_LLDIV_T
! /* Define if you have the atan2f function. */
! #define _GLIBCPP_HAVE_ATAN2F 1
! /* Define if you have the atan2l function. */
! #define _GLIBCPP_HAVE_ATAN2L 1
! /* Define if you have the copysignf function. */
! #define _GLIBCPP_HAVE_COPYSIGNF 1
! /* Define if you have the modff function. */
#undef HAVE_MODFF
! /* Define if you have the modfl function. */
#undef HAVE_MODFL
// Define if the compiler/host combination has __builtin_abs
--- 21,45 ----
// Define if code specialized for wchar_t should be used.
#undef _GLIBCPP_USE_WCHAR_T
! // Define if you have the atan2f function.
! #undef _GLIBCPP_HAVE_ATAN2F
! // Define if you have the atan2l function.
! #undef _GLIBCPP_HAVE_ATAN2L
! // Define if you have the copysignf function.
! #undef _GLIBCPP_HAVE_COPYSIGNF
! // Define if lldiv_t exists in stdlib.h.
! #undef HAVE_LLDIV_T
!
! // Define if mbstate_t exists in wchar.h. */
! #undef HAVE_MBSTATE_T
! // Define if you have the modff function. */
#undef HAVE_MODFF
! // Define if you have the modfl function. */
#undef HAVE_MODFL
// Define if the compiler/host combination has __builtin_abs
***************
*** 74,85 ****
// Define if the compiler/host combination has __builtin_sqrtl
#undef HAVE___BUILTIN_SQRTL
-
- // Define if GCC support for __complex__ float is buggy.
- #undef _GLIBCPP_BUGGY_FLOAT_COMPLEX
-
- // Define if GCC support for __complex__ is buggy.
- #undef _GLIBCPP_BUGGY_COMPLEX
// Define if LC_MESSAGES is available in <locale.h>.
#undef HAVE_LC_MESSAGES
--- 83,88 ----
Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/acinclude.m4,v
retrieving revision 1.116
diff -c -p -r1.116 acinclude.m4
*** acinclude.m4 2000/12/23 07:13:55 1.116
--- acinclude.m4 2001/01/02 07:31:43
*************** dnl If --disable-c-mbchar was given, no
*** 967,1069 ****
dnl must have been previously checked.)
dnl
dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found
! dnl Define _GLIBCPP_NEED_MBSTATE_T if mbstate_t is not in wchar.h
dnl
dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
- if test x$enable_c_mbchar != xno; then
! dnl Sanity check for existence of ISO C99 headers for extended encoding.
! AC_CHECK_HEADER(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
! AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
!
! dnl Only continue checking if the ISO C99 headers exist.
! if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes; then
!
! dnl Test wchar.h for mbstate_t, which is needed for char_traits
! dnl and others.
! AC_MSG_CHECKING([for mbstate_t])
! AC_TRY_COMPILE([#include <wchar.h>],
! [mbstate_t teststate;],
! use_native_mbstatet=yes, use_native_mbstatet=no)
! AC_MSG_RESULT($use_native_mbstatet)
!
! dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
! dnl numeric_limits can instantiate type_traits<wchar_t>
! AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
! AC_TRY_COMPILE([#include <wchar.h>],
! [int i = WCHAR_MIN; int j = WCHAR_MAX;],
! has_wchar_minmax=yes, has_wchar_minmax=no)
! AC_MSG_RESULT($has_wchar_minmax)
! dnl Test wchar.h for WEOF, which is what we use to determine whether
! dnl to specialize for char_traits<wchar_t> or not.
! AC_MSG_CHECKING([for WEOF])
! AC_TRY_COMPILE([
! #include <wchar.h>
! #include <stddef.h>],
! [wint_t i = WEOF;],
! has_weof=yes, has_weof=no)
! AC_MSG_RESULT($has_weof)
!
! dnl Tests for wide character functions used in char_traits<wchar_t>.
! AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \
! wcsrtombs mbsrtowcs, ac_wfuncs=yes, ac_wfuncs=no)
!
! AC_MSG_CHECKING([for ISO C99 wchar_t support])
! if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \
! && test x"$ac_wfuncs" = xyes; then
! ac_isoC99_wchar_t=yes
! else
! ac_isoC99_wchar_t=no
! fi
! AC_MSG_RESULT($ac_isoC99_wchar_t)
!
! dnl Use iconv for wchar_t to char conversions. As such, check for
! dnl X/Open Portability Guide, version 2 features (XPG2).
! AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
! AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
! dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
! AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
! ac_save_LIBS="$LIBS"
! LIBS="$LIBS $libiconv"
! AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
! ac_XPG2funcs=yes, ac_XPG2funcs=no)
! LIBS="$ac_save_LIBS"
! AC_MSG_CHECKING([for XPG2 wchar_t support])
! if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \
! && test x"$ac_XPG2funcs" = xyes; then
! ac_XPG2_wchar_t=yes
! else
! ac_XPG2_wchar_t=no
! fi
! AC_MSG_RESULT($ac_XPG2_wchar_t)
!
! dnl At the moment, only enable wchar_t specializations if all the
! dnl above support is present.
! AC_MSG_CHECKING([for enabled wchar_t specializations])
! if test x"$ac_isoC99_wchar_t" = xyes \
! && test x"$ac_XPG2_wchar_t" = xyes; then
! libinst_wstring_la="libinst-wstring.la"
! AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
! AC_MSG_RESULT("yes")
! else
! libinst_wstring_la=""
! AC_MSG_RESULT("no")
! fi
! AC_SUBST(libinst_wstring_la)
else
! AC_MSG_WARN([<wchar.h> not found])
fi
!
else
! dnl Wide characters disabled by the user. Maybe print a warning?
! :
fi
])
--- 967,1068 ----
dnl must have been previously checked.)
dnl
dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found
! dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
dnl
dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
! dnl Test wchar.h for mbstate_t, which is needed for char_traits and
! dnl others even if wchar_t support is not on.
! AC_MSG_CHECKING([for mbstate_t])
! AC_TRY_COMPILE([#include <wchar.h>],
! [mbstate_t teststate;],
! have_mbstate_t=yes, have_mbstate_t=no)
! AC_MSG_RESULT($have_mbstate_t)
! if test x"$have_mbstate_t" = xyes; then
! AC_DEFINE(HAVE_MBSTATE_T)
! fi
!
! dnl Sanity check for existence of ISO C99 headers for extended encoding.
! AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
! AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
!
! dnl Only continue checking if the ISO C99 headers exist and support is on.
! if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes \
! && test x"$enable_c_mbchar" != xno; then
!
! dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
! dnl numeric_limits can instantiate type_traits<wchar_t>
! AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
! AC_TRY_COMPILE([#include <wchar.h>],
! [int i = WCHAR_MIN; int j = WCHAR_MAX;],
! has_wchar_minmax=yes, has_wchar_minmax=no)
! AC_MSG_RESULT($has_wchar_minmax)
! dnl Test wchar.h for WEOF, which is what we use to determine whether
! dnl to specialize for char_traits<wchar_t> or not.
! AC_MSG_CHECKING([for WEOF])
! AC_TRY_COMPILE([
! #include <wchar.h>
! #include <stddef.h>],
! [wint_t i = WEOF;],
! has_weof=yes, has_weof=no)
! AC_MSG_RESULT($has_weof)
!
! dnl Tests for wide character functions used in char_traits<wchar_t>.
! AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \
! wcsrtombs mbsrtowcs, ac_wfuncs=yes, ac_wfuncs=no)
!
! AC_MSG_CHECKING([for ISO C99 wchar_t support])
! if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \
! && test x"$ac_wfuncs" = xyes; then
! ac_isoC99_wchar_t=yes
! else
! ac_isoC99_wchar_t=no
! fi
! AC_MSG_RESULT($ac_isoC99_wchar_t)
!
! dnl Use iconv for wchar_t to char conversions. As such, check for
! dnl X/Open Portability Guide, version 2 features (XPG2).
! AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
! AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
! dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
! AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
! ac_save_LIBS="$LIBS"
! LIBS="$LIBS $libiconv"
! AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
! ac_XPG2funcs=yes, ac_XPG2funcs=no)
! LIBS="$ac_save_LIBS"
! AC_MSG_CHECKING([for XPG2 wchar_t support])
! if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \
! && test x"$ac_XPG2funcs" = xyes; then
! ac_XPG2_wchar_t=yes
! else
! ac_XPG2_wchar_t=no
! fi
! AC_MSG_RESULT($ac_XPG2_wchar_t)
+ dnl At the moment, only enable wchar_t specializations if all the
+ dnl above support is present.
+ AC_MSG_CHECKING([for enabled wchar_t specializations])
+ if test x"$ac_isoC99_wchar_t" = xyes \
+ && test x"$ac_XPG2_wchar_t" = xyes; then
+ libinst_wstring_la="libinst-wstring.la"
+ AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
+ AC_MSG_RESULT("yes")
else
! libinst_wstring_la=""
! AC_MSG_RESULT("no")
fi
! AC_SUBST(libinst_wstring_la)
!
else
! dnl Wide characters disabled by the user.
! AC_MSG_WARN([wchar_t support disabled.])
fi
])