Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2007-12-29 14:50:24


Author: turkanis
Date: 2007-12-29 14:50:22 EST (Sat, 29 Dec 2007)
New Revision: 42343
URL: http://svn.boost.org/trac/boost/changeset/42343

Log:
ported changes from branches/iostreams_dev revisions 42306-42342: reworking of low-level file access to address #824, plus rigorous tests for large seeks
Added:
   trunk/boost/iostreams/detail/config/rtl.hpp
      - copied unchanged from r42342, /branches/iostreams_dev/boost/iostreams/detail/config/rtl.hpp
   trunk/libs/iostreams/test/large_file_test.cpp
      - copied unchanged from r42342, /branches/iostreams_dev/libs/iostreams/test/large_file_test.cpp
Text files modified:
   trunk/boost/iostreams/detail/streambuf/linked_streambuf.hpp | 2
   trunk/libs/iostreams/src/file_descriptor.cpp | 65 ++++++++++++++-------------------------
   trunk/libs/iostreams/test/Jamfile.v2 | 48 +++++++++++++++++-----------
   3 files changed, 53 insertions(+), 62 deletions(-)

Modified: trunk/boost/iostreams/detail/streambuf/linked_streambuf.hpp
==============================================================================
--- trunk/boost/iostreams/detail/streambuf/linked_streambuf.hpp (original)
+++ trunk/boost/iostreams/detail/streambuf/linked_streambuf.hpp 2007-12-29 14:50:22 EST (Sat, 29 Dec 2007)
@@ -61,7 +61,7 @@
     template<typename Chain, typename Mode, typename Access>
     friend class chainbuf;
     template<typename U>
- friend struct member_close_operation;
+ friend class member_close_operation;
 #else
     public:
         typedef BOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) base;

Modified: trunk/libs/iostreams/src/file_descriptor.cpp
==============================================================================
--- trunk/libs/iostreams/src/file_descriptor.cpp (original)
+++ trunk/libs/iostreams/src/file_descriptor.cpp 2007-12-29 14:50:22 EST (Sat, 29 Dec 2007)
@@ -1,4 +1,4 @@
-// (C) Copyright Jonathan Turkanis 2003.
+// (C) Copyright Jonathan Turkanis 2003-2007.
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
 
@@ -13,19 +13,19 @@
 #define BOOST_IOSTREAMS_SOURCE
 
 #include <cassert>
-#include <boost/config.hpp> // BOOST_JOIN
+#include <cerrno>
+#include <cstdio> // SEEK_SET, etc.
+#include <boost/config.hpp> // BOOST_JOIN
 #include <boost/iostreams/detail/error.hpp>
 #include <boost/iostreams/detail/config/dyn_link.hpp>
+#include <boost/iostreams/detail/config/rtl.hpp> // BOOST_IOSTREAMS_FD_XXX
 #include <boost/iostreams/detail/config/windows_posix.hpp>
-#include <boost/iostreams/detail/ios.hpp> // openmodes, failure.
+#include <boost/iostreams/detail/ios.hpp> // openmodes, failure.
 #include <boost/iostreams/device/file_descriptor.hpp>
 #include <boost/integer_traits.hpp>
 
     // OS-specific headers for low-level i/o.
 
-#include <cassert>
-#include <cstdio> // SEEK_SET, etc.
-#include <errno.h>
 #include <fcntl.h> // file opening flags.
 #include <sys/stat.h> // file access permissions.
 #ifdef BOOST_IOSTREAMS_WINDOWS
@@ -40,17 +40,6 @@
 # include <unistd.h> // low-level file i/o.
 #endif
 
-// Names of runtime library routines vary.
-#if defined(__BORLANDC__)
-# define BOOST_RTL(x) BOOST_JOIN(_rtl_, x)
-#else
-# if defined(BOOST_IOSTREAMS_WINDOWS) && !defined(__CYGWIN__)
-# define BOOST_RTL(x) BOOST_JOIN(_, x)
-# else
-# define BOOST_RTL(x) ::x
-# endif
-#endif
-
 namespace boost { namespace iostreams {
 
 //------------------Implementation of file_descriptor-------------------------//
@@ -126,6 +115,9 @@
     }
     if (m & BOOST_IOS::trunc)
         oflag |= O_CREAT;
+ #ifdef _LARGEFILE64_SOURCE
+ oflag |= O_LARGEFILE;
+ #endif
 
         // Calculate pmode argument to open.
 
@@ -135,7 +127,7 @@
 
         // Open file.
 
- int fd = BOOST_RTL(open)(path.c_str(), oflag, pmode);
+ int fd = BOOST_IOSTREAMS_FD_OPEN(path.c_str(), oflag, pmode);
     if (fd == -1) {
         throw BOOST_IOSTREAMS_FAILURE("bad open");
     } else {
@@ -156,7 +148,7 @@
     }
 #endif
     errno = 0;
- std::streamsize result = BOOST_RTL(read)(pimpl_->fd_, s, n);
+ std::streamsize result = BOOST_IOSTREAMS_FD_READ(pimpl_->fd_, s, n);
     if (errno != 0)
         throw detail::bad_read();
     return result == 0 ? -1 : result;
@@ -181,7 +173,7 @@
         return n;
     }
 #endif
- int amt = BOOST_RTL(write)(pimpl_->fd_, s, n);
+ int amt = BOOST_IOSTREAMS_FD_WRITE(pimpl_->fd_, s, n);
     if (amt < n)
         throw detail::bad_write(); // Handles blocking fd's only.
     return n;
@@ -215,32 +207,21 @@
         }
     }
 #endif // #ifdef BOOST_IOSTREAMS_WINDOWS
-
-#ifndef BOOST_IOSTREAMS_HAS_LSEEK64
- if ( off > integer_traits<long>::const_max ||
- off < integer_traits<long>::const_min )
+ if ( off > integer_traits<BOOST_IOSTREAMS_FD_OFFSET>::const_max ||
+ off < integer_traits<BOOST_IOSTREAMS_FD_OFFSET>::const_min )
     {
         throw BOOST_IOSTREAMS_FAILURE("bad offset");
     }
-#endif
-
     stream_offset result =
- #ifdef BOOST_IOSTREAMS_HAS_LSEEK64
- lseek64
- #else
- lseek
- #endif
- ( pimpl_->fd_,
- #ifdef BOOST_IOSTREAMS_HAS_LSEEK64
- off,
- #else
- static_cast<long>(off),
- #endif
- way == BOOST_IOS::beg ?
+ BOOST_IOSTREAMS_FD_SEEK(
+ pimpl_->fd_,
+ static_cast<BOOST_IOSTREAMS_FD_OFFSET>(off),
+ ( way == BOOST_IOS::beg ?
                   SEEK_SET :
- way == BOOST_IOS::cur ?
- SEEK_CUR :
- SEEK_END );
+ way == BOOST_IOS::cur ?
+ SEEK_CUR :
+ SEEK_END )
+ );
     if (result == -1)
         throw detail::bad_seek();
     return offset_to_position(result);
@@ -260,7 +241,7 @@
     }
 #endif
     if (i.fd_ != -1) {
- if (BOOST_RTL(close)(i.fd_) == -1)
+ if (BOOST_IOSTREAMS_FD_CLOSE(i.fd_) == -1)
             throw BOOST_IOSTREAMS_FAILURE("bad close");
         i.fd_ = -1;
         i.flags_ = 0;

Modified: trunk/libs/iostreams/test/Jamfile.v2
==============================================================================
--- trunk/libs/iostreams/test/Jamfile.v2 (original)
+++ trunk/libs/iostreams/test/Jamfile.v2 2007-12-29 14:50:22 EST (Sat, 29 Dec 2007)
@@ -11,7 +11,8 @@
 
 local NO_BZIP2 = [ modules.peek : NO_BZIP2 ] ;
 local NO_ZLIB = [ modules.peek : NO_ZLIB ] ;
-
+local LARGE_FILE_TEMP = [ modules.peek : LARGE_FILE_TEMP ] ;
+local LARGE_FILE_KEEP = [ modules.peek : LARGE_FILE_KEEP ] ;
 
 rule test-iostreams ( sources * : requirements * ) {
     return [
@@ -30,7 +31,6 @@
         ] ;
 }
 
-
     local all-tests =
           [ test-iostreams array_test.cpp ]
           [ test-iostreams auto_close_test.cpp ]
@@ -39,9 +39,6 @@
           [ test-iostreams
                 code_converter_test.cpp
                 detail/utf8_codecvt_facet.cpp ]
-
- #: # build requirements
- # std::locale-support ]
           [ test-iostreams compose_test.cpp ]
           [ test-iostreams component_access_test.cpp ]
           [ test-iostreams copy_test.cpp ]
@@ -54,13 +51,7 @@
                 file_descriptor_test.cpp
                 ../build//boost_iostreams : <link>static ]
           [ test-iostreams filtering_stream_test.cpp ]
- [ test-iostreams
- finite_state_filter_test.cpp
- : # build requirements
- # FIXME: yet to implement
- #std::locale-support
- ]
-
+ [ test-iostreams finite_state_filter_test.cpp ]
           [ test-iostreams flush_test.cpp ]
           [ test-iostreams invert_test.cpp ]
           [ test-iostreams line_filter_test.cpp ]
@@ -87,18 +78,37 @@
           [ test-iostreams wide_stream_test.cpp ]
           ;
 
+ if $(LARGE_FILE_KEEP)
+ {
+ all-tests +=
+ [ test-iostreams
+ large_file_test.cpp
+ ../build//boost_iostreams
+ : <define>LARGE_FILE_KEEP=$(LARGE_FILE_KEEP)
+ $(KEEP) ] ;
+ }
+ if $(LARGE_FILE_TEMP)
+ {
+ all-tests +=
+ [ test-iostreams
+ large_file_test.cpp
+ ../build//boost_iostreams
+ : <define>LARGE_FILE_TEMP=$(LARGE_FILE_TEMP)
+ $(KEEP) ] ;
+ }
       if ! $(NO_BZIP2)
       {
           all-tests += [ test-iostreams
- bzip2_test.cpp ../build//boost_iostreams ] ;
- }
+ bzip2_test.cpp ../build//boost_iostreams ] ;
+ }
       if ! $(NO_ZLIB)
       {
- all-tests += [ test-iostreams
- gzip_test.cpp ../build//boost_iostreams ]
- [ test-iostreams
- zlib_test.cpp ../build//boost_iostreams ] ;
- }
+ all-tests +=
+ [ test-iostreams
+ gzip_test.cpp ../build//boost_iostreams ]
+ [ test-iostreams
+ zlib_test.cpp ../build//boost_iostreams ] ;
+ }
           
     test-suite "iostreams" : $(all-tests) ;
     


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk