Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55533 - branches/release/boost/interprocess/detail
From: igaztanaga_at_[hidden]
Date: 2009-08-11 17:44:19


Author: igaztanaga
Date: 2009-08-11 17:44:18 EDT (Tue, 11 Aug 2009)
New Revision: 55533
URL: http://svn.boost.org/trac/boost/changeset/55533

Log:
FreeBSD 8 fixes
Text files modified:
   branches/release/boost/interprocess/detail/managed_open_or_create_impl.hpp | 35 -----------------------------------
   branches/release/boost/interprocess/detail/os_file_functions.hpp | 34 +++++++++++++++++++++++++++++-----
   branches/release/boost/interprocess/detail/workaround.hpp | 2 +-
   3 files changed, 30 insertions(+), 41 deletions(-)

Modified: branches/release/boost/interprocess/detail/managed_open_or_create_impl.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/managed_open_or_create_impl.hpp (original)
+++ branches/release/boost/interprocess/detail/managed_open_or_create_impl.hpp 2009-08-11 17:44:18 EDT (Tue, 11 Aug 2009)
@@ -200,40 +200,6 @@
 
    //These are templatized to allow explicit instantiations
    template<bool dummy>
- static void write_whole_device(DeviceAbstraction &, std::size_t, detail::false_)
- {} //Empty
-
- template<bool dummy>
- static void write_whole_device(DeviceAbstraction &dev, std::size_t size, detail::true_)
- {
- file_handle_t hnd = detail::file_handle_from_mapping_handle(dev.get_mapping_handle());
-
- if(size <= ManagedOpenOrCreateUserOffset){
- throw interprocess_exception(error_info(system_error_code()));
- }
-
- size -= ManagedOpenOrCreateUserOffset;
-
- if(!detail::set_file_pointer(hnd, ManagedOpenOrCreateUserOffset, file_begin)){
- throw interprocess_exception(error_info(system_error_code()));
- }
-
- //We will write zeros in the file
- for(std::size_t remaining = size, write_size = 0
- ;remaining > 0
- ;remaining -= write_size){
- const std::size_t DataSize = 512;
- static char data [DataSize];
- write_size = DataSize < remaining ? DataSize : remaining;
- if(!detail::write_file(hnd, data, write_size)){
- error_info err = system_error_code();
- throw interprocess_exception(err);
- }
- }
- }
-
- //These are templatized to allow explicit instantiations
- template<bool dummy>
    static void truncate_device(DeviceAbstraction &, std::size_t, detail::false_)
    {} //Empty
 
@@ -342,7 +308,6 @@
 
             if(previous == UninitializedSegment){
                try{
- write_whole_device<FileBased>(dev, size, file_like_t());
                   construct_func(static_cast<char*>(region.get_address()) + ManagedOpenOrCreateUserOffset, size - ManagedOpenOrCreateUserOffset, true);
                   //All ok, just move resources to the external mapped region
                   m_mapped_region.swap(region);

Modified: branches/release/boost/interprocess/detail/os_file_functions.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/os_file_functions.hpp (original)
+++ branches/release/boost/interprocess/detail/os_file_functions.hpp 2009-08-11 17:44:18 EDT (Tue, 11 Aug 2009)
@@ -113,13 +113,37 @@
 { return winapi::unlink_file(name); }
 
 inline bool truncate_file (file_handle_t hnd, std::size_t size)
-{
- if(!winapi::set_file_pointer_ex(hnd, size, 0, winapi::file_begin)){
+{
+ offset_t filesize;
+ if(!winapi::get_file_size(hnd, filesize))
       return false;
- }
 
- if(!winapi::set_end_of_file(hnd)){
- return false;
+ if(size > filesize){
+ if(!winapi::set_file_pointer_ex(hnd, filesize, 0, winapi::file_begin)){
+ return false;
+ }
+ //We will write zeros in the end of the file
+ //since set_end_of_file does not guarantee this
+ for(std::size_t remaining = size - filesize, write_size = 0
+ ;remaining > 0
+ ;remaining -= write_size){
+ const std::size_t DataSize = 512;
+ static char data [DataSize];
+ write_size = DataSize < remaining ? DataSize : remaining;
+ unsigned long written;
+ winapi::write_file(hnd, data, (unsigned long)write_size, &written, 0);
+ if(written != write_size){
+ return false;
+ }
+ }
+ }
+ else{
+ if(!winapi::set_file_pointer_ex(hnd, size, 0, winapi::file_begin)){
+ return false;
+ }
+ if(!winapi::set_end_of_file(hnd)){
+ return false;
+ }
    }
    return true;
 }

Modified: branches/release/boost/interprocess/detail/workaround.hpp
==============================================================================
--- branches/release/boost/interprocess/detail/workaround.hpp (original)
+++ branches/release/boost/interprocess/detail/workaround.hpp 2009-08-11 17:44:18 EDT (Tue, 11 Aug 2009)
@@ -95,7 +95,7 @@
    //portable "/shmname" format does not work due to permission issues
    //For those systems we need to form a path to a temporary directory:
    // hp-ux tru64 vms freebsd
- #if defined(__hpux) || defined(__osf__) || defined(__vms) || defined(__FreeBSD__)
+ #if defined(__hpux) || defined(__osf__) || defined(__vms) || (defined(__FreeBSD__) && (__FreeBSD__ < 8))
    #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_RESOURCES
    #endif
 


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