Boost logo

Boost-Commit :

From: igaztanaga_at_[hidden]
Date: 2007-11-18 05:42:01


Author: igaztanaga
Date: 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
New Revision: 41194
URL: http://svn.boost.org/trac/boost/changeset/41194

Log:
Interprocess changes to support systems with filesystem-based shared memory
Text files modified:
   trunk/boost/interprocess/allocators/adaptive_pool.hpp | 1
   trunk/boost/interprocess/allocators/cached_adaptive_pool.hpp | 1
   trunk/boost/interprocess/allocators/cached_node_allocator.hpp | 1
   trunk/boost/interprocess/allocators/detail/adaptive_node_pool.hpp | 7 +
   trunk/boost/interprocess/allocators/detail/node_pool.hpp | 5 +
   trunk/boost/interprocess/allocators/node_allocator.hpp | 1
   trunk/boost/interprocess/allocators/private_adaptive_pool.hpp | 1
   trunk/boost/interprocess/allocators/private_node_allocator.hpp | 2
   trunk/boost/interprocess/containers/detail/flat_tree.hpp | 2
   trunk/boost/interprocess/containers/detail/node_alloc_holder.hpp | 2
   trunk/boost/interprocess/containers/vector.hpp | 10 -
   trunk/boost/interprocess/detail/config_begin.hpp | 2
   trunk/boost/interprocess/detail/managed_memory_impl.hpp | 2
   trunk/boost/interprocess/detail/win32_api.hpp | 25 ++----
   trunk/boost/interprocess/detail/workaround.hpp | 159 ++++++++++++++++-----------------------
   trunk/boost/interprocess/errors.hpp | 1
   trunk/boost/interprocess/interprocess_fwd.hpp | 2
   trunk/boost/interprocess/mapped_region.hpp | 4
   trunk/boost/interprocess/mem_algo/detail/mem_algo_common.hpp | 36 ++++++--
   trunk/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp | 144 +++++++++++++++++++++++++++++++-----
   trunk/boost/interprocess/mem_algo/rbtree_best_fit.hpp | 102 ++++++++++++++++++-------
   trunk/boost/interprocess/offset_ptr.hpp | 38 +++++++++
   trunk/boost/interprocess/shared_memory_object.hpp | 99 +++++++++++++++---------
   trunk/boost/interprocess/streams/bufferstream.hpp | 2
   trunk/boost/interprocess/streams/vectorstream.hpp | 2
   trunk/boost/interprocess/sync/emulation/named_creation_functor.hpp | 1
   trunk/boost/interprocess/sync/file_lock.hpp | 2
   trunk/boost/interprocess/sync/interprocess_barrier.hpp | 3
   trunk/boost/interprocess/sync/interprocess_mutex.hpp | 2
   trunk/boost/interprocess/sync/interprocess_recursive_mutex.hpp | 2
   trunk/boost/interprocess/sync/interprocess_upgradable_mutex.hpp | 2
   trunk/boost/interprocess/sync/named_condition.hpp | 8 +-
   trunk/boost/interprocess/sync/named_mutex.hpp | 6
   trunk/boost/interprocess/sync/named_semaphore.hpp | 6
   trunk/boost/interprocess/sync/posix/pthread_helpers.hpp | 4
   trunk/boost/interprocess/sync/posix/ptime_to_timespec.hpp | 1
   36 files changed, 432 insertions(+), 256 deletions(-)

Modified: trunk/boost/interprocess/allocators/adaptive_pool.hpp
==============================================================================
--- trunk/boost/interprocess/allocators/adaptive_pool.hpp (original)
+++ trunk/boost/interprocess/allocators/adaptive_pool.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -27,7 +27,6 @@
 #include <boost/interprocess/exceptions.hpp>
 #include <memory>
 #include <algorithm>
-#include <stdio.h>
 #include <cstddef>
 
 //!\file

Modified: trunk/boost/interprocess/allocators/cached_adaptive_pool.hpp
==============================================================================
--- trunk/boost/interprocess/allocators/cached_adaptive_pool.hpp (original)
+++ trunk/boost/interprocess/allocators/cached_adaptive_pool.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -28,7 +28,6 @@
 #include <boost/interprocess/allocators/detail/node_tools.hpp>
 #include <memory>
 #include <algorithm>
-#include <stdio.h>
 #include <cstddef>
 
 //!\file

Modified: trunk/boost/interprocess/allocators/cached_node_allocator.hpp
==============================================================================
--- trunk/boost/interprocess/allocators/cached_node_allocator.hpp (original)
+++ trunk/boost/interprocess/allocators/cached_node_allocator.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -27,7 +27,6 @@
 #include <boost/interprocess/exceptions.hpp>
 #include <memory>
 #include <algorithm>
-#include <stdio.h>
 #include <cstddef>
 
 //!\file

Modified: trunk/boost/interprocess/allocators/detail/adaptive_node_pool.hpp
==============================================================================
--- trunk/boost/interprocess/allocators/detail/adaptive_node_pool.hpp (original)
+++ trunk/boost/interprocess/allocators/detail/adaptive_node_pool.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -30,7 +30,7 @@
 #include <cstddef>
 #include <cmath>
 #include <cassert>
-#include <assert.h>
+#include <cassert>
 
 //!\file
 //!Describes the real adaptive pool shared by many Interprocess pool allocators
@@ -102,6 +102,9 @@
    ~private_adaptive_node_pool_impl()
    { priv_clear(); }
 
+ std::size_t get_real_num_node() const
+ { return m_real_num_node; }
+
    //!Returns the segment manager. Never throws
    segment_manager_base_type* get_segment_manager_base()const
    { return detail::get_pointer(mp_segment_mngr_base); }
@@ -162,7 +165,7 @@
       std::size_t count = 0;
       citerator it (m_first_free_chunk), itend(m_chunklist.end());
       for(; it != itend; ++it){
- count += it->size();
+ count += it->free_nodes.size();
       }
       return count;
    }

Modified: trunk/boost/interprocess/allocators/detail/node_pool.hpp
==============================================================================
--- trunk/boost/interprocess/allocators/detail/node_pool.hpp (original)
+++ trunk/boost/interprocess/allocators/detail/node_pool.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -28,7 +28,7 @@
 #include <cstddef>
 #include <functional>
 #include <algorithm>
-#include <assert.h>
+#include <cassert>
 
 //!\file
 //!Describes the real adaptive pool shared by many Interprocess adaptive pool allocators
@@ -78,6 +78,9 @@
    ~private_node_pool_impl()
    { priv_clear(); }
 
+ std::size_t get_real_num_node() const
+ { return m_nodes_per_chunk; }
+
    //!Returns the segment manager. Never throws
    segment_manager_base_type* get_segment_manager_base()const
    { return detail::get_pointer(mp_segment_mngr_base); }

Modified: trunk/boost/interprocess/allocators/node_allocator.hpp
==============================================================================
--- trunk/boost/interprocess/allocators/node_allocator.hpp (original)
+++ trunk/boost/interprocess/allocators/node_allocator.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -27,7 +27,6 @@
 #include <boost/interprocess/exceptions.hpp>
 #include <memory>
 #include <algorithm>
-#include <stdio.h>
 #include <cstddef>
 
 //!\file

Modified: trunk/boost/interprocess/allocators/private_adaptive_pool.hpp
==============================================================================
--- trunk/boost/interprocess/allocators/private_adaptive_pool.hpp (original)
+++ trunk/boost/interprocess/allocators/private_adaptive_pool.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -27,7 +27,6 @@
 #include <boost/interprocess/detail/workaround.hpp>
 #include <memory>
 #include <algorithm>
-#include <stdio.h>
 #include <cstddef>
 
 //!\file

Modified: trunk/boost/interprocess/allocators/private_node_allocator.hpp
==============================================================================
--- trunk/boost/interprocess/allocators/private_node_allocator.hpp (original)
+++ trunk/boost/interprocess/allocators/private_node_allocator.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -27,8 +27,6 @@
 #include <boost/interprocess/detail/workaround.hpp>
 #include <memory>
 #include <algorithm>
-
-#include <stdio.h>
 #include <cstddef>
 
 //!\file

Modified: trunk/boost/interprocess/containers/detail/flat_tree.hpp
==============================================================================
--- trunk/boost/interprocess/containers/detail/flat_tree.hpp (original)
+++ trunk/boost/interprocess/containers/detail/flat_tree.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -147,7 +147,7 @@
    { }
 
    flat_tree& operator=(const flat_tree& x)
- { flat_tree(x).swap(*this); return *this; }
+ { m_data = x.m_data; return *this; }
 
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    flat_tree& operator=(const detail::moved_object<flat_tree>& mx)

Modified: trunk/boost/interprocess/containers/detail/node_alloc_holder.hpp
==============================================================================
--- trunk/boost/interprocess/containers/detail/node_alloc_holder.hpp (original)
+++ trunk/boost/interprocess/containers/detail/node_alloc_holder.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -276,7 +276,7 @@
       multiallocation_iterator itbeg =
          this->node_alloc().allocate_individual(n), itend, itold;
       int constructed = 0;
- Node *p;
+ Node *p = 0;
       BOOST_TRY{
          for(difference_type i = 0; i < n; ++i, ++beg, --constructed){
             p = &*itbeg;

Modified: trunk/boost/interprocess/containers/vector.hpp
==============================================================================
--- trunk/boost/interprocess/containers/vector.hpp (original)
+++ trunk/boost/interprocess/containers/vector.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -52,8 +52,6 @@
 #include <stdexcept>
 #include <iterator>
 #include <utility>
-#include <string.h> //for memcopy, memmove
-
 #include <boost/detail/no_exceptions_support.hpp>
 #include <boost/type_traits/has_trivial_destructor.hpp>
 #include <boost/type_traits/has_trivial_copy.hpp>
@@ -329,7 +327,7 @@
    protected:
    void prot_deallocate()
    {
- if(!this->members_.m_start) return;
+ if(!this->members_.m_capacity) return;
       this->alloc().deallocate(this->members_.m_start, this->members_.m_capacity);
       this->members_.m_start = 0;
       this->members_.m_size = 0;
@@ -803,7 +801,6 @@
       if (&x != this){
          this->swap(x);
          x.clear();
-//? base_t::prot_deallocate();
       }
       return *this;
    }
@@ -815,7 +812,6 @@
       if (&x != this){
          this->swap(x);
          x.clear();
-//? base_t::prot_deallocate();
       }
       return *this;
    }
@@ -1124,7 +1120,7 @@
    private:
    void priv_shrink_to_fit(allocator_v1)
    {
- if(this->members_.m_start){
+ if(this->members_.m_capacity){
          if(!size()){
             this->prot_deallocate();
          }
@@ -1137,7 +1133,7 @@
 
    void priv_shrink_to_fit(allocator_v2)
    {
- if(this->members_.m_start){
+ if(this->members_.m_capacity){
          if(!size()){
             this->prot_deallocate();
          }

Modified: trunk/boost/interprocess/detail/config_begin.hpp
==============================================================================
--- trunk/boost/interprocess/detail/config_begin.hpp (original)
+++ trunk/boost/interprocess/detail/config_begin.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -9,6 +9,8 @@
    #define _CRT_SECURE_NO_DEPRECATE
    #endif
    #pragma warning (push)
+ #pragma warning (disable : 4706) // assignment within conditional expression
+ #pragma warning (disable : 4127) // conditional expression is constant
    #pragma warning (disable : 4146) // unary minus operator applied to unsigned type, result still unsigned
    #pragma warning (disable : 4284) // odd return type for operator->
    #pragma warning (disable : 4244) // possible loss of data

Modified: trunk/boost/interprocess/detail/managed_memory_impl.hpp
==============================================================================
--- trunk/boost/interprocess/detail/managed_memory_impl.hpp (original)
+++ trunk/boost/interprocess/detail/managed_memory_impl.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -35,7 +35,7 @@
 #include <utility>
 #include <fstream>
 #include <new>
-#include <assert.h>
+#include <cassert>
 
 //!\file
 //!Describes a named shared memory allocation user class.

Modified: trunk/boost/interprocess/detail/win32_api.hpp
==============================================================================
--- trunk/boost/interprocess/detail/win32_api.hpp (original)
+++ trunk/boost/interprocess/detail/win32_api.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -13,7 +13,7 @@
 
 #include <boost/interprocess/detail/config_begin.hpp>
 #include <boost/interprocess/detail/workaround.hpp>
-#include <stddef.h>
+#include <cstddef>
 
 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
 # pragma once
@@ -21,8 +21,7 @@
 #endif
 
 #if (defined BOOST_WINDOWS) && !(defined BOOST_DISABLE_WIN32)
-# include <stddef.h>
-# include <stdarg.h>
+# include <cstdarg>
 # include <boost/detail/interlocked.hpp>
 #else
 # error "This file can only be included in Windows OS"
@@ -224,17 +223,17 @@
 extern "C" __declspec(dllimport) int __stdcall ReleaseSemaphore(void *, long, long *);
 extern "C" __declspec(dllimport) void * __stdcall OpenSemaphoreA(unsigned long, int, const char *);
 extern "C" __declspec(dllimport) void * __stdcall CreateFileMappingA (void *, interprocess_security_attributes*, unsigned long, unsigned long, unsigned long, const char *);
-extern "C" __declspec(dllimport) void * __stdcall MapViewOfFileEx (void *, unsigned long, unsigned long, unsigned long, size_t, void*);
+extern "C" __declspec(dllimport) void * __stdcall MapViewOfFileEx (void *, unsigned long, unsigned long, unsigned long, std::size_t, void*);
 extern "C" __declspec(dllimport) void * __stdcall OpenFileMappingA (unsigned long, int, const char *);
 extern "C" __declspec(dllimport) void * __stdcall CreateFileA (const char *, unsigned long, unsigned long, struct _SECURITY_ATTRIBUTES*, unsigned long, unsigned long, void *);
 extern "C" __declspec(dllimport) int __stdcall DeleteFileA (const char *);
 extern "C" __declspec(dllimport) void __stdcall GetSystemInfo (struct system_info *);
-extern "C" __declspec(dllimport) int __stdcall FlushViewOfFile (void *, size_t);
+extern "C" __declspec(dllimport) int __stdcall FlushViewOfFile (void *, std::size_t);
 extern "C" __declspec(dllimport) int __stdcall GetFileSizeEx (void *, __int64 *size);
 extern "C" __declspec(dllimport) unsigned long __stdcall FormatMessageA
    (unsigned long dwFlags, const void *lpSource, unsigned long dwMessageId,
    unsigned long dwLanguageId, char *lpBuffer, unsigned long nSize,
- va_list *Arguments);
+ std::va_list *Arguments);
 extern "C" __declspec(dllimport) void *__stdcall LocalFree (void *);
 extern "C" __declspec(dllimport) int __stdcall CreateDirectoryA(const char *, interprocess_security_attributes*);
 extern "C" __declspec(dllimport) int __stdcall GetTempPathA(unsigned long length, char *buffer);
@@ -250,14 +249,6 @@
 extern "C" __declspec(dllimport) int __stdcall InitializeSecurityDescriptor(interprocess_security_descriptor *pSecurityDescriptor, unsigned long dwRevision);
 extern "C" __declspec(dllimport) int __stdcall SetSecurityDescriptorDacl(interprocess_security_descriptor *pSecurityDescriptor, int bDaclPresent, interprocess_acl *pDacl, int bDaclDefaulted);
 
-/*
-extern "C" __declspec(dllimport) long __stdcall InterlockedIncrement( long volatile * );
-extern "C" __declspec(dllimport) long __stdcall InterlockedDecrement( long volatile * );
-extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long volatile *, long, long );
-extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd(long volatile *, long);
-extern "C" __declspec(dllimport) long __stdcall InterlockedExchange(long volatile *, long);
-*/
-
 } //namespace winapi {
 } //namespace interprocess {
 } //namespace boost {
@@ -273,7 +264,7 @@
 static inline unsigned long format_message
    (unsigned long dwFlags, const void *lpSource,
     unsigned long dwMessageId, unsigned long dwLanguageId,
- char *lpBuffer, unsigned long nSize, va_list *Arguments)
+ char *lpBuffer, unsigned long nSize, std::va_list *Arguments)
 {
    return FormatMessageA
       (dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments);
@@ -360,7 +351,7 @@
 static inline void * open_file_mapping (unsigned long access, const char *name)
 { return OpenFileMappingA (access, 0, name); }
 
-static inline void *map_view_of_file_ex(void *handle, unsigned long file_access, unsigned long highoffset, unsigned long lowoffset, size_t numbytes, void *base_addr)
+static inline void *map_view_of_file_ex(void *handle, unsigned long file_access, unsigned long highoffset, unsigned long lowoffset, std::size_t numbytes, void *base_addr)
 { return MapViewOfFileEx(handle, file_access, highoffset, lowoffset, numbytes, base_addr); }
 
 static inline void *create_file(const char *name, unsigned long access, unsigned long creation_flags, unsigned long attributes = 0)
@@ -372,7 +363,7 @@
 static inline void get_system_info(system_info *info)
 { GetSystemInfo(info); }
 
-static inline int flush_view_of_file(void *base_addr, size_t numbytes)
+static inline int flush_view_of_file(void *base_addr, std::size_t numbytes)
 { return FlushViewOfFile(base_addr, numbytes); }
 
 static inline bool get_file_size(void *handle, __int64 &size)

Modified: trunk/boost/interprocess/detail/workaround.hpp
==============================================================================
--- trunk/boost/interprocess/detail/workaround.hpp (original)
+++ trunk/boost/interprocess/detail/workaround.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -14,22 +14,29 @@
 #include <boost/interprocess/detail/config_begin.hpp>
 
 #if !(defined BOOST_WINDOWS) || (defined BOOST_DISABLE_WIN32)
- #if defined(_POSIX_THREAD_PROCESS_SHARED) && (_POSIX_THREAD_PROCESS_SHARED - 0 > 0)
- #if !defined(__CYGWIN__)
- #define BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
- #endif
- #endif
 
- #if defined(_POSIX_BARRIERS) && (_POSIX_BARRIERS - 0 > 0)
- #define BOOST_INTERPROCESS_POSIX_BARRIERS
- #endif //
-
- #if defined(_POSIX_SEMAPHORES) && (_POSIX_SEMAPHORES - 0 > 0)
- #define BOOST_INTERPROCESS_POSIX_SEMAPHORES
- #if defined(__CYGWIN__)
- #define BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK
- #endif
- #endif
+ #if defined(_POSIX_THREAD_PROCESS_SHARED)
+ # if !((_XOPEN_VERSION >= 600) && (_POSIX_THREAD_PROCESS_SHARED - 0 <= 0))
+ # if !defined(__CYGWIN__)
+ # define BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
+ # endif
+ # endif
+ #endif
+
+ #if defined(_POSIX_BARRIERS)
+ # if !((_XOPEN_VERSION >= 600) && (_POSIX_BARRIERS - 0 <= 0))
+ # define BOOST_INTERPROCESS_POSIX_BARRIERS
+ # endif
+ #endif
+
+ #if defined(_POSIX_SEMAPHORES)
+ # if !((_XOPEN_VERSION >= 600) && (_POSIX_SEMAPHORES - 0 <= 0))
+ # define BOOST_INTERPROCESS_POSIX_SEMAPHORES
+ # if defined(__CYGWIN__)
+ #define BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK
+ # endif
+ # endif
+ #endif
 
    #if ((defined _V6_ILP32_OFFBIG) &&(_V6_ILP32_OFFBIG - 0 > 0)) ||\
        ((defined _V6_LP64_OFF64) &&(_V6_LP64_OFF64 - 0 > 0)) ||\
@@ -43,12 +50,32 @@
    #else
    #endif
 
- #if defined(_POSIX_SHARED_MEMORY_OBJECTS) && (_POSIX_SHARED_MEMORY_OBJECTS - 0 > 0)
- #define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
- #endif
-
- #if defined(_POSIX_TIMEOUTS) && (_POSIX_TIMEOUTS - 0 > 0)
- #define BOOST_INTERPROCESS_POSIX_TIMEOUTS
+ #if defined(_POSIX_SHARED_MEMORY_OBJECTS)
+ # if !((_XOPEN_VERSION >= 600) && (_POSIX_SHARED_MEMORY_OBJECTS - 0 <= 0))
+ # define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
+ # endif
+ #else
+ # if defined(__vms)
+ # if __CRTL_VER >= 70200000
+ # define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
+ # endif
+ # endif
+ #endif
+
+ #if defined(_POSIX_TIMEOUTS)
+ # if !((_XOPEN_VERSION >= 600) && (_POSIX_TIMEOUTS - 0 <= 0))
+ # define BOOST_INTERPROCESS_POSIX_TIMEOUTS
+ # endif
+ #endif
+
+ #ifdef BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
+ //Some systems have filesystem-based shared memory, so the
+ //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
+ #if defined(__hpux) || defined(__osf__) || defined(__vms)
+ #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
+ #endif
    #endif
 
 #endif
@@ -68,80 +95,22 @@
 #if defined(BOOST_INTERPROCESS_RVALUE_REFERENCE) || defined(BOOST_INTERPROCESS_VARIADIC_TEMPLATES)
 #define BOOST_INTERPROCESS_PERFECT_FORWARDING
 #endif
-/*
-namespace boost {
-namespace interprocess {
-namespace workaround{
-
-//////////////////////////////////////////////////
-// //
-// We want generally const_shm_ptr to inherit//
-// from iterator class but for void this //
-// doesn't work, so we must inherit from //
-// other class. //
-// //
-//////////////////////////////////////////////////
-
-//Empty class
-struct empty_type{};
-
-template<class T>
-struct random_it
-: public std::iterator<std::random_access_iterator_tag,
- T, std::ptrdiff_t, T*, T&>
-{
- typedef const T* const_pointer;
- typedef const T& const_reference;
-};
-
-template<> struct random_it<void>
-{
- typedef void * pointer;
- typedef const void * const_pointer;
- typedef empty_type& reference;
- typedef const empty_type& const_reference;
- typedef void value_type;
- typedef empty_type difference_type;
- typedef empty_type iterator_category;
-};
-
-template<> struct random_it<const void>
-{
- typedef const void * pointer;
- typedef const void * const_pointer;
- typedef const empty_type & reference;
- typedef const empty_type & const_reference;
- typedef const void value_type;
- typedef empty_type difference_type;
- typedef empty_type iterator_category;
-};
-
-template<> struct random_it<volatile void>
-{
- typedef volatile void * pointer;
- typedef const volatile void * const_pointer;
- typedef empty_type& reference;
- typedef const empty_type& const_reference;
- typedef volatile void value_type;
- typedef empty_type difference_type;
- typedef empty_type iterator_category;
-};
-
-template<> struct random_it<const volatile void>
-{
- typedef const volatile void * pointer;
- typedef const volatile void * const_pointer;
- typedef const empty_type & reference;
- typedef const empty_type & const_reference;
- typedef const volatile void value_type;
- typedef empty_type difference_type;
- typedef empty_type iterator_category;
-};
-
-} //namespace workaround
-} //namespace interprocess {
-} //namespace boost {
-*/
+
+//Now declare some Boost.Interprocess features depending on the implementation
+
+#if defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
+
+#define BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES
+
+#endif
+
+#if defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
+
+#define BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES
+#define BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES
+
+#endif
+
 #include <boost/interprocess/detail/config_end.hpp>
 
 #endif //#ifndef BOOST_INTERPROCESS_PTR_WRKRND_HPP

Modified: trunk/boost/interprocess/errors.hpp
==============================================================================
--- trunk/boost/interprocess/errors.hpp (original)
+++ trunk/boost/interprocess/errors.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -38,6 +38,7 @@
 #else
 # ifdef BOOST_HAS_UNISTD_H
 # include <errno.h> //Errors
+# include <cstring> //strerror
 # else //ifdef BOOST_HAS_UNISTD_H
 # error Unknown platform
 # endif //ifdef BOOST_HAS_UNISTD_H

Modified: trunk/boost/interprocess/interprocess_fwd.hpp
==============================================================================
--- trunk/boost/interprocess/interprocess_fwd.hpp (original)
+++ trunk/boost/interprocess/interprocess_fwd.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -151,7 +151,7 @@
 //////////////////////////////////////////////////////////////////////////////
 
 //Single segment memory allocation algorithms
-template<class MutexFamily, class VoidMutex = offset_ptr<void> >
+template<class MutexFamily, class VoidMutex = void*>//offset_ptr<void> >
 class simple_seq_fit;
 
 template<class MutexFamily, class VoidMutex = offset_ptr<void> >

Modified: trunk/boost/interprocess/mapped_region.hpp
==============================================================================
--- trunk/boost/interprocess/mapped_region.hpp (original)
+++ trunk/boost/interprocess/mapped_region.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -246,7 +246,9 @@
          #ifdef max
          #undef max
          #endif
- if(total_size > std::numeric_limits<std::size_t>::max()){
+
+ if(static_cast<unsigned __int64>(total_size) >
+ std::numeric_limits<std::size_t>::max()){
             error_info err(size_error);
             throw interprocess_exception(err);
          }

Modified: trunk/boost/interprocess/mem_algo/detail/mem_algo_common.hpp
==============================================================================
--- trunk/boost/interprocess/mem_algo/detail/mem_algo_common.hpp (original)
+++ trunk/boost/interprocess/mem_algo/detail/mem_algo_common.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -126,12 +126,18 @@
    static const std::size_t BlockCtrlBytes = MemoryAlgorithm::BlockCtrlBytes;
    static const std::size_t BlockCtrlUnits = MemoryAlgorithm::BlockCtrlUnits;
 
- static void check_alignment(const void *ptr)
+ static void assert_alignment(const void *ptr)
+ { assert_alignment((std::size_t)ptr); }
+
+ static void assert_alignment(std::size_t uint_ptr)
    {
- (void)ptr;
- BOOST_ASSERT(((std::size_t)ptr) % Alignment == 0);
+ (void)uint_ptr;
+ BOOST_ASSERT(uint_ptr % Alignment == 0);
    }
 
+ static bool check_alignment(const void *ptr)
+ { return (((std::size_t)ptr) % Alignment == 0); }
+
    static std::size_t ceil_units(std::size_t size)
    { return detail::get_rounded_size(size, Alignment)/Alignment; }
 
@@ -174,7 +180,7 @@
       //We can find a aligned portion if we allocate a chunk that has alignment
       //nbytes + alignment bytes or more.
       std::size_t minimum_allocation = max_value
- ( nbytes + alignment, std::size_t(MinBlockUnits*Alignment));
+ (nbytes + alignment, std::size_t(MinBlockUnits*Alignment));
       //Since we will split that chunk, we must request a bit more memory
       //if the alignment is near the beginning of the buffer, because otherwise,
       //there is no space for a new chunk before the alignment.
@@ -185,7 +191,7 @@
       // | MBU |
       // -----------------------------------------------------
       std::size_t request =
- minimum_allocation + (MinBlockUnits*Alignment - AllocatedCtrlBytes);
+ minimum_allocation + (2*MinBlockUnits*Alignment - AllocatedCtrlBytes);
 
       //Now allocate the buffer
       void *buffer = memory_algo->priv_allocate(allocate_new, request, request, real_size).first;
@@ -232,7 +238,9 @@
       //Now obtain the address of the blocks
       block_ctrl *first = memory_algo->priv_get_block(buffer);
       block_ctrl *second = memory_algo->priv_get_block(pos);
-
+ assert(pos <= ((char*)first + first->m_size*Alignment));
+ assert(first->m_size >= 2*MinBlockUnits);
+ assert((pos + MinBlockUnits*Alignment - AllocatedCtrlBytes + nbytes*Alignment/Alignment) <= ((char*)first + first->m_size*Alignment));
       //Set the new size of the first block
       std::size_t old_size = first->m_size;
       first->m_size = ((char*)second - (char*)first)/Alignment;
@@ -264,6 +272,7 @@
       }
       else{
          second->m_size = old_size - first->m_size;
+ assert(second->m_size >= MinBlockUnits);
          memory_algo->priv_mark_new_allocated_block(second);
       }
 
@@ -284,7 +293,7 @@
       BOOST_ASSERT(memory_algo->priv_is_allocated_block(block));
 
       //Check if alignment and block size are right
- check_alignment(ptr);
+ assert_alignment(ptr);
 
       //Put this to a safe value
       received_size = (old_block_units - AllocatedCtrlUnits)*Alignment;
@@ -374,19 +383,22 @@
 
       //Calculate the total size of all requests
       std::size_t total_request_units = 0;
- std::size_t elem_units;
+ std::size_t elem_units = 0;
+ const std::size_t ptr_size_units = memory_algo->priv_get_total_units(sizeof(multi_allocation_next_ptr));
       if(!sizeof_element){
          elem_units = memory_algo->priv_get_total_units(*elem_sizes);
+ elem_units = ptr_size_units > elem_units ? ptr_size_units : elem_units;
          total_request_units = n_elements*elem_units;
       }
       else{
          for(std::size_t i = 0; i < n_elements; ++i){
             elem_units = memory_algo->priv_get_total_units(elem_sizes[i]*sizeof_element);
+ elem_units = ptr_size_units > elem_units ? ptr_size_units : elem_units;
             total_request_units += elem_units;
          }
       }
 
- multi_allocation_next_ptr first = 0, previous;
+ multi_allocation_next_ptr first = 0, previous = 0;
       std::size_t low_idx = 0;
       while(low_idx < n_elements){
          std::size_t total_bytes = total_request_units*Alignment - AllocatedCtrlBytes;
@@ -410,12 +422,14 @@
          while(total_used_units < received_units){
             if(sizeof_element){
                elem_units = memory_algo->priv_get_total_units(elem_sizes[low_idx]*sizeof_element);
+ elem_units = ptr_size_units > elem_units ? ptr_size_units : elem_units;
             }
             if(total_used_units + elem_units > received_units)
                break;
             total_request_units -= elem_units;
             //This is the position where the new block must be created
             block_ctrl *new_block = new(block_address)block_ctrl;
+ assert_alignment(new_block);
 
             //The last block should take all the remaining space
             if((low_idx + 1) == n_elements ||
@@ -457,7 +471,10 @@
 
             block_address += new_block->m_size*Alignment;
             total_used_units += new_block->m_size;
+ //Check we have enough room to overwrite the intrusive pointer
+ assert((new_block->m_size*Alignment - AllocatedCtrlUnits) >= sizeof(multi_allocation_next_t));
             multi_allocation_next_ptr p = new(memory_algo->priv_get_user_buffer(new_block))multi_allocation_next_t(0);
+
             if(!first){
                first = p;
             }
@@ -482,7 +499,6 @@
       else{
          return multiallocation_iterator(first);
       }
- return multiallocation_iterator(first);
    }
 };
 

Modified: trunk/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp
==============================================================================
--- trunk/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp (original)
+++ trunk/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -31,8 +31,7 @@
 #include <algorithm>
 #include <utility>
 #include <cstring>
-
-#include <assert.h>
+#include <cassert>
 #include <new>
 
 //!\file
@@ -104,6 +103,8 @@
       std::size_t m_allocated;
       //!The size of the memory segment
       std::size_t m_size;
+ //!The extra size required by the segment
+ std::size_t m_extra_hdr_bytes;
    } m_header;
 
    friend class detail::basic_multiallocation_iterator<void_pointer>;
@@ -150,6 +151,9 @@
    //!Increases managed memory in extra_size bytes more
    void grow(std::size_t extra_size);
 
+ //!Decreases managed memory as much as possible
+ void shrink_to_fit();
+
    //!Returns true if all allocated memory has been deallocated
    bool all_memory_deallocated();
 
@@ -199,6 +203,9 @@
    //!of "userbytes" bytes really occupies (including header)
    static std::size_t priv_get_total_units(std::size_t userbytes);
 
+ static std::size_t priv_first_block_offset(const void *this_ptr, std::size_t extra_hdr_bytes);
+ std::size_t priv_block_end_offset() const;
+
    //!Returns next block if it's free.
    //!Returns 0 if next block is not free.
    block_ctrl *priv_next_block_if_free(block_ctrl *ptr);
@@ -242,7 +249,7 @@
 
    static const std::size_t Alignment = detail::alignment_of<detail::max_align>::value;
    static const std::size_t BlockCtrlBytes = detail::ct_rounded_size<sizeof(block_ctrl), Alignment>::value;
- static const std::size_t BlockCtrlUnits = BlockCtrlBytes/Alignment;
+ static const std::size_t BlockCtrlUnits = BlockCtrlBytes/Alignment;
    static const std::size_t MinBlockUnits = BlockCtrlUnits;
    static const std::size_t MinBlockSize = MinBlockUnits*Alignment;
    static const std::size_t AllocatedCtrlBytes = BlockCtrlBytes;
@@ -253,17 +260,49 @@
 };
 
 template<class MutexFamily, class VoidPointer>
+inline std::size_t simple_seq_fit_impl<MutexFamily, VoidPointer>
+ ::priv_first_block_offset(const void *this_ptr, std::size_t extra_hdr_bytes)
+{
+ //First align "this" pointer
+ std::size_t uint_this = (std::size_t)this_ptr;
+ std::size_t uint_aligned_this = uint_this/Alignment*Alignment;
+ std::size_t this_disalignment = (uint_this - uint_aligned_this);
+ std::size_t block1_off =
+ detail::get_rounded_size(sizeof(simple_seq_fit_impl) + extra_hdr_bytes + this_disalignment, Alignment)
+ - this_disalignment;
+ algo_impl_t::assert_alignment(this_disalignment + block1_off);
+ return block1_off;
+}
+
+template<class MutexFamily, class VoidPointer>
+inline std::size_t simple_seq_fit_impl<MutexFamily, VoidPointer>
+ ::priv_block_end_offset() const
+{
+ //First align "this" pointer
+ std::size_t uint_this = (std::size_t)this;
+ std::size_t uint_aligned_this = uint_this/Alignment*Alignment;
+ std::size_t this_disalignment = (uint_this - uint_aligned_this);
+ std::size_t old_end =
+ detail::get_truncated_size(m_header.m_size + this_disalignment, Alignment)
+ - this_disalignment;
+ algo_impl_t::assert_alignment(old_end + this_disalignment);
+ return old_end;
+}
+
+template<class MutexFamily, class VoidPointer>
 inline simple_seq_fit_impl<MutexFamily, VoidPointer>::
    simple_seq_fit_impl(std::size_t size, std::size_t extra_hdr_bytes)
 {
    //Initialize sizes and counters
    m_header.m_allocated = 0;
    m_header.m_size = size;
+ m_header.m_extra_hdr_bytes = extra_hdr_bytes;
 
    //Initialize pointers
- std::size_t block1_off = detail::get_rounded_size(sizeof(*this)+extra_hdr_bytes, Alignment);
+ std::size_t block1_off = priv_first_block_offset(this, extra_hdr_bytes);
    m_header.m_root.m_next = reinterpret_cast<block_ctrl*>
                               (detail::char_ptr_cast(this) + block1_off);
+ algo_impl_t::assert_alignment(detail::get_pointer(m_header.m_root.m_next));
    m_header.m_root.m_next->m_size = (size - block1_off)/Alignment;
    m_header.m_root.m_next->m_next = &m_header.m_root;
 }
@@ -278,9 +317,9 @@
 
 template<class MutexFamily, class VoidPointer>
 inline void simple_seq_fit_impl<MutexFamily, VoidPointer>::grow(std::size_t extra_size)
-{
+{
    //Old highest address block's end offset
- std::size_t old_end = m_header.m_size/Alignment*Alignment;
+ std::size_t old_end = this->priv_block_end_offset();
 
    //Update managed buffer's size
    m_header.m_size += extra_size;
@@ -294,6 +333,7 @@
    block_ctrl *new_block = reinterpret_cast<block_ctrl*>
                               (detail::char_ptr_cast(this) + old_end);
 
+ algo_impl_t::assert_alignment(new_block);
    new_block->m_next = 0;
    new_block->m_size = (m_header.m_size - old_end)/Alignment;
    m_header.m_allocated += new_block->m_size*Alignment;
@@ -301,6 +341,60 @@
 }
 
 template<class MutexFamily, class VoidPointer>
+void simple_seq_fit_impl<MutexFamily, VoidPointer>::shrink_to_fit()
+{
+ //Get the root and the first memory block
+ block_ctrl *prev = &m_header.m_root;
+ block_ctrl *last = &m_header.m_root;
+ block_ctrl *block = detail::get_pointer(last->m_next);
+ block_ctrl *root = &m_header.m_root;
+
+ //No free block?
+ if(block == root) return;
+
+ //Iterate through the free block list
+ while(block != root){
+ prev = last;
+ last = block;
+ block = detail::get_pointer(block->m_next);
+ }
+
+ char *last_free_end_address = (char*)last + last->m_size*Alignment;
+ if(last_free_end_address != ((char*)this + priv_block_end_offset())){
+ //there is an allocated block in the end of this block
+ //so no shrinking is possible
+ return;
+ }
+
+ //Check if have only 1 big free block
+ void *unique_block = 0;
+ if(!m_header.m_allocated){
+ assert(prev == root);
+ std::size_t ignore;
+ unique_block = priv_allocate(allocate_new, 0, 0, ignore).first;
+ if(!unique_block)
+ return;
+ last = detail::get_pointer(m_header.m_root.m_next);
+ assert(last_free_end_address == ((char*)last + last->m_size*Alignment));
+ }
+ std::size_t last_units = last->m_size;
+
+ std::size_t received_size;
+ void *addr = priv_check_and_allocate(last_units, prev, last, received_size);
+ assert(addr);
+ assert(received_size == last_units*Alignment - AllocatedCtrlBytes);
+
+ //Shrink it
+ m_header.m_size /= Alignment;
+ m_header.m_size -= last->m_size;
+ m_header.m_size *= Alignment;
+ m_header.m_allocated -= last->m_size*Alignment;
+
+ if(unique_block)
+ priv_deallocate(unique_block);
+}
+
+template<class MutexFamily, class VoidPointer>
 inline void simple_seq_fit_impl<MutexFamily, VoidPointer>::
    priv_mark_new_allocated_block(block_ctrl *new_block)
 {
@@ -324,6 +418,7 @@
 template<class MutexFamily, class VoidPointer>
 inline void simple_seq_fit_impl<MutexFamily, VoidPointer>::priv_add_segment(void *addr, std::size_t size)
 {
+ algo_impl_t::assert_alignment(addr);
    //Check size
    assert(!(size < MinBlockSize));
    if(size < MinBlockSize)
@@ -346,15 +441,15 @@
 inline std::size_t simple_seq_fit_impl<MutexFamily, VoidPointer>::get_free_memory() const
 {
    return m_header.m_size - m_header.m_allocated -
- ((char*)detail::get_pointer(m_header.m_root.m_next) - (char*)this);
+ algo_impl_t::multiple_of_units(sizeof(*this) + m_header.m_extra_hdr_bytes);
 }
 
 template<class MutexFamily, class VoidPointer>
 inline std::size_t simple_seq_fit_impl<MutexFamily, VoidPointer>::
    get_min_size (std::size_t extra_hdr_bytes)
 {
- return detail::get_rounded_size(sizeof(simple_seq_fit_impl)+extra_hdr_bytes
- ,Alignment)
+ return detail::get_rounded_size(sizeof(simple_seq_fit_impl),Alignment) +
+ detail::get_rounded_size(extra_hdr_bytes,Alignment)
           + MinBlockSize;
 }
 
@@ -400,7 +495,10 @@
    std::size_t free_memory = 0;
 
    //Iterate through all blocks obtaining their size
- do{
+ while(block != &m_header.m_root){
+ algo_impl_t::assert_alignment(block);
+ if(!algo_impl_t::check_alignment(block))
+ return false;
       //Free blocks's next must be always valid
       block_ctrl *next = detail::get_pointer(block->m_next);
       if(!next){
@@ -409,7 +507,6 @@
       free_memory += block->m_size*Alignment;
       block = next;
    }
- while(block != &m_header.m_root);
 
    //Check allocated bytes are less than size
    if(m_header.m_allocated > m_header.m_size){
@@ -648,8 +745,10 @@
    if(reuse_ptr && (command & (expand_fwd | expand_bwd))){
       void *ret = priv_expand_both_sides
          (command, limit_size, preferred_size, received_size, reuse_ptr, true);
- if(ret)
+ if(ret){
+ algo_impl_t::assert_alignment(ret);
          return return_type(ret, true);
+ }
    }
 
    if(command & allocate_new){
@@ -661,8 +760,12 @@
             biggest_size = block->m_size;
             biggest_block = block;
          }
+ algo_impl_t::assert_alignment(block);
          void *addr = this->priv_check_and_allocate(nunits, prev, block, received_size);
- if(addr) return return_type(addr, false);
+ if(addr){
+ algo_impl_t::assert_alignment(addr);
+ return return_type(addr, false);
+ }
          //Bad luck, let's check next block
          prev = block;
          block = detail::get_pointer(block->m_next);
@@ -679,13 +782,16 @@
          void *ret = this->priv_check_and_allocate
             (biggest_block->m_size, prev_biggest_block, biggest_block, received_size);
          assert(ret != 0);
+ algo_impl_t::assert_alignment(ret);
          return return_type(ret, false);
       }
    }
    //Now try to expand both sides with min size
    if(reuse_ptr && (command & (expand_fwd | expand_bwd))){
- return return_type(priv_expand_both_sides
+ return_type ret (priv_expand_both_sides
          (command, limit_size, preferred_size, received_size, reuse_ptr, false), true);
+ algo_impl_t::assert_alignment(ret.first);
+ return ret;
    }
    return return_type(0, false);
 }
@@ -837,8 +943,8 @@
 
    if (block->m_size > upper_nunits){
       //This block is bigger than needed, split it in
- //two blocks, the first's size will be (block->m_size-units)
- //the second's size (units)
+ //two blocks, the first's size will be "units"
+ //the second's size will be "block->m_size-units"
       std::size_t total_size = block->m_size;
       block->m_size = nunits;
       block_ctrl *new_block = reinterpret_cast<block_ctrl*>
@@ -863,8 +969,7 @@
       //Mark the block as allocated
       block->m_next = 0;
       //Check alignment
- assert(((detail::char_ptr_cast(block) - detail::char_ptr_cast(this))
- % Alignment) == 0 );
+ algo_impl_t::assert_alignment(block);
       return priv_get_user_buffer(block);
    }
    return 0;
@@ -897,8 +1002,7 @@
    assert(block->m_next == 0);
 
    //Check if alignment and block size are right
- assert((detail::char_ptr_cast(addr) - detail::char_ptr_cast(this))
- % Alignment == 0 );
+ algo_impl_t::assert_alignment(addr);
 
    std::size_t total_size = Alignment*block->m_size;
    assert(m_header.m_allocated >= total_size);

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 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -33,10 +33,11 @@
 #include <boost/static_assert.hpp>
 #include <algorithm>
 #include <utility>
-#include <limits.h>
+#include <climits>
+#include <cstring>
 #include <iterator>
 
-#include <assert.h>
+#include <cassert>
 #include <new>
 
 //#define BOOST_INTERPROCESS_RBTREE_BEST_FIT_USE_SPLAY
@@ -44,7 +45,9 @@
 #ifndef BOOST_INTERPROCESS_RBTREE_BEST_FIT_USE_SPLAY
 #include <boost/intrusive/set.hpp>
 #else
-#include <boost/intrusive/splay_set.hpp>
+//#include <boost/intrusive/splay_set.hpp>
+//#include <boost/intrusive/avl_set.hpp>
+#include <boost/intrusive/sg_set.hpp>
 #endif
 
 //!\file
@@ -87,7 +90,9 @@
 #ifndef BOOST_INTERPROCESS_RBTREE_BEST_FIT_USE_SPLAY
    typedef typename bi::make_set_base_hook
 #else
- typedef typename bi::make_splay_set_base_hook
+// typedef typename bi::make_splay_set_base_hook
+// typedef typename bi::make_avl_set_base_hook
+ typedef typename bi::make_sg_set_base_hook
 #endif
       < bi::void_pointer<VoidPointer>
       , bi::optimize_size<true>
@@ -134,7 +139,9 @@
 #ifndef BOOST_INTERPROCESS_RBTREE_BEST_FIT_USE_SPLAY
    typedef typename bi::make_multiset
 #else
- typedef typename bi::make_splay_multiset
+ //typedef typename bi::make_splay_multiset
+ //typedef typename bi::make_avl_multiset
+ typedef typename bi::make_sg_multiset
 #endif
       <block_ctrl, bi::base_hook<TreeHook> >::type Imultiset;
 
@@ -232,6 +239,8 @@
 
    /// @cond
    private:
+ static std::size_t priv_first_block_offset(const void *this_ptr, std::size_t extra_hdr_bytes);
+
    std::pair<void*, bool>
       priv_allocation_command(allocation_type command, std::size_t limit_size,
                         std::size_t preferred_size,std::size_t &received_size,
@@ -308,6 +317,10 @@
    void priv_mark_new_allocated_block(block_ctrl *block);
 
    static const std::size_t Alignment = detail::alignment_of<detail::max_align>::value;
+ //Due to embedded bits in size, Alignment must be at least 2
+ BOOST_STATIC_ASSERT((Alignment >= 2));
+ //Due to rbtree size optimizations, Alignment must have at least pointer alignment
+ BOOST_STATIC_ASSERT((Alignment >= detail::alignment_of<void_pointer>::value));
    static const std::size_t AlignmentMask = (Alignment - 1);
    static const std::size_t BlockCtrlBytes = detail::ct_rounded_size<sizeof(block_ctrl), Alignment>::value;
    static const std::size_t BlockCtrlUnits = BlockCtrlBytes/Alignment;
@@ -325,6 +338,21 @@
 };
 
 template<class MutexFamily, class VoidPointer>
+inline std::size_t rbtree_best_fit<MutexFamily, VoidPointer>
+ ::priv_first_block_offset(const void *this_ptr, std::size_t extra_hdr_bytes)
+{
+ //First align "this" pointer
+ std::size_t uint_this = (std::size_t)this_ptr;
+ std::size_t uint_aligned_this = uint_this/Alignment*Alignment;
+ std::size_t this_disalignment = (uint_this - uint_aligned_this);
+ std::size_t block1_off =
+ detail::get_rounded_size(sizeof(rbtree_best_fit) + extra_hdr_bytes + this_disalignment, Alignment)
+ - this_disalignment;
+ algo_impl_t::assert_alignment(this_disalignment + block1_off);
+ return block1_off;
+}
+
+template<class MutexFamily, class VoidPointer>
 inline rbtree_best_fit<MutexFamily, VoidPointer>::
    rbtree_best_fit(std::size_t size, std::size_t extra_hdr_bytes)
 {
@@ -335,9 +363,8 @@
 
    //Now write calculate the offset of the first big block that will
    //cover the whole segment
- std::size_t block1_off = algo_impl_t::multiple_of_units(sizeof(*this)+extra_hdr_bytes);
    assert(get_min_size(extra_hdr_bytes) <= size);
-
+ std::size_t block1_off = priv_first_block_offset(this, extra_hdr_bytes);
    priv_add_segment(detail::char_ptr_cast(this) + block1_off, size - block1_off);
 }
 
@@ -353,8 +380,8 @@
 void rbtree_best_fit<MutexFamily, VoidPointer>::grow(std::size_t extra_size)
 {
    //Get the address of the first block
- std::size_t block1_off =
- algo_impl_t::multiple_of_units(sizeof(*this) + m_header.m_extra_hdr_bytes);
+ std::size_t block1_off =
+ priv_first_block_offset(this, m_header.m_extra_hdr_bytes);
 
    block_ctrl *first_block = reinterpret_cast<block_ctrl *>
                                  (detail::char_ptr_cast(this) + block1_off);
@@ -405,17 +432,22 @@
 void rbtree_best_fit<MutexFamily, VoidPointer>::shrink_to_fit()
 {
    //Get the address of the first block
- std::size_t block1_off =
- algo_impl_t::multiple_of_units(sizeof(*this) + m_header.m_extra_hdr_bytes);
+ std::size_t block1_off =
+ priv_first_block_offset(this, m_header.m_extra_hdr_bytes);
 
- block_ctrl *first_block = reinterpret_cast<block_ctrl *>
+ block_ctrl *first_block = reinterpret_cast<block_ctrl*>
                                  (detail::char_ptr_cast(this) + block1_off);
+ algo_impl_t::assert_alignment(first_block);
+
    block_ctrl *old_end_block = priv_prev_block(first_block);
+ algo_impl_t::assert_alignment(old_end_block);
    assert(priv_is_allocated_block(old_end_block));
    assert(old_end_block->m_end);
- std::size_t old_end_block_size = old_end_block->m_size;
 
    block_ctrl *last_block = priv_prev_block(old_end_block);
+ algo_impl_t::assert_alignment(old_end_block);
+
+ std::size_t old_end_block_size = old_end_block->m_size;
 
    void *unique_block = 0;
    if(last_block == first_block){
@@ -423,7 +455,9 @@
       unique_block = priv_allocate(allocate_new, 0, 0, ignore).first;
       if(!unique_block)
          return;
- last_block = priv_prev_block(old_end_block);
+ algo_impl_t::assert_alignment(unique_block);
+ last_block = priv_prev_block(old_end_block);
+ algo_impl_t::assert_alignment(last_block);
    }
 
    //The last block must be free to be able to shrink
@@ -432,9 +466,6 @@
 
    std::size_t last_block_size = last_block->m_size;
 
- //Update managed buffer's size
- m_header.m_size -= last_block->m_size*Alignment;
-
    //Erase block from the free tree, since we will erase it
    m_header.m_imultiset.erase(Imultiset::s_iterator_to(*last_block));
 
@@ -442,12 +473,15 @@
                                        detail::char_ptr_cast(this)) + EndCtrlBlockBytes;
    
    block_ctrl *new_end_block = last_block;
+ algo_impl_t::assert_alignment(new_end_block);
    priv_mark_as_allocated_block(new_end_block);
    new_end_block->m_end = 1;
    new_end_block->m_size = old_end_block_size + last_block_size;
    priv_tail_size(new_end_block, new_end_block->m_size);
    assert(priv_prev_block(first_block) == new_end_block);
- assert(shrunk_border_offset == m_header.m_size);
+
+ //Update managed buffer's size
+ m_header.m_size = shrunk_border_offset;
    if(unique_block)
       priv_deallocate(unique_block);
 }
@@ -457,7 +491,7 @@
    priv_add_segment(void *addr, std::size_t size)
 {
    //Check alignment
- assert(((detail::char_ptr_cast(addr) - ((char*)0)) % Alignment) == 0 );
+ algo_impl_t::check_alignment(addr);
    //Check size
    assert(size >= (BlockCtrlBytes + EndCtrlBlockBytes));
 
@@ -512,14 +546,15 @@
 inline std::size_t rbtree_best_fit<MutexFamily, VoidPointer>::get_free_memory() const
 {
    return m_header.m_size - m_header.m_allocated -
- algo_impl_t::multiple_of_units(sizeof(*this) + m_header.m_extra_hdr_bytes);
+ priv_first_block_offset(this, m_header.m_extra_hdr_bytes);
 }
 
 template<class MutexFamily, class VoidPointer>
 inline std::size_t rbtree_best_fit<MutexFamily, VoidPointer>::
    get_min_size (std::size_t extra_hdr_bytes)
 {
- return (algo_impl_t::ceil_units(sizeof(rbtree_best_fit) + extra_hdr_bytes) +
+ return (algo_impl_t::ceil_units(sizeof(rbtree_best_fit)) +
+ algo_impl_t::ceil_units(extra_hdr_bytes) +
            MinBlockUnits + EndCtrlBlockUnits)*Alignment;
 }
 
@@ -531,7 +566,7 @@
    boost::interprocess::scoped_lock<interprocess_mutex> guard(m_header);
    //-----------------------
    std::size_t block1_off =
- algo_impl_t::multiple_of_units(sizeof(*this)+m_header.m_extra_hdr_bytes);
+ priv_first_block_offset(this, m_header.m_extra_hdr_bytes);
 
    return m_header.m_allocated == 0 &&
       m_header.m_imultiset.begin() != m_header.m_imultiset.end() &&
@@ -554,6 +589,9 @@
    //Iterate through all blocks obtaining their size
    for(; ib != ie; ++ib){
       free_memory += ib->m_size*Alignment;
+ algo_impl_t::assert_alignment(&*ib);
+ if(!algo_impl_t::check_alignment(&*ib))
+ return false;
    }
 
    //Check allocated bytes are less than size
@@ -562,7 +600,7 @@
    }
 
    std::size_t block1_off =
- algo_impl_t::multiple_of_units(sizeof(*this)+m_header.m_extra_hdr_bytes);
+ priv_first_block_offset(this, m_header.m_extra_hdr_bytes);
 
    //Check free bytes are less than size
    if(free_memory > (m_header.m_size - block1_off)){
@@ -672,6 +710,7 @@
                          ,bool only_preferred_backwards
                          ,std::size_t backwards_multiple)
 {
+ algo_impl_t::assert_alignment(reuse_ptr);
    if(command & expand_fwd){
       if(priv_expand(reuse_ptr, min_size, preferred_size, received_size))
          return reuse_ptr;
@@ -693,7 +732,7 @@
 
       //Sanity check
       assert(reuse->m_size == priv_tail_size(reuse));
- algo_impl_t::check_alignment(reuse);
+ algo_impl_t::assert_alignment(reuse);
 
       block_ctrl *prev_block;
 
@@ -704,7 +743,7 @@
 
       //Some sanity checks
       assert(prev_block->m_size == priv_tail_size(prev_block));
- algo_impl_t::check_alignment(prev_block);
+ algo_impl_t::assert_alignment(prev_block);
 
       //Let's calculate the number of extra bytes of data before the current
       //block's begin. The value is a multiple of backwards_multiple
@@ -760,13 +799,14 @@
             m_header.m_allocated += needs_backwards_aligned;
          
             //Check alignment
- algo_impl_t::check_alignment(new_block);
+ algo_impl_t::assert_alignment(new_block);
 
             //If the backwards expansion has remaining bytes in the
             //first bytes, fill them with a pattern
             void *p = priv_get_user_buffer(new_block);
             void *user_ptr = detail::char_ptr_cast(p);
             assert(((char*)reuse_ptr - (char*)user_ptr) % backwards_multiple == 0);
+ algo_impl_t::assert_alignment(user_ptr);
             return user_ptr;
          }
          //Check if there is no place to create a new block and
@@ -792,6 +832,7 @@
             void *p = priv_get_user_buffer(prev_block);
             void *user_ptr = detail::char_ptr_cast(p);
             assert(((char*)reuse_ptr - (char*)user_ptr) % backwards_multiple == 0);
+ algo_impl_t::assert_alignment(user_ptr);
             return user_ptr;
          }
          else{
@@ -944,6 +985,7 @@
    if(priv_is_allocated_block(next_block = priv_next_block(block))){
       return received_size >= min_size ? true : false;
    }
+ algo_impl_t::assert_alignment(next_block);
 
    //Is "block" + "next_block" big enough?
    const std::size_t merged_units = old_block_units + next_block->m_size;
@@ -977,6 +1019,7 @@
       block_ctrl *new_block = new(reinterpret_cast<block_ctrl*>
                      (detail::char_ptr_cast(block) + intended_units*Alignment))block_ctrl;
       new_block->m_size = merged_units - intended_units;
+ algo_impl_t::assert_alignment(new_block);
       assert(new_block->m_size >= BlockCtrlUnits);
       priv_tail_size(new_block, new_block->m_size);
       priv_mark_as_free_block(new_block);
@@ -1057,6 +1100,7 @@
 {
    std::size_t upper_nunits = nunits + BlockCtrlUnits;
    imultiset_iterator it_old = Imultiset::s_iterator_to(*block);
+ algo_impl_t::assert_alignment(block);
 
    if (block->m_size >= upper_nunits){
       //This block is bigger than needed, split it in
@@ -1070,6 +1114,7 @@
       //This is the remaining block
       block_ctrl *new_block = new(reinterpret_cast<block_ctrl*>
                      (detail::char_ptr_cast(block) + Alignment*nunits))block_ctrl;
+ algo_impl_t::assert_alignment(new_block);
       new_block->m_size = block_old_size - nunits;
       assert(new_block->m_size >= BlockCtrlUnits);
       priv_tail_size(new_block, new_block->m_size);
@@ -1108,9 +1153,6 @@
    //Mark the block as allocated
    priv_mark_as_allocated_block(block);
 
- //Check alignment
- algo_impl_t::check_alignment(block);
-
    //Clear the memory occupied by the tree hook, since this won't be
    //cleared with zero_free_memory
    TreeHook *t = static_cast<TreeHook*>(block);
@@ -1140,7 +1182,7 @@
    assert(block->m_size == priv_tail_size(block));
 
    //Check if alignment and block size are right
- algo_impl_t::check_alignment(addr);
+ algo_impl_t::assert_alignment(addr);
 
    std::size_t block_old_size = Alignment*block->m_size;
    assert(m_header.m_allocated >= block_old_size);

Modified: trunk/boost/interprocess/offset_ptr.hpp
==============================================================================
--- trunk/boost/interprocess/offset_ptr.hpp (original)
+++ trunk/boost/interprocess/offset_ptr.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -322,7 +322,6 @@
    pt2 = ptr;
 }
 
-
 //!Simulation of static_cast between pointers. Never throws.
 template<class T, class U>
 inline boost::interprocess::offset_ptr<T>
@@ -407,7 +406,7 @@
 template<std::size_t N>
 struct has_pointer_plus_bit<boost::interprocess::offset_ptr<void>, N>
 {
- enum { value = (N % 4u) == 0 };
+ static const bool value = (N % 4u == 0);
 };
 
 //Predeclaration
@@ -433,6 +432,41 @@
    { n = (T*)(std::size_t(get_pointer(n).get()) | (std::size_t(c) << 1u)); }
 };
 
+//Predeclaration to avoid including header
+template<class VoidPointer, std::size_t N>
+struct has_pointer_plus_2_bits;
+
+template<std::size_t N>
+struct has_pointer_plus_2_bits<boost::interprocess::offset_ptr<void>, N>
+{
+ static const bool value = (N % 8u == 0);
+};
+
+//Predeclaration
+template<class Pointer>
+struct pointer_plus_2_bits;
+
+template<class T>
+struct pointer_plus_2_bits<boost::interprocess::offset_ptr<T> >
+{
+ typedef boost::interprocess::offset_ptr<T> pointer;
+
+ static pointer get_pointer(const pointer &n)
+ { return (T*)(std::size_t(n.get()) & ~std::size_t(6u)); }
+
+ static void set_pointer(pointer &n, pointer p)
+ { n = (T*)(std::size_t(p.get()) | (std::size_t(n.get()) & std::size_t(6u))); }
+
+ static std::size_t get_bits(const pointer &n)
+ { return(std::size_t(n.get()) & std::size_t(6u)) >> 1u; }
+
+ static void set_bits(pointer &n, std::size_t b)
+ {
+ assert(b < 4);
+ n = (T*)(std::size_t(get_pointer(n).get()) | (b << 1u));
+ }
+};
+
 } //namespace intrusive
 } //namespace boost{
 /// @endcond

Modified: trunk/boost/interprocess/shared_memory_object.hpp
==============================================================================
--- trunk/boost/interprocess/shared_memory_object.hpp (original)
+++ trunk/boost/interprocess/shared_memory_object.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -21,6 +21,7 @@
 #include <boost/interprocess/detail/os_file_functions.hpp>
 #include <cstddef>
 #include <string>
+#include <cstdio> //std::remove
 #include <algorithm>
 
 #ifdef BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
@@ -139,6 +140,14 @@
    //!Closes a previously opened file mapping. Never throws.
    void priv_close();
 
+ //!Create a temporary file name
+ static void priv_tmp_filename(const char *name, std::string &tmp_name);
+
+ //!Create a temporary file name
+ static void priv_create_tmp_dir_and_get_filename(const char *name, std::string &tmp_name);
+
+ static void priv_add_leading_slash(const char *name, std::string &new_name);
+
    //!Closes a previously opened file mapping. Never throws.
    bool priv_open_or_create(detail::create_enum_t type, const char *filename, mode_t mode);
 
@@ -175,26 +184,36 @@
 inline mode_t shared_memory_object::get_mode() const
 { return m_mode; }
 
-#if !defined(BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS)
-
-inline bool shared_memory_object::priv_open_or_create
- (detail::create_enum_t type, const char *filename, mode_t mode)
+inline void shared_memory_object::priv_tmp_filename
+ (const char *filename, std::string &tmp_name)
 {
- m_filename = filename;
+ const char *tmp_dir = detail::get_temporary_path();
+ if(!tmp_dir){
+ error_info err = system_error_code();
+ throw interprocess_exception(err);
+ }
+ tmp_name = tmp_dir;
+
+ //Remove final null.
+ tmp_name += "/boost_interprocess/";
+ tmp_name += filename;
+}
 
+inline void shared_memory_object::priv_create_tmp_dir_and_get_filename
+ (const char *filename, std::string &tmp_name)
+{
    const char *tmp_path = detail::get_temporary_path();
    if(!tmp_path){
       error_info err = system_error_code();
       throw interprocess_exception(err);
    }
 
- std::string shmfile = tmp_path;
-
- shmfile += "/boost_interprocess";
+ tmp_name = tmp_path;
+ tmp_name += "/boost_interprocess";
 
    //Create the temporary directory.
    //If fails, check that it's because already exists
- if(!detail::create_directory(shmfile.c_str())){
+ if(!detail::create_directory(tmp_name.c_str())){
       error_info info(system_error_code());
       if(info.get_error_code() != already_exists_error){
          throw interprocess_exception(info);
@@ -202,8 +221,27 @@
    }
 
    //Add filename
- shmfile += '/';
- shmfile += filename;
+ tmp_name += '/';
+ tmp_name += filename;
+}
+
+inline void shared_memory_object::priv_add_leading_slash
+ (const char *name, std::string &new_name)
+{
+ if(name[0] != '/'){
+ new_name = '/';
+ }
+ new_name += name;
+}
+
+#if !defined(BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS)
+
+inline bool shared_memory_object::priv_open_or_create
+ (detail::create_enum_t type, const char *filename, mode_t mode)
+{
+ m_filename = filename;
+ std::string shmfile;
+ priv_create_tmp_dir_and_get_filename(filename, shmfile);
 
    //Set accesses
    if (mode != read_write && mode != read_only){
@@ -244,17 +282,7 @@
    try{
       //Make sure a temporary path is created for shared memory
       std::string shmfile;
-
- const char *tmp_dir = detail::get_temporary_path();
- if(!tmp_dir){
- error_info err = system_error_code();
- throw interprocess_exception(err);
- }
- shmfile = tmp_dir;
-
- //Remove final null.
- shmfile += "/boost_interprocess/";
- shmfile += filename;
+ priv_tmp_filename(filename, shmfile);
       return std::remove(shmfile.c_str()) == 0;
    }
    catch(...){
@@ -285,13 +313,11 @@
     const char *filename,
     mode_t mode)
 {
- bool slash_added = filename[0] != '/';
- //First add preceding "/"
- m_filename.clear();
- if(slash_added){
- m_filename = '/';
- }
- m_filename += filename;
+ #ifndef BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
+ priv_add_leading_slash(filename, m_filename);
+ #else
+ priv_create_tmp_dir_and_get_filename(filename, m_filename);
+ #endif
 
    //Create new mapping
    int oflag = 0;
@@ -333,10 +359,7 @@
       throw interprocess_exception(err);
    }
 
- if(slash_added){
- m_filename.erase(m_filename.begin());
- }
-
+ m_filename = filename;
    m_mode = mode;
    return true;
 }
@@ -345,11 +368,11 @@
 {
    try{
       std::string file_str;
- //First add preceding "/"
- if(filename[0] != '/'){
- file_str = '/';
- }
- file_str += filename;
+ #ifndef BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
+ priv_add_leading_slash(filename, file_str);
+ #else
+ priv_tmp_filename(filename, file_str);
+ #endif
       return 0 != shm_unlink(file_str.c_str());
    }
    catch(...){

Modified: trunk/boost/interprocess/streams/bufferstream.hpp
==============================================================================
--- trunk/boost/interprocess/streams/bufferstream.hpp (original)
+++ trunk/boost/interprocess/streams/bufferstream.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -44,7 +44,7 @@
 #include <ostream>
 #include <string> // char traits
 #include <cstddef> // ptrdiff_t
-#include <assert.h>
+#include <cassert>
 #include <boost/interprocess/interprocess_fwd.hpp>
 
 namespace boost { namespace interprocess {

Modified: trunk/boost/interprocess/streams/vectorstream.hpp
==============================================================================
--- trunk/boost/interprocess/streams/vectorstream.hpp (original)
+++ trunk/boost/interprocess/streams/vectorstream.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -46,7 +46,7 @@
 #include <string> // char traits
 #include <cstddef> // ptrdiff_t
 #include <boost/interprocess/interprocess_fwd.hpp>
-#include <assert.h>
+#include <cassert>
 
 namespace boost { namespace interprocess {
 

Modified: trunk/boost/interprocess/sync/emulation/named_creation_functor.hpp
==============================================================================
--- trunk/boost/interprocess/sync/emulation/named_creation_functor.hpp (original)
+++ trunk/boost/interprocess/sync/emulation/named_creation_functor.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -55,7 +55,6 @@
             return false;
          break;
       }
- return true;
    }
    private:
    detail::create_enum_t m_creation_type;

Modified: trunk/boost/interprocess/sync/file_lock.hpp
==============================================================================
--- trunk/boost/interprocess/sync/file_lock.hpp (original)
+++ trunk/boost/interprocess/sync/file_lock.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -18,7 +18,7 @@
 #include <boost/interprocess/detail/config_begin.hpp>
 #include <boost/interprocess/detail/workaround.hpp>
 #include <boost/interprocess/exceptions.hpp>
-#include <assert.h>
+#include <cassert>
 #include <boost/interprocess/detail/os_file_functions.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
 

Modified: trunk/boost/interprocess/sync/interprocess_barrier.hpp
==============================================================================
--- trunk/boost/interprocess/sync/interprocess_barrier.hpp (original)
+++ trunk/boost/interprocess/sync/interprocess_barrier.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -33,8 +33,7 @@
 #include <boost/interprocess/detail/config_begin.hpp>
 #include <boost/interprocess/detail/workaround.hpp>
 
-#if defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED &&\
- defined BOOST_INTERPROCESS_POSIX_BARRIERS
+#if defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED && defined BOOST_INTERPROCESS_POSIX_BARRIERS
 # include <pthread.h>
 # include <errno.h>
 # include <boost/interprocess/sync/posix/pthread_helpers.hpp>

Modified: trunk/boost/interprocess/sync/interprocess_mutex.hpp
==============================================================================
--- trunk/boost/interprocess/sync/interprocess_mutex.hpp (original)
+++ trunk/boost/interprocess/sync/interprocess_mutex.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -34,7 +34,7 @@
 #include <boost/interprocess/detail/config_begin.hpp>
 #include <boost/interprocess/detail/workaround.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
-#include <assert.h>
+#include <cassert>
 
 #if defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
    #include <pthread.h>

Modified: trunk/boost/interprocess/sync/interprocess_recursive_mutex.hpp
==============================================================================
--- trunk/boost/interprocess/sync/interprocess_recursive_mutex.hpp (original)
+++ trunk/boost/interprocess/sync/interprocess_recursive_mutex.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -34,7 +34,7 @@
 #include <boost/interprocess/detail/config_begin.hpp>
 #include <boost/interprocess/detail/workaround.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
-#include <assert.h>
+#include <cassert>
 
 #if defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
    #include <pthread.h>

Modified: trunk/boost/interprocess/sync/interprocess_upgradable_mutex.hpp
==============================================================================
--- trunk/boost/interprocess/sync/interprocess_upgradable_mutex.hpp (original)
+++ trunk/boost/interprocess/sync/interprocess_upgradable_mutex.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -20,7 +20,7 @@
 #include <boost/interprocess/sync/scoped_lock.hpp>
 #include <boost/interprocess/sync/interprocess_mutex.hpp>
 #include <boost/interprocess/sync/interprocess_condition.hpp>
-#include <limits.h>
+#include <climits>
 
 
 //!\file

Modified: trunk/boost/interprocess/sync/named_condition.hpp
==============================================================================
--- trunk/boost/interprocess/sync/named_condition.hpp (original)
+++ trunk/boost/interprocess/sync/named_condition.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -24,7 +24,7 @@
 #include <boost/interprocess/detail/managed_open_or_create_impl.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
 #include <boost/interprocess/sync/emulation/named_creation_functor.hpp>
-#if defined BOOST_INTERPROCESS_POSIX_SEMAPHORES && defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
+#if defined BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES
 #include <boost/interprocess/sync/interprocess_mutex.hpp>
 #include <boost/interprocess/sync/scoped_lock.hpp>
 #endif
@@ -119,7 +119,7 @@
       interprocess_condition cond_;
       //If named_mutex is implemented using semaphores
       //we need to store an additional mutex
- #if defined BOOST_INTERPROCESS_POSIX_SEMAPHORES && defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
+ #if defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
       interprocess_mutex mutex_;
       #endif
    };
@@ -139,7 +139,7 @@
       void unlock() { l_.lock(); }
    };
 
- #if defined BOOST_INTERPROCESS_POSIX_SEMAPHORES && defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
+ #if defined (BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
    interprocess_mutex *mutex() const
    { return &static_cast<condition_holder*>(m_shmem.get_user_address())->mutex_; }
 
@@ -210,7 +210,7 @@
 inline void named_condition::dont_close_on_destruction()
 { detail::interprocess_tester::dont_close_on_destruction(m_shmem); }
 
-#if defined BOOST_INTERPROCESS_POSIX_SEMAPHORES && defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
+#if defined(BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
 
 inline void named_condition::notify_one()
 {

Modified: trunk/boost/interprocess/sync/named_mutex.hpp
==============================================================================
--- trunk/boost/interprocess/sync/named_mutex.hpp (original)
+++ trunk/boost/interprocess/sync/named_mutex.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -22,7 +22,7 @@
 #include <boost/interprocess/sync/emulation/named_creation_functor.hpp>
 #include <boost/interprocess/detail/interprocess_tester.hpp>
 
-#if defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
+#if defined(BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
    #include <boost/interprocess/sync/posix/semaphore_wrapper.hpp>
 #else
    #include <boost/interprocess/shared_memory_object.hpp>
@@ -106,7 +106,7 @@
    friend class detail::interprocess_tester;
    void dont_close_on_destruction();
 
- #if defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
+ #if defined(BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
    detail::named_semaphore_wrapper m_sem;
    #else
    interprocess_mutex *mutex() const
@@ -120,7 +120,7 @@
 
 /// @cond
 
-#if defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
+#if defined(BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES)
 
 inline named_mutex::named_mutex(create_only_t, const char *name)
    : m_sem(detail::DoCreate, name, read_write, 1)

Modified: trunk/boost/interprocess/sync/named_semaphore.hpp
==============================================================================
--- trunk/boost/interprocess/sync/named_semaphore.hpp (original)
+++ trunk/boost/interprocess/sync/named_semaphore.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -22,7 +22,7 @@
 #include <boost/interprocess/detail/interprocess_tester.hpp>
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
 
-#if defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
+#if defined(BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES)
 #include <boost/interprocess/sync/posix/semaphore_wrapper.hpp>
 #else
 #include <boost/interprocess/shared_memory_object.hpp>
@@ -107,7 +107,7 @@
    friend class detail::interprocess_tester;
    void dont_close_on_destruction();
 
- #if defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
+ #if defined(BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES)
    detail::named_semaphore_wrapper m_sem;
    #else
    interprocess_semaphore *semaphore() const
@@ -121,7 +121,7 @@
 
 /// @cond
 
-#if defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
+#if defined(BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES)
 
 inline named_semaphore::named_semaphore
    (create_only_t, const char *name, int initialCount)

Modified: trunk/boost/interprocess/sync/posix/pthread_helpers.hpp
==============================================================================
--- trunk/boost/interprocess/sync/posix/pthread_helpers.hpp (original)
+++ trunk/boost/interprocess/sync/posix/pthread_helpers.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -111,7 +111,7 @@
 
    #endif // #if defined BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
 
- #if defined BOOST_INTERPROCESS_POSIX_BARRIERS
+ #if defined(BOOST_INTERPROCESS_POSIX_BARRIERS) && defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED)
 
    //!Makes pthread_barrierattr_t cleanup easy when using exceptions
    struct barrierattr_wrapper
@@ -155,7 +155,7 @@
       pthread_barrier_t *mp_barrier;
    };
 
- #endif //#if defined BOOST_INTERPROCESS_POSIX_BARRIERS
+ #endif //#if defined(BOOST_INTERPROCESS_POSIX_BARRIERS) && defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED)
 
 }//namespace detail
 

Modified: trunk/boost/interprocess/sync/posix/ptime_to_timespec.hpp
==============================================================================
--- trunk/boost/interprocess/sync/posix/ptime_to_timespec.hpp (original)
+++ trunk/boost/interprocess/sync/posix/ptime_to_timespec.hpp 2007-11-18 05:41:57 EST (Sun, 18 Nov 2007)
@@ -12,7 +12,6 @@
 #define BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP
 
 #include <boost/interprocess/detail/posix_time_types_wrk.hpp>
-#include <time.h>
 
 namespace boost {
 


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