diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2fb1197050807ccb55d59608aa156ce6e914666b..60af9a7d1e7ad75c0c23d5ab9041db41dc7ab0b2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2008-09-07 Paolo Carlini <paolo.carlini@oracle.com> + + * acinclude.m4 ([GLIBCXX_CHECK_C99_TR1]): Check wcstoimax and + wcstoumax, define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1. + * include/tr1_impl/cinttypes: Use the latter. + * testsuite/tr1/8_c_compatibility/cinttypes/functions.cc: Likewise. + * configure: Regenerate. + * config.h.in: Likewise. + 2008-09-05 Peter Dimov <pdimov@mmltd.net> * testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc: New. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index b334657042d5183a7e43941a9a96a077874ba8bb..2485922eb701e4e573850f0d04b190dd30e39d00 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -1520,7 +1520,7 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [ fi # Check for the existence of <inttypes.h> functions (NB: doesn't make - # sense if the previous check fails, per C99, 7.8/1). + # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1). ac_c99_inttypes_tr1=no; if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>]) @@ -1541,6 +1541,27 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [ <tr1/cinttypes> in namespace std::tr1.]) fi + # Check for the existence of whcar_t <inttypes.h> functions (NB: doesn't + # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1). + ac_c99_inttypes_wchar_t_tr1=no; + if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then + AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>]) + AC_TRY_COMPILE([#include <inttypes.h>], + [intmax_t base; + const wchar_t* s; + wchar_t** endptr; + intmax_t ret = wcstoimax(s, endptr, base); + uintmax_t uret = wcstoumax(s, endptr, base); + ],[ac_c99_inttypes_wchar_t_tr1=yes], + [ac_c99_inttypes_wchar_t_tr1=no]) + fi + AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1) + if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then + AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1, + [Define if wchar_t C99 functions in <inttypes.h> should be + imported in <tr1/cinttypes> in namespace std::tr1.]) + fi + # Check for the existence of the <stdbool.h> header. AC_CHECK_HEADERS(stdbool.h) diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 91e6cb87e0e2a67cbb80b481385ac8dfaa6e7721..8e3b000fbd189ef86910c8159786cb283047366d 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -760,6 +760,10 @@ <tr1/cinttypes> in namespace std::tr1. */ #undef _GLIBCXX_USE_C99_INTTYPES_TR1 +/* Define if wchar_t C99 functions in <inttypes.h> should be imported in + <tr1/cinttypes> in namespace std::tr1. */ +#undef _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 + /* Define if C99 functions or macros in <math.h> should be imported in <cmath> in namespace std. */ #undef _GLIBCXX_USE_C99_MATH diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index a6223e7a40df8b42eed1fd397feaddcb1362014a..1a1c4182c7d3df350a3078d79be47a2c9e70c316 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -20351,7 +20351,7 @@ _ACEOF fi # Check for the existence of <inttypes.h> functions (NB: doesn't make - # sense if the previous check fails, per C99, 7.8/1). + # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1). ac_c99_inttypes_tr1=no; if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then echo "$as_me:$LINENO: checking for ISO C99 support to TR1 in <inttypes.h>" >&5 @@ -20419,6 +20419,73 @@ _ACEOF fi + # Check for the existence of whcar_t <inttypes.h> functions (NB: doesn't + # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1). + ac_c99_inttypes_wchar_t_tr1=no; + if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then + echo "$as_me:$LINENO: checking for wchar_t ISO C99 support to TR1 in <inttypes.h>" >&5 +echo $ECHO_N "checking for wchar_t ISO C99 support to TR1 in <inttypes.h>... $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 <inttypes.h> +int +main () +{ +intmax_t base; + const wchar_t* s; + wchar_t** endptr; + intmax_t ret = wcstoimax(s, endptr, base); + uintmax_t uret = wcstoumax(s, endptr, base); + + ; + return 0; +} +_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_c99_inttypes_wchar_t_tr1=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_c99_inttypes_wchar_t_tr1=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + fi + echo "$as_me:$LINENO: result: $ac_c99_inttypes_wchar_t_tr1" >&5 +echo "${ECHO_T}$ac_c99_inttypes_wchar_t_tr1" >&6 + if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then + +cat >>confdefs.h <<\_ACEOF +#define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 +_ACEOF + + fi + # Check for the existence of the <stdbool.h> header. for ac_header in stdbool.h diff --git a/libstdc++-v3/include/tr1_impl/cinttypes b/libstdc++-v3/include/tr1_impl/cinttypes index 17625931100e5ac0c8f3c33d5ee217e159a0ad3d..2dfafa824f9060d3fb1b5293df3ef8a6a89b8d69 100644 --- a/libstdc++-v3/include/tr1_impl/cinttypes +++ b/libstdc++-v3/include/tr1_impl/cinttypes @@ -1,6 +1,6 @@ // TR1 cinttypes -*- C++ -*- -// Copyright (C) 2007 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008 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 @@ -64,7 +64,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 using ::strtoimax; using ::strtoumax; -#ifdef _GLIBCXX_USE_WCHAR_T +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 using ::wcstoimax; using ::wcstoumax; #endif diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cinttypes/functions.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cinttypes/functions.cc index cd5a0378554868f92dc1155944a99fc5d0780c0b..97bab0c260b1ca59a2c15d5ddd9947fb18598c37 100644 --- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/cinttypes/functions.cc +++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/cinttypes/functions.cc @@ -2,7 +2,7 @@ // 2006-01-30 Paolo Carlini <pcarlini@suse.de> // -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -31,7 +31,7 @@ void test01() std::tr1::intmax_t i = 0, numer = 0, denom = 0, base = 0; const char* s = 0; char** endptr = 0; -#ifdef _GLIBCXX_USE_WCHAR_T +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 const wchar_t* ws = 0; wchar_t** wendptr = 0; #endif @@ -49,7 +49,7 @@ void test01() ret = std::tr1::strtoimax(s, endptr, base); uret = std::tr1::strtoumax(s, endptr, base); -#ifdef _GLIBCXX_USE_WCHAR_T +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 ret = std::tr1::wcstoimax(ws, wendptr, base); uret = std::tr1::wcstoumax(ws, wendptr, base); #endif