acinclude.m4 ([GLIBCXX_CHECK_STDIO_MACROS]): New, checks for common values of EOF, SEEK_CUR, SEEK_END.

2008-08-06  Paolo Carlini  <paolo.carlini@oracle.com>

	* acinclude.m4 ([GLIBCXX_CHECK_STDIO_MACROS]): New, checks for
	common values of EOF, SEEK_CUR, SEEK_END.
	* configure.ac: Use it.
	* include/bits/ios_base.h: Likewise.
	* include/bits/char_traits.h: Likewise.
	* config/locale/gnu/ctype_members.cc: Include <cstdio>.
	* config/locale/generic/ctype_members.cc: Likewise.
	* testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust dg-error lines.
	* testsuite/27_io/ios_base/cons/copy_neg.cc: Likewise.
	* configure: Regenerate.
	* config.h.in: Likewise.

From-SVN: r138829
This commit is contained in:
Paolo Carlini 2008-08-06 23:17:05 +00:00 committed by Paolo Carlini
parent 865a3a421a
commit 1814157e88
11 changed files with 143 additions and 12 deletions

View File

@ -1,4 +1,18 @@
008-08-06 Paolo Carlini <paolo.carlini@oracle.com>
2008-08-06 Paolo Carlini <paolo.carlini@oracle.com>
* acinclude.m4 ([GLIBCXX_CHECK_STDIO_MACROS]): New, checks for
common values of EOF, SEEK_CUR, SEEK_END.
* configure.ac: Use it.
* include/bits/ios_base.h: Likewise.
* include/bits/char_traits.h: Likewise.
* config/locale/gnu/ctype_members.cc: Include <cstdio>.
* config/locale/generic/ctype_members.cc: Likewise.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust dg-error lines.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Likewise.
* configure: Regenerate.
* config.h.in: Likewise.
2008-08-06 Paolo Carlini <paolo.carlini@oracle.com>
* acinclude.m4 ([GLIBCXX_CHECK_INT64_T]): Also check whether int64_t
is actually a typedef to long or long long.

View File

@ -1460,6 +1460,29 @@ AC_DEFUN([GLIBCXX_CHECK_RANDOM_TR1], [
])
dnl
dnl Check whether EOF, SEEK_CUR, and SEEK_END have the most common values:
dnl in that case including <cstdio> in some C++ headers can be avoided.
dnl
AC_DEFUN([GLIBCXX_CHECK_STDIO_MACROS], [
AC_MSG_CHECKING([for EOF == -1, SEEK_CUR == 1, SEEK_END == 2])
AC_CACHE_VAL(glibcxx_cv_stdio_macros, [
AC_TRY_COMPILE([#include <stdio.h>],
[#if ((EOF != -1) || (SEEK_CUR != 1) || (SEEK_END != 2))
unusual values...
#endif
], [glibcxx_cv_stdio_macros=yes],
[glibcxx_cv_stdio_macros=no])
])
AC_MSG_RESULT($glibcxx_cv_stdio_macros)
if test x"$glibcxx_cv_stdio_macros" = x"yes"; then
AC_DEFINE(_GLIBCXX_STDIO_MACROS, 1,
[Define if EOF == -1, SEEK_CUR == 1, SEEK_END == 2.])
fi
])
dnl
dnl Check whether macros, etc are present for <system_error>
dnl

View File

@ -767,6 +767,9 @@
/* Define if the compiler is configured for setjmp/longjmp exceptions. */
#undef _GLIBCXX_SJLJ_EXCEPTIONS
/* Define if EOF == -1, SEEK_CUR == 1, SEEK_END == 2. */
#undef _GLIBCXX_STDIO_MACROS
/* Define to use symbol versioning in the shared library. */
#undef _GLIBCXX_SYMVER

View File

@ -1,6 +1,6 @@
// std::ctype implementation details, generic version -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -37,6 +37,7 @@
#include <locale>
#include <cstdlib>
#include <cstring>
#include <cstdio>
_GLIBCXX_BEGIN_NAMESPACE(std)

View File

@ -1,6 +1,6 @@
// std::ctype implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -35,6 +35,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <cstdio>
#include <bits/c++locale_internal.h>
_GLIBCXX_BEGIN_NAMESPACE(std)

View File

@ -41812,6 +41812,78 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
#
echo "$as_me:$LINENO: checking for EOF == -1, SEEK_CUR == 1, SEEK_END == 2" >&5
echo $ECHO_N "checking for EOF == -1, SEEK_CUR == 1, SEEK_END == 2... $ECHO_C" >&6
if test "${glibcxx_cv_stdio_macros+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 <stdio.h>
int
main ()
{
#if ((EOF != -1) || (SEEK_CUR != 1) || (SEEK_END != 2))
unusual values...
#endif
;
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_c_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_stdio_macros=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
glibcxx_cv_stdio_macros=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $glibcxx_cv_stdio_macros" >&5
echo "${ECHO_T}$glibcxx_cv_stdio_macros" >&6
if test x"$glibcxx_cv_stdio_macros" = x"yes"; then
cat >>confdefs.h <<\_ACEOF
#define _GLIBCXX_STDIO_MACROS 1
_ACEOF
fi
# For TLS support.
# Check whether --enable-tls or --disable-tls was given.

View File

@ -167,6 +167,9 @@ if $GLIBCXX_IS_NATIVE; then
# For gettimeofday support.
GLIBCXX_CHECK_GETTIMEOFDAY
#
GLIBCXX_CHECK_STDIO_MACROS
# For TLS support.
GCC_CHECK_TLS

View File

@ -1,7 +1,7 @@
// Character Traits for use by standard string and iostream -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
// 2006, 2007
// 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -45,9 +45,15 @@
#include <bits/stl_algobase.h> // std::copy, std::fill_n
#include <bits/postypes.h> // For streampos
#include <cstdio> // For EOF
#include <cwchar> // For WEOF, wmemmove, wmemset, etc.
#ifndef _GLIBCXX_STDIO_MACROS
# include <cstdio> // For EOF
# define _CHAR_TRAITS_EOF EOF
#else
# define _CHAR_TRAITS_EOF (-1)
#endif
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
/**
@ -138,7 +144,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
static int_type
eof()
{ return static_cast<int_type>(EOF); }
{ return static_cast<int_type>(_CHAR_TRAITS_EOF); }
static int_type
not_eof(const int_type& __c)
@ -292,7 +298,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return __c1 == __c2; }
static int_type
eof() { return static_cast<int_type>(EOF); }
eof() { return static_cast<int_type>(_CHAR_TRAITS_EOF); }
static int_type
not_eof(const int_type& __c)

View File

@ -46,7 +46,15 @@
#include <ext/atomicity.h>
#include <bits/localefwd.h>
#include <bits/locale_classes.h>
#include <cstdio> // For SEEK_CUR, SEEK_END
#ifndef _GLIBCXX_STDIO_MACROS
# include <cstdio> // For SEEK_CUR, SEEK_END
# define _IOS_BASE_SEEK_CUR SEEK_CUR
# define _IOS_BASE_SEEK_END SEEK_END
#else
# define _IOS_BASE_SEEK_CUR 1
# define _IOS_BASE_SEEK_END 2
#endif
_GLIBCXX_BEGIN_NAMESPACE(std)
@ -186,8 +194,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
enum _Ios_Seekdir
{
_S_beg = 0,
_S_cur = SEEK_CUR,
_S_end = SEEK_END,
_S_cur = _IOS_BASE_SEEK_CUR,
_S_end = _IOS_BASE_SEEK_END,
_S_ios_seekdir_end = 1L << 16
};

View File

@ -43,5 +43,5 @@ void test01()
}
// { dg-error "synthesized" "" { target *-*-* } 42 }
// { dg-error "within this context" "" { target *-*-* } 35 }
// { dg-error "is private" "" { target *-*-* } 786 }
// { dg-error "is private" "" { target *-*-* } 794 }
// { dg-error "operator=" "" { target *-*-* } 0 }

View File

@ -43,5 +43,5 @@ void test02()
}
// { dg-error "within this context" "" { target *-*-* } 36 }
// { dg-error "synthesized" "" { target *-*-* } 42 }
// { dg-error "is private" "" { target *-*-* } 783 }
// { dg-error "is private" "" { target *-*-* } 791 }
// { dg-error "copy constructor" "" { target *-*-* } 0 }