aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog24
-rw-r--r--libstdc++-v3/acconfig.h3
-rw-r--r--libstdc++-v3/acinclude.m417
-rw-r--r--libstdc++-v3/aclocal.m417
-rw-r--r--libstdc++-v3/config.h.in9
-rw-r--r--libstdc++-v3/config/io/basic_file_stdio.cc38
-rw-r--r--libstdc++-v3/config/io/basic_file_stdio.h4
-rwxr-xr-xlibstdc++-v3/configure165
-rw-r--r--libstdc++-v3/configure.in4
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc48
-rw-r--r--libstdc++-v3/include/std/std_fstream.h5
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc4
12 files changed, 286 insertions, 52 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f686a3c..24bde10 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,27 @@
+2003-07-14 Paolo Carlini <pcarlini@unitus.it>
+ Nathan C. Myers <ncm-nospam@cantrip.org>
+
+ PR libstdc++/11378
+ * include/std/std_fstream.h (xsputn): Declare only.
+ * include/bits/fstream.tcc (xsputn): Define, optimize for the
+ always_noconv() case: when __n is sufficiently large flush
+ the buffer and issue a direct write, if possible combining the
+ two with writev in __basic_file<>::xsputn_2.
+ * config/io/basic_file_stdio.h (__basic_file<>::xsputn_2):
+ New, declare.
+ * config/io/basic_file_stdio.cc (__basic_file<>::xsputn_2):
+ Define.
+ * acinclude.m4 (GLIBCXX_CHECK_WRITE): New macro, checking for
+ the availability of writev in <sys/uio.h>.
+ * configure.in: Call here.
+ * acconfig.h: Add undef for the corresponding symbol.
+ * aclocal.m4: Regenerate.
+ * configure: Regenerate.
+ * config.h.in: Regenerate.
+ * testsuite/27_io/basic_filebuf/setbuf/char/3.cc: Tweak.
+
+ * include/std/std_fstream.h (sync): Constify a variable.
+
2003-07-14 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/27_io/ios_base/cons/assign_neg.cc: Fix line numbers.
diff --git a/libstdc++-v3/acconfig.h b/libstdc++-v3/acconfig.h
index b856b6b..dbc1c5a 100644
--- a/libstdc++-v3/acconfig.h
+++ b/libstdc++-v3/acconfig.h
@@ -144,6 +144,9 @@
// Define if S_IFREG is available in <sys/stat.h>.
#undef HAVE_S_IFREG
+// Define if writev is available in <sys/uio.h>.
+#undef HAVE_WRITEV
+
// Define if LC_MESSAGES is available in <locale.h>.
#undef HAVE_LC_MESSAGES
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 953c460..8f74811 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2162,6 +2162,23 @@ AC_DEFUN(GLIBCXX_CHECK_POLL, [
fi
])
+dnl
+dnl Check whether writev is available in <sys/uio.h>.
+dnl
+
+AC_DEFUN(GLIBCXX_CHECK_WRITEV, [
+ AC_CACHE_VAL(glibcxx_cv_WRITEV, [
+ AC_TRY_COMPILE([#include <sys/uio.h>],
+ [struct iovec iov[2]; writev(0, iov, 0); ],
+ [glibcxx_cv_WRITEV=yes],
+ [glibcxx_cv_WRITEV=no])
+ ])
+ if test x$glibcxx_cv_WRITEV = xyes; then
+ AC_DEFINE(HAVE_WRITEV)
+ fi
+])
+
+
# Check whether LC_MESSAGES is available in <locale.h>.
# Ulrich Drepper <drepper@cygnus.com>, 1995.
#
diff --git a/libstdc++-v3/aclocal.m4 b/libstdc++-v3/aclocal.m4
index b0cdfd9..f5677b8 100644
--- a/libstdc++-v3/aclocal.m4
+++ b/libstdc++-v3/aclocal.m4
@@ -2174,6 +2174,23 @@ AC_DEFUN(GLIBCXX_CHECK_POLL, [
fi
])
+dnl
+dnl Check whether writev is available in <sys/uio.h>.
+dnl
+
+AC_DEFUN(GLIBCXX_CHECK_WRITEV, [
+ AC_CACHE_VAL(glibcxx_cv_WRITEV, [
+ AC_TRY_COMPILE([#include <sys/uio.h>],
+ [struct iovec iov[2]; writev(0, iov, 0); ],
+ [glibcxx_cv_WRITEV=yes],
+ [glibcxx_cv_WRITEV=no])
+ ])
+ if test x$glibcxx_cv_WRITEV = xyes; then
+ AC_DEFINE(HAVE_WRITEV)
+ fi
+])
+
+
# Check whether LC_MESSAGES is available in <locale.h>.
# Ulrich Drepper <drepper@cygnus.com>, 1995.
#
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 81e994d..41d86ad 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -122,6 +122,9 @@
// Define if S_IFREG is available in <sys/stat.h>.
#undef HAVE_S_IFREG
+// Define if writev is available in <sys/uio.h>.
+#undef HAVE_WRITEV
+
// Define if LC_MESSAGES is available in <locale.h>.
#undef HAVE_LC_MESSAGES
@@ -749,9 +752,6 @@
/* Define if you have the <nan.h> header file. */
#undef HAVE_NAN_H
-/* Define if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
/* Define if you have the <sys/filio.h> header file. */
#undef HAVE_SYS_FILIO_H
@@ -776,6 +776,9 @@
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
+/* Define if you have the <sys/uio.h> header file. */
+#undef HAVE_SYS_UIO_H
+
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc
index 2c099d3..5a3921c 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.cc
+++ b/libstdc++-v3/config/io/basic_file_stdio.cc
@@ -50,6 +50,10 @@
#include <poll.h>
#endif
+#ifdef _GLIBCXX_HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
#if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG)
# include <sys/stat.h>
# ifdef _GLIBCXX_HAVE_S_ISREG
@@ -225,6 +229,40 @@ namespace std
return __ret;
}
+ streamsize
+ __basic_file<char>::xsputn_2(const char* __s1, streamsize __n1,
+ const char* __s2, streamsize __n2)
+ {
+ streamsize __ret = 0;
+#ifdef _GLIBCXX_HAVE_WRITEV
+ struct iovec __iov[2];
+ __iov[0].iov_base = const_cast<char*>(__s1);
+ __iov[0].iov_len = __n1;
+ __iov[1].iov_base = const_cast<char*>(__s2);
+ __iov[1].iov_len = __n2;
+
+ do
+ __ret = writev(this->fd(), __iov, 2);
+ while (__ret == -1L && errno == EINTR);
+#else
+ if (__n1)
+ do
+ __ret = write(this->fd(), __s1, __n1);
+ while (__ret == -1L && errno == EINTR);
+
+ if (__ret == __n1)
+ {
+ do
+ __ret = write(this->fd(), __s2, __n2);
+ while (__ret == -1L && errno == EINTR);
+
+ if (__ret != -1L)
+ __ret += __n1;
+ }
+#endif
+ return __ret;
+ }
+
streampos
__basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way,
ios_base::openmode /*__mode*/)
diff --git a/libstdc++-v3/config/io/basic_file_stdio.h b/libstdc++-v3/config/io/basic_file_stdio.h
index 7c0ffbf..90721bb 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.h
+++ b/libstdc++-v3/config/io/basic_file_stdio.h
@@ -97,6 +97,10 @@ namespace std
xsputn(const char* __s, streamsize __n);
streamsize
+ xsputn_2(const char* __s1, streamsize __n1,
+ const char* __s2, streamsize __n2);
+
+ streamsize
xsgetn(char* __s, streamsize __n);
streampos
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index c3444b9..2464c33 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -1476,7 +1476,7 @@ else
if { (eval echo configure:1477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
for file in conftest.*; do
case $file in
- *.$ac_ext | *.c | *.o | *.obj) ;;
+ *.c | *.o | *.obj) ;;
*) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
esac
done
@@ -22819,20 +22819,95 @@ EOF
fi
+ # For xsputn_2().
+ for ac_hdr in sys/uio.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:22828: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 22833 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:22838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+ if eval "test \"`echo '$''{'glibcxx_cv_WRITEV'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ cat > conftest.$ac_ext <<EOF
+#line 22870 "configure"
+#include "confdefs.h"
+#include <sys/uio.h>
+int main() {
+struct iovec iov[2]; writev(0, iov, 0);
+; return 0; }
+EOF
+if { (eval echo configure:22877: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ glibcxx_cv_WRITEV=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ glibcxx_cv_WRITEV=no
+fi
+rm -f conftest*
+
+fi
+
+ if test x$glibcxx_cv_WRITEV = xyes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_WRITEV 1
+EOF
+
+ fi
+
+
ac_safe=`echo "locale.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for locale.h""... $ac_c" 1>&6
-echo "configure:22826: checking for locale.h" >&5
+echo "configure:22901: checking for locale.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 22831 "configure"
+#line 22906 "configure"
#include "confdefs.h"
#include <locale.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:22836: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:22911: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -22850,19 +22925,19 @@ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6
-echo "configure:22854: checking for LC_MESSAGES" >&5
+echo "configure:22929: checking for LC_MESSAGES" >&5
if eval "test \"`echo '$''{'ac_cv_val_LC_MESSAGES'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 22859 "configure"
+#line 22934 "configure"
#include "confdefs.h"
#include <locale.h>
int main() {
return LC_MESSAGES
; return 0; }
EOF
-if { (eval echo configure:22866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:22941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_val_LC_MESSAGES=yes
else
@@ -22889,7 +22964,7 @@ fi
cat > conftest.$ac_ext <<EOF
-#line 22893 "configure"
+#line 22968 "configure"
#include "confdefs.h"
#include <setjmp.h>
@@ -22898,7 +22973,7 @@ int main() {
sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);
; return 0; }
EOF
-if { (eval echo configure:22902: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:22977: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cat >> confdefs.h <<\EOF
#define HAVE_SIGSETJMP 1
@@ -22915,17 +22990,17 @@ rm -f conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:22919: checking for $ac_hdr" >&5
+echo "configure:22994: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 22924 "configure"
+#line 22999 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:22929: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:23004: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -22954,12 +23029,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:22958: checking for $ac_func" >&5
+echo "configure:23033: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 22963 "configure"
+#line 23038 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -22982,7 +23057,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:22986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:23061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -23007,7 +23082,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:23011: checking for working mmap" >&5
+echo "configure:23086: checking for working mmap" >&5
if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -23015,7 +23090,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 23019 "configure"
+#line 23094 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@@ -23155,7 +23230,7 @@ main()
}
EOF
-if { (eval echo configure:23159: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:23234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
@@ -23206,18 +23281,18 @@ fi
# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
if test $enable_symvers != no; then
echo $ac_n "checking for shared libgcc""... $ac_c" 1>&6
-echo "configure:23210: checking for shared libgcc" >&5
+echo "configure:23285: checking for shared libgcc" >&5
ac_save_CFLAGS="$CFLAGS"
CFLAGS=' -lgcc_s'
cat > conftest.$ac_ext <<EOF
-#line 23214 "configure"
+#line 23289 "configure"
#include "confdefs.h"
int main() {
return 0
; return 0; }
EOF
-if { (eval echo configure:23221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:23296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
glibcxx_shared_libgcc=yes
else
@@ -23287,7 +23362,7 @@ else
GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE=
fi
echo $ac_n "checking versioning on shared library symbols""... $ac_c" 1>&6
-echo "configure:23291: checking versioning on shared library symbols" >&5
+echo "configure:23366: checking versioning on shared library symbols" >&5
echo "$ac_t""$enable_symvers" 1>&6
@@ -23302,17 +23377,17 @@ echo "$ac_t""$enable_symvers" 1>&6
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:23306: checking for $ac_hdr" >&5
+echo "configure:23381: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 23311 "configure"
+#line 23386 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:23316: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:23391: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -23345,7 +23420,7 @@ done
# Can't do these in a loop, else the resulting syntax is wrong.
cat > conftest.$ac_ext <<EOF
-#line 23349 "configure"
+#line 23424 "configure"
#include "confdefs.h"
#include <unistd.h>
#include <sys/time.h>
@@ -23355,7 +23430,7 @@ int main() {
int f = RLIMIT_DATA ;
; return 0; }
EOF
-if { (eval echo configure:23359: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:23434: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
glibcxx_mresult=1
else
@@ -23372,7 +23447,7 @@ EOF
cat > conftest.$ac_ext <<EOF
-#line 23376 "configure"
+#line 23451 "configure"
#include "confdefs.h"
#include <unistd.h>
#include <sys/time.h>
@@ -23382,7 +23457,7 @@ int main() {
int f = RLIMIT_RSS ;
; return 0; }
EOF
-if { (eval echo configure:23386: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:23461: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
glibcxx_mresult=1
else
@@ -23399,7 +23474,7 @@ EOF
cat > conftest.$ac_ext <<EOF
-#line 23403 "configure"
+#line 23478 "configure"
#include "confdefs.h"
#include <unistd.h>
#include <sys/time.h>
@@ -23409,7 +23484,7 @@ int main() {
int f = RLIMIT_VMEM ;
; return 0; }
EOF
-if { (eval echo configure:23413: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:23488: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
glibcxx_mresult=1
else
@@ -23426,7 +23501,7 @@ EOF
cat > conftest.$ac_ext <<EOF
-#line 23430 "configure"
+#line 23505 "configure"
#include "confdefs.h"
#include <unistd.h>
#include <sys/time.h>
@@ -23436,7 +23511,7 @@ int main() {
int f = RLIMIT_AS ;
; return 0; }
EOF
-if { (eval echo configure:23440: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:23515: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
glibcxx_mresult=1
else
@@ -23458,7 +23533,7 @@ EOF
else
cat > conftest.$ac_ext <<EOF
-#line 23462 "configure"
+#line 23537 "configure"
#include "confdefs.h"
#include <unistd.h>
#include <sys/time.h>
@@ -23468,7 +23543,7 @@ int main() {
struct rlimit r; setrlimit(0, &r);
; return 0; }
EOF
-if { (eval echo configure:23472: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:23547: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_setrlimit=yes
else
@@ -23484,7 +23559,7 @@ fi
fi
echo $ac_n "checking for testsuite memory limit support""... $ac_c" 1>&6
-echo "configure:23488: checking for testsuite memory limit support" >&5
+echo "configure:23563: checking for testsuite memory limit support" >&5
if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
ac_mem_limits=yes
cat >> confdefs.h <<\EOF
@@ -23500,7 +23575,7 @@ EOF
# Look for setenv, so that extended locale tests can be performed.
echo $ac_n "checking for setenv declaration""... $ac_c" 1>&6
-echo "configure:23504: checking for setenv declaration" >&5
+echo "configure:23579: checking for setenv declaration" >&5
if test x${glibcxx_cv_func_setenv_use+set} != xset; then
if eval "test \"`echo '$''{'glibcxx_cv_func_setenv_use'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -23515,14 +23590,14 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
cat > conftest.$ac_ext <<EOF
-#line 23519 "configure"
+#line 23594 "configure"
#include "confdefs.h"
#include <stdlib.h>
int main() {
setenv(0, 0, 0);
; return 0; }
EOF
-if { (eval echo configure:23526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:23601: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
glibcxx_cv_func_setenv_use=yes
else
@@ -23548,12 +23623,12 @@ fi
for ac_func in setenv
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:23552: checking for $ac_func" >&5
+echo "configure:23627: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 23557 "configure"
+#line 23632 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -23576,7 +23651,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:23580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:23655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -23736,7 +23811,7 @@ glibcxx_prefixdir=${prefix}
# Process the option --with-gxx-include-dir=<path to include-files directory>
echo $ac_n "checking for --with-gxx-include-dir""... $ac_c" 1>&6
-echo "configure:23740: checking for --with-gxx-include-dir" >&5
+echo "configure:23815: checking for --with-gxx-include-dir" >&5
# Check whether --with-gxx-include-dir or --without-gxx-include-dir was given.
if test "${with_gxx_include_dir+set}" = set; then
withval="$with_gxx_include_dir"
@@ -23760,7 +23835,7 @@ echo "$ac_t""$gxx_include_dir" 1>&6
# Process the option "--enable-version-specific-runtime-libs"
echo $ac_n "checking for --enable-version-specific-runtime-libs""... $ac_c" 1>&6
-echo "configure:23764: checking for --enable-version-specific-runtime-libs" >&5
+echo "configure:23839: checking for --enable-version-specific-runtime-libs" >&5
# Check whether --enable-version-specific-runtime-libs or --disable-version-specific-runtime-libs was given.
if test "${enable_version_specific_runtime_libs+set}" = set; then
enableval="$enable_version_specific_runtime_libs"
@@ -23811,7 +23886,7 @@ if test x"$glibcxx_toolexecdir" = x"no"; then
fi
echo $ac_n "checking for install location""... $ac_c" 1>&6
-echo "configure:23815: checking for install location" >&5
+echo "configure:23890: checking for install location" >&5
echo "$ac_t""$gxx_include_dir" 1>&6
diff --git a/libstdc++-v3/configure.in b/libstdc++-v3/configure.in
index 4d02007..a0d003e 100644
--- a/libstdc++-v3/configure.in
+++ b/libstdc++-v3/configure.in
@@ -423,6 +423,10 @@ else
GLIBCXX_CHECK_POLL
GLIBCXX_CHECK_S_ISREG_OR_S_IFREG
+ # For xsputn_2().
+ AC_CHECK_HEADERS(sys/uio.h)
+ GLIBCXX_CHECK_WRITEV
+
AC_LC_MESSAGES
AC_TRY_COMPILE([
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index c25d501..458b6ef 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -438,6 +438,54 @@ namespace std
return __elen && __elen == __plen;
}
+ template<typename _CharT, typename _Traits>
+ streamsize
+ basic_filebuf<_CharT, _Traits>::
+ xsputn(const _CharT* __s, streamsize __n)
+ {
+ streamsize __ret = 0;
+
+ // Optimization in the always_noconv() case, to be generalized in the
+ // future: when __n is sufficiently large we write directly instead of
+ // using the buffer.
+ const bool __testout = this->_M_mode & ios_base::out;
+ if (__testout && !_M_reading
+ && __check_facet(_M_codecvt).always_noconv())
+ {
+ // Measurement would reveal the best choice.
+ const streamsize __chunk = 1ul << 10;
+ streamsize __bufavail = this->epptr() - this->pptr();
+
+ // Don't mistake 'uncommitted' mode buffered with unbuffered.
+ if (!_M_writing && this->_M_buf_size > 1)
+ __bufavail = this->_M_buf_size - 1;
+
+ const streamsize __limit = std::min(__chunk, __bufavail);
+ if (__n >= __limit)
+ {
+ const streamsize __buffill = this->pptr() - this->pbase();
+ const char* __buf = reinterpret_cast<const char*>(this->pbase());
+ __ret = _M_file.xsputn_2(__buf, __buffill,
+ reinterpret_cast<const char*>(__s), __n);
+ if (__ret == __buffill + __n)
+ {
+ _M_set_buffer(0);
+ _M_writing = true;
+ }
+ if (__ret > __buffill)
+ __ret -= __buffill;
+ else
+ __ret = 0;
+ }
+ else
+ __ret = __streambuf_type::xsputn(__s, __n);
+ }
+ else
+ __ret = __streambuf_type::xsputn(__s, __n);
+
+ return __ret;
+ }
+
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__streambuf_type*
basic_filebuf<_CharT, _Traits>::
diff --git a/libstdc++-v3/include/std/std_fstream.h b/libstdc++-v3/include/std/std_fstream.h
index 209be67..ca4171c 100644
--- a/libstdc++-v3/include/std/std_fstream.h
+++ b/libstdc++-v3/include/std/std_fstream.h
@@ -365,7 +365,7 @@ namespace std
// NB: _M_file.sync() will be called within.
if (this->pbase() < this->pptr())
{
- int_type __tmp = this->overflow();
+ const int_type __tmp = this->overflow();
if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__ret = -1;
else
@@ -407,8 +407,7 @@ namespace std
// [documentation is inherited]
virtual streamsize
- xsputn(const char_type* __s, streamsize __n)
- { return __streambuf_type::xsputn(__s, __n); }
+ xsputn(const char_type* __s, streamsize __n);
/**
* @if maint
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc
index 2927991..f7a6587 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/3.cc
@@ -34,7 +34,9 @@ void test02()
filebuf fbuf01;
fbuf01.open("tmp", ios_base::out);
- fbuf01.pubsetbuf(buf, strlitsize);
+ // NB: +2 otherwise sputn is optimized to a direct write,
+ // bypassing the buffer.
+ fbuf01.pubsetbuf(buf, strlitsize + 2);
fbuf01.sputn(strlit, strlitsize);
VERIFY( std::strncmp(strlit, buf, strlitsize) == 0 );
}