From fc9ab7b4c0c1b54407d3ad4f3219014c6f5e3414 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 6 Aug 2008 12:25:00 +0000 Subject: [PATCH] acinclude.m4 ([GLIBCXX_CHECK_INT64_T]): Also check whether int64_t is actually a typedef to long or long long. 2008-08-06 Paolo Carlini * acinclude.m4 ([GLIBCXX_CHECK_INT64_T]): Also check whether int64_t is actually a typedef to long or long long. * include/bits/postypes.h: If int64_t is actually a typedef for long or long long don't include unnecessarily. * configure: Regenerate. * config.h.in: Likewise. From-SVN: r138797 --- libstdc++-v3/ChangeLog | 9 ++ libstdc++-v3/acinclude.m4 | 40 ++++++- libstdc++-v3/config.h.in | 6 + libstdc++-v3/configure | 160 ++++++++++++++++++++++++++- libstdc++-v3/include/bits/postypes.h | 9 +- 5 files changed, 218 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 704ae7c810c..8d81860ee74 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +008-08-06 Paolo Carlini + + * acinclude.m4 ([GLIBCXX_CHECK_INT64_T]): Also check whether int64_t + is actually a typedef to long or long long. + * include/bits/postypes.h: If int64_t is actually a typedef for + long or long long don't include unnecessarily. + * configure: Regenerate. + * config.h.in: Likewise. + 2008-08-05 Paolo Carlini * testsuite/util/testsuite_api.h (diamond_derivation<>::test): diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 0a669c9a7fa..50f207c2382 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -466,8 +466,13 @@ AC_DEFUN([GLIBCXX_CHECK_WRITEV], [ dnl dnl Check whether int64_t is available in , and define HAVE_INT64_T. +dnl Also check whether int64_t is actually a typedef to long or long long. dnl AC_DEFUN([GLIBCXX_CHECK_INT64_T], [ + + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_MSG_CHECKING([for int64_t]) AC_CACHE_VAL(glibcxx_cv_INT64_T, [ AC_TRY_COMPILE( @@ -476,10 +481,43 @@ AC_DEFUN([GLIBCXX_CHECK_INT64_T], [ [glibcxx_cv_INT64_T=yes], [glibcxx_cv_INT64_T=no]) ]) + if test $glibcxx_cv_INT64_T = yes; then AC_DEFINE(HAVE_INT64_T, 1, [Define if int64_t is available in .]) + AC_MSG_RESULT($glibcxx_cv_INT64_T) + + AC_MSG_CHECKING([for int64_t as long]) + AC_CACHE_VAL(glibcxx_cv_int64_t_long, [ + AC_TRY_COMPILE( + [#include + template struct same { enum { value = -1 }; }; + template struct same { enum { value = 1 }; }; + int array[same::value];], [], + [glibcxx_cv_int64_t_long=yes], [glibcxx_cv_int64_t_long=no]) + ]) + + if test $glibcxx_cv_int64_t_long = yes; then + AC_DEFINE(HAVE_INT64_T_LONG, 1, [Define if int64_t is a long.]) + AC_MSG_RESULT($glibcxx_cv_int64_t_long) + fi + + AC_MSG_CHECKING([for int64_t as long long]) + AC_CACHE_VAL(glibcxx_cv_int64_t_long_long, [ + AC_TRY_COMPILE( + [#include + template struct same { enum { value = -1 }; }; + template struct same { enum { value = 1 }; }; + int array[same::value];], [], + [glibcxx_cv_int64_t_long_long=yes], [glibcxx_cv_int64_t_long_long=no]) + ]) + + if test $glibcxx_cv_int64_t_long_long = yes; then + AC_DEFINE(HAVE_INT64_T_LONG_LONG, 1, [Define if int64_t is a long long.]) + AC_MSG_RESULT($glibcxx_cv_int64_t_long_long) + fi fi - AC_MSG_RESULT($glibcxx_cv_INT64_T) + + AC_LANG_RESTORE ]) diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 256637abcec..438fe1488c4 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -184,6 +184,12 @@ /* Define if int64_t is available in . */ #undef HAVE_INT64_T +/* Define if int64_t is a long. */ +#undef HAVE_INT64_T_LONG + +/* Define if int64_t is a long long. */ +#undef HAVE_INT64_T_LONG_LONG + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 2ea940ae8a1..5fb310780a6 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -39677,6 +39677,16 @@ echo "${ECHO_T}$glibcxx_cv_WRITEV" >&6 # For the __streamoff_base_type typedef. + + + + ac_ext=cc +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 + + echo "$as_me:$LINENO: checking for int64_t" >&5 echo $ECHO_N "checking for int64_t... $ECHO_C" >&6 if test "${glibcxx_cv_INT64_T+set}" = set; then @@ -39707,7 +39717,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { 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 @@ -39731,16 +39741,160 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi + if test $glibcxx_cv_INT64_T = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_INT64_T 1 _ACEOF - fi - echo "$as_me:$LINENO: result: $glibcxx_cv_INT64_T" >&5 + echo "$as_me:$LINENO: result: $glibcxx_cv_INT64_T" >&5 echo "${ECHO_T}$glibcxx_cv_INT64_T" >&6 + echo "$as_me:$LINENO: checking for int64_t as long" >&5 +echo $ECHO_N "checking for int64_t as long... $ECHO_C" >&6 + if test "${glibcxx_cv_int64_t_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + template struct same { enum { value = -1 }; }; + template struct same { enum { value = 1 }; }; + int array[same::value]; +int +main () +{ + + ; + 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 + glibcxx_cv_int64_t_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +glibcxx_cv_int64_t_long=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +fi + + + if test $glibcxx_cv_int64_t_long = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_INT64_T_LONG 1 +_ACEOF + + echo "$as_me:$LINENO: result: $glibcxx_cv_int64_t_long" >&5 +echo "${ECHO_T}$glibcxx_cv_int64_t_long" >&6 + fi + + echo "$as_me:$LINENO: checking for int64_t as long long" >&5 +echo $ECHO_N "checking for int64_t as long long... $ECHO_C" >&6 + if test "${glibcxx_cv_int64_t_long_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + template struct same { enum { value = -1 }; }; + template struct same { enum { value = 1 }; }; + int array[same::value]; +int +main () +{ + + ; + 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 + glibcxx_cv_int64_t_long_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +glibcxx_cv_int64_t_long_long=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +fi + + + if test $glibcxx_cv_int64_t_long_long = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_INT64_T_LONG_LONG 1 +_ACEOF + + echo "$as_me:$LINENO: result: $glibcxx_cv_int64_t_long_long" >&5 +echo "${ECHO_T}$glibcxx_cv_int64_t_long_long" >&6 + fi + fi + + 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 LFS support. diff --git a/libstdc++-v3/include/bits/postypes.h b/libstdc++-v3/include/bits/postypes.h index cdcafe2051f..1bc972af187 100644 --- a/libstdc++-v3/include/bits/postypes.h +++ b/libstdc++-v3/include/bits/postypes.h @@ -49,7 +49,8 @@ // XXX If is really needed, make sure to define the macros, // in order not to break (and in C++0x). // Reconsider all this as soon as possible... -#ifdef _GLIBCXX_HAVE_INT64_T +#if (defined(_GLIBCXX_HAVE_INT64_T) && !defined(_GLIBCXX_HAVE_INT64_T_LONG) \ + && !defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)) #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif @@ -76,7 +77,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * Note: In versions of GCC up to and including GCC 3.3, streamoff * was typedef long. */ -#ifdef _GLIBCXX_HAVE_INT64_T +#ifdef _GLIBCXX_HAVE_INT64_T_LONG + typedef long streamoff; +#elif defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG) + typedef long long streamoff; +#elif defined(_GLIBCXX_HAVE_INT64_T) typedef int64_t streamoff; #else typedef long long streamoff;