Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70838 - in trunk/boost/interprocess: detail mem_algo
From: igaztanaga_at_[hidden]
Date: 2011-04-01 18:03:50


Author: igaztanaga
Date: 2011-04-01 18:03:49 EDT (Fri, 01 Apr 2011)
New Revision: 70838
URL: http://svn.boost.org/trac/boost/changeset/70838

Log:
Fixes for Boost 1.47
Text files modified:
   trunk/boost/interprocess/detail/managed_open_or_create_impl.hpp | 18 +++++++++++++++---
   trunk/boost/interprocess/detail/tmp_dir_helpers.hpp | 16 ++++++++--------
   trunk/boost/interprocess/detail/win32_api.hpp | 11 ++++++++++-
   trunk/boost/interprocess/mem_algo/rbtree_best_fit.hpp | 4 ++--
   4 files changed, 35 insertions(+), 14 deletions(-)

Modified: trunk/boost/interprocess/detail/managed_open_or_create_impl.hpp
==============================================================================
--- trunk/boost/interprocess/detail/managed_open_or_create_impl.hpp (original)
+++ trunk/boost/interprocess/detail/managed_open_or_create_impl.hpp 2011-04-01 18:03:49 EDT (Fri, 01 Apr 2011)
@@ -263,13 +263,22 @@
 
    //These are templatized to allow explicit instantiations
    template<bool dummy>
- static void truncate_device(DeviceAbstraction &, std::size_t, detail::false_)
+ static void truncate_device(DeviceAbstraction &, offset_t, detail::false_)
    {} //Empty
 
    template<bool dummy>
- static void truncate_device(DeviceAbstraction &dev, std::size_t size, detail::true_)
+ static void truncate_device(DeviceAbstraction &dev, offset_t size, detail::true_)
    { dev.truncate(size); }
 
+
+ template<bool dummy>
+ static bool check_offset_t_size(std::size_t , detail::false_)
+ { return true; } //Empty
+
+ template<bool dummy>
+ static bool check_offset_t_size(std::size_t size, detail::true_)
+ { return size == std::size_t(offset_t(size)); }
+
    //These are templatized to allow explicit instantiations
    template<bool dummy>
    static void create_device(DeviceAbstraction &dev, const device_id_t & id, std::size_t size, const permissions &perm, detail::false_)
@@ -305,7 +314,10 @@
       if(type != detail::DoOpen && size < ManagedOpenOrCreateUserOffset){
          throw interprocess_exception(error_info(size_error));
       }
-
+ //Check size can be represented by offset_t (used by truncate)
+ if(type != detail::DoOpen && !check_offset_t_size<FileBased>(size, file_like_t())){
+ throw interprocess_exception(error_info(size_error));
+ }
       if(type == detail::DoOpen && mode == read_write){
          DeviceAbstraction tmp(open_only, id, read_write);
          tmp.swap(dev);

Modified: trunk/boost/interprocess/detail/tmp_dir_helpers.hpp
==============================================================================
--- trunk/boost/interprocess/detail/tmp_dir_helpers.hpp (original)
+++ trunk/boost/interprocess/detail/tmp_dir_helpers.hpp 2011-04-01 18:03:49 EDT (Fri, 01 Apr 2011)
@@ -23,11 +23,11 @@
    //#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
    //#include <boost/interprocess/detail/win32_api.hpp>
 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
- #include <sys/sysctl.h>
- #if defined(CTL_KERN) && defined (KERN_BOOTTIME)
- #define BOOST_INTERPROCESS_HAS_BSD_KERNEL_BOOTTIME
- #define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
- #endif
+ //#include <sys/sysctl.h>
+ //#if defined(CTL_KERN) && defined (KERN_BOOTTIME)
+ //#define BOOST_INTERPROCESS_HAS_BSD_KERNEL_BOOTTIME
+ //#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
+ //#endif
 #endif
 
 namespace boost {
@@ -64,9 +64,9 @@
       , '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
 
    std::size_t char_counter = 0;
- long fields[2] = { result.tv_sec, result.tv_usec };
+ long long fields[2] = { result.tv_sec, result.tv_usec };
    for(std::size_t field = 0; field != 2; ++field){
- for(std::size_t i = 0; i != sizeof(long); ++i){
+ for(std::size_t i = 0; i != sizeof(long long); ++i){
          const char *ptr = (const char *)&fields[field];
          bootstamp_str[char_counter++] = Characters[(ptr[i]&0xF0)>>4];
          bootstamp_str[char_counter++] = Characters[(ptr[i]&0x0F)];
@@ -86,7 +86,7 @@
 {
    #if defined (BOOST_INTERPROCESS_WINDOWS)
    winapi::get_shared_documents_folder(tmp_name);
- if(tmp_name.empty()){
+ if(tmp_name.empty() || !winapi::is_directory(tmp_name.c_str())){
       tmp_name = get_temporary_path();
    }
    #else

Modified: trunk/boost/interprocess/detail/win32_api.hpp
==============================================================================
--- trunk/boost/interprocess/detail/win32_api.hpp (original)
+++ trunk/boost/interprocess/detail/win32_api.hpp 2011-04-01 18:03:49 EDT (Fri, 01 Apr 2011)
@@ -132,6 +132,7 @@
 static const unsigned long lang_neutral = (unsigned long)0x00;
 static const unsigned long sublang_default = (unsigned long)0x01;
 static const unsigned long invalid_file_size = (unsigned long)0xFFFFFFFF;
+static const unsigned long invalid_file_attributes = ((unsigned long)-1);
 static void * const invalid_handle_value = (void*)(long)(-1);
 static const unsigned long create_new = 1;
 static const unsigned long create_always = 2;
@@ -822,6 +823,7 @@
    unsigned long dwLanguageId, char *lpBuffer, unsigned long nSize,
    std::va_list *Arguments);
 extern "C" __declspec(dllimport) void *__stdcall LocalFree (void *);
+extern "C" __declspec(dllimport) unsigned long __stdcall GetFileAttributesA(const char *);
 extern "C" __declspec(dllimport) int __stdcall CreateDirectoryA(const char *, interprocess_security_attributes*);
 extern "C" __declspec(dllimport) int __stdcall RemoveDirectoryA(const char *lpPathName);
 extern "C" __declspec(dllimport) int __stdcall GetTempPathA(unsigned long length, char *buffer);
@@ -842,7 +844,6 @@
 extern "C" __declspec(dllimport) void *__stdcall GetModuleHandleA(const char*);
 extern "C" __declspec(dllimport) void *__stdcall GetFileInformationByHandle(void *, interprocess_by_handle_file_information*);
 
-
 //COM API
 extern "C" __declspec(dllimport) long __stdcall CoInitialize(void *pvReserved);
 extern "C" __declspec(dllimport) long __stdcall CoInitializeSecurity(
@@ -1472,6 +1473,7 @@
    if(co_init_ret != S_OK_IG && co_init_ret != S_FALSE_IG)
       return false;
    co_uninitializer co_initialize_end;
+ (void)co_initialize_end;
 
    bool bRet = false;
    long sec_init_ret = CoInitializeSecurity
@@ -1587,6 +1589,13 @@
    return ret;
 }
 
+inline bool is_directory(const char *path)
+{
+ unsigned long attrib = GetFileAttributesA(path);
+
+ return (attrib != invalid_file_attributes &&
+ (attrib & file_attribute_directory));
+}
 
 } //namespace winapi
 } //namespace interprocess

Modified: trunk/boost/interprocess/mem_algo/rbtree_best_fit.hpp
==============================================================================
--- trunk/boost/interprocess/mem_algo/rbtree_best_fit.hpp (original)
+++ trunk/boost/interprocess/mem_algo/rbtree_best_fit.hpp 2011-04-01 18:03:49 EDT (Fri, 01 Apr 2011)
@@ -338,8 +338,8 @@
    public:
    
    static const size_type Alignment = !MemAlignment
- ? ::boost::alignment_of< ::boost::detail::max_align>::value
- : MemAlignment
+ ? size_type(::boost::alignment_of< ::boost::detail::max_align>::value)
+ : size_type(MemAlignment)
       ;
 
    private:


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