]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
acinclude.m4 ([GLIBCXX_CHECK_STDIO_MACROS]): New, checks for common values of EOF...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 6 Aug 2008 23:17:05 +0000 (23:17 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 6 Aug 2008 23:17:05 +0000 (23:17 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/acinclude.m4
libstdc++-v3/config.h.in
libstdc++-v3/config/locale/generic/ctype_members.cc
libstdc++-v3/config/locale/gnu/ctype_members.cc
libstdc++-v3/configure
libstdc++-v3/configure.ac
libstdc++-v3/include/bits/char_traits.h
libstdc++-v3/include/bits/ios_base.h
libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc
libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc

index 8d81860ee7492cd2114fa44af5b3c626e7d4043f..2a4e4adfa3144691a79788d2e4b6fbf10c55bcdc 100644 (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.
index 50f207c238265eb49b533991f785370387c029dc..3197682df8ff4749b4e47a3b4d4cc6407e667d25 100644 (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
index 438fe1488c4789aa4d54af4a6960444d4db3d437..b4cb3f3b5c7ae7b4bf7e3c03e16faf7e9e827a60 100644 (file)
 /* 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
 
index ae1c7cf1d0fd59aa18f9fedcd31460f9e3cfce54..6b4fbd7ea7d9edffcefc62d55cd400cc45e4a3ea 100644 (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)
 
index 3aec312f89b378c7fbedb0e17e2a1f63e478c489..9e517605914266551f62a9c3a1d323d0bcbddcbd 100644 (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)
index 5fb310780a641749d70a937f831eaf9aec4a7b54..fd776092e1f9548aac066dc594d36215e83d6acb 100755 (executable)
@@ -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.
index b23e17714dd2e90938387ef934b4b9e4c781eaf6..6f530b3faa4fb2dfbd43d6ce1c59bf7d28e895ac 100644 (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
 
index ae0f6cfbe092a694674be9da146a68ab01415a9c..85e4167758e16acb02d09ff3d66635e7facc0952 100644 (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
 
 #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)
index 95a3d2b91042a7acef8b9e62406f1799f0cf986b..8b55028c537cfc776af4cada4c7772775bc09a78 100644 (file)
 #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 
     };
 
index 5325523a0cca363d02733d6b81dc9b49240c4b9a..7df9d46334361f7b4aca4b3cf8e73d61fa2f2c24 100644 (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 } 
index 536682eb6f33af4f7ca79e126967b52aec53b7aa..8f17ac6b884d9b3d3ae52a66940a8d27ca00f6b7 100644 (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 }