Commit dd5d134b by Paolo Carlini Committed by Paolo Carlini

PR libstdc++/12882 (cont)

2004-09-21  Paolo Carlini  <pcarlini@suse.de>

	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
parent fd375c53
2004-09-21 Paolo Carlini <pcarlini@suse.de>
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 <redi@gcc.gnu.org> 2004-09-17 Jonathan Wakely <redi@gcc.gnu.org>
* include/bits/stl_algo.h (remove): Remove too restrictive * include/bits/stl_algo.h (remove): Remove too restrictive
......
...@@ -573,12 +573,15 @@ AC_DEFUN([GLIBCXX_CHECK_LFS], [ ...@@ -573,12 +573,15 @@ AC_DEFUN([GLIBCXX_CHECK_LFS], [
AC_TRY_LINK( AC_TRY_LINK(
[#include <unistd.h> [#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h>
], ],
[FILE* fp; [FILE* fp;
fopen64("t", "w"); fopen64("t", "w");
fseeko64(fp, 0, SEEK_CUR); fseeko64(fp, 0, SEEK_CUR);
ftello64(fp); 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=yes],
[glibcxx_cv_LFS=no]) [glibcxx_cv_LFS=no])
]) ])
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
# endif # endif
#endif #endif
#include <limits> // For <off_t>::max() and min() #include <limits> // For <off_t>::max() and min() and <streamsize>::max()
namespace __gnu_internal namespace __gnu_internal
{ {
...@@ -315,8 +315,8 @@ namespace std ...@@ -315,8 +315,8 @@ namespace std
#ifdef _GLIBCXX_USE_LFS #ifdef _GLIBCXX_USE_LFS
return lseek64(this->fd(), __off, __way); return lseek64(this->fd(), __off, __way);
#else #else
if (__off > std::numeric_limits<off_t>::max() if (__off > numeric_limits<off_t>::max()
|| __off < std::numeric_limits<off_t>::min()) || __off < numeric_limits<off_t>::min())
return -1L; return -1L;
return lseek(this->fd(), __off, __way); return lseek(this->fd(), __off, __way);
#endif #endif
...@@ -352,10 +352,21 @@ namespace std ...@@ -352,10 +352,21 @@ namespace std
#if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG) #if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG)
// Regular files. // 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<streamsize>::max()));
}
#else
struct stat __buffer; struct stat __buffer;
int __ret = fstat(this->fd(), &__buffer); const int __err = fstat(this->fd(), &__buffer);
if (!__ret && _GLIBCXX_ISREG(__buffer.st_mode)) if (!__err && _GLIBCXX_ISREG(__buffer.st_mode))
return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur); return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur);
#endif
#endif #endif
return 0; return 0;
} }
......
...@@ -30148,6 +30148,7 @@ cat >>conftest.$ac_ext <<_ACEOF ...@@ -30148,6 +30148,7 @@ cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */ /* end confdefs.h. */
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h>
int int
main () main ()
...@@ -30157,6 +30158,8 @@ FILE* fp; ...@@ -30157,6 +30158,8 @@ FILE* fp;
fseeko64(fp, 0, SEEK_CUR); fseeko64(fp, 0, SEEK_CUR);
ftello64(fp); ftello64(fp);
lseek64(1, 0, SEEK_CUR); lseek64(1, 0, SEEK_CUR);
struct stat64 buf;
fstat64(1, &buf);
; ;
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment