Opened 16 years ago

Closed 15 years ago

#824 closed Bugs (fixed)

BOOST_IOSTREAMS_HAS_LSEEK64 on Mac OS X

Reported by: gmsb Owned by: Jonathan Turkanis
Milestone: Component: iostreams
Version: None Severity: Showstopper
Keywords: Cc:

Description (last modified by Marshall Clow)

Mac OS X has 64-bit file offsets but uses the standard lseek call rather than lseek64.

The following is one fix for file_descriptor::seek() but there's no doubt a better way...

Change lines 203 and 218 from:

  203 #ifndef BOOST_IOSTREAMS_HAS_LSEEK64
  204     if ( off > integer_traits<long>::const_max ||
  205          off < integer_traits<long>::const_min )
  206     {
  207         throw BOOST_IOSTREAMS_FAILURE("bad offset");
  208     }
  209 #endif
  210 
  211     stream_offset result =
  212         #ifdef BOOST_IOSTREAMS_HAS_LSEEK64
  213             lseek64
  214         #else
  215             lseek
  216         #endif
  217             ( pimpl_->fd_,
  218               #ifdef BOOST_IOSTREAMS_HAS_LSEEK64
  219                   off,
  220               #else
  221                   static_cast<long>(off),
  222               #endif
  223               way == BOOST_IOS::beg ?
  224                   SEEK_SET :
  225                       way == BOOST_IOS::cur ?
  226                           SEEK_CUR :
  227                           SEEK_END );

To:

  203 #if !defined(BOOST_IOSTREAMS_HAS_LSEEK64) && !defined(__MACH__)
  ...
  218               #if defined(BOOST_IOSTREAMS_HAS_LSEEK64) || defined(__MACH__)
  ...


Change History (6)

comment:1 by Marshall Clow, 15 years ago

Owner: changed from beman_dawes to Beman Dawes
Severity: Showstopper
Status: assignednew

assigning to actual user "bemandawes" instead of unknown user "beman_dawes"

comment:2 by Marshall Clow, 15 years ago

Component: Noneiostreams
Description: modified (diff)

comment:3 by Beman Dawes, 15 years ago

Owner: Beman Dawes removed

comment:4 by Marshall Clow, 15 years ago

Owner: set to Jonathan Turkanis

comment:5 by Jonathan Turkanis, 15 years ago

Status: newassigned

attempted fix in [42343].

The new header boost/iostreams/detail/config/rtl.hpp attempts to set the preprocessor symbols BOOST_IOSTREAMS_FD_XXX to correct values for XXX = open, close, read, write, seek, truncate, stat, and offset. The implementation of file_descriptor uses these constants where possible instead of using platform specific functions or types.

A new test, large_file_test.cpp, was introduced to test seeking with offsets of 1GB to 8GB. In order to enable this test, regression test runners will have to set one of the variables LARGE_FILE_TEMP or LARGE_FILE_KEEP to a pathname where the iostreams library can create an 8GB file.

comment:6 by Jonathan Turkanis, 15 years ago

Resolution: Nonefixed
Status: assignedclosed

Tested on Cygwin, which is like Darwin in that there are no foo64 functions, but off_t is 64-bit, and on Fedora 8 with _LARGEFILE64_SOURCE defined and _FILE_OFFSET_BITS undefined.

I am going to call this fixed.

Note: See TracTickets for help on using tickets.