From dd5d134bc9bc9b234c0dca42d610b098991276d7 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 21 Sep 2004 09:06:08 +0000 Subject: [PATCH] PR libstdc++/12882 (cont) 2004-09-21 Paolo Carlini PR libstdc++/12882 (cont) * acinclude.m4 (GLIBCXX_CHECK_LFS): Check for fstat64 too. * configure: Regenerate. * config/io/basic_file_stdio.cc (__basic_file<>::showmanyc): When _GLIBCXX_USE_LFS use fstat64 and lseek64, thus providing a non trivial showmanyc for large files too. From-SVN: r87797 --- libstdc++-v3/ChangeLog | 9 +++++++++ libstdc++-v3/acinclude.m4 | 5 ++++- libstdc++-v3/config/io/basic_file_stdio.cc | 23 ++++++++++++++++------ libstdc++-v3/configure | 3 +++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d32dc805d69..6452377a922 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2004-09-21 Paolo Carlini + + PR libstdc++/12882 (cont) + * acinclude.m4 (GLIBCXX_CHECK_LFS): Check for fstat64 too. + * configure: Regenerate. + * config/io/basic_file_stdio.cc (__basic_file<>::showmanyc): When + _GLIBCXX_USE_LFS use fstat64 and lseek64, thus providing a non + trivial showmanyc for large files too. + 2004-09-17 Jonathan Wakely * include/bits/stl_algo.h (remove): Remove too restrictive diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 97b20a724f0..6e531007cac 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -573,12 +573,15 @@ AC_DEFUN([GLIBCXX_CHECK_LFS], [ AC_TRY_LINK( [#include #include + #include ], [FILE* fp; fopen64("t", "w"); fseeko64(fp, 0, SEEK_CUR); ftello64(fp); - lseek64(1, 0, SEEK_CUR);], + lseek64(1, 0, SEEK_CUR); + struct stat64 buf; + fstat64(1, &buf);], [glibcxx_cv_LFS=yes], [glibcxx_cv_LFS=no]) ]) diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc index 0a4e154ebbc..c5cbf04b8da 100644 --- a/libstdc++-v3/config/io/basic_file_stdio.cc +++ b/libstdc++-v3/config/io/basic_file_stdio.cc @@ -68,7 +68,7 @@ # endif #endif -#include // For ::max() and min() +#include // For ::max() and min() and ::max() namespace __gnu_internal { @@ -315,8 +315,8 @@ namespace std #ifdef _GLIBCXX_USE_LFS return lseek64(this->fd(), __off, __way); #else - if (__off > std::numeric_limits::max() - || __off < std::numeric_limits::min()) + if (__off > numeric_limits::max() + || __off < numeric_limits::min()) return -1L; return lseek(this->fd(), __off, __way); #endif @@ -352,10 +352,21 @@ namespace std #if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG) // Regular files. +#ifdef _GLIBCXX_USE_LFS + struct stat64 __buffer; + const int __err = fstat64(this->fd(), &__buffer); + if (!__err && _GLIBCXX_ISREG(__buffer.st_mode)) + { + const streamoff __off = __buffer.st_size - lseek64(this->fd(), 0, + ios_base::cur); + return std::min(__off, streamoff(numeric_limits::max())); + } +#else struct stat __buffer; - int __ret = fstat(this->fd(), &__buffer); - if (!__ret && _GLIBCXX_ISREG(__buffer.st_mode)) - return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur); + const int __err = fstat(this->fd(), &__buffer); + if (!__err && _GLIBCXX_ISREG(__buffer.st_mode)) + return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur); +#endif #endif return 0; } diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 140d681cdf0..92492dbe5e5 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -30148,6 +30148,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include + #include int main () @@ -30157,6 +30158,8 @@ FILE* fp; fseeko64(fp, 0, SEEK_CUR); ftello64(fp); lseek64(1, 0, SEEK_CUR); + struct stat64 buf; + fstat64(1, &buf); ; return 0; } -- 2.30.2