This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] libstdc++/8399


Hi,

tested on x86-linux by me and on freebsd by Loren.

Ciao, Paolo.

///////////////

2002-11-15  Paolo Carlini  <pcarlini@unitus.it>
           Loren J. Rittle  <ljrittle@acm.org>

       PR libstdc++/8399
       * acinclude.m4
       (GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1): New macro to
       check for unistd.h functions.
       (GLIBCPP_CHECK_UNISTD_SUPPORT): New macro, check for isatty
       in unistd.h.
       * configure.in: Call here.
       * src/ios.cc (ios_base::Init::_S_ios_create(bool)):
       Use _GLIBCPP_HAVE_ISATTY: ifdef, in case of interactive
       input __in_size = 1 even when sync_with_stdio is false;
       otherwise fall back to __in_size = 1.
       * aclocal.m4: Regenerate.
       * config.h.in: Regenerate.
       * configure: Regenerate.
--- acinclude.m4.orig	2002-11-14 00:51:25.000000000 +0100
+++ acinclude.m4	2002-11-13 23:56:47.000000000 +0100
@@ -591,6 +591,33 @@
   fi
 ])
 
+dnl
+dnl Check to see if the (unistd function) argument passed is
+dnl 1) declared when using the c++ compiler
+dnl 2) has "C" linkage
+dnl
+dnl argument 1 is name of function to check
+dnl
+dnl ASSUMES argument is a function with ONE parameter
+dnl
+dnl GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1
+AC_DEFUN(GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1, [
+  AC_MSG_CHECKING([for $1 declaration])
+  if test x${glibcpp_cv_func_$1_use+set} != xset; then
+    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
+      AC_LANG_SAVE
+      AC_LANG_CPLUSPLUS
+      AC_TRY_COMPILE([#include <unistd.h>], 
+                     [ $1(0);], 
+                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
+      AC_LANG_RESTORE
+    ])
+  fi
+  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
+  if test x$glibcpp_cv_func_$1_use = x"yes"; then
+    AC_CHECK_FUNCS($1)    
+  fi
+])
 
 dnl
 dnl Because the builtins are picky picky picky about the arguments they take, 
@@ -702,9 +729,8 @@
   fi
 ])
 
-
 dnl
-dnl Check to see what the underlying c library 
+dnl Check to see what the underlying c library is like
 dnl These checks need to do two things: 
 dnl 1) make sure the name is declared when using the c++ compiler
 dnl 2) make sure the name has "C" linkage
@@ -727,6 +753,25 @@
   CXXFLAGS="$ac_save_CXXFLAGS"
 ])
 
+dnl
+dnl Check to see what the underlying c library is like
+dnl These checks need to do two things: 
+dnl 1) make sure the name is declared when using the c++ compiler
+dnl 2) make sure the name has "C" linkage
+dnl This might seem like overkill but experience has shown that it's not...
+dnl
+dnl Define HAVE_ISATTY if "isatty" is declared and links
+dnl
+dnl GLIBCPP_CHECK_UNISTD_SUPPORT
+AC_DEFUN(GLIBCPP_CHECK_UNISTD_SUPPORT, [
+  ac_test_CXXFLAGS="${CXXFLAGS+set}"
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
+
+  GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1(isatty)
+  
+  CXXFLAGS="$ac_save_CXXFLAGS"
+])
 
 dnl
 dnl Check to see what the underlying c library or math library is like.
--- configure.in.orig	2002-11-14 00:51:39.000000000 +0100
+++ configure.in	2002-11-13 23:56:01.000000000 +0100
@@ -397,6 +397,7 @@
   GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
   GLIBCPP_CHECK_WCHAR_T_SUPPORT
   GLIBCPP_CHECK_STDLIB_SUPPORT
+  GLIBCPP_CHECK_UNISTD_SUPPORT
   AC_LC_MESSAGES
 
   AC_TRY_COMPILE([
--- ios.cc.orig	2002-11-14 00:52:14.000000000 +0100
+++ ios.cc	2002-11-14 00:21:43.000000000 +0100
@@ -157,7 +157,11 @@
   ios_base::Init::_S_ios_create(bool __sync)
   {
     int __out_size = __sync ? 0 : static_cast<int>(BUFSIZ);
-    int __in_size = __sync ? 1 : static_cast<int>(BUFSIZ);
+#ifdef _GLIBCPP_HAVE_ISATTY
+    int __in_size = (__sync || isatty (0)) ? 1 : static_cast<int>(BUFSIZ);
+#else
+    int __in_size = 1;
+#endif
 
     // NB: The file globals.cc creates the four standard files
     // with NULL buffers. At this point, we swap out the dummy NULL

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]