Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74115 - in sandbox/mmap/boost/mmap: . detail handles mappble_objects/file mappble_objects/file/posix mappble_objects/file/win32 mappble_objects/shared_memory/posix mappble_objects/shared_memory/win32 mapping mapping/nt mapping/posix mapping/win32
From: dsaritz_at_[hidden]
Date: 2011-08-28 20:17:58


Author: psiha
Date: 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
New Revision: 74115
URL: http://svn.boost.org/trac/boost/changeset/74115

Log:
Extracted remaining mapping flags from the mapped_view module into appropriate impl headers in mappable_objects/file/* and mappable_objects/shared_memory/* directoris.
Split file flags structure(s) into file open and file mapping flags.
Extracted create_mapping() functions from the mapped_view_reference<>::map() member function(s) into appropriate impl modules.
Various other cleanups and restructuring.
Added:
   sandbox/mmap/boost/mmap/detail/posix.hpp (contents, props changed)
   sandbox/mmap/boost/mmap/detail/windows.hpp (contents, props changed)
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/mapping_flags.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mapped_view.hpp
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/mapping_flags.inl
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mapped_view.inl
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/open_flags.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/open_flags.inl
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/mapping_flags.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mapped_view.hpp
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/mapping_flags.inl
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mapped_view.inl
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/open_flags.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/open_flags.inl
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl
   sandbox/mmap/boost/mmap/mappble_objects/shared_memory/posix/flags.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mapped_view.hpp
   sandbox/mmap/boost/mmap/mappble_objects/shared_memory/posix/flags.inl
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mapped_view.inl
   sandbox/mmap/boost/mmap/mappble_objects/shared_memory/win32/flags.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mapped_view.hpp
   sandbox/mmap/boost/mmap/mappble_objects/shared_memory/win32/flags.inl
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/mapped_view.inl
   sandbox/mmap/boost/mmap/mapping/ (props changed)
   sandbox/mmap/boost/mmap/mapping/mapping.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp
   sandbox/mmap/boost/mmap/mapping/nt/ (props changed)
   sandbox/mmap/boost/mmap/mapping/posix/ (props changed)
   sandbox/mmap/boost/mmap/mapping/posix/mapping.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp
   sandbox/mmap/boost/mmap/mapping/posix/mapping.inl
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/handles/win32/handle.inl
   sandbox/mmap/boost/mmap/mapping/win32/ (props changed)
   sandbox/mmap/boost/mmap/mapping/win32/mapping.hpp
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp
   sandbox/mmap/boost/mmap/mapping/win32/mapping.inl
      - copied, changed from r74074, /sandbox/mmap/boost/mmap/handles/win32/handle.inl
Removed:
   sandbox/mmap/boost/mmap/handles/mapping_handle.hpp
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl
Text files modified:
   sandbox/mmap/boost/mmap/mappble_objects/file/file.hpp | 4
   sandbox/mmap/boost/mmap/mappble_objects/file/flags.hpp | 3
   sandbox/mmap/boost/mmap/mappble_objects/file/handle.hpp | 6
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.hpp | 12 +
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.inl | 14 +
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/mapping_flags.hpp | 309 ++++-----------------------------------
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/mapping_flags.inl | 248 -------------------------------
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/open_flags.hpp | 79 ++++-----
   sandbox/mmap/boost/mmap/mappble_objects/file/posix/open_flags.inl | 71 ++------
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.hpp | 20 +
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.inl | 50 ++++--
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/mapping_flags.hpp | 308 +++-----------------------------------
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/mapping_flags.inl | 247 ++-----------------------------
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/open_flags.hpp | 79 +++++-----
   sandbox/mmap/boost/mmap/mappble_objects/file/win32/open_flags.inl | 67 +++----
   sandbox/mmap/boost/mmap/mappble_objects/shared_memory/posix/flags.hpp | 306 ++------------------------------------
   sandbox/mmap/boost/mmap/mappble_objects/shared_memory/posix/flags.inl | 254 +-------------------------------
   sandbox/mmap/boost/mmap/mappble_objects/shared_memory/win32/flags.hpp | 305 ++------------------------------------
   sandbox/mmap/boost/mmap/mappble_objects/shared_memory/win32/flags.inl | 254 +-------------------------------
   sandbox/mmap/boost/mmap/mapped_view.hpp | 207 ++++++++------------------
   sandbox/mmap/boost/mmap/mapped_view.inl | 227 ++++-------------------------
   sandbox/mmap/boost/mmap/mapping/mapping.hpp | 23 +-
   sandbox/mmap/boost/mmap/mapping/posix/mapping.hpp | 42 +++-
   sandbox/mmap/boost/mmap/mapping/posix/mapping.inl | 74 ++++----
   sandbox/mmap/boost/mmap/mapping/win32/mapping.hpp | 42 +++-
   sandbox/mmap/boost/mmap/mapping/win32/mapping.inl | 83 ++++++----
   26 files changed, 598 insertions(+), 2736 deletions(-)

Added: sandbox/mmap/boost/mmap/detail/posix.hpp
==============================================================================
--- (empty file)
+++ sandbox/mmap/boost/mmap/detail/posix.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -0,0 +1,50 @@
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \file posix.hpp
+/// ---------------
+///
+/// Copyright (c) 2011 Domagoj Saric
+///
+/// Use, modification and distribution is subject to 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)
+///
+/// For more information, see http://www.boost.org
+///
+////////////////////////////////////////////////////////////////////////////////
+//------------------------------------------------------------------------------
+#ifndef posix_hpp__8FC3F669_80D4_4455_829D_F72E8ABDE9D0
+#define posix_hpp__8FC3F669_80D4_4455_829D_F72E8ABDE9D0
+#pragma once
+//------------------------------------------------------------------------------
+#include "boost/config.hpp"
+
+#if defined( BOOST_HAS_UNISTD_H )
+ #include "boost/config/posix_features.hpp"
+#elif defined( BOOST_MSVC )
+ #pragma warning ( disable : 4996 ) // "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name."
+ #include "io.h"
+ #include "wchar.h"
+#else
+ #error no suitable POSIX implementation found
+#endif // BOOST_MSVC
+
+#if defined( BOOST_MSVC )
+ #define BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( standard, linux, osx, msvc ) msvc
+#elif defined( __APPLE__ )
+ #define BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( standard, linux, osx, msvc ) osx
+#elif defined( _GNU_SOURCE )
+ #define BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( standard, linux, osx, msvc ) linux
+#else
+ #define BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( standard, linux, osx, msvc ) standard
+#endif // POSIX impl
+//------------------------------------------------------------------------------
+namespace boost
+{
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+} // namespace boost
+//------------------------------------------------------------------------------
+#endif // posix_hpp

Added: sandbox/mmap/boost/mmap/detail/windows.hpp
==============================================================================
--- (empty file)
+++ sandbox/mmap/boost/mmap/detail/windows.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \file windows.hpp
+/// ------------------
+///
+/// Copyright (c) 2011 Domagoj Saric
+///
+/// Use, modification and distribution is subject to 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)
+///
+/// For more information, see http://www.boost.org
+///
+////////////////////////////////////////////////////////////////////////////////
+//------------------------------------------------------------------------------
+#ifndef windows_hpp__886EAB51_B4AD_4246_9BE3_D5272EA7D59F
+#define windows_hpp__886EAB51_B4AD_4246_9BE3_D5272EA7D59F
+#pragma once
+//------------------------------------------------------------------------------
+#ifndef BOOST_MMAP_HEADER_ONLY
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+ #endif // WIN32_LEAN_AND_MEAN
+ #ifndef NOMINMAX
+ #define NOMINMAX
+ #endif // NOMINMAX
+#endif // BOOST_MMAP_HEADER_ONLY
+#include "windows.h"
+//------------------------------------------------------------------------------
+namespace boost
+{
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+} // namespace boost
+//------------------------------------------------------------------------------
+#endif // windows_hpp

Deleted: sandbox/mmap/boost/mmap/handles/mapping_handle.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/handles/mapping_handle.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
+++ (empty file)
@@ -1,44 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file mapping_handle.hpp
-/// ------------------------
-///
-/// Copyright (c) 2011 Domagoj Saric
-///
-/// Use, modification and distribution is subject to 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)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
-#define mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
-#pragma once
-//------------------------------------------------------------------------------
-#include "handle.hpp"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace mmap
-{
-//------------------------------------------------------------------------------
-
-template <typename Impl> class handle;
-
-template <typename Impl>
-class mapping_handle : handle<Impl>
-{
-public:
- mapping_handle( typename handle<Impl>::handle_t const native_handle )
- : handle<Impl>( native_handle ) {}
-};
-
-//------------------------------------------------------------------------------
-} // namespace mmap
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-#endif // handle_hpp

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/file.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/file.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/file.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -20,7 +20,7 @@
 #include "../../detail/impl_selection.hpp"
 
 #include BOOST_MMAP_IMPL_INCLUDE( BOOST_PP_EMPTY, BOOST_PP_IDENTITY( /file.hpp ) )
-#include BOOST_MMAP_IMPL_INCLUDE( BOOST_PP_EMPTY, BOOST_PP_IDENTITY( /flags.hpp ) )
+#include "flags.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -29,7 +29,7 @@
 {
 //------------------------------------------------------------------------------
 
-typedef file_flags<BOOST_MMAP_IMPL()> native_file_flags;
+typedef file_open_flags<BOOST_MMAP_IMPL()> native_file_open_flags;
 
 inline bool delete_file( char const * const file_name ) { return delete_file( file_name, BOOST_MMAP_IMPL() () ); }
 inline bool delete_file( wchar_t const * const file_name ) { return delete_file( file_name, BOOST_MMAP_IMPL() () ); }

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/flags.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/flags.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -19,6 +19,7 @@
 //------------------------------------------------------------------------------
 #include "../../detail/impl_selection.hpp"
 
-#include BOOST_MMAP_IMPL_INCLUDE( BOOST_PP_EMPTY, BOOST_PP_IDENTITY( /flags.hpp ) )
+#include BOOST_MMAP_IMPL_INCLUDE( BOOST_PP_EMPTY, BOOST_PP_IDENTITY( /mapping_flags.hpp ) )
+#include BOOST_MMAP_IMPL_INCLUDE( BOOST_PP_EMPTY, BOOST_PP_IDENTITY( /open_flags.hpp ) )
 //------------------------------------------------------------------------------
 #endif // flags_hpp

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/handle.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/handle.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/handle.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapping_handle.hpp
-/// ------------------------
+/// \file handle.hpp
+/// ----------------
 ///
 /// Copyright (c) 2011 Domagoj Saric
 ///
@@ -34,6 +34,8 @@
         : handle<Impl>( native_handle ) {}
 
     typedef handle_ref< file_handle<Impl> > reference;
+
+ operator reference () const { return reference( get() ); }
 };
 
 //------------------------------------------------------------------------------

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -18,6 +18,7 @@
 #pragma once
 //------------------------------------------------------------------------------
 #include "../handle.hpp"
+#include "../../../detail/posix.hpp"
 #include "../../../implementations.hpp"
 
 #include <cstddef>
@@ -29,7 +30,8 @@
 {
 //------------------------------------------------------------------------------
 
-template <typename Impl > struct file_flags;
+template <typename Impl > struct file_open_flags;
+template <typename Impl > struct file_mapping_flags;
 template <class Handle> struct is_resizable;
 
 #ifdef BOOST_HAS_UNISTD_H
@@ -39,9 +41,9 @@
 #endif // BOOST_HAS_UNISTD_H
 
 
-file_handle<posix> create_file( char const * file_name, file_flags<posix> const & );
+file_handle<posix> create_file( char const * file_name, file_open_flags<posix> const & );
 #ifdef BOOST_MSVC
-file_handle<posix> create_file( wchar_t const * file_name, file_flags<posix> const & );
+file_handle<posix> create_file( wchar_t const * file_name, file_open_flags<posix> const & );
 #endif // BOOST_MSVC
 
 bool delete_file( char const * file_name, posix );
@@ -53,6 +55,10 @@
 #endif // BOOST_HAS_UNISTD_H
 std::size_t get_size( file_handle<posix>::reference );
 
+#ifdef BOOST_HAS_UNISTD_H
+mapping<posix> create_mapping( file_handle<posix>::reference, file_mapping_flags<posix> const & );
+#endif // BOOST_HAS_UNISTD_H
+
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/file.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -41,7 +41,7 @@
 //------------------------------------------------------------------------------
 
 BOOST_IMPL_INLINE
-file_handle<posix> create_file( char const * const file_name, file_flags<posix> const & flags )
+file_handle<posix> create_file( char const * const file_name, file_open_flags<posix> const & flags )
 {
     typedef file_handle<posix> posix_file_handle;
 
@@ -57,7 +57,7 @@
 
 #ifdef BOOST_MSVC
 BOOST_IMPL_INLINE
-file_handle<posix> create_file( wchar_t const * const file_name, file_flags<posix> const & flags )
+file_handle<posix> create_file( wchar_t const * const file_name, file_open_flags<posix> const & flags )
 {
     BOOST_ASSERT( file_name );
 
@@ -102,6 +102,16 @@
     return file_info.st_size;
 }
 
+
+#ifdef BOOST_HAS_UNISTD_H
+// Apple guidelines http://developer.apple.com/library/mac/#documentation/Performance/Conceptual/FileSystem/Articles/MappingFiles.html
+BOOST_IMPL_INLINE
+mapping<posix> create_mapping( file_handle<posix>::reference const file, file_mapping_flags<posix> const & flags )
+{
+ return mapping<posix>( file, flags );
+}
+#endif // BOOST_HAS_UNISTD_H
+
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------

Deleted: sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
+++ (empty file)
@@ -1,120 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file flags.hpp
-/// ---------------
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to 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)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef flags_hpp__0F422517_D9AA_4E3F_B3E4_B139021D068E
-#define flags_hpp__0F422517_D9AA_4E3F_B3E4_B139021D068E
-#pragma once
-//------------------------------------------------------------------------------
-#include "boost/assert.hpp"
-#include "boost/noncopyable.hpp"
-
-#include "fcntl.h"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace mmap
-{
-//------------------------------------------------------------------------------
-
-template <typename Impl> struct file_flags;
-
-// Implementation note:
-// Using structs with public members and factory functions to enable (almost)
-// zero-overhead 'link-time' conversion to native flag formats and to allow the
-// user to modify the created flags or create fully custom ones so that specific
-// platform-dependent use-cases, not otherwise covered through the generic
-// interface, can also be covered.
-// (10.10.2010.) (Domagoj Saric)
-
-template <>
-struct file_flags<posix>
-{
- struct handle_access_rights
- {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- struct share_mode
- {
- static unsigned int const none ;
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const remove;
- };
-
- struct open_policy
- {
- enum value_type
- {
- create_new = O_CREAT | O_EXCL ,
- create_new_or_truncate_existing = O_CREAT | O_TRUNC,
- open_existing = 0 ,
- open_or_create = O_CREAT ,
- open_and_truncate_existing = O_TRUNC
- };
- };
- typedef open_policy::value_type open_policy_t;
-
- struct system_hints
- {
- static unsigned int const random_access ;
- static unsigned int const sequential_access;
- static unsigned int const non_cached ;
- static unsigned int const delete_on_close ;
- static unsigned int const temporary ;
- };
-
- struct on_construction_rights
- {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- static file_flags<posix> create
- (
- unsigned int handle_access_flags ,
- unsigned int share_mode ,
- open_policy_t ,
- unsigned int system_hints ,
- unsigned int on_construction_rights
- );
-
- static file_flags<posix> create_for_opening_existing_files
- (
- unsigned int handle_access_flags,
- unsigned int share_mode ,
- bool truncate ,
- unsigned int system_hints
- );
-
- int oflag;
- int pmode;
-};
-
-//------------------------------------------------------------------------------
-} // namespace mmap
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-
-#ifdef BOOST_MMAP_HEADER_ONLY
- #include "flags.inl"
-#endif // BOOST_MMAP_HEADER_ONLY
-
-#endif // flags_hpp

Deleted: sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
+++ (empty file)
@@ -1,122 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file flags.inl
-/// ---------------
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to 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)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#include "flags.hpp"
-
-#include "../../../detail/impl_inline.hpp"
-
-#include "boost/assert.hpp"
-
-#ifdef _WIN32
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) win32
- #pragma warning ( disable : 4996 ) // "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name."
- #include "io.h"
- #include "sys/stat.h"
-#else
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) posix
- #include "sys/mman.h" // mmap, munmap.
- #include "sys/stat.h"
- #include "sys/types.h" // struct stat.
- #include "unistd.h" // sysconf.
-#endif // _WIN32
-#include "errno.h"
-#include "fcntl.h"
-
-#ifndef _WIN32
- #ifdef __APPLE__
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) osx
- #else
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) posix
- #endif
-#endif
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace mmap
-{
-//------------------------------------------------------------------------------
-
-unsigned int const file_flags<posix>::handle_access_rights::read = O_RDONLY;
-unsigned int const file_flags<posix>::handle_access_rights::write = O_WRONLY;
-unsigned int const file_flags<posix>::handle_access_rights::execute = O_RDONLY;
-
-unsigned int const file_flags<posix>::share_mode::none = 0;
-unsigned int const file_flags<posix>::share_mode::read = 0;
-unsigned int const file_flags<posix>::share_mode::write = 0;
-unsigned int const file_flags<posix>::share_mode::remove = 0;
-
-unsigned int const file_flags<posix>::system_hints::random_access = BOOST_AUX_IO_WIN32_OR_POSIX( O_RANDOM , 0 );
-unsigned int const file_flags<posix>::system_hints::sequential_access = BOOST_AUX_IO_WIN32_OR_POSIX( O_SEQUENTIAL , 0 );
-// http://stackoverflow.com/questions/2299402/how-does-one-do-raw-io-on-mac-os-x-ie-equivalent-to-linuxs-o-direct-flag
-unsigned int const file_flags<posix>::system_hints::non_cached = BOOST_AUX_IO_WIN32_OR_POSIX( 0 , BOOST_AUX_MMAP_POSIX_OR_OSX( O_DIRECT, 0 ) );
-unsigned int const file_flags<posix>::system_hints::delete_on_close = BOOST_AUX_IO_WIN32_OR_POSIX( O_TEMPORARY , 0 );
-unsigned int const file_flags<posix>::system_hints::temporary = BOOST_AUX_IO_WIN32_OR_POSIX( _O_SHORT_LIVED, 0 );
-
-unsigned int const file_flags<posix>::on_construction_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IREAD , S_IRUSR );
-unsigned int const file_flags<posix>::on_construction_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IWRITE, S_IWUSR );
-unsigned int const file_flags<posix>::on_construction_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IEXEC , S_IXUSR );
-
-BOOST_IMPL_INLINE
-file_flags<posix> file_flags<posix>::create
-(
- unsigned int const handle_access_flags ,
- unsigned int const /*share_mode*/ ,
- open_policy_t const open_flags ,
- unsigned int const system_hints ,
- unsigned int const on_construction_rights
-)
-{
- unsigned int const oflag
- (
- ( ( handle_access_flags == ( O_RDONLY | O_WRONLY ) ) ? O_RDWR : handle_access_flags )
- |
- open_flags
- |
- system_hints
- );
-
- unsigned int const pmode( on_construction_rights );
-
- file_flags<posix> const flags =
- {
- static_cast<int>( oflag ),
- static_cast<int>( pmode )
- };
- return flags;
-}
-
-
-BOOST_IMPL_INLINE
-file_flags<posix> file_flags<posix>::create_for_opening_existing_files( unsigned int const handle_access_flags, unsigned int const share_mode , bool const truncate, unsigned int const system_hints )
-{
- return create
- (
- handle_access_flags,
- share_mode,
- truncate
- ? open_policy::open_and_truncate_existing
- : open_policy::open_existing,
- system_hints,
- 0
- );
-}
-
-
-//------------------------------------------------------------------------------
-} // mmap
-//------------------------------------------------------------------------------
-} // boost
-//------------------------------------------------------------------------------

Copied: sandbox/mmap/boost/mmap/mappble_objects/file/posix/mapping_flags.hpp (from r74074, /sandbox/mmap/boost/mmap/mapped_view.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/mapped_view.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/mapping_flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapped_view.hpp
-/// ---------------------
+/// \file mapping_flags.hpp
+/// -----------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,31 +13,13 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
-#define mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
+#ifndef mapping_flags_hpp__79CF82B8_F71B_4C75_BE77_98F4FB8A7FFA
+#define mapping_flags_hpp__79CF82B8_F71B_4C75_BE77_98F4FB8A7FFA
 #pragma once
 //------------------------------------------------------------------------------
-#include "handles/handle.hpp"
-//...zzz...
-#include "mappble_objects/file/file.hpp"
-#include "mappble_objects/file/posix/file.hpp"
-#ifdef _WIN32
-#include "mappble_objects/file/win32/file.hpp"
-#endif // _WIN32
-
-#include "boost/assert.hpp"
-#include "boost/noncopyable.hpp"
-#include "boost/range/iterator_range.hpp"
-
-#ifndef _WIN32
- #include "fcntl.h"
-#endif // _WIN32
-
-#ifdef _WIN32
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) win32
-#else
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) posix
-#endif
+#include "../../../detail/posix.hpp"
+
+#include "sys/mman.h"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -46,274 +28,47 @@
 {
 //------------------------------------------------------------------------------
 
-// Implementation note:
-// Using structs with public members and factory functions to enable (almost)
-// zero-overhead 'link-time' conversion to native flag formats and to allow the
-// user to modify the created flags or create fully custom ones so that specific
-// platform-dependent use-cases, not otherwise covered through the generic
-// interface, can also be covered.
-// (10.10.2010.) (Domagoj Saric)
+template <typename Impl> struct file_mapping_flags;
+
+struct posix;
+
+typedef unsigned flags_t;
 
-struct mapping_flags
+template <>
+struct file_mapping_flags<posix>
 {
     struct handle_access_rights
     {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
+ enum values
+ {
+ read = PROT_READ ,
+ write = PROT_WRITE,
+ execute = PROT_EXEC ,
+ all = read | write | execute
+ };
     };
 
     struct share_mode
     {
- static unsigned int const shared;
- static unsigned int const hidden;
- };
-
- struct system_hint
- {
- static unsigned int const lock_to_ram ;
- static unsigned int const reserve_page_file_space;
- static unsigned int const precommit ;
- static unsigned int const uninitialized ;
+ enum value_type
+ {
+ shared = MAP_SHARED,
+ hidden = MAP_PRIVATE
+ }
     };
 
- static mapping_flags create
+ static file_mapping_flags<posix> create
     (
- unsigned int handle_access_rights,
- unsigned int share_mode ,
- unsigned int system_hints
+ flags_t combined_handle_access_rights,
+ share_mode::value_type share_mode
     );
 
-#ifdef _WIN32
- unsigned int create_mapping_flags;
- unsigned int map_view_flags;
-#else
+
     int protection;
     int flags ;
-#endif // _WIN32
 };
 
 
-typedef iterator_range<unsigned char *> basic_memory_range_t;
-typedef iterator_range<unsigned char const *> basic_read_only_memory_range_t;
-
-template <typename Element>
-class mapped_view_reference;
-
-typedef mapped_view_reference<unsigned char > basic_mapped_view_ref;
-typedef mapped_view_reference<unsigned char const> basic_mapped_read_only_view_ref;
-
-namespace detail
-{
- template <typename Element>
- class mapped_view_base : public iterator_range<Element *>
- {
- public:
- typedef iterator_range<Element *> memory_range_t;
-
- public: // Factory methods.
- static void unmap( mapped_view_base const & );
-
- protected:
- mapped_view_base( iterator_range<Element *> const & mapped_range ) : iterator_range<Element *>( mapped_range ) {}
- mapped_view_base( Element * const p_begin, Element * const p_end ) : iterator_range<Element *>( p_begin, p_end ) {}
-
- static mapped_view_reference<unsigned char const>
- #ifdef BOOST_MSVC
- const &
- #endif
- make_basic_view( mapped_view_base<Element> const & );
-
- static mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- const &
- #endif
- make_typed_range( mapped_view_base<unsigned char> const & );
-
- private: // Hide mutable members
- void advance_begin();
- void advance_end ();
-
- void pop_front();
- void pop_back ();
- };
-
-
- template <typename Element>
- void mapped_view_base<Element>::unmap( mapped_view_base<Element> const & mapped_range )
- {
- mapped_view_base<unsigned char const>::unmap( make_basic_view( mapped_range ) );
- }
-
- template <>
- void mapped_view_base<unsigned char const>::unmap( mapped_view_base<unsigned char const> const & );
-} // namespace detail
-
-template <typename Element>
-class mapped_view_reference : public detail::mapped_view_base<Element>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char *>( static_cast<void *>( this->begin() ) ),
- static_cast<unsigned char *>( static_cast<void *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
- (
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size = 0,
- std::size_t offset = 0
- );
-
-private:
- template <typename T> friend class detail::mapped_view_base;
-
- mapped_view_reference( iterator_range<Element *> const & mapped_range ) : detail::mapped_view_base<Element>( mapped_range ) {}
- mapped_view_reference( Element * const p_begin, Element * const p_end ) : detail::mapped_view_base<Element>( p_begin, p_end ) {}
-};
-
-template <typename Element>
-class mapped_view_reference<Element const> : public detail::mapped_view_base<Element const>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char const *>( static_cast<void const *>( this->begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
- (
- native_handle::reference object_handle,
- std::size_t desired_size = 0,
- std::size_t offset = 0,
- bool map_for_code_execution = false
- );
-
-private:
- template <typename T> friend class detail::mapped_view_base;
-
- mapped_view_reference( iterator_range<Element const *> const & mapped_range ) : detail::mapped_view_base<Element const>( mapped_range ) {}
- mapped_view_reference( Element const * const p_begin, Element const * const p_end ) : detail::mapped_view_base<Element const>( p_begin, p_end ) {}
- mapped_view_reference( mapped_view_reference<Element> const & mutable_view ) : detail::mapped_view_base<Element const>( mutable_view ) {}
-};
-
-
-namespace detail
-{
- // Implementation note:
- // These have to be defined after mapped_view_reference for eager
- // compilers (e.g. GCC and Clang).
- // (14.07.2011.) (Domagoj Saric)
-
- template <typename Element>
- mapped_view_reference<unsigned char const>
- #ifdef BOOST_MSVC
- const &
- #endif
- mapped_view_base<Element>::make_basic_view( mapped_view_base<Element> const & range )
- {
- return
- #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<unsigned char const> const &>( range );
- #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
- (
- static_cast<unsigned char const *>( static_cast<void const *>( range.begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( range.end () ) )
- );
- #endif // compiler
- }
-
-
- template <typename Element>
- mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- const &
- #endif
- mapped_view_base<Element>::make_typed_range( mapped_view_base<unsigned char> const & range )
- {
- BOOST_ASSERT( reinterpret_cast<std::size_t>( range.begin() ) % sizeof( Element ) == 0 );
- BOOST_ASSERT( reinterpret_cast<std::size_t>( range.end () ) % sizeof( Element ) == 0 );
- BOOST_ASSERT( range.size () % sizeof( Element ) == 0 );
- return
- #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<Element> const &>( range );
- #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
- (
- static_cast<Element *>( static_cast<void *>( range.begin() ) ),
- static_cast<Element *>( static_cast<void *>( range.end () ) )
- );
- #endif // compiler
- }
-} // namespace detail
-
-
-template <typename Handle>
-struct is_mappable : mpl::false_ {};
-
-template <> struct is_mappable<char *> : mpl::true_ {};
-template <> struct is_mappable<char const *> : mpl::true_ {};
-template <> struct is_mappable<FILE *> : mpl::true_ {};
-template <> struct is_mappable<handle<posix>::native_handle_t > : mpl::true_ {};
-#ifdef _WIN32
-template <> struct is_mappable<wchar_t *> : mpl::true_ {};
-template <> struct is_mappable<wchar_t const *> : mpl::true_ {};
-template <> struct is_mappable<handle<win32>::native_handle_t > : mpl::true_ {};
-#endif // _WIN32
-
-
-template <>
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size,
- std::size_t offset
-);
-
-template <>
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference object_handle,
- std::size_t desired_size,
- std::size_t offset,
- bool map_for_code_execution
-);
-
-
-template <typename Element>
-class mapped_view
- :
- public mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- ,private noncopyable
- #endif // BOOST_MSVC
-{
-public:
- mapped_view( mapped_view_reference<Element> const range ) : mapped_view_reference<Element>( range ) {}
- ~mapped_view<Element>() { mapped_view_reference<Element>::unmap( *this ); }
-
- #ifndef BOOST_MSVC
- mapped_view( mapped_view const & ); // noncopyable
- #endif // BOOST_MSVC
-};
-
-
-basic_mapped_view_ref map_file ( char const * file_name, std::size_t desired_size );
-basic_mapped_read_only_view_ref map_read_only_file( char const * file_name );
-
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------
@@ -321,7 +76,7 @@
 //------------------------------------------------------------------------------
 
 #ifdef BOOST_MMAP_HEADER_ONLY
- #include "mapped_view.inl"
+ #include "mapping_flags.inl"
 #endif
 
-#endif // mapped_view_hpp
+#endif // mapping_flags.hpp

Copied: sandbox/mmap/boost/mmap/mappble_objects/file/posix/mapping_flags.inl (from r74074, /sandbox/mmap/boost/mmap/mapped_view.inl)
==============================================================================
--- /sandbox/mmap/boost/mmap/mapped_view.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/mapping_flags.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapped_view.inl
-/// ---------------------
+/// \file mapping_flags.inl
+/// -----------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,39 +13,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#include "mapped_view.hpp"
-
-#include "detail/impl_inline.hpp"
-#include "implementations.hpp"
-#include "mappble_objects/file/handle.hpp"
-
-#include "boost/assert.hpp"
-
-#ifdef _WIN32
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif // WIN32_LEAN_AND_MEAN
- #include "windows.h"
-
- #pragma warning ( disable : 4996 ) // "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name."
- #include "io.h"
-#else
- #include "sys/mman.h" // mmap, munmap.
- #include "sys/stat.h"
- #include "sys/types.h" // struct stat.
- #include "unistd.h" // sysconf.
-#endif // _WIN32
-#include "errno.h"
-#include "fcntl.h"
-
-#ifndef _WIN32
- #ifdef __APPLE__
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) osx
- #else
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) posix
- #endif
-#endif
-
+#include "mapping_flags.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -54,223 +22,21 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const mapping_flags::handle_access_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_READ , PROT_READ );
-unsigned int const mapping_flags::handle_access_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_WRITE , PROT_WRITE );
-unsigned int const mapping_flags::handle_access_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_EXECUTE, PROT_EXEC );
-
-unsigned int const mapping_flags::share_mode::shared = BOOST_AUX_IO_WIN32_OR_POSIX( 0, MAP_SHARED );
-unsigned int const mapping_flags::share_mode::hidden = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_COPY, MAP_PRIVATE );
-
-unsigned int const mapping_flags::system_hint::lock_to_ram = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_LOCKED, 0 ) );
-unsigned int const mapping_flags::system_hint::reserve_page_file_space = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_RESERVE, /*khm#1*/MAP_NORESERVE );
-unsigned int const mapping_flags::system_hint::precommit = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_POPULATE, 0 ) );
-unsigned int const mapping_flags::system_hint::uninitialized = BOOST_AUX_IO_WIN32_OR_POSIX( 0, BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_UNINITIALIZED, 0 ) );
-
-
 BOOST_IMPL_INLINE
-mapping_flags mapping_flags::create
+file_mapping_flags<posix> file_mapping_flags<posix>::create
 (
- unsigned int const handle_access_flags,
- unsigned int const share_mode ,
- unsigned int const system_hints
+ flags_t const combined_handle_access_flags,
+ share_mode::value_type const share_mode
 )
 {
     mapping_flags flags;
 
-#ifdef _WIN32
- flags.create_mapping_flags = ( handle_access_flags & handle_access_rights::execute ) ? PAGE_EXECUTE : PAGE_NOACCESS;
- if ( share_mode == share_mode::hidden ) // WRITECOPY
- flags.create_mapping_flags *= 8;
- else
- if ( handle_access_flags & handle_access_rights::write )
- flags.create_mapping_flags *= 4;
- else
- {
- BOOST_ASSERT( handle_access_flags & handle_access_rights::read );
- flags.create_mapping_flags *= 2;
- }
-
- flags.create_mapping_flags |= system_hints;
-
- flags.map_view_flags = handle_access_flags;
-#else
- flags.protection = handle_access_flags;
+ flags.protection = combined_handle_access_flags;
     flags.flags = share_mode | system_hints;
- if ( ( system_hints & system_hint::reserve_page_file_space ) ) /*khm#1*/
- flags.flags &= ~MAP_NORESERVE;
- else
- flags.flags |= MAP_NORESERVE;
-#endif // _WIN32
 
     return flags;
 }
 
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference const object_handle,
- mapping_flags const & flags,
- std::size_t const desired_size,
- std::size_t const offset
-)
-{
- typedef mapped_view_reference<unsigned char>::iterator iterator_t;
-
-#ifdef _WIN32
-
- // Implementation note:
- // Mapped views hold internal references to the following handles so we do
- // not need to hold/store them ourselves:
- // http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
- // (26.03.2010.) (Domagoj Saric)
-
- ULARGE_INTEGER large_integer;
-
- // CreateFileMapping accepts INVALID_HANDLE_VALUE as valid input but only if
- // the size parameter is not null.
- large_integer.QuadPart = desired_size;
- handle<win32> const mapping
- (
- ::CreateFileMappingW( object_handle, 0, flags.create_mapping_flags, large_integer.HighPart, large_integer.LowPart, 0 )
- );
- BOOST_ASSERT
- (
- !mapping || ( object_handle == INVALID_HANDLE_VALUE ) || ( desired_size != 0 )
- );
-
- large_integer.QuadPart = offset;
- iterator_t const view_start( static_cast<iterator_t>( ::MapViewOfFile( mapping.get(), flags.map_view_flags, large_integer.HighPart, large_integer.LowPart, desired_size ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start && ( object_handle != INVALID_HANDLE_VALUE ) )
- ? view_start + desired_size
- : view_start
- );
-
-#else // POSIX
-
- iterator_t const view_start( static_cast<iterator_t>( ::mmap( 0, desired_size, flags.protection, flags.flags, object_handle, 0 ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start != MAP_FAILED )
- ? view_start + desired_size
- : view_start
- );
-
-#endif // OS API
-}
-
-
-template <> BOOST_IMPL_INLINE
-void detail::mapped_view_base<unsigned char const>::unmap( detail::mapped_view_base<unsigned char const> const & mapped_range )
-{
-#ifdef _WIN32
- BOOST_VERIFY( ::UnmapViewOfFile( mapped_range.begin() ) || mapped_range.empty() );
-#else
- BOOST_VERIFY( ( ::munmap ( const_cast<unsigned char *>( mapped_range.begin() ), mapped_range.size() ) == 0 ) || mapped_range.empty() );
-#endif // _WIN32
-}
-
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference const object_handle,
- std::size_t const desired_size,
- std::size_t const offset,
- bool const map_for_code_execution
-)
-{
- return mapped_view_reference<unsigned char>::map
- (
- object_handle,
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | ( map_for_code_execution ? mapping_flags::handle_access_rights::execute : 0 ),
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- offset
- );
-}
-
-
-BOOST_IMPL_INLINE
-basic_mapped_view_ref map_file( char const * const file_name, std::size_t desired_size )
-{
- typedef native_file_flags file_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- file_flags::create
- (
- file_flags::handle_access_rights::read | file_flags::handle_access_rights::write,
- file_flags::share_mode ::read,
- file_flags::open_policy::open_or_create,
- file_flags::system_hints ::sequential_access,
- file_flags::on_construction_rights::read | file_flags::on_construction_rights::write
- )
- )
- );
-
- if ( desired_size )
- set_size( file_handle.get(), desired_size );
- else
- desired_size = get_size( file_handle.get() );
-
- return basic_mapped_view_ref::map
- (
- file_handle.get(),
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- 0
- );
-}
-
-
-BOOST_IMPL_INLINE
-basic_mapped_read_only_view_ref map_read_only_file( char const * const file_name )
-{
- typedef native_file_flags file_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- file_flags::create_for_opening_existing_files
- (
- file_flags::handle_access_rights::read,
- file_flags::share_mode ::read | file_flags::share_mode::write,
- false,
- file_flags::system_hints ::sequential_access
- )
- )
- );
-
- return basic_mapped_read_only_view_ref::map
- (
- file_handle.get(),
- // Implementation note:
- // Windows APIs interpret zero as 'whole file' but we still need to
- // query the file size in order to be able to properly set the end
- // pointer.
- // (13.07.2011.) (Domagoj Saric)
- get_size( file_handle.get() )
- );
-}
-
-
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------

Copied: sandbox/mmap/boost/mmap/mappble_objects/file/posix/open_flags.hpp (from r74074, /sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/open_flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file flags.hpp
-/// ---------------
+/// \file open_flags.hpp
+/// --------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,12 +13,11 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef flags_hpp__0F422517_D9AA_4E3F_B3E4_B139021D068E
-#define flags_hpp__0F422517_D9AA_4E3F_B3E4_B139021D068E
+#ifndef open_flags_hpp__0F422517_D9AA_4E3F_B3E4_B139021D068E
+#define open_flags_hpp__0F422517_D9AA_4E3F_B3E4_B139021D068E
 #pragma once
 //------------------------------------------------------------------------------
-#include "boost/assert.hpp"
-#include "boost/noncopyable.hpp"
+#include "../../../detail/posix.hpp"
 
 #include "fcntl.h"
 //------------------------------------------------------------------------------
@@ -29,7 +28,7 @@
 {
 //------------------------------------------------------------------------------
 
-template <typename Impl> struct file_flags;
+template <typename Impl> struct file_open_flags;
 
 // Implementation note:
 // Using structs with public members and factory functions to enable (almost)
@@ -40,21 +39,17 @@
 // (10.10.2010.) (Domagoj Saric)
 
 template <>
-struct file_flags<posix>
+struct file_open_flags<posix>
 {
     struct handle_access_rights
     {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- struct share_mode
- {
- static unsigned int const none ;
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const remove;
+ enum values
+ {
+ read = O_RDONLY,
+ write = O_WRONLY,
+ execute = O_RDONLY,
+ all = read | write | execute
+ }
     };
 
     struct open_policy
@@ -68,39 +63,41 @@
             open_and_truncate_existing = O_TRUNC
         };
     };
- typedef open_policy::value_type open_policy_t;
 
     struct system_hints
     {
- static unsigned int const random_access ;
- static unsigned int const sequential_access;
- static unsigned int const non_cached ;
- static unsigned int const delete_on_close ;
- static unsigned int const temporary ;
+ enum values
+ {
+ random_access = BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( 0, 0, 0, O_RANDOM ),
+ sequential_access = BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( 0, 0, 0, O_SEQUENTIAL ),
+ avoid_caching = BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( 0, O_DIRECT, 0, 0 ),
+ temporary = BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( 0, 0, 0, O_TEMPORARY | _O_SHORT_LIVED ),
+ }
     };
 
     struct on_construction_rights
     {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
+ enum values
+ {
+ read = BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( S_IRUSR, S_IRUSR, S_IRUSR, _S_IREAD ),
+ write = BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( S_IWUSR, S_IWUSR, S_IWUSR, _S_IWRITE ),
+ execute = BOOST_MMAP_POSIX_STANDARD_LINUX_OSX_MSVC( S_IXUSR, S_IXUSR, S_IXUSR, _S_IEXEC )
+ }
     };
 
- static file_flags<posix> create
+ static file_open_flags<posix> create
     (
- unsigned int handle_access_flags ,
- unsigned int share_mode ,
- open_policy_t ,
- unsigned int system_hints ,
- unsigned int on_construction_rights
+ flags_t handle_access_flags ,
+ open_policy::value_type ,
+ flags_t system_hints ,
+ flags_t on_construction_rights
     );
 
- static file_flags<posix> create_for_opening_existing_files
+ static file_open_flags<posix> create_for_opening_existing_files
     (
- unsigned int handle_access_flags,
- unsigned int share_mode ,
- bool truncate ,
- unsigned int system_hints
+ flags_t handle_access_flags,
+ bool truncate ,
+ flags_t system_hints
     );
 
     int oflag;
@@ -114,7 +111,7 @@
 //------------------------------------------------------------------------------
 
 #ifdef BOOST_MMAP_HEADER_ONLY
- #include "flags.inl"
+ #include "open_flags.inl"
 #endif // BOOST_MMAP_HEADER_ONLY
 
-#endif // flags_hpp
+#endif // open_flags_hpp

Copied: sandbox/mmap/boost/mmap/mappble_objects/file/posix/open_flags.inl (from r74074, /sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl)
==============================================================================
--- /sandbox/mmap/boost/mmap/mappble_objects/file/posix/flags.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/posix/open_flags.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file flags.inl
-/// ---------------
+/// \file open_flags.inl
+/// --------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -19,28 +19,7 @@
 
 #include "boost/assert.hpp"
 
-#ifdef _WIN32
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) win32
- #pragma warning ( disable : 4996 ) // "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name."
- #include "io.h"
- #include "sys/stat.h"
-#else
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) posix
- #include "sys/mman.h" // mmap, munmap.
- #include "sys/stat.h"
- #include "sys/types.h" // struct stat.
- #include "unistd.h" // sysconf.
-#endif // _WIN32
 #include "errno.h"
-#include "fcntl.h"
-
-#ifndef _WIN32
- #ifdef __APPLE__
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) osx
- #else
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) posix
- #endif
-#endif
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -49,36 +28,18 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const file_flags<posix>::handle_access_rights::read = O_RDONLY;
-unsigned int const file_flags<posix>::handle_access_rights::write = O_WRONLY;
-unsigned int const file_flags<posix>::handle_access_rights::execute = O_RDONLY;
-
-unsigned int const file_flags<posix>::share_mode::none = 0;
-unsigned int const file_flags<posix>::share_mode::read = 0;
-unsigned int const file_flags<posix>::share_mode::write = 0;
-unsigned int const file_flags<posix>::share_mode::remove = 0;
-
-unsigned int const file_flags<posix>::system_hints::random_access = BOOST_AUX_IO_WIN32_OR_POSIX( O_RANDOM , 0 );
-unsigned int const file_flags<posix>::system_hints::sequential_access = BOOST_AUX_IO_WIN32_OR_POSIX( O_SEQUENTIAL , 0 );
-// http://stackoverflow.com/questions/2299402/how-does-one-do-raw-io-on-mac-os-x-ie-equivalent-to-linuxs-o-direct-flag
-unsigned int const file_flags<posix>::system_hints::non_cached = BOOST_AUX_IO_WIN32_OR_POSIX( 0 , BOOST_AUX_MMAP_POSIX_OR_OSX( O_DIRECT, 0 ) );
-unsigned int const file_flags<posix>::system_hints::delete_on_close = BOOST_AUX_IO_WIN32_OR_POSIX( O_TEMPORARY , 0 );
-unsigned int const file_flags<posix>::system_hints::temporary = BOOST_AUX_IO_WIN32_OR_POSIX( _O_SHORT_LIVED, 0 );
-
-unsigned int const file_flags<posix>::on_construction_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IREAD , S_IRUSR );
-unsigned int const file_flags<posix>::on_construction_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IWRITE, S_IWUSR );
-unsigned int const file_flags<posix>::on_construction_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( _S_IEXEC , S_IXUSR );
-
 BOOST_IMPL_INLINE
-file_flags<posix> file_flags<posix>::create
+file_open_flags<posix> file_open_flags<posix>::create
 (
- unsigned int const handle_access_flags ,
- unsigned int const /*share_mode*/ ,
- open_policy_t const open_flags ,
- unsigned int const system_hints ,
- unsigned int const on_construction_rights
+ flags_t const handle_access_flags ,
+ open_policy::value_type const open_flags ,
+ flags_t const system_hints ,
+ flags_t const on_construction_rights
 )
 {
+ //...zzz...use fadvise...
+ // http://stackoverflow.com/questions/2299402/how-does-one-do-raw-io-on-mac-os-x-ie-equivalent-to-linuxs-o-direct-flag
+
     unsigned int const oflag
     (
         ( ( handle_access_flags == ( O_RDONLY | O_WRONLY ) ) ? O_RDWR : handle_access_flags )
@@ -90,7 +51,7 @@
 
     unsigned int const pmode( on_construction_rights );
 
- file_flags<posix> const flags =
+ file_open_flags<posix> const flags =
     {
         static_cast<int>( oflag ),
         static_cast<int>( pmode )
@@ -100,13 +61,17 @@
 
 
 BOOST_IMPL_INLINE
-file_flags<posix> file_flags<posix>::create_for_opening_existing_files( unsigned int const handle_access_flags, unsigned int const share_mode , bool const truncate, unsigned int const system_hints )
+file_open_flags<posix> file_open_flags<posix>::create_for_opening_existing_files
+(
+ flags_t const handle_access_flags,
+ bool const truncate,
+ flags_t const system_hints
+)
 {
     return create
     (
         handle_access_flags,
- share_mode,
- truncate
+ truncate
             ? open_policy::open_and_truncate_existing
             : open_policy::open_existing,
         system_hints,

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -17,8 +17,11 @@
 #define file_hpp__FB482005_18D9_4E3B_9193_A13DBFE88F45
 #pragma once
 //------------------------------------------------------------------------------
-#include "../handle.hpp"
 #include "../../../implementations.hpp"
+#include "../../../mapping/mapping.hpp"
+#include "../handle.hpp"
+
+#include "boost/cstdint.hpp"
 
 #include <cstddef>
 //------------------------------------------------------------------------------
@@ -29,22 +32,25 @@
 {
 //------------------------------------------------------------------------------
 
-template <typename Impl > struct file_flags;
+template <typename Impl > struct file_open_flags;
+template <typename Impl > struct file_mapping_flags;
 template <class Handle> struct is_resizable;
 
 template <> struct is_resizable< file_handle<win32> > : mpl::true_ {};
 
 
-file_handle<win32> create_file( char const * file_name, file_flags<win32> const & );
-file_handle<win32> create_file( wchar_t const * file_name, file_flags<win32> const & );
-bool delete_file( char const * file_name, win32 );
-bool delete_file( wchar_t const * file_name, win32 );
+file_handle<win32> create_file( char const * file_name, file_open_flags<win32> const & );
+file_handle<win32> create_file( wchar_t const * file_name, file_open_flags<win32> const & );
+bool delete_file( char const * file_name, win32 );
+bool delete_file( wchar_t const * file_name, win32 );
 
 
 bool set_size( file_handle<win32>::reference, std::size_t desired_size );
 std::size_t get_size( file_handle<win32>::reference );
 
 
+mapping<win32> create_mapping( file_handle<win32>::reference, file_mapping_flags<win32> const & );
+
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------
@@ -53,6 +59,6 @@
 
 #ifdef BOOST_MMAP_HEADER_ONLY
     #include "file.inl"
-#endif
+#endif // BOOST_MMAP_HEADER_ONLY
 
 #endif // file_hpp

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/file.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -17,13 +17,9 @@
 
 #include "flags.hpp"
 #include "../../detail/impl_inline.hpp"
+#include "../../detail/windows.hpp"
 
 #include "boost/assert.hpp"
-
-#ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
-#endif // WIN32_LEAN_AND_MEAN
-#include "windows.h"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -32,8 +28,14 @@
 {
 //------------------------------------------------------------------------------
 
+namespace
+{
+ // http://en.wikipedia.org/wiki/File_locking#In_UNIX
+ DWORD const default_unix_shared_semantics( FILE_SHARE_READ | FILE_SHARE_WRITE );
+}
+
 BOOST_IMPL_INLINE
-file_handle<win32> create_file( char const * const file_name, file_flags<win32> const & flags )
+file_handle<win32> create_file( char const * const file_name, file_open_flags<win32> const & flags )
 {
     /// \note
     /// This typedef is required by MSVC++ 10 SP1 and must be placed before
@@ -47,7 +49,7 @@
     (
         ::CreateFileA
         (
- file_name, flags.desired_access, flags.share_mode, 0, flags.creation_disposition, flags.flags_and_attributes, 0
+ file_name, flags.desired_access, default_unix_shared_semantics, 0, flags.creation_disposition, flags.flags_and_attributes, 0
         )
     );
     BOOST_ASSERT( ( file_handle == INVALID_HANDLE_VALUE ) || ( ::GetLastError() == NO_ERROR ) || ( ::GetLastError() == ERROR_ALREADY_EXISTS ) );
@@ -56,26 +58,20 @@
 }
 
 BOOST_IMPL_INLINE
-file_handle<win32> create_file( wchar_t const * const file_name, file_flags<win32> const & flags )
+file_handle<win32> create_file( wchar_t const * const file_name, file_open_flags<win32> const & flags )
 {
- /// \note
- /// This typedef is required by MSVC++ 10 SP1 and must be placed before
- /// the CreateFile call, otherwise it breaks at the return statement.
- /// (25.08.2011.) (Domagoj Saric)
- typedef file_handle<win32> win32_file_handle;
-
     BOOST_ASSERT( file_name );
 
- HANDLE const file_handle
+ HANDLE const handle
     (
         ::CreateFileW
         (
- file_name, flags.desired_access, flags.share_mode, 0, flags.creation_disposition, flags.flags_and_attributes, 0
+ file_name, flags.desired_access, default_unix_shared_semantics, 0, flags.creation_disposition, flags.flags_and_attributes, 0
         )
     );
- BOOST_ASSERT( ( file_handle == INVALID_HANDLE_VALUE ) || ( ::GetLastError() == NO_ERROR ) || ( ::GetLastError() == ERROR_ALREADY_EXISTS ) );
+ BOOST_ASSERT( ( handle == INVALID_HANDLE_VALUE ) || ( ::GetLastError() == NO_ERROR ) || ( ::GetLastError() == ERROR_ALREADY_EXISTS ) );
     
- return win32_file_handle( file_handle );
+ return file_handle<win32>( handle );
 }
 
 
@@ -92,7 +88,6 @@
 }
 
 
-
 BOOST_IMPL_INLINE
 bool set_size( file_handle<win32>::reference const file_handle, std::size_t const desired_size )
 {
@@ -141,6 +136,23 @@
     #endif // _WIN32/64
 }
 
+
+BOOST_IMPL_INLINE
+mapping<win32> create_mapping( file_handle<win32>::reference const file, file_mapping_flags<win32> const & flags )
+{
+ HANDLE const mapping_handle
+ (
+ ::CreateFileMappingW( file, NULL, flags.create_mapping_flags, 0, 0, NULL )
+ );
+ // CreateFileMapping accepts INVALID_HANDLE_VALUE as valid input but only if
+ // the size parameter is not null.
+ BOOST_ASSERT
+ (
+ ( file != INVALID_HANDLE_VALUE ) || !mapping_handle
+ );
+ return mapping<win32>( mapping_handle, flags.map_view_flags );
+}
+
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------

Deleted: sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
+++ (empty file)
@@ -1,120 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file flags.hpp
-/// ---------------
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to 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)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#ifndef flags_hpp__77AE8A6F_0E93_433B_A1F2_531BBBB353FC
-#define flags_hpp__77AE8A6F_0E93_433B_A1F2_531BBBB353FC
-#pragma once
-//------------------------------------------------------------------------------
-#include "boost/assert.hpp"
-#include "boost/noncopyable.hpp"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace mmap
-{
-//------------------------------------------------------------------------------
-
-template <typename Impl> struct file_flags;
-
-// Implementation note:
-// Using structs with public members and factory functions to enable (almost)
-// zero-overhead 'link-time' conversion to native flag formats and to allow the
-// user to modify the created flags or create fully custom ones so that specific
-// platform-dependent use-cases, not otherwise covered through the generic
-// interface, can also be covered.
-// (10.10.2010.) (Domagoj Saric)
-
-template <>
-struct file_flags<win32>
-{
- struct handle_access_rights
- {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- struct share_mode
- {
- static unsigned int const none ;
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const remove;
- };
-
- struct open_policy
- {
- enum value_type
- {
- create_new = 1,
- create_new_or_truncate_existing = 2,
- open_existing = 3,
- open_or_create = 4,
- open_and_truncate_existing = 5
- };
- };
- typedef open_policy::value_type open_policy_t;
-
- struct system_hints
- {
- static unsigned int const random_access ;
- static unsigned int const sequential_access;
- static unsigned int const non_cached ;
- static unsigned int const delete_on_close ;
- static unsigned int const temporary ;
- };
-
- struct on_construction_rights
- {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- static file_flags<win32> create
- (
- unsigned int handle_access_flags ,
- unsigned int share_mode ,
- open_policy_t ,
- unsigned int system_hints ,
- unsigned int on_construction_rights
- );
-
- static file_flags<win32> create_for_opening_existing_files
- (
- unsigned int handle_access_flags,
- unsigned int share_mode ,
- bool truncate ,
- unsigned int system_hints
- );
-
- unsigned long desired_access ;
- unsigned long share_mode ;
- unsigned long creation_disposition;
- unsigned long flags_and_attributes;
-};
-
-//------------------------------------------------------------------------------
-} // namespace mmap
-//------------------------------------------------------------------------------
-} // namespace boost
-//------------------------------------------------------------------------------
-
-#ifdef BOOST_MMAP_HEADER_ONLY
- #include "flags.inl"
-#endif // BOOST_MMAP_HEADER_ONLY
-
-#endif // flags_hpp

Deleted: sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
+++ (empty file)
@@ -1,107 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// \file flags.inl
-/// ---------------
-///
-/// Copyright (c) Domagoj Saric 2010.-2011.
-///
-/// Use, modification and distribution is subject to 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)
-///
-/// For more information, see http://www.boost.org
-///
-////////////////////////////////////////////////////////////////////////////////
-//------------------------------------------------------------------------------
-#include "flags.hpp"
-
-#include "../../detail/impl_inline.hpp"
-
-#include "boost/assert.hpp"
-
-#ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
-#endif // WIN32_LEAN_AND_MEAN
-#include "windows.h"
-//------------------------------------------------------------------------------
-namespace boost
-{
-//------------------------------------------------------------------------------
-namespace mmap
-{
-//------------------------------------------------------------------------------
-
-unsigned int const file_flags<win32>::handle_access_rights::read = GENERIC_READ ;
-unsigned int const file_flags<win32>::handle_access_rights::write = GENERIC_WRITE ;
-unsigned int const file_flags<win32>::handle_access_rights::execute = GENERIC_EXECUTE;
-
-unsigned int const file_flags<win32>::share_mode::none = 0 ;
-unsigned int const file_flags<win32>::share_mode::read = FILE_SHARE_READ ;
-unsigned int const file_flags<win32>::share_mode::write = FILE_SHARE_WRITE ;
-unsigned int const file_flags<win32>::share_mode::remove = FILE_SHARE_DELETE;
-
-unsigned int const file_flags<win32>::system_hints::random_access = FILE_FLAG_RANDOM_ACCESS ;
-unsigned int const file_flags<win32>::system_hints::sequential_access = FILE_FLAG_SEQUENTIAL_SCAN ;
-unsigned int const file_flags<win32>::system_hints::non_cached = FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
-unsigned int const file_flags<win32>::system_hints::delete_on_close = FILE_FLAG_DELETE_ON_CLOSE ;
-unsigned int const file_flags<win32>::system_hints::temporary = FILE_ATTRIBUTE_TEMPORARY ;
-
-unsigned int const file_flags<win32>::on_construction_rights::read = FILE_ATTRIBUTE_READONLY;
-unsigned int const file_flags<win32>::on_construction_rights::write = FILE_ATTRIBUTE_NORMAL ;
-unsigned int const file_flags<win32>::on_construction_rights::execute = FILE_ATTRIBUTE_READONLY;
-
-BOOST_IMPL_INLINE
-file_flags<win32> file_flags<win32>::create
-(
- unsigned int const handle_access_flags ,
- unsigned int const share_mode ,
- open_policy_t const open_flags ,
- unsigned int const system_hints ,
- unsigned int const on_construction_rights
-)
-{
- file_flags<win32> const flags =
- {
- handle_access_flags, // desired_access
- share_mode, // share_mode
- open_flags, // creation_disposition
- system_hints
- |
- (
- ( on_construction_rights & FILE_ATTRIBUTE_NORMAL )
- ? ( on_construction_rights & ~FILE_ATTRIBUTE_READONLY )
- : on_construction_rights
- ) // flags_and_attributes
- };
-
- return flags;
-}
-
-
-BOOST_IMPL_INLINE
-file_flags<win32> file_flags<win32>::create_for_opening_existing_files
-(
- unsigned int const handle_access_flags,
- unsigned int const share_mode,
- bool const truncate,
- unsigned int const system_hints
-)
-{
- return create
- (
- handle_access_flags,
- share_mode,
- truncate
- ? open_policy::open_and_truncate_existing
- : open_policy::open_existing,
- system_hints,
- 0
- );
-}
-
-
-//------------------------------------------------------------------------------
-} // mmap
-//------------------------------------------------------------------------------
-} // boost
-//------------------------------------------------------------------------------

Copied: sandbox/mmap/boost/mmap/mappble_objects/file/win32/mapping_flags.hpp (from r74074, /sandbox/mmap/boost/mmap/mapped_view.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/mapped_view.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/mapping_flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapped_view.hpp
-/// ---------------------
+/// \file mapping_flags.hpp
+/// -----------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,31 +13,10 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
-#define mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
+#ifndef mapping_flags_hpp__CD518463_D4CB_4E18_8E35_E0FBBA8CA1D1
+#define mapping_flags_hpp__CD518463_D4CB_4E18_8E35_E0FBBA8CA1D1
 #pragma once
 //------------------------------------------------------------------------------
-#include "handles/handle.hpp"
-//...zzz...
-#include "mappble_objects/file/file.hpp"
-#include "mappble_objects/file/posix/file.hpp"
-#ifdef _WIN32
-#include "mappble_objects/file/win32/file.hpp"
-#endif // _WIN32
-
-#include "boost/assert.hpp"
-#include "boost/noncopyable.hpp"
-#include "boost/range/iterator_range.hpp"
-
-#ifndef _WIN32
- #include "fcntl.h"
-#endif // _WIN32
-
-#ifdef _WIN32
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) win32
-#else
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) posix
-#endif
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -46,274 +25,47 @@
 {
 //------------------------------------------------------------------------------
 
-// Implementation note:
-// Using structs with public members and factory functions to enable (almost)
-// zero-overhead 'link-time' conversion to native flag formats and to allow the
-// user to modify the created flags or create fully custom ones so that specific
-// platform-dependent use-cases, not otherwise covered through the generic
-// interface, can also be covered.
-// (10.10.2010.) (Domagoj Saric)
+template <typename Impl> struct file_mapping_flags;
+
+struct win32;
 
-struct mapping_flags
+typedef unsigned flags_t;
+
+template <>
+struct file_mapping_flags<win32>
 {
     struct handle_access_rights
     {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
+ enum values
+ {
+ read = 0x0004,
+ write = 0x0002,
+ execute = 0x0020,
+ all = read | write | execute
+ };
     };
 
     struct share_mode
     {
- static unsigned int const shared;
- static unsigned int const hidden;
- };
-
- struct system_hint
- {
- static unsigned int const lock_to_ram ;
- static unsigned int const reserve_page_file_space;
- static unsigned int const precommit ;
- static unsigned int const uninitialized ;
+ enum value_type
+ {
+ shared = 0,
+ hidden = 0x0001
+ };
     };
 
- static mapping_flags create
- (
- unsigned int handle_access_rights,
- unsigned int share_mode ,
- unsigned int system_hints
- );
-
-#ifdef _WIN32
- unsigned int create_mapping_flags;
- unsigned int map_view_flags;
-#else
- int protection;
- int flags ;
-#endif // _WIN32
-};
-
-
-typedef iterator_range<unsigned char *> basic_memory_range_t;
-typedef iterator_range<unsigned char const *> basic_read_only_memory_range_t;
-
-template <typename Element>
-class mapped_view_reference;
-
-typedef mapped_view_reference<unsigned char > basic_mapped_view_ref;
-typedef mapped_view_reference<unsigned char const> basic_mapped_read_only_view_ref;
-
-namespace detail
-{
- template <typename Element>
- class mapped_view_base : public iterator_range<Element *>
- {
- public:
- typedef iterator_range<Element *> memory_range_t;
-
- public: // Factory methods.
- static void unmap( mapped_view_base const & );
-
- protected:
- mapped_view_base( iterator_range<Element *> const & mapped_range ) : iterator_range<Element *>( mapped_range ) {}
- mapped_view_base( Element * const p_begin, Element * const p_end ) : iterator_range<Element *>( p_begin, p_end ) {}
-
- static mapped_view_reference<unsigned char const>
- #ifdef BOOST_MSVC
- const &
- #endif
- make_basic_view( mapped_view_base<Element> const & );
-
- static mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- const &
- #endif
- make_typed_range( mapped_view_base<unsigned char> const & );
-
- private: // Hide mutable members
- void advance_begin();
- void advance_end ();
-
- void pop_front();
- void pop_back ();
- };
-
-
- template <typename Element>
- void mapped_view_base<Element>::unmap( mapped_view_base<Element> const & mapped_range )
- {
- mapped_view_base<unsigned char const>::unmap( make_basic_view( mapped_range ) );
- }
-
- template <>
- void mapped_view_base<unsigned char const>::unmap( mapped_view_base<unsigned char const> const & );
-} // namespace detail
-
-template <typename Element>
-class mapped_view_reference : public detail::mapped_view_base<Element>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char *>( static_cast<void *>( this->begin() ) ),
- static_cast<unsigned char *>( static_cast<void *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
- (
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size = 0,
- std::size_t offset = 0
- );
-
-private:
- template <typename T> friend class detail::mapped_view_base;
-
- mapped_view_reference( iterator_range<Element *> const & mapped_range ) : detail::mapped_view_base<Element>( mapped_range ) {}
- mapped_view_reference( Element * const p_begin, Element * const p_end ) : detail::mapped_view_base<Element>( p_begin, p_end ) {}
-};
-
-template <typename Element>
-class mapped_view_reference<Element const> : public detail::mapped_view_base<Element const>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char const *>( static_cast<void const *>( this->begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
+ static file_mapping_flags<win32> create
     (
- native_handle::reference object_handle,
- std::size_t desired_size = 0,
- std::size_t offset = 0,
- bool map_for_code_execution = false
+ flags_t combined_handle_access_rights,
+ share_mode::value_type share_mode
     );
 
-private:
- template <typename T> friend class detail::mapped_view_base;
 
- mapped_view_reference( iterator_range<Element const *> const & mapped_range ) : detail::mapped_view_base<Element const>( mapped_range ) {}
- mapped_view_reference( Element const * const p_begin, Element const * const p_end ) : detail::mapped_view_base<Element const>( p_begin, p_end ) {}
- mapped_view_reference( mapped_view_reference<Element> const & mutable_view ) : detail::mapped_view_base<Element const>( mutable_view ) {}
-};
-
-
-namespace detail
-{
- // Implementation note:
- // These have to be defined after mapped_view_reference for eager
- // compilers (e.g. GCC and Clang).
- // (14.07.2011.) (Domagoj Saric)
-
- template <typename Element>
- mapped_view_reference<unsigned char const>
- #ifdef BOOST_MSVC
- const &
- #endif
- mapped_view_base<Element>::make_basic_view( mapped_view_base<Element> const & range )
- {
- return
- #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<unsigned char const> const &>( range );
- #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
- (
- static_cast<unsigned char const *>( static_cast<void const *>( range.begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( range.end () ) )
- );
- #endif // compiler
- }
-
-
- template <typename Element>
- mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- const &
- #endif
- mapped_view_base<Element>::make_typed_range( mapped_view_base<unsigned char> const & range )
- {
- BOOST_ASSERT( reinterpret_cast<std::size_t>( range.begin() ) % sizeof( Element ) == 0 );
- BOOST_ASSERT( reinterpret_cast<std::size_t>( range.end () ) % sizeof( Element ) == 0 );
- BOOST_ASSERT( range.size () % sizeof( Element ) == 0 );
- return
- #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<Element> const &>( range );
- #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
- (
- static_cast<Element *>( static_cast<void *>( range.begin() ) ),
- static_cast<Element *>( static_cast<void *>( range.end () ) )
- );
- #endif // compiler
- }
-} // namespace detail
-
-
-template <typename Handle>
-struct is_mappable : mpl::false_ {};
-
-template <> struct is_mappable<char *> : mpl::true_ {};
-template <> struct is_mappable<char const *> : mpl::true_ {};
-template <> struct is_mappable<FILE *> : mpl::true_ {};
-template <> struct is_mappable<handle<posix>::native_handle_t > : mpl::true_ {};
-#ifdef _WIN32
-template <> struct is_mappable<wchar_t *> : mpl::true_ {};
-template <> struct is_mappable<wchar_t const *> : mpl::true_ {};
-template <> struct is_mappable<handle<win32>::native_handle_t > : mpl::true_ {};
-#endif // _WIN32
-
-
-template <>
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size,
- std::size_t offset
-);
-
-template <>
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference object_handle,
- std::size_t desired_size,
- std::size_t offset,
- bool map_for_code_execution
-);
-
-
-template <typename Element>
-class mapped_view
- :
- public mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- ,private noncopyable
- #endif // BOOST_MSVC
-{
-public:
- mapped_view( mapped_view_reference<Element> const range ) : mapped_view_reference<Element>( range ) {}
- ~mapped_view<Element>() { mapped_view_reference<Element>::unmap( *this ); }
-
- #ifndef BOOST_MSVC
- mapped_view( mapped_view const & ); // noncopyable
- #endif // BOOST_MSVC
+ unsigned int create_mapping_flags;
+ unsigned int map_view_flags ;
 };
 
 
-basic_mapped_view_ref map_file ( char const * file_name, std::size_t desired_size );
-basic_mapped_read_only_view_ref map_read_only_file( char const * file_name );
-
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------
@@ -321,7 +73,7 @@
 //------------------------------------------------------------------------------
 
 #ifdef BOOST_MMAP_HEADER_ONLY
- #include "mapped_view.inl"
+ #include "mapping_flags.inl"
 #endif
 
-#endif // mapped_view_hpp
+#endif // mapping_flags.hpp

Copied: sandbox/mmap/boost/mmap/mappble_objects/file/win32/mapping_flags.inl (from r74074, /sandbox/mmap/boost/mmap/mapped_view.inl)
==============================================================================
--- /sandbox/mmap/boost/mmap/mapped_view.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/mapping_flags.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapped_view.inl
-/// ---------------------
+/// \file mapping_flags.inl
+/// -----------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,39 +13,11 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#include "mapped_view.hpp"
+#include "mapping_flags.hpp"
 
-#include "detail/impl_inline.hpp"
-#include "implementations.hpp"
-#include "mappble_objects/file/handle.hpp"
-
-#include "boost/assert.hpp"
-
-#ifdef _WIN32
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif // WIN32_LEAN_AND_MEAN
- #include "windows.h"
-
- #pragma warning ( disable : 4996 ) // "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name."
- #include "io.h"
-#else
- #include "sys/mman.h" // mmap, munmap.
- #include "sys/stat.h"
- #include "sys/types.h" // struct stat.
- #include "unistd.h" // sysconf.
-#endif // _WIN32
-#include "errno.h"
-#include "fcntl.h"
-
-#ifndef _WIN32
- #ifdef __APPLE__
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) osx
- #else
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) posix
- #endif
-#endif
+#include "../../../detail/windows.hpp"
 
+#include "boost/static_assert.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -54,223 +26,40 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const mapping_flags::handle_access_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_READ , PROT_READ );
-unsigned int const mapping_flags::handle_access_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_WRITE , PROT_WRITE );
-unsigned int const mapping_flags::handle_access_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_EXECUTE, PROT_EXEC );
-
-unsigned int const mapping_flags::share_mode::shared = BOOST_AUX_IO_WIN32_OR_POSIX( 0, MAP_SHARED );
-unsigned int const mapping_flags::share_mode::hidden = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_COPY, MAP_PRIVATE );
+BOOST_STATIC_ASSERT( file_mapping_flags<win32>::handle_access_rights::read == FILE_MAP_READ );
+BOOST_STATIC_ASSERT( file_mapping_flags<win32>::handle_access_rights::write == FILE_MAP_WRITE );
+BOOST_STATIC_ASSERT( file_mapping_flags<win32>::handle_access_rights::execute == FILE_MAP_EXECUTE );
 
-unsigned int const mapping_flags::system_hint::lock_to_ram = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_LOCKED, 0 ) );
-unsigned int const mapping_flags::system_hint::reserve_page_file_space = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_RESERVE, /*khm#1*/MAP_NORESERVE );
-unsigned int const mapping_flags::system_hint::precommit = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_POPULATE, 0 ) );
-unsigned int const mapping_flags::system_hint::uninitialized = BOOST_AUX_IO_WIN32_OR_POSIX( 0, BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_UNINITIALIZED, 0 ) );
+BOOST_STATIC_ASSERT( file_mapping_flags<win32>::share_mode::shared == 0 );
+BOOST_STATIC_ASSERT( file_mapping_flags<win32>::share_mode::hidden == FILE_MAP_COPY );
 
 
 BOOST_IMPL_INLINE
-mapping_flags mapping_flags::create
+file_mapping_flags<win32> file_mapping_flags<win32>::create
 (
- unsigned int const handle_access_flags,
- unsigned int const share_mode ,
- unsigned int const system_hints
+ flags_t const combined_handle_access_flags,
+ share_mode::value_type const share_mode
 )
 {
- mapping_flags flags;
+ file_mapping_flags flags;
 
-#ifdef _WIN32
- flags.create_mapping_flags = ( handle_access_flags & handle_access_rights::execute ) ? PAGE_EXECUTE : PAGE_NOACCESS;
+ flags.create_mapping_flags = ( combined_handle_access_flags & handle_access_rights::execute ) ? PAGE_EXECUTE : PAGE_NOACCESS;
     if ( share_mode == share_mode::hidden ) // WRITECOPY
         flags.create_mapping_flags *= 8;
     else
- if ( handle_access_flags & handle_access_rights::write )
+ if ( combined_handle_access_flags & handle_access_rights::write )
         flags.create_mapping_flags *= 4;
     else
     {
- BOOST_ASSERT( handle_access_flags & handle_access_rights::read );
+ BOOST_ASSERT( combined_handle_access_flags & handle_access_rights::read );
         flags.create_mapping_flags *= 2;
     }
 
- flags.create_mapping_flags |= system_hints;
-
- flags.map_view_flags = handle_access_flags;
-#else
- flags.protection = handle_access_flags;
- flags.flags = share_mode | system_hints;
- if ( ( system_hints & system_hint::reserve_page_file_space ) ) /*khm#1*/
- flags.flags &= ~MAP_NORESERVE;
- else
- flags.flags |= MAP_NORESERVE;
-#endif // _WIN32
+ flags.map_view_flags = combined_handle_access_flags;
 
     return flags;
 }
 
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference const object_handle,
- mapping_flags const & flags,
- std::size_t const desired_size,
- std::size_t const offset
-)
-{
- typedef mapped_view_reference<unsigned char>::iterator iterator_t;
-
-#ifdef _WIN32
-
- // Implementation note:
- // Mapped views hold internal references to the following handles so we do
- // not need to hold/store them ourselves:
- // http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
- // (26.03.2010.) (Domagoj Saric)
-
- ULARGE_INTEGER large_integer;
-
- // CreateFileMapping accepts INVALID_HANDLE_VALUE as valid input but only if
- // the size parameter is not null.
- large_integer.QuadPart = desired_size;
- handle<win32> const mapping
- (
- ::CreateFileMappingW( object_handle, 0, flags.create_mapping_flags, large_integer.HighPart, large_integer.LowPart, 0 )
- );
- BOOST_ASSERT
- (
- !mapping || ( object_handle == INVALID_HANDLE_VALUE ) || ( desired_size != 0 )
- );
-
- large_integer.QuadPart = offset;
- iterator_t const view_start( static_cast<iterator_t>( ::MapViewOfFile( mapping.get(), flags.map_view_flags, large_integer.HighPart, large_integer.LowPart, desired_size ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start && ( object_handle != INVALID_HANDLE_VALUE ) )
- ? view_start + desired_size
- : view_start
- );
-
-#else // POSIX
-
- iterator_t const view_start( static_cast<iterator_t>( ::mmap( 0, desired_size, flags.protection, flags.flags, object_handle, 0 ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start != MAP_FAILED )
- ? view_start + desired_size
- : view_start
- );
-
-#endif // OS API
-}
-
-
-template <> BOOST_IMPL_INLINE
-void detail::mapped_view_base<unsigned char const>::unmap( detail::mapped_view_base<unsigned char const> const & mapped_range )
-{
-#ifdef _WIN32
- BOOST_VERIFY( ::UnmapViewOfFile( mapped_range.begin() ) || mapped_range.empty() );
-#else
- BOOST_VERIFY( ( ::munmap ( const_cast<unsigned char *>( mapped_range.begin() ), mapped_range.size() ) == 0 ) || mapped_range.empty() );
-#endif // _WIN32
-}
-
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference const object_handle,
- std::size_t const desired_size,
- std::size_t const offset,
- bool const map_for_code_execution
-)
-{
- return mapped_view_reference<unsigned char>::map
- (
- object_handle,
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | ( map_for_code_execution ? mapping_flags::handle_access_rights::execute : 0 ),
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- offset
- );
-}
-
-
-BOOST_IMPL_INLINE
-basic_mapped_view_ref map_file( char const * const file_name, std::size_t desired_size )
-{
- typedef native_file_flags file_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- file_flags::create
- (
- file_flags::handle_access_rights::read | file_flags::handle_access_rights::write,
- file_flags::share_mode ::read,
- file_flags::open_policy::open_or_create,
- file_flags::system_hints ::sequential_access,
- file_flags::on_construction_rights::read | file_flags::on_construction_rights::write
- )
- )
- );
-
- if ( desired_size )
- set_size( file_handle.get(), desired_size );
- else
- desired_size = get_size( file_handle.get() );
-
- return basic_mapped_view_ref::map
- (
- file_handle.get(),
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- 0
- );
-}
-
-
-BOOST_IMPL_INLINE
-basic_mapped_read_only_view_ref map_read_only_file( char const * const file_name )
-{
- typedef native_file_flags file_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- file_flags::create_for_opening_existing_files
- (
- file_flags::handle_access_rights::read,
- file_flags::share_mode ::read | file_flags::share_mode::write,
- false,
- file_flags::system_hints ::sequential_access
- )
- )
- );
-
- return basic_mapped_read_only_view_ref::map
- (
- file_handle.get(),
- // Implementation note:
- // Windows APIs interpret zero as 'whole file' but we still need to
- // query the file size in order to be able to properly set the end
- // pointer.
- // (13.07.2011.) (Domagoj Saric)
- get_size( file_handle.get() )
- );
-}
-
-
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------

Copied: sandbox/mmap/boost/mmap/mappble_objects/file/win32/open_flags.hpp (from r74074, /sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/open_flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file flags.hpp
-/// ---------------
+/// \file open_flags.hpp
+/// --------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,8 +13,8 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef flags_hpp__77AE8A6F_0E93_433B_A1F2_531BBBB353FC
-#define flags_hpp__77AE8A6F_0E93_433B_A1F2_531BBBB353FC
+#ifndef open_flags_hpp__77AE8A6F_0E93_433B_A1F2_531BBBB353FC
+#define open_flags_hpp__77AE8A6F_0E93_433B_A1F2_531BBBB353FC
 #pragma once
 //------------------------------------------------------------------------------
 #include "boost/assert.hpp"
@@ -27,7 +27,7 @@
 {
 //------------------------------------------------------------------------------
 
-template <typename Impl> struct file_flags;
+template <typename Impl> struct file_open_flags;
 
 // Implementation note:
 // Using structs with public members and factory functions to enable (almost)
@@ -37,22 +37,20 @@
 // interface, can also be covered.
 // (10.10.2010.) (Domagoj Saric)
 
+typedef unsigned flags_t;
+
 template <>
-struct file_flags<win32>
+struct file_open_flags<win32>
 {
     struct handle_access_rights
     {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- struct share_mode
- {
- static unsigned int const none ;
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const remove;
+ enum values
+ {
+ read = 0x80000000L,
+ write = 0x40000000L,
+ execute = 0x20000000L,
+ all = 0x10000000L
+ };
     };
 
     struct open_policy
@@ -66,43 +64,44 @@
             open_and_truncate_existing = 5
         };
     };
- typedef open_policy::value_type open_policy_t;
 
     struct system_hints
     {
- static unsigned int const random_access ;
- static unsigned int const sequential_access;
- static unsigned int const non_cached ;
- static unsigned int const delete_on_close ;
- static unsigned int const temporary ;
+ enum values
+ {
+ random_access = 0x10000000,
+ sequential_access = 0x08000000,
+ avoid_caching = 0x20000000 | 0x80000000,
+ temporary = 0x00000100 | 0x04000000
+ };
     };
 
     struct on_construction_rights
     {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
+ enum values
+ {
+ read = 0x00000001,
+ write = 0x00000080,
+ execute = 0x00000001,
+ };
     };
 
- static file_flags<win32> create
+ static file_open_flags<win32> create
     (
- unsigned int handle_access_flags ,
- unsigned int share_mode ,
- open_policy_t ,
- unsigned int system_hints ,
- unsigned int on_construction_rights
+ flags_t handle_access_flags ,
+ open_policy::value_type ,
+ flags_t system_hints ,
+ flags_t on_construction_rights
     );
 
- static file_flags<win32> create_for_opening_existing_files
+ static file_open_flags<win32> create_for_opening_existing_files
     (
- unsigned int handle_access_flags,
- unsigned int share_mode ,
- bool truncate ,
- unsigned int system_hints
+ flags_t handle_access_flags,
+ bool truncate ,
+ flags_t system_hints
     );
 
     unsigned long desired_access ;
- unsigned long share_mode ;
     unsigned long creation_disposition;
     unsigned long flags_and_attributes;
 };
@@ -114,7 +113,7 @@
 //------------------------------------------------------------------------------
 
 #ifdef BOOST_MMAP_HEADER_ONLY
- #include "flags.inl"
+ #include "open_flags.inl"
 #endif // BOOST_MMAP_HEADER_ONLY
 
-#endif // flags_hpp
+#endif // open_flags_hpp

Copied: sandbox/mmap/boost/mmap/mappble_objects/file/win32/open_flags.inl (from r74074, /sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl)
==============================================================================
--- /sandbox/mmap/boost/mmap/mappble_objects/file/win32/flags.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/win32/open_flags.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file flags.inl
-/// ---------------
+/// \file open_flags.inl
+/// --------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,11 +13,11 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#include "flags.hpp"
+#include "open_flags.hpp"
 
 #include "../../detail/impl_inline.hpp"
 
-#include "boost/assert.hpp"
+#include "boost/static_assert.hpp"
 
 #ifndef WIN32_LEAN_AND_MEAN
     #define WIN32_LEAN_AND_MEAN
@@ -31,46 +31,39 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const file_flags<win32>::handle_access_rights::read = GENERIC_READ ;
-unsigned int const file_flags<win32>::handle_access_rights::write = GENERIC_WRITE ;
-unsigned int const file_flags<win32>::handle_access_rights::execute = GENERIC_EXECUTE;
-
-unsigned int const file_flags<win32>::share_mode::none = 0 ;
-unsigned int const file_flags<win32>::share_mode::read = FILE_SHARE_READ ;
-unsigned int const file_flags<win32>::share_mode::write = FILE_SHARE_WRITE ;
-unsigned int const file_flags<win32>::share_mode::remove = FILE_SHARE_DELETE;
-
-unsigned int const file_flags<win32>::system_hints::random_access = FILE_FLAG_RANDOM_ACCESS ;
-unsigned int const file_flags<win32>::system_hints::sequential_access = FILE_FLAG_SEQUENTIAL_SCAN ;
-unsigned int const file_flags<win32>::system_hints::non_cached = FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
-unsigned int const file_flags<win32>::system_hints::delete_on_close = FILE_FLAG_DELETE_ON_CLOSE ;
-unsigned int const file_flags<win32>::system_hints::temporary = FILE_ATTRIBUTE_TEMPORARY ;
-
-unsigned int const file_flags<win32>::on_construction_rights::read = FILE_ATTRIBUTE_READONLY;
-unsigned int const file_flags<win32>::on_construction_rights::write = FILE_ATTRIBUTE_NORMAL ;
-unsigned int const file_flags<win32>::on_construction_rights::execute = FILE_ATTRIBUTE_READONLY;
+BOOST_STATIC_ASSERT( file_open_flags<win32>::handle_access_rights::read == GENERIC_READ );
+BOOST_STATIC_ASSERT( file_open_flags<win32>::handle_access_rights::write == GENERIC_WRITE );
+BOOST_STATIC_ASSERT( file_open_flags<win32>::handle_access_rights::execute == GENERIC_EXECUTE );
+BOOST_STATIC_ASSERT( file_open_flags<win32>::handle_access_rights::all == GENERIC_ALL );
+
+BOOST_STATIC_ASSERT( file_open_flags<win32>::system_hints::random_access == FILE_FLAG_RANDOM_ACCESS );
+BOOST_STATIC_ASSERT( file_open_flags<win32>::system_hints::sequential_access == FILE_FLAG_SEQUENTIAL_SCAN );
+BOOST_STATIC_ASSERT( file_open_flags<win32>::system_hints::avoid_caching == ( FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH ) );
+BOOST_STATIC_ASSERT( file_open_flags<win32>::system_hints::temporary == ( FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE ) );
+
+BOOST_STATIC_ASSERT( file_open_flags<win32>::on_construction_rights::read == FILE_ATTRIBUTE_READONLY );
+BOOST_STATIC_ASSERT( file_open_flags<win32>::on_construction_rights::write == FILE_ATTRIBUTE_NORMAL );
+BOOST_STATIC_ASSERT( file_open_flags<win32>::on_construction_rights::execute == FILE_ATTRIBUTE_READONLY );
 
 BOOST_IMPL_INLINE
-file_flags<win32> file_flags<win32>::create
+file_open_flags<win32> file_open_flags<win32>::create
 (
- unsigned int const handle_access_flags ,
- unsigned int const share_mode ,
- open_policy_t const open_flags ,
- unsigned int const system_hints ,
- unsigned int const on_construction_rights
+ flags_t const handle_access_flags ,
+ open_policy::value_type const open_flags ,
+ flags_t const system_hints ,
+ flags_t const on_construction_rights
 )
 {
- file_flags<win32> const flags =
+ file_open_flags<win32> const flags =
     {
         handle_access_flags, // desired_access
- share_mode, // share_mode
         open_flags, // creation_disposition
         system_hints
             |
         (
             ( on_construction_rights & FILE_ATTRIBUTE_NORMAL )
- ? ( on_construction_rights & ~FILE_ATTRIBUTE_READONLY )
- : on_construction_rights
+ ? FILE_ATTRIBUTE_NORMAL
+ : on_construction_rights
         ) // flags_and_attributes
     };
 
@@ -79,18 +72,16 @@
 
 
 BOOST_IMPL_INLINE
-file_flags<win32> file_flags<win32>::create_for_opening_existing_files
+file_open_flags<win32> file_open_flags<win32>::create_for_opening_existing_files
 (
- unsigned int const handle_access_flags,
- unsigned int const share_mode,
- bool const truncate,
- unsigned int const system_hints
+ flags_t const handle_access_flags,
+ bool const truncate,
+ flags_t const system_hints
 )
 {
     return create
     (
         handle_access_flags,
- share_mode,
         truncate
             ? open_policy::open_and_truncate_existing
             : open_policy::open_existing,

Copied: sandbox/mmap/boost/mmap/mappble_objects/shared_memory/posix/flags.hpp (from r74074, /sandbox/mmap/boost/mmap/mapped_view.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/mapped_view.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/shared_memory/posix/flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapped_view.hpp
-/// ---------------------
+/// \file flags.hpp
+/// ---------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,31 +13,12 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
-#define mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
+#ifndef flags_hpp__F9CD9C91_1F07_4107_A422_0D814F0FE487
+#define flags_hpp__F9CD9C91_1F07_4107_A422_0D814F0FE487
 #pragma once
 //------------------------------------------------------------------------------
-#include "handles/handle.hpp"
-//...zzz...
-#include "mappble_objects/file/file.hpp"
-#include "mappble_objects/file/posix/file.hpp"
-#ifdef _WIN32
-#include "mappble_objects/file/win32/file.hpp"
-#endif // _WIN32
-
-#include "boost/assert.hpp"
-#include "boost/noncopyable.hpp"
-#include "boost/range/iterator_range.hpp"
-
-#ifndef _WIN32
- #include "fcntl.h"
-#endif // _WIN32
-
-#ifdef _WIN32
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) win32
-#else
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) posix
-#endif
+#include "../../file/posix/mapping_flags.hpp"
+#include "../../../detail/posix.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -46,274 +27,33 @@
 {
 //------------------------------------------------------------------------------
 
-// Implementation note:
-// Using structs with public members and factory functions to enable (almost)
-// zero-overhead 'link-time' conversion to native flag formats and to allow the
-// user to modify the created flags or create fully custom ones so that specific
-// platform-dependent use-cases, not otherwise covered through the generic
-// interface, can also be covered.
-// (10.10.2010.) (Domagoj Saric)
-
-struct mapping_flags
-{
- struct handle_access_rights
- {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- struct share_mode
- {
- static unsigned int const shared;
- static unsigned int const hidden;
- };
-
- struct system_hint
- {
- static unsigned int const lock_to_ram ;
- static unsigned int const reserve_page_file_space;
- static unsigned int const precommit ;
- static unsigned int const uninitialized ;
- };
-
- static mapping_flags create
- (
- unsigned int handle_access_rights,
- unsigned int share_mode ,
- unsigned int system_hints
- );
-
-#ifdef _WIN32
- unsigned int create_mapping_flags;
- unsigned int map_view_flags;
-#else
- int protection;
- int flags ;
-#endif // _WIN32
-};
-
+template <typename Impl> struct shared_memory_flags;
 
-typedef iterator_range<unsigned char *> basic_memory_range_t;
-typedef iterator_range<unsigned char const *> basic_read_only_memory_range_t;
+struct posix;
 
-template <typename Element>
-class mapped_view_reference;
+typedef unsigned flags_t;
 
-typedef mapped_view_reference<unsigned char > basic_mapped_view_ref;
-typedef mapped_view_reference<unsigned char const> basic_mapped_read_only_view_ref;
-
-namespace detail
+template <>
+struct shared_memory_flags<posix> : file_mapping_flags<posix>
 {
- template <typename Element>
- class mapped_view_base : public iterator_range<Element *>
+ struct system_hints
     {
- public:
- typedef iterator_range<Element *> memory_range_t;
-
- public: // Factory methods.
- static void unmap( mapped_view_base const & );
-
- protected:
- mapped_view_base( iterator_range<Element *> const & mapped_range ) : iterator_range<Element *>( mapped_range ) {}
- mapped_view_base( Element * const p_begin, Element * const p_end ) : iterator_range<Element *>( p_begin, p_end ) {}
-
- static mapped_view_reference<unsigned char const>
- #ifdef BOOST_MSVC
- const &
- #endif
- make_basic_view( mapped_view_base<Element> const & );
-
- static mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- const &
- #endif
- make_typed_range( mapped_view_base<unsigned char> const & );
-
- private: // Hide mutable members
- void advance_begin();
- void advance_end ();
-
- void pop_front();
- void pop_back ();
+ enum value_type
+ {
+ default = 0,
+ only_reserve_address_space = MAP_NORESERVE
+ }
     };
 
-
- template <typename Element>
- void mapped_view_base<Element>::unmap( mapped_view_base<Element> const & mapped_range )
- {
- mapped_view_base<unsigned char const>::unmap( make_basic_view( mapped_range ) );
- }
-
- template <>
- void mapped_view_base<unsigned char const>::unmap( mapped_view_base<unsigned char const> const & );
-} // namespace detail
-
-template <typename Element>
-class mapped_view_reference : public detail::mapped_view_base<Element>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char *>( static_cast<void *>( this->begin() ) ),
- static_cast<unsigned char *>( static_cast<void *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
+ static shared_memory_flags<posix> create
     (
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size = 0,
- std::size_t offset = 0
+ flags_t combined_handle_access_rights,
+ share_mode ::value_type share_mode,
+ system_hints::value_type system_hint
     );
-
-private:
- template <typename T> friend class detail::mapped_view_base;
-
- mapped_view_reference( iterator_range<Element *> const & mapped_range ) : detail::mapped_view_base<Element>( mapped_range ) {}
- mapped_view_reference( Element * const p_begin, Element * const p_end ) : detail::mapped_view_base<Element>( p_begin, p_end ) {}
-};
-
-template <typename Element>
-class mapped_view_reference<Element const> : public detail::mapped_view_base<Element const>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char const *>( static_cast<void const *>( this->begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
- (
- native_handle::reference object_handle,
- std::size_t desired_size = 0,
- std::size_t offset = 0,
- bool map_for_code_execution = false
- );
-
-private:
- template <typename T> friend class detail::mapped_view_base;
-
- mapped_view_reference( iterator_range<Element const *> const & mapped_range ) : detail::mapped_view_base<Element const>( mapped_range ) {}
- mapped_view_reference( Element const * const p_begin, Element const * const p_end ) : detail::mapped_view_base<Element const>( p_begin, p_end ) {}
- mapped_view_reference( mapped_view_reference<Element> const & mutable_view ) : detail::mapped_view_base<Element const>( mutable_view ) {}
-};
-
-
-namespace detail
-{
- // Implementation note:
- // These have to be defined after mapped_view_reference for eager
- // compilers (e.g. GCC and Clang).
- // (14.07.2011.) (Domagoj Saric)
-
- template <typename Element>
- mapped_view_reference<unsigned char const>
- #ifdef BOOST_MSVC
- const &
- #endif
- mapped_view_base<Element>::make_basic_view( mapped_view_base<Element> const & range )
- {
- return
- #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<unsigned char const> const &>( range );
- #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
- (
- static_cast<unsigned char const *>( static_cast<void const *>( range.begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( range.end () ) )
- );
- #endif // compiler
- }
-
-
- template <typename Element>
- mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- const &
- #endif
- mapped_view_base<Element>::make_typed_range( mapped_view_base<unsigned char> const & range )
- {
- BOOST_ASSERT( reinterpret_cast<std::size_t>( range.begin() ) % sizeof( Element ) == 0 );
- BOOST_ASSERT( reinterpret_cast<std::size_t>( range.end () ) % sizeof( Element ) == 0 );
- BOOST_ASSERT( range.size () % sizeof( Element ) == 0 );
- return
- #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<Element> const &>( range );
- #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
- (
- static_cast<Element *>( static_cast<void *>( range.begin() ) ),
- static_cast<Element *>( static_cast<void *>( range.end () ) )
- );
- #endif // compiler
- }
-} // namespace detail
-
-
-template <typename Handle>
-struct is_mappable : mpl::false_ {};
-
-template <> struct is_mappable<char *> : mpl::true_ {};
-template <> struct is_mappable<char const *> : mpl::true_ {};
-template <> struct is_mappable<FILE *> : mpl::true_ {};
-template <> struct is_mappable<handle<posix>::native_handle_t > : mpl::true_ {};
-#ifdef _WIN32
-template <> struct is_mappable<wchar_t *> : mpl::true_ {};
-template <> struct is_mappable<wchar_t const *> : mpl::true_ {};
-template <> struct is_mappable<handle<win32>::native_handle_t > : mpl::true_ {};
-#endif // _WIN32
-
-
-template <>
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size,
- std::size_t offset
-);
-
-template <>
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference object_handle,
- std::size_t desired_size,
- std::size_t offset,
- bool map_for_code_execution
-);
-
-
-template <typename Element>
-class mapped_view
- :
- public mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- ,private noncopyable
- #endif // BOOST_MSVC
-{
-public:
- mapped_view( mapped_view_reference<Element> const range ) : mapped_view_reference<Element>( range ) {}
- ~mapped_view<Element>() { mapped_view_reference<Element>::unmap( *this ); }
-
- #ifndef BOOST_MSVC
- mapped_view( mapped_view const & ); // noncopyable
- #endif // BOOST_MSVC
 };
 
 
-basic_mapped_view_ref map_file ( char const * file_name, std::size_t desired_size );
-basic_mapped_read_only_view_ref map_read_only_file( char const * file_name );
-
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------
@@ -321,7 +61,7 @@
 //------------------------------------------------------------------------------
 
 #ifdef BOOST_MMAP_HEADER_ONLY
- #include "mapped_view.inl"
+ #include "flags.inl"
 #endif
 
-#endif // mapped_view_hpp
+#endif // flags.hpp

Copied: sandbox/mmap/boost/mmap/mappble_objects/shared_memory/posix/flags.inl (from r74074, /sandbox/mmap/boost/mmap/mapped_view.inl)
==============================================================================
--- /sandbox/mmap/boost/mmap/mapped_view.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/shared_memory/posix/flags.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapped_view.inl
-/// ---------------------
+/// \file flags.inl
+/// ---------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,39 +13,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#include "mapped_view.hpp"
-
-#include "detail/impl_inline.hpp"
-#include "implementations.hpp"
-#include "mappble_objects/file/handle.hpp"
-
-#include "boost/assert.hpp"
-
-#ifdef _WIN32
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif // WIN32_LEAN_AND_MEAN
- #include "windows.h"
-
- #pragma warning ( disable : 4996 ) // "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name."
- #include "io.h"
-#else
- #include "sys/mman.h" // mmap, munmap.
- #include "sys/stat.h"
- #include "sys/types.h" // struct stat.
- #include "unistd.h" // sysconf.
-#endif // _WIN32
-#include "errno.h"
-#include "fcntl.h"
-
-#ifndef _WIN32
- #ifdef __APPLE__
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) osx
- #else
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) posix
- #endif
-#endif
-
+#include "flags.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -54,223 +22,19 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const mapping_flags::handle_access_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_READ , PROT_READ );
-unsigned int const mapping_flags::handle_access_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_WRITE , PROT_WRITE );
-unsigned int const mapping_flags::handle_access_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_EXECUTE, PROT_EXEC );
-
-unsigned int const mapping_flags::share_mode::shared = BOOST_AUX_IO_WIN32_OR_POSIX( 0, MAP_SHARED );
-unsigned int const mapping_flags::share_mode::hidden = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_COPY, MAP_PRIVATE );
-
-unsigned int const mapping_flags::system_hint::lock_to_ram = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_LOCKED, 0 ) );
-unsigned int const mapping_flags::system_hint::reserve_page_file_space = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_RESERVE, /*khm#1*/MAP_NORESERVE );
-unsigned int const mapping_flags::system_hint::precommit = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_POPULATE, 0 ) );
-unsigned int const mapping_flags::system_hint::uninitialized = BOOST_AUX_IO_WIN32_OR_POSIX( 0, BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_UNINITIALIZED, 0 ) );
-
-
 BOOST_IMPL_INLINE
-mapping_flags mapping_flags::create
+shared_memory_flags<posix> shared_memory_flags<posix>::create
 (
- unsigned int const handle_access_flags,
- unsigned int const share_mode ,
- unsigned int const system_hints
+ flags_t const combined_handle_access_flags,
+ share_mode ::value_type const share_mode,
+ system_hints::value_type const system_hint
 )
 {
- mapping_flags flags;
-
-#ifdef _WIN32
- flags.create_mapping_flags = ( handle_access_flags & handle_access_rights::execute ) ? PAGE_EXECUTE : PAGE_NOACCESS;
- if ( share_mode == share_mode::hidden ) // WRITECOPY
- flags.create_mapping_flags *= 8;
- else
- if ( handle_access_flags & handle_access_rights::write )
- flags.create_mapping_flags *= 4;
- else
- {
- BOOST_ASSERT( handle_access_flags & handle_access_rights::read );
- flags.create_mapping_flags *= 2;
- }
-
- flags.create_mapping_flags |= system_hints;
-
- flags.map_view_flags = handle_access_flags;
-#else
- flags.protection = handle_access_flags;
- flags.flags = share_mode | system_hints;
- if ( ( system_hints & system_hint::reserve_page_file_space ) ) /*khm#1*/
- flags.flags &= ~MAP_NORESERVE;
- else
- flags.flags |= MAP_NORESERVE;
-#endif // _WIN32
-
+ shared_memory_flags<posix> flags( file_mapping_flags<posix>::create( combined_handle_access_flags, share_mode ) );
+ flags.flags |= system_hint;
     return flags;
 }
 
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference const object_handle,
- mapping_flags const & flags,
- std::size_t const desired_size,
- std::size_t const offset
-)
-{
- typedef mapped_view_reference<unsigned char>::iterator iterator_t;
-
-#ifdef _WIN32
-
- // Implementation note:
- // Mapped views hold internal references to the following handles so we do
- // not need to hold/store them ourselves:
- // http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
- // (26.03.2010.) (Domagoj Saric)
-
- ULARGE_INTEGER large_integer;
-
- // CreateFileMapping accepts INVALID_HANDLE_VALUE as valid input but only if
- // the size parameter is not null.
- large_integer.QuadPart = desired_size;
- handle<win32> const mapping
- (
- ::CreateFileMappingW( object_handle, 0, flags.create_mapping_flags, large_integer.HighPart, large_integer.LowPart, 0 )
- );
- BOOST_ASSERT
- (
- !mapping || ( object_handle == INVALID_HANDLE_VALUE ) || ( desired_size != 0 )
- );
-
- large_integer.QuadPart = offset;
- iterator_t const view_start( static_cast<iterator_t>( ::MapViewOfFile( mapping.get(), flags.map_view_flags, large_integer.HighPart, large_integer.LowPart, desired_size ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start && ( object_handle != INVALID_HANDLE_VALUE ) )
- ? view_start + desired_size
- : view_start
- );
-
-#else // POSIX
-
- iterator_t const view_start( static_cast<iterator_t>( ::mmap( 0, desired_size, flags.protection, flags.flags, object_handle, 0 ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start != MAP_FAILED )
- ? view_start + desired_size
- : view_start
- );
-
-#endif // OS API
-}
-
-
-template <> BOOST_IMPL_INLINE
-void detail::mapped_view_base<unsigned char const>::unmap( detail::mapped_view_base<unsigned char const> const & mapped_range )
-{
-#ifdef _WIN32
- BOOST_VERIFY( ::UnmapViewOfFile( mapped_range.begin() ) || mapped_range.empty() );
-#else
- BOOST_VERIFY( ( ::munmap ( const_cast<unsigned char *>( mapped_range.begin() ), mapped_range.size() ) == 0 ) || mapped_range.empty() );
-#endif // _WIN32
-}
-
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference const object_handle,
- std::size_t const desired_size,
- std::size_t const offset,
- bool const map_for_code_execution
-)
-{
- return mapped_view_reference<unsigned char>::map
- (
- object_handle,
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | ( map_for_code_execution ? mapping_flags::handle_access_rights::execute : 0 ),
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- offset
- );
-}
-
-
-BOOST_IMPL_INLINE
-basic_mapped_view_ref map_file( char const * const file_name, std::size_t desired_size )
-{
- typedef native_file_flags file_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- file_flags::create
- (
- file_flags::handle_access_rights::read | file_flags::handle_access_rights::write,
- file_flags::share_mode ::read,
- file_flags::open_policy::open_or_create,
- file_flags::system_hints ::sequential_access,
- file_flags::on_construction_rights::read | file_flags::on_construction_rights::write
- )
- )
- );
-
- if ( desired_size )
- set_size( file_handle.get(), desired_size );
- else
- desired_size = get_size( file_handle.get() );
-
- return basic_mapped_view_ref::map
- (
- file_handle.get(),
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- 0
- );
-}
-
-
-BOOST_IMPL_INLINE
-basic_mapped_read_only_view_ref map_read_only_file( char const * const file_name )
-{
- typedef native_file_flags file_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- file_flags::create_for_opening_existing_files
- (
- file_flags::handle_access_rights::read,
- file_flags::share_mode ::read | file_flags::share_mode::write,
- false,
- file_flags::system_hints ::sequential_access
- )
- )
- );
-
- return basic_mapped_read_only_view_ref::map
- (
- file_handle.get(),
- // Implementation note:
- // Windows APIs interpret zero as 'whole file' but we still need to
- // query the file size in order to be able to properly set the end
- // pointer.
- // (13.07.2011.) (Domagoj Saric)
- get_size( file_handle.get() )
- );
-}
-
-
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------

Copied: sandbox/mmap/boost/mmap/mappble_objects/shared_memory/win32/flags.hpp (from r74074, /sandbox/mmap/boost/mmap/mapped_view.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/mapped_view.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/shared_memory/win32/flags.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapped_view.hpp
-/// ---------------------
+/// \file mapping_flags.hpp
+/// -----------------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,31 +13,11 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
-#define mapped_view_hpp__D9C84FF5_E506_4ECB_9778_61E036048D28
+#ifndef flags_hpp__504C3F9E_97C2_4E8C_82C6_881340C5FBA6
+#define flags_hpp__504C3F9E_97C2_4E8C_82C6_881340C5FBA6
 #pragma once
 //------------------------------------------------------------------------------
-#include "handles/handle.hpp"
-//...zzz...
-#include "mappble_objects/file/file.hpp"
-#include "mappble_objects/file/posix/file.hpp"
-#ifdef _WIN32
-#include "mappble_objects/file/win32/file.hpp"
-#endif // _WIN32
-
-#include "boost/assert.hpp"
-#include "boost/noncopyable.hpp"
-#include "boost/range/iterator_range.hpp"
-
-#ifndef _WIN32
- #include "fcntl.h"
-#endif // _WIN32
-
-#ifdef _WIN32
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) win32
-#else
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) posix
-#endif
+#include "../../file/win32/mapping_flags.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -46,274 +26,33 @@
 {
 //------------------------------------------------------------------------------
 
-// Implementation note:
-// Using structs with public members and factory functions to enable (almost)
-// zero-overhead 'link-time' conversion to native flag formats and to allow the
-// user to modify the created flags or create fully custom ones so that specific
-// platform-dependent use-cases, not otherwise covered through the generic
-// interface, can also be covered.
-// (10.10.2010.) (Domagoj Saric)
-
-struct mapping_flags
-{
- struct handle_access_rights
- {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- struct share_mode
- {
- static unsigned int const shared;
- static unsigned int const hidden;
- };
-
- struct system_hint
- {
- static unsigned int const lock_to_ram ;
- static unsigned int const reserve_page_file_space;
- static unsigned int const precommit ;
- static unsigned int const uninitialized ;
- };
-
- static mapping_flags create
- (
- unsigned int handle_access_rights,
- unsigned int share_mode ,
- unsigned int system_hints
- );
-
-#ifdef _WIN32
- unsigned int create_mapping_flags;
- unsigned int map_view_flags;
-#else
- int protection;
- int flags ;
-#endif // _WIN32
-};
-
+template <typename Impl> struct shared_memory_flags;
 
-typedef iterator_range<unsigned char *> basic_memory_range_t;
-typedef iterator_range<unsigned char const *> basic_read_only_memory_range_t;
+struct win32;
 
-template <typename Element>
-class mapped_view_reference;
+typedef unsigned flags_t;
 
-typedef mapped_view_reference<unsigned char > basic_mapped_view_ref;
-typedef mapped_view_reference<unsigned char const> basic_mapped_read_only_view_ref;
-
-namespace detail
+template <>
+struct shared_memory_flags<win32> : file_mapping_flags<win32>
 {
- template <typename Element>
- class mapped_view_base : public iterator_range<Element *>
+ struct system_hints
     {
- public:
- typedef iterator_range<Element *> memory_range_t;
-
- public: // Factory methods.
- static void unmap( mapped_view_base const & );
-
- protected:
- mapped_view_base( iterator_range<Element *> const & mapped_range ) : iterator_range<Element *>( mapped_range ) {}
- mapped_view_base( Element * const p_begin, Element * const p_end ) : iterator_range<Element *>( p_begin, p_end ) {}
-
- static mapped_view_reference<unsigned char const>
- #ifdef BOOST_MSVC
- const &
- #endif
- make_basic_view( mapped_view_base<Element> const & );
-
- static mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- const &
- #endif
- make_typed_range( mapped_view_base<unsigned char> const & );
-
- private: // Hide mutable members
- void advance_begin();
- void advance_end ();
-
- void pop_front();
- void pop_back ();
+ enum value_type
+ {
+ default = 0x8000000,
+ only_reserve_address_space = 0x4000000
+ }
     };
 
-
- template <typename Element>
- void mapped_view_base<Element>::unmap( mapped_view_base<Element> const & mapped_range )
- {
- mapped_view_base<unsigned char const>::unmap( make_basic_view( mapped_range ) );
- }
-
- template <>
- void mapped_view_base<unsigned char const>::unmap( mapped_view_base<unsigned char const> const & );
-} // namespace detail
-
-template <typename Element>
-class mapped_view_reference : public detail::mapped_view_base<Element>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char *>( static_cast<void *>( this->begin() ) ),
- static_cast<unsigned char *>( static_cast<void *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
+ static shared_memory_flags<win32> create
     (
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size = 0,
- std::size_t offset = 0
+ flags_t combined_handle_access_rights,
+ share_mode ::value_type share_mode,
+ system_hints::value_type system_hint
     );
-
-private:
- template <typename T> friend class detail::mapped_view_base;
-
- mapped_view_reference( iterator_range<Element *> const & mapped_range ) : detail::mapped_view_base<Element>( mapped_range ) {}
- mapped_view_reference( Element * const p_begin, Element * const p_end ) : detail::mapped_view_base<Element>( p_begin, p_end ) {}
-};
-
-template <typename Element>
-class mapped_view_reference<Element const> : public detail::mapped_view_base<Element const>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char const *>( static_cast<void const *>( this->begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
- (
- native_handle::reference object_handle,
- std::size_t desired_size = 0,
- std::size_t offset = 0,
- bool map_for_code_execution = false
- );
-
-private:
- template <typename T> friend class detail::mapped_view_base;
-
- mapped_view_reference( iterator_range<Element const *> const & mapped_range ) : detail::mapped_view_base<Element const>( mapped_range ) {}
- mapped_view_reference( Element const * const p_begin, Element const * const p_end ) : detail::mapped_view_base<Element const>( p_begin, p_end ) {}
- mapped_view_reference( mapped_view_reference<Element> const & mutable_view ) : detail::mapped_view_base<Element const>( mutable_view ) {}
-};
-
-
-namespace detail
-{
- // Implementation note:
- // These have to be defined after mapped_view_reference for eager
- // compilers (e.g. GCC and Clang).
- // (14.07.2011.) (Domagoj Saric)
-
- template <typename Element>
- mapped_view_reference<unsigned char const>
- #ifdef BOOST_MSVC
- const &
- #endif
- mapped_view_base<Element>::make_basic_view( mapped_view_base<Element> const & range )
- {
- return
- #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<unsigned char const> const &>( range );
- #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
- (
- static_cast<unsigned char const *>( static_cast<void const *>( range.begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( range.end () ) )
- );
- #endif // compiler
- }
-
-
- template <typename Element>
- mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- const &
- #endif
- mapped_view_base<Element>::make_typed_range( mapped_view_base<unsigned char> const & range )
- {
- BOOST_ASSERT( reinterpret_cast<std::size_t>( range.begin() ) % sizeof( Element ) == 0 );
- BOOST_ASSERT( reinterpret_cast<std::size_t>( range.end () ) % sizeof( Element ) == 0 );
- BOOST_ASSERT( range.size () % sizeof( Element ) == 0 );
- return
- #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<Element> const &>( range );
- #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
- (
- static_cast<Element *>( static_cast<void *>( range.begin() ) ),
- static_cast<Element *>( static_cast<void *>( range.end () ) )
- );
- #endif // compiler
- }
-} // namespace detail
-
-
-template <typename Handle>
-struct is_mappable : mpl::false_ {};
-
-template <> struct is_mappable<char *> : mpl::true_ {};
-template <> struct is_mappable<char const *> : mpl::true_ {};
-template <> struct is_mappable<FILE *> : mpl::true_ {};
-template <> struct is_mappable<handle<posix>::native_handle_t > : mpl::true_ {};
-#ifdef _WIN32
-template <> struct is_mappable<wchar_t *> : mpl::true_ {};
-template <> struct is_mappable<wchar_t const *> : mpl::true_ {};
-template <> struct is_mappable<handle<win32>::native_handle_t > : mpl::true_ {};
-#endif // _WIN32
-
-
-template <>
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size,
- std::size_t offset
-);
-
-template <>
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference object_handle,
- std::size_t desired_size,
- std::size_t offset,
- bool map_for_code_execution
-);
-
-
-template <typename Element>
-class mapped_view
- :
- public mapped_view_reference<Element>
- #ifdef BOOST_MSVC
- ,private noncopyable
- #endif // BOOST_MSVC
-{
-public:
- mapped_view( mapped_view_reference<Element> const range ) : mapped_view_reference<Element>( range ) {}
- ~mapped_view<Element>() { mapped_view_reference<Element>::unmap( *this ); }
-
- #ifndef BOOST_MSVC
- mapped_view( mapped_view const & ); // noncopyable
- #endif // BOOST_MSVC
 };
 
 
-basic_mapped_view_ref map_file ( char const * file_name, std::size_t desired_size );
-basic_mapped_read_only_view_ref map_read_only_file( char const * file_name );
-
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------
@@ -321,7 +60,7 @@
 //------------------------------------------------------------------------------
 
 #ifdef BOOST_MMAP_HEADER_ONLY
- #include "mapped_view.inl"
+ #include "flags.inl"
 #endif
 
-#endif // mapped_view_hpp
+#endif // flags.hpp

Copied: sandbox/mmap/boost/mmap/mappble_objects/shared_memory/win32/flags.inl (from r74074, /sandbox/mmap/boost/mmap/mapped_view.inl)
==============================================================================
--- /sandbox/mmap/boost/mmap/mapped_view.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/shared_memory/win32/flags.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapped_view.inl
-/// ---------------------
+/// \file flags.inl
+/// ---------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,39 +13,11 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#include "mapped_view.hpp"
+#include "flags.hpp"
 
-#include "detail/impl_inline.hpp"
-#include "implementations.hpp"
-#include "mappble_objects/file/handle.hpp"
-
-#include "boost/assert.hpp"
-
-#ifdef _WIN32
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif // WIN32_LEAN_AND_MEAN
- #include "windows.h"
-
- #pragma warning ( disable : 4996 ) // "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name."
- #include "io.h"
-#else
- #include "sys/mman.h" // mmap, munmap.
- #include "sys/stat.h"
- #include "sys/types.h" // struct stat.
- #include "unistd.h" // sysconf.
-#endif // _WIN32
-#include "errno.h"
-#include "fcntl.h"
-
-#ifndef _WIN32
- #ifdef __APPLE__
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) osx
- #else
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) posix
- #endif
-#endif
+#include "../../../detail/windows.hpp"
 
+#include "boost/static_assert.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -54,223 +26,23 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const mapping_flags::handle_access_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_READ , PROT_READ );
-unsigned int const mapping_flags::handle_access_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_WRITE , PROT_WRITE );
-unsigned int const mapping_flags::handle_access_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_EXECUTE, PROT_EXEC );
-
-unsigned int const mapping_flags::share_mode::shared = BOOST_AUX_IO_WIN32_OR_POSIX( 0, MAP_SHARED );
-unsigned int const mapping_flags::share_mode::hidden = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_COPY, MAP_PRIVATE );
-
-unsigned int const mapping_flags::system_hint::lock_to_ram = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_LOCKED, 0 ) );
-unsigned int const mapping_flags::system_hint::reserve_page_file_space = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_RESERVE, /*khm#1*/MAP_NORESERVE );
-unsigned int const mapping_flags::system_hint::precommit = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_POPULATE, 0 ) );
-unsigned int const mapping_flags::system_hint::uninitialized = BOOST_AUX_IO_WIN32_OR_POSIX( 0, BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_UNINITIALIZED, 0 ) );
+BOOST_STATIC_ASSERT( shared_memory_flags<win32>::system_hints::default == SEC_COMMIT );
+BOOST_STATIC_ASSERT( shared_memory_flags<win32>::system_hints::only_reserve_address_space == SEC_RESERVE );
 
 
 BOOST_IMPL_INLINE
-mapping_flags mapping_flags::create
+shared_memory_flags<win32> shared_memory_flags<win32>::create
 (
- unsigned int const handle_access_flags,
- unsigned int const share_mode ,
- unsigned int const system_hints
+ flags_t const combined_handle_access_flags,
+ share_mode ::value_type const share_mode,
+ system_hints::value_type const system_hint
 )
 {
- mapping_flags flags;
-
-#ifdef _WIN32
- flags.create_mapping_flags = ( handle_access_flags & handle_access_rights::execute ) ? PAGE_EXECUTE : PAGE_NOACCESS;
- if ( share_mode == share_mode::hidden ) // WRITECOPY
- flags.create_mapping_flags *= 8;
- else
- if ( handle_access_flags & handle_access_rights::write )
- flags.create_mapping_flags *= 4;
- else
- {
- BOOST_ASSERT( handle_access_flags & handle_access_rights::read );
- flags.create_mapping_flags *= 2;
- }
-
- flags.create_mapping_flags |= system_hints;
-
- flags.map_view_flags = handle_access_flags;
-#else
- flags.protection = handle_access_flags;
- flags.flags = share_mode | system_hints;
- if ( ( system_hints & system_hint::reserve_page_file_space ) ) /*khm#1*/
- flags.flags &= ~MAP_NORESERVE;
- else
- flags.flags |= MAP_NORESERVE;
-#endif // _WIN32
-
+ shared_memory_flags<win32> flags( file_mapping_flags<win32>::create( combined_handle_access_flags, share_mode ) );
+ flags.create_mapping_flags |= system_hint;
     return flags;
 }
 
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference const object_handle,
- mapping_flags const & flags,
- std::size_t const desired_size,
- std::size_t const offset
-)
-{
- typedef mapped_view_reference<unsigned char>::iterator iterator_t;
-
-#ifdef _WIN32
-
- // Implementation note:
- // Mapped views hold internal references to the following handles so we do
- // not need to hold/store them ourselves:
- // http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
- // (26.03.2010.) (Domagoj Saric)
-
- ULARGE_INTEGER large_integer;
-
- // CreateFileMapping accepts INVALID_HANDLE_VALUE as valid input but only if
- // the size parameter is not null.
- large_integer.QuadPart = desired_size;
- handle<win32> const mapping
- (
- ::CreateFileMappingW( object_handle, 0, flags.create_mapping_flags, large_integer.HighPart, large_integer.LowPart, 0 )
- );
- BOOST_ASSERT
- (
- !mapping || ( object_handle == INVALID_HANDLE_VALUE ) || ( desired_size != 0 )
- );
-
- large_integer.QuadPart = offset;
- iterator_t const view_start( static_cast<iterator_t>( ::MapViewOfFile( mapping.get(), flags.map_view_flags, large_integer.HighPart, large_integer.LowPart, desired_size ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start && ( object_handle != INVALID_HANDLE_VALUE ) )
- ? view_start + desired_size
- : view_start
- );
-
-#else // POSIX
-
- iterator_t const view_start( static_cast<iterator_t>( ::mmap( 0, desired_size, flags.protection, flags.flags, object_handle, 0 ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start != MAP_FAILED )
- ? view_start + desired_size
- : view_start
- );
-
-#endif // OS API
-}
-
-
-template <> BOOST_IMPL_INLINE
-void detail::mapped_view_base<unsigned char const>::unmap( detail::mapped_view_base<unsigned char const> const & mapped_range )
-{
-#ifdef _WIN32
- BOOST_VERIFY( ::UnmapViewOfFile( mapped_range.begin() ) || mapped_range.empty() );
-#else
- BOOST_VERIFY( ( ::munmap ( const_cast<unsigned char *>( mapped_range.begin() ), mapped_range.size() ) == 0 ) || mapped_range.empty() );
-#endif // _WIN32
-}
-
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference const object_handle,
- std::size_t const desired_size,
- std::size_t const offset,
- bool const map_for_code_execution
-)
-{
- return mapped_view_reference<unsigned char>::map
- (
- object_handle,
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | ( map_for_code_execution ? mapping_flags::handle_access_rights::execute : 0 ),
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- offset
- );
-}
-
-
-BOOST_IMPL_INLINE
-basic_mapped_view_ref map_file( char const * const file_name, std::size_t desired_size )
-{
- typedef native_file_flags file_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- file_flags::create
- (
- file_flags::handle_access_rights::read | file_flags::handle_access_rights::write,
- file_flags::share_mode ::read,
- file_flags::open_policy::open_or_create,
- file_flags::system_hints ::sequential_access,
- file_flags::on_construction_rights::read | file_flags::on_construction_rights::write
- )
- )
- );
-
- if ( desired_size )
- set_size( file_handle.get(), desired_size );
- else
- desired_size = get_size( file_handle.get() );
-
- return basic_mapped_view_ref::map
- (
- file_handle.get(),
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- 0
- );
-}
-
-
-BOOST_IMPL_INLINE
-basic_mapped_read_only_view_ref map_read_only_file( char const * const file_name )
-{
- typedef native_file_flags file_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- file_flags::create_for_opening_existing_files
- (
- file_flags::handle_access_rights::read,
- file_flags::share_mode ::read | file_flags::share_mode::write,
- false,
- file_flags::system_hints ::sequential_access
- )
- )
- );
-
- return basic_mapped_read_only_view_ref::map
- (
- file_handle.get(),
- // Implementation note:
- // Windows APIs interpret zero as 'whole file' but we still need to
- // query the file size in order to be able to properly set the end
- // pointer.
- // (13.07.2011.) (Domagoj Saric)
- get_size( file_handle.get() )
- );
-}
-
-
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------

Modified: sandbox/mmap/boost/mmap/mapped_view.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mapped_view.hpp (original)
+++ sandbox/mmap/boost/mmap/mapped_view.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -18,26 +18,11 @@
 #pragma once
 //------------------------------------------------------------------------------
 #include "handles/handle.hpp"
-//...zzz...
-#include "mappble_objects/file/file.hpp"
-#include "mappble_objects/file/posix/file.hpp"
-#ifdef _WIN32
-#include "mappble_objects/file/win32/file.hpp"
-#endif // _WIN32
+#include "detail/impl_selection.hpp"
 
 #include "boost/assert.hpp"
 #include "boost/noncopyable.hpp"
-#include "boost/range/iterator_range.hpp"
-
-#ifndef _WIN32
- #include "fcntl.h"
-#endif // _WIN32
-
-#ifdef _WIN32
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) win32
-#else
- #define BOOST_AUX_IO_WIN32_OR_POSIX( win32, posix ) posix
-#endif
+#include "boost/range/iterator_range_core.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -46,58 +31,10 @@
 {
 //------------------------------------------------------------------------------
 
-// Implementation note:
-// Using structs with public members and factory functions to enable (almost)
-// zero-overhead 'link-time' conversion to native flag formats and to allow the
-// user to modify the created flags or create fully custom ones so that specific
-// platform-dependent use-cases, not otherwise covered through the generic
-// interface, can also be covered.
-// (10.10.2010.) (Domagoj Saric)
-
-struct mapping_flags
-{
- struct handle_access_rights
- {
- static unsigned int const read ;
- static unsigned int const write ;
- static unsigned int const execute;
- };
-
- struct share_mode
- {
- static unsigned int const shared;
- static unsigned int const hidden;
- };
-
- struct system_hint
- {
- static unsigned int const lock_to_ram ;
- static unsigned int const reserve_page_file_space;
- static unsigned int const precommit ;
- static unsigned int const uninitialized ;
- };
-
- static mapping_flags create
- (
- unsigned int handle_access_rights,
- unsigned int share_mode ,
- unsigned int system_hints
- );
-
-#ifdef _WIN32
- unsigned int create_mapping_flags;
- unsigned int map_view_flags;
-#else
- int protection;
- int flags ;
-#endif // _WIN32
-};
-
-
 typedef iterator_range<unsigned char *> basic_memory_range_t;
 typedef iterator_range<unsigned char const *> basic_read_only_memory_range_t;
 
-template <typename Element>
+template <typename Element, typename Impl = BOOST_MMAP_IMPL()>
 class mapped_view_reference;
 
 typedef mapped_view_reference<unsigned char > basic_mapped_view_ref;
@@ -105,7 +42,7 @@
 
 namespace detail
 {
- template <typename Element>
+ template <typename Element, typename Impl>
     class mapped_view_base : public iterator_range<Element *>
     {
     public:
@@ -118,17 +55,17 @@
         mapped_view_base( iterator_range<Element *> const & mapped_range ) : iterator_range<Element *>( mapped_range ) {}
         mapped_view_base( Element * const p_begin, Element * const p_end ) : iterator_range<Element *>( p_begin, p_end ) {}
 
- static mapped_view_reference<unsigned char const>
+ static mapped_view_reference<unsigned char const, Impl>
         #ifdef BOOST_MSVC
             const &
         #endif
- make_basic_view( mapped_view_base<Element> const & );
+ make_basic_view( mapped_view_base<Element, Impl> const & );
 
- static mapped_view_reference<Element>
+ static mapped_view_reference<Element, Impl>
         #ifdef BOOST_MSVC
             const &
         #endif
- make_typed_range( mapped_view_base<unsigned char> const & );
+ make_typed_range( mapped_view_base<unsigned char, Impl> const & );
 
     private: // Hide mutable members
         void advance_begin();
@@ -139,18 +76,17 @@
     };
 
 
- template <typename Element>
- void mapped_view_base<Element>::unmap( mapped_view_base<Element> const & mapped_range )
+ template <typename Element, typename Impl>
+ void mapped_view_base<Element, Impl>::unmap( mapped_view_base<Element, Impl> const & mapped_range )
     {
- mapped_view_base<unsigned char const>::unmap( make_basic_view( mapped_range ) );
+ mapped_view_base<unsigned char const, Impl>::unmap( make_basic_view( mapped_range ) );
     }
-
- template <>
- void mapped_view_base<unsigned char const>::unmap( mapped_view_base<unsigned char const> const & );
 } // namespace detail
 
-template <typename Element>
-class mapped_view_reference : public detail::mapped_view_base<Element>
+template <typename Impl> struct mapping;
+
+template <typename Element, typename Impl>
+class mapped_view_reference : public detail::mapped_view_base<Element, Impl>
 {
 public:
     basic_memory_range_t basic_range() const
@@ -165,48 +101,29 @@
 public: // Factory methods.
     static mapped_view_reference map
     (
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size = 0,
- std::size_t offset = 0
+ mapping<Impl> const & source_mapping,
+ boost::uint64_t offset = 0,
+ std ::size_t desired_size = 0
     );
 
 private:
- template <typename T> friend class detail::mapped_view_base;
+ template <typename T, typename Impl> friend class detail::mapped_view_base;
 
- mapped_view_reference( iterator_range<Element *> const & mapped_range ) : detail::mapped_view_base<Element>( mapped_range ) {}
- mapped_view_reference( Element * const p_begin, Element * const p_end ) : detail::mapped_view_base<Element>( p_begin, p_end ) {}
+ mapped_view_reference( iterator_range<Element *> const & mapped_range ) : detail::mapped_view_base<Element, Impl>( mapped_range ) {}
+ mapped_view_reference( Element * const p_begin, Element * const p_end ) : detail::mapped_view_base<Element, Impl>( p_begin, p_end ) {}
 };
 
-template <typename Element>
-class mapped_view_reference<Element const> : public detail::mapped_view_base<Element const>
-{
-public:
- basic_memory_range_t basic_range() const
- {
- return basic_memory_range_t
- (
- static_cast<unsigned char const *>( static_cast<void const *>( this->begin() ) ),
- static_cast<unsigned char const *>( static_cast<void const *>( this->end () ) )
- );
- }
-
-public: // Factory methods.
- static mapped_view_reference map
- (
- native_handle::reference object_handle,
- std::size_t desired_size = 0,
- std::size_t offset = 0,
- bool map_for_code_execution = false
- );
-
-private:
- template <typename T> friend class detail::mapped_view_base;
 
- mapped_view_reference( iterator_range<Element const *> const & mapped_range ) : detail::mapped_view_base<Element const>( mapped_range ) {}
- mapped_view_reference( Element const * const p_begin, Element const * const p_end ) : detail::mapped_view_base<Element const>( p_begin, p_end ) {}
- mapped_view_reference( mapped_view_reference<Element> const & mutable_view ) : detail::mapped_view_base<Element const>( mutable_view ) {}
-};
+//...zzz...
+//template <typename Element, typename Impl>
+//basic_read_only_memory_range_t mapped_view_reference<Element const, Impl>::basic_range() const
+//{
+// return basic_read_only_memory_range_t
+// (
+// static_cast<unsigned char const *>( static_cast<void const *>( this->begin() ) ),
+// static_cast<unsigned char const *>( static_cast<void const *>( this->end () ) )
+// );
+//}
 
 
 namespace detail
@@ -216,18 +133,18 @@
     // compilers (e.g. GCC and Clang).
     // (14.07.2011.) (Domagoj Saric)
 
- template <typename Element>
- mapped_view_reference<unsigned char const>
+ template <typename Element, typename Impl>
+ mapped_view_reference<unsigned char const, Impl>
     #ifdef BOOST_MSVC
         const &
     #endif
- mapped_view_base<Element>::make_basic_view( mapped_view_base<Element> const & range )
+ mapped_view_base<Element, Impl>::make_basic_view( mapped_view_base<Element, Impl> const & range )
     {
         return
         #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<unsigned char const> const &>( range );
+ reinterpret_cast<mapped_view_reference<unsigned char const, Impl> const &>( range );
         #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
+ mapped_view_reference<unsigned char const, Impl>
             (
                 static_cast<unsigned char const *>( static_cast<void const *>( range.begin() ) ),
                 static_cast<unsigned char const *>( static_cast<void const *>( range.end () ) )
@@ -236,21 +153,21 @@
     }
 
 
- template <typename Element>
- mapped_view_reference<Element>
+ template <typename Element, typename Impl>
+ mapped_view_reference<Element, Impl>
     #ifdef BOOST_MSVC
         const &
     #endif
- mapped_view_base<Element>::make_typed_range( mapped_view_base<unsigned char> const & range )
+ mapped_view_base<Element, Impl>::make_typed_range( mapped_view_base<unsigned char, Impl> const & range )
     {
         BOOST_ASSERT( reinterpret_cast<std::size_t>( range.begin() ) % sizeof( Element ) == 0 );
         BOOST_ASSERT( reinterpret_cast<std::size_t>( range.end () ) % sizeof( Element ) == 0 );
         BOOST_ASSERT( range.size () % sizeof( Element ) == 0 );
         return
         #ifdef BOOST_MSVC
- reinterpret_cast<mapped_view_reference<Element> const &>( range );
+ reinterpret_cast<mapped_view_reference<Element, Impl> const &>( range );
         #else // compiler might care about strict aliasing rules
- mapped_view_reference<unsigned char const>
+ mapped_view_reference<Element, Impl>
             (
                 static_cast<Element *>( static_cast<void *>( range.begin() ) ),
                 static_cast<Element *>( static_cast<void *>( range.end () ) )
@@ -273,37 +190,39 @@
 template <> struct is_mappable<handle<win32>::native_handle_t > : mpl::true_ {};
 #endif // _WIN32
 
-
-template <>
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
+template <typename Element, typename Impl>
+mapped_view_reference<Element, Impl> mapped_view_reference<Element, Impl>::map
 (
- native_handle::reference,
- mapping_flags const &,
- std::size_t desired_size,
- std::size_t offset
-);
+ mapping<Impl> const & source_mapping,
+ boost::uint64_t offset = 0,
+ std ::size_t desired_size = 0
+)
+{
+ BOOST_ASSERT_MSG( !boost::is_const<Element>::value || source_mapping.is_read_only(), "Use const element mapped view for read only mappings." );
+ return mapped_view_reference<unsigned char, Impl>::map( source_mapping, offset, desired_size );
+}
 
-template <>
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference object_handle,
- std::size_t desired_size,
- std::size_t offset,
- bool map_for_code_execution
-);
+//...zzz...
+//template <unsigned char, typename Impl>
+//static mapped_view_reference<unsigned char, Impl> mapped_view_reference<unsigned char, Impl>::map
+//(
+// mapping<Impl> const & source_mapping,
+// boost::uint64_t offset = 0,
+// std ::size_t desired_size = 0
+//);
 
 
-template <typename Element>
+template <typename Element, typename Impl = BOOST_MMAP_IMPL()>
 class mapped_view
     :
- public mapped_view_reference<Element>
+ public mapped_view_reference<Element, Impl>
     #ifdef BOOST_MSVC
         ,private noncopyable
     #endif // BOOST_MSVC
 {
 public:
- mapped_view( mapped_view_reference<Element> const range ) : mapped_view_reference<Element>( range ) {}
- ~mapped_view<Element>() { mapped_view_reference<Element>::unmap( *this ); }
+ mapped_view( mapped_view_reference<Element, Impl> const range ) : mapped_view_reference<Element, Impl>( range ) {}
+ ~mapped_view() { mapped_view_reference<Element, Impl>::unmap( *this ); }
 
     #ifndef BOOST_MSVC
         mapped_view( mapped_view const & ); // noncopyable

Modified: sandbox/mmap/boost/mmap/mapped_view.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mapped_view.inl (original)
+++ sandbox/mmap/boost/mmap/mapped_view.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -17,35 +17,9 @@
 
 #include "detail/impl_inline.hpp"
 #include "implementations.hpp"
-#include "mappble_objects/file/handle.hpp"
+#include "mappble_objects/file/file.hpp"
 
 #include "boost/assert.hpp"
-
-#ifdef _WIN32
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif // WIN32_LEAN_AND_MEAN
- #include "windows.h"
-
- #pragma warning ( disable : 4996 ) // "The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name."
- #include "io.h"
-#else
- #include "sys/mman.h" // mmap, munmap.
- #include "sys/stat.h"
- #include "sys/types.h" // struct stat.
- #include "unistd.h" // sysconf.
-#endif // _WIN32
-#include "errno.h"
-#include "fcntl.h"
-
-#ifndef _WIN32
- #ifdef __APPLE__
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) osx
- #else
- #define BOOST_AUX_MMAP_POSIX_OR_OSX( posix, osx ) posix
- #endif
-#endif
-
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -54,167 +28,21 @@
 {
 //------------------------------------------------------------------------------
 
-unsigned int const mapping_flags::handle_access_rights::read = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_READ , PROT_READ );
-unsigned int const mapping_flags::handle_access_rights::write = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_WRITE , PROT_WRITE );
-unsigned int const mapping_flags::handle_access_rights::execute = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_EXECUTE, PROT_EXEC );
-
-unsigned int const mapping_flags::share_mode::shared = BOOST_AUX_IO_WIN32_OR_POSIX( 0, MAP_SHARED );
-unsigned int const mapping_flags::share_mode::hidden = BOOST_AUX_IO_WIN32_OR_POSIX( FILE_MAP_COPY, MAP_PRIVATE );
-
-unsigned int const mapping_flags::system_hint::lock_to_ram = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_LOCKED, 0 ) );
-unsigned int const mapping_flags::system_hint::reserve_page_file_space = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_RESERVE, /*khm#1*/MAP_NORESERVE );
-unsigned int const mapping_flags::system_hint::precommit = BOOST_AUX_IO_WIN32_OR_POSIX( SEC_COMMIT , BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_POPULATE, 0 ) );
-unsigned int const mapping_flags::system_hint::uninitialized = BOOST_AUX_IO_WIN32_OR_POSIX( 0, BOOST_AUX_MMAP_POSIX_OR_OSX( MAP_UNINITIALIZED, 0 ) );
-
-
-BOOST_IMPL_INLINE
-mapping_flags mapping_flags::create
-(
- unsigned int const handle_access_flags,
- unsigned int const share_mode ,
- unsigned int const system_hints
-)
-{
- mapping_flags flags;
-
-#ifdef _WIN32
- flags.create_mapping_flags = ( handle_access_flags & handle_access_rights::execute ) ? PAGE_EXECUTE : PAGE_NOACCESS;
- if ( share_mode == share_mode::hidden ) // WRITECOPY
- flags.create_mapping_flags *= 8;
- else
- if ( handle_access_flags & handle_access_rights::write )
- flags.create_mapping_flags *= 4;
- else
- {
- BOOST_ASSERT( handle_access_flags & handle_access_rights::read );
- flags.create_mapping_flags *= 2;
- }
-
- flags.create_mapping_flags |= system_hints;
-
- flags.map_view_flags = handle_access_flags;
-#else
- flags.protection = handle_access_flags;
- flags.flags = share_mode | system_hints;
- if ( ( system_hints & system_hint::reserve_page_file_space ) ) /*khm#1*/
- flags.flags &= ~MAP_NORESERVE;
- else
- flags.flags |= MAP_NORESERVE;
-#endif // _WIN32
-
- return flags;
-}
-
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char> mapped_view_reference<unsigned char>::map
-(
- native_handle::reference const object_handle,
- mapping_flags const & flags,
- std::size_t const desired_size,
- std::size_t const offset
-)
-{
- typedef mapped_view_reference<unsigned char>::iterator iterator_t;
-
-#ifdef _WIN32
-
- // Implementation note:
- // Mapped views hold internal references to the following handles so we do
- // not need to hold/store them ourselves:
- // http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
- // (26.03.2010.) (Domagoj Saric)
-
- ULARGE_INTEGER large_integer;
-
- // CreateFileMapping accepts INVALID_HANDLE_VALUE as valid input but only if
- // the size parameter is not null.
- large_integer.QuadPart = desired_size;
- handle<win32> const mapping
- (
- ::CreateFileMappingW( object_handle, 0, flags.create_mapping_flags, large_integer.HighPart, large_integer.LowPart, 0 )
- );
- BOOST_ASSERT
- (
- !mapping || ( object_handle == INVALID_HANDLE_VALUE ) || ( desired_size != 0 )
- );
-
- large_integer.QuadPart = offset;
- iterator_t const view_start( static_cast<iterator_t>( ::MapViewOfFile( mapping.get(), flags.map_view_flags, large_integer.HighPart, large_integer.LowPart, desired_size ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start && ( object_handle != INVALID_HANDLE_VALUE ) )
- ? view_start + desired_size
- : view_start
- );
-
-#else // POSIX
-
- iterator_t const view_start( static_cast<iterator_t>( ::mmap( 0, desired_size, flags.protection, flags.flags, object_handle, 0 ) ) );
- return mapped_view_reference<unsigned char>
- (
- view_start,
- ( view_start != MAP_FAILED )
- ? view_start + desired_size
- : view_start
- );
-
-#endif // OS API
-}
-
-
-template <> BOOST_IMPL_INLINE
-void detail::mapped_view_base<unsigned char const>::unmap( detail::mapped_view_base<unsigned char const> const & mapped_range )
-{
-#ifdef _WIN32
- BOOST_VERIFY( ::UnmapViewOfFile( mapped_range.begin() ) || mapped_range.empty() );
-#else
- BOOST_VERIFY( ( ::munmap ( const_cast<unsigned char *>( mapped_range.begin() ), mapped_range.size() ) == 0 ) || mapped_range.empty() );
-#endif // _WIN32
-}
-
-
-template <> BOOST_IMPL_INLINE
-mapped_view_reference<unsigned char const> mapped_view_reference<unsigned char const>::map
-(
- native_handle::reference const object_handle,
- std::size_t const desired_size,
- std::size_t const offset,
- bool const map_for_code_execution
-)
-{
- return mapped_view_reference<unsigned char>::map
- (
- object_handle,
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read | ( map_for_code_execution ? mapping_flags::handle_access_rights::execute : 0 ),
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
- ),
- desired_size,
- offset
- );
-}
-
-
 BOOST_IMPL_INLINE
 basic_mapped_view_ref map_file( char const * const file_name, std::size_t desired_size )
 {
- typedef native_file_flags file_flags;
+ typedef file_open_flags<BOOST_MMAP_IMPL()> open_flags;
     file_handle<BOOST_MMAP_IMPL()> const file_handle
     (
         create_file
         (
             file_name,
- file_flags::create
+ open_flags::create
             (
- file_flags::handle_access_rights::read | file_flags::handle_access_rights::write,
- file_flags::share_mode ::read,
- file_flags::open_policy::open_or_create,
- file_flags::system_hints ::sequential_access,
- file_flags::on_construction_rights::read | file_flags::on_construction_rights::write
+ open_flags::handle_access_rights ::read | open_flags::handle_access_rights::write,
+ open_flags::open_policy ::open_or_create,
+ open_flags::system_hints ::sequential_access,
+ open_flags::on_construction_rights::read | open_flags::on_construction_rights::write
             )
         )
     );
@@ -224,14 +52,17 @@
     else
         desired_size = get_size( file_handle.get() );
 
+ typedef file_mapping_flags<BOOST_MMAP_IMPL()> mapping_flags;
     return basic_mapped_view_ref::map
     (
- file_handle.get(),
- mapping_flags::create
+ create_mapping
         (
- mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
- mapping_flags::share_mode::shared,
- mapping_flags::system_hint::uninitialized
+ file_handle,
+ mapping_flags::create
+ (
+ mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
+ mapping_flags::share_mode ::shared
+ )
         ),
         desired_size,
         0
@@ -242,31 +73,35 @@
 BOOST_IMPL_INLINE
 basic_mapped_read_only_view_ref map_read_only_file( char const * const file_name )
 {
- typedef native_file_flags file_flags;
+ typedef file_open_flags<BOOST_MMAP_IMPL()> open_flags;
     file_handle<BOOST_MMAP_IMPL()> const file_handle
     (
         create_file
         (
             file_name,
- file_flags::create_for_opening_existing_files
+ open_flags::create_for_opening_existing_files
             (
- file_flags::handle_access_rights::read,
- file_flags::share_mode ::read | file_flags::share_mode::write,
+ open_flags::handle_access_rights::read,
                 false,
- file_flags::system_hints ::sequential_access
+ open_flags::system_hints ::sequential_access
             )
         )
     );
 
+ typedef file_mapping_flags<BOOST_MMAP_IMPL()> mapping_flags;
     return basic_mapped_read_only_view_ref::map
     (
- file_handle.get(),
- // Implementation note:
- // Windows APIs interpret zero as 'whole file' but we still need to
- // query the file size in order to be able to properly set the end
- // pointer.
- // (13.07.2011.) (Domagoj Saric)
- get_size( file_handle.get() )
+ create_mapping
+ (
+ file_handle,
+ mapping_flags::create
+ (
+ mapping_flags::handle_access_rights::read,
+ mapping_flags::share_mode ::shared
+ )
+ ),
+ get_size( file_handle.get() ),
+ 0
     );
 }
 

Copied: sandbox/mmap/boost/mmap/mapping/mapping.hpp (from r74074, /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp (original)
+++ sandbox/mmap/boost/mmap/mapping/mapping.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapping_handle.hpp
-/// ------------------------
+/// \file mapping.hpp
+/// -----------------
 ///
 /// Copyright (c) 2011 Domagoj Saric
 ///
@@ -13,11 +13,13 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
-#define mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
+#ifndef mapping_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
+#define mapping_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
 #pragma once
 //------------------------------------------------------------------------------
-#include "handle.hpp"
+#include "../detail/impl_selection.hpp"
+
+#include BOOST_MMAP_IMPL_INCLUDE( BOOST_PP_EMPTY, BOOST_PP_IDENTITY( /mapping.hpp ) )
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -26,19 +28,12 @@
 {
 //------------------------------------------------------------------------------
 
-template <typename Impl> class handle;
-
 template <typename Impl>
-class mapping_handle : handle<Impl>
-{
-public:
- mapping_handle( typename handle<Impl>::handle_t const native_handle )
- : handle<Impl>( native_handle ) {}
-};
+struct mapping;
 
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // handle_hpp
+#endif // mapping_hpp

Copied: sandbox/mmap/boost/mmap/mapping/posix/mapping.hpp (from r74074, /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp (original)
+++ sandbox/mmap/boost/mmap/mapping/posix/mapping.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapping_handle.hpp
-/// ------------------------
+/// \file mapping.hpp
+/// -----------------
 ///
 /// Copyright (c) 2011 Domagoj Saric
 ///
@@ -13,11 +13,14 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
-#define mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
+#ifndef mapping_hpp__99837E03_86B1_42F5_A57D_69A6E828DD08
+#define mapping_hpp__99837E03_86B1_42F5_A57D_69A6E828DD08
 #pragma once
 //------------------------------------------------------------------------------
-#include "handle.hpp"
+#include "../../handles/posix/handle.hpp"
+#include "../../mappble_objects/file/posix/mapping_flags.hpp"
+
+#include "boost/config/suffix.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -26,14 +29,24 @@
 {
 //------------------------------------------------------------------------------
 
-template <typename Impl> class handle;
+template <typename Impl> struct mapping;
 
-template <typename Impl>
-class mapping_handle : handle<Impl>
+template <>
+struct mapping<posix>
+ :
+ handle<posix>::reference
 {
-public:
- mapping_handle( typename handle<Impl>::handle_t const native_handle )
- : handle<Impl>( native_handle ) {}
+ typedef handle<posix>::handle_t native_handle_t;
+ typedef mapping const & reference;
+
+ BOOST_STATIC_CONSTANT( bool, owns_parent_handle = false );
+
+ mapping( native_handle_t const native_handle, file_mapping_flags<posix> const & view_mapping_flags_param )
+ : handle<posix>::reference( native_handle ), view_mapping_flags( view_mapping_flags_param ) {}
+
+ bool is_read_only() const { return ( view_mapping_flags.protection & file_mapping_flags<posix>::handle_access_rights::write ) == 0; }
+
+ file_mapping_flags<posix> const view_mapping_flags;
 };
 
 //------------------------------------------------------------------------------
@@ -41,4 +54,9 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // handle_hpp
+
+#ifdef BOOST_MMAP_HEADER_ONLY
+ #include "mapping.inl"
+#endif // BOOST_MMAP_HEADER_ONLY
+
+#endif // mapping_hpp

Copied: sandbox/mmap/boost/mmap/mapping/posix/mapping.inl (from r74074, /sandbox/mmap/boost/mmap/handles/win32/handle.inl)
==============================================================================
--- /sandbox/mmap/boost/mmap/handles/win32/handle.inl (original)
+++ sandbox/mmap/boost/mmap/mapping/posix/mapping.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file handle.inl
-/// ----------------
+/// \file mapping.inl
+/// -----------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,20 +13,9 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#include "handle.hpp"
+#include "mapping.hpp"
 
-#include "../../detail/impl_inline.hpp"
-
-#include "boost/assert.hpp"
-
-#ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
-#endif // WIN32_LEAN_AND_MEAN
-#include "windows.h"
-
-#ifdef BOOST_MSVC
- #include "io.h"
-#endif // BOOST_MSVC
+#include "../../detail/posix.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -35,37 +24,48 @@
 {
 //------------------------------------------------------------------------------
 
-BOOST_IMPL_INLINE
-handle<win32>::handle( native_handle_t const handle )
- :
- handle_( handle )
-{}
-
-BOOST_IMPL_INLINE
-handle<win32>::~handle()
+template <> BOOST_IMPL_INLINE
+mapped_view_reference<unsigned char, posix> mapped_view_reference<unsigned char, posix>::map
+(
+ mapping<posix> const & source_mapping,
+ boost::uint64_t const offset ,
+ std ::size_t const desired_size
+)
 {
- BOOST_VERIFY
+ iterator const view_start
+ (
+ static_cast<iterator>
+ (
+ ::mmap
+ (
+ 0,
+ desired_size,
+ source_mapping.view_mapping_flags.protection,
+ source_mapping.view_mapping_flags.flags,
+ source_mapping,
+ 0
+ )
+ )
+ );
+
+ return mapped_view_reference<unsigned char>
     (
- ( ::CloseHandle( handle_ ) != false ) ||
- ( handle_ == 0 || handle_ == INVALID_HANDLE_VALUE )
+ view_start,
+ ( view_start != MAP_FAILED )
+ ? view_start + desired_size
+ : view_start
     );
 }
 
 
-#ifdef BOOST_MSVC
- BOOST_IMPL_INLINE
- handle<posix> make_posix_handle( handle<win32>::native_handle_t const native_handle, int const flags )
- {
- return handle<posix>( ::_open_osfhandle( reinterpret_cast<intptr_t>( native_handle ), flags ) );
- }
-#endif // BOOST_MSVC
+template <> BOOST_IMPL_INLINE
+void detail::mapped_view_base<unsigned char const, posix>::unmap( detail::mapped_view_base<unsigned char const, posix> const & mapped_range )
+{
+ BOOST_VERIFY( ( ::munmap( const_cast<unsigned char *>( mapped_range.begin() ), mapped_range.size() ) == 0 ) || mapped_range.empty() );
+}
 
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------
 } // boost
 //------------------------------------------------------------------------------
-
-#ifndef BOOST_MMAP_HEADER_ONLY
- #include "../posix/handle.inl"
-#endif // BOOST_MMAP_HEADER_ONLY

Copied: sandbox/mmap/boost/mmap/mapping/win32/mapping.hpp (from r74074, /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp)
==============================================================================
--- /sandbox/mmap/boost/mmap/handles/mapping_handle.hpp (original)
+++ sandbox/mmap/boost/mmap/mapping/win32/mapping.hpp 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file mapping_handle.hpp
-/// ------------------------
+/// \file mapping.hpp
+/// -----------------
 ///
 /// Copyright (c) 2011 Domagoj Saric
 ///
@@ -13,11 +13,14 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#ifndef mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
-#define mapping_handle_hpp__D42BC724_FD9A_4C7B_B521_CF3C29C948B3
+#ifndef mapping_hpp__8B2CEDFB_C87C_4AA4_B9D0_8EF0A42825F2
+#define mapping_hpp__8B2CEDFB_C87C_4AA4_B9D0_8EF0A42825F2
 #pragma once
 //------------------------------------------------------------------------------
-#include "handle.hpp"
+#include "../../handles/win32/handle.hpp"
+#include "../../mappble_objects/file/win32/mapping_flags.hpp"
+
+#include "boost/config/suffix.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -26,14 +29,24 @@
 {
 //------------------------------------------------------------------------------
 
-template <typename Impl> class handle;
+template <typename Impl> struct mapping;
 
-template <typename Impl>
-class mapping_handle : handle<Impl>
+template <>
+struct mapping<win32>
+ :
+ handle<win32>
 {
-public:
- mapping_handle( typename handle<Impl>::handle_t const native_handle )
- : handle<Impl>( native_handle ) {}
+ typedef handle<win32>::native_handle_t native_handle_t;
+ typedef mapping const & reference;
+
+ BOOST_STATIC_CONSTANT( bool, owns_parent_handle = true );
+
+ mapping( native_handle_t const native_handle, unsigned int const view_mapping_flags_param )
+ : handle<win32>( native_handle ), view_mapping_flags( view_mapping_flags_param ) {}
+
+ bool is_read_only() const { return ( view_mapping_flags & file_mapping_flags<win32>::handle_access_rights::write ) == 0; }
+
+ unsigned int const view_mapping_flags;
 };
 
 //------------------------------------------------------------------------------
@@ -41,4 +54,9 @@
 //------------------------------------------------------------------------------
 } // namespace boost
 //------------------------------------------------------------------------------
-#endif // handle_hpp
+
+#ifdef BOOST_MMAP_HEADER_ONLY
+ #include "mapping.inl"
+#endif // BOOST_MMAP_HEADER_ONLY
+
+#endif // mapping_hpp

Copied: sandbox/mmap/boost/mmap/mapping/win32/mapping.inl (from r74074, /sandbox/mmap/boost/mmap/handles/win32/handle.inl)
==============================================================================
--- /sandbox/mmap/boost/mmap/handles/win32/handle.inl (original)
+++ sandbox/mmap/boost/mmap/mapping/win32/mapping.inl 2011-08-28 20:17:54 EDT (Sun, 28 Aug 2011)
@@ -1,7 +1,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \file handle.inl
-/// ----------------
+/// \file mapping.inl
+/// -----------------
 ///
 /// Copyright (c) Domagoj Saric 2010.-2011.
 ///
@@ -13,20 +13,9 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 //------------------------------------------------------------------------------
-#include "handle.hpp"
+#include "mapping.hpp"
 
-#include "../../detail/impl_inline.hpp"
-
-#include "boost/assert.hpp"
-
-#ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
-#endif // WIN32_LEAN_AND_MEAN
-#include "windows.h"
-
-#ifdef BOOST_MSVC
- #include "io.h"
-#endif // BOOST_MSVC
+#include "../../detail/windows.hpp"
 //------------------------------------------------------------------------------
 namespace boost
 {
@@ -35,37 +24,59 @@
 {
 //------------------------------------------------------------------------------
 
+template <>
 BOOST_IMPL_INLINE
-handle<win32>::handle( native_handle_t const handle )
- :
- handle_( handle )
-{}
-
-BOOST_IMPL_INLINE
-handle<win32>::~handle()
+mapped_view_reference<unsigned char, win32> mapped_view_reference<unsigned char, win32>::map
+(
+ mapping<win32> const & source_mapping,
+ boost::uint64_t const offset ,
+ std ::size_t const desired_size
+)
 {
- BOOST_VERIFY
+ // Implementation note:
+ // Mapped views hold internal references to the following handles so we do
+ // not need to hold/store them ourselves:
+ // http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
+ // (26.03.2010.) (Domagoj Saric)
+
+ typedef mapped_view_reference<unsigned char, win32>::iterator iterator_t;
+
+ ULARGE_INTEGER large_integer;
+ large_integer.QuadPart = offset;
+
+ iterator_t const view_start
+ (
+ static_cast<iterator_t>
+ (
+ ::MapViewOfFile
+ (
+ source_mapping.get(),
+ source_mapping.view_mapping_flags,
+ large_integer.HighPart,
+ large_integer.LowPart,
+ desired_size
+ )
+ )
+ );
+
+ return mapped_view_reference<unsigned char>
     (
- ( ::CloseHandle( handle_ ) != false ) ||
- ( handle_ == 0 || handle_ == INVALID_HANDLE_VALUE )
+ view_start,
+ view_start
+ ? view_start + desired_size
+ : view_start
     );
 }
 
 
-#ifdef BOOST_MSVC
- BOOST_IMPL_INLINE
- handle<posix> make_posix_handle( handle<win32>::native_handle_t const native_handle, int const flags )
- {
- return handle<posix>( ::_open_osfhandle( reinterpret_cast<intptr_t>( native_handle ), flags ) );
- }
-#endif // BOOST_MSVC
+template <> BOOST_IMPL_INLINE
+void detail::mapped_view_base<unsigned char const, win32>::unmap( detail::mapped_view_base<unsigned char const, win32> const & mapped_range )
+{
+ BOOST_VERIFY( ::UnmapViewOfFile( mapped_range.begin() ) || mapped_range.empty() );
+}
 
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------
 } // boost
 //------------------------------------------------------------------------------
-
-#ifndef BOOST_MMAP_HEADER_ONLY
- #include "../posix/handle.inl"
-#endif // BOOST_MMAP_HEADER_ONLY


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