|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83142 - in trunk: boost/interprocess boost/interprocess/detail libs/interprocess/doc
From: igaztanaga_at_[hidden]
Date: 2013-02-24 17:38:07
Author: igaztanaga
Date: 2013-02-24 17:38:07 EST (Sun, 24 Feb 2013)
New Revision: 83142
URL: http://svn.boost.org/trac/boost/changeset/83142
Log:
Fixes #8030
Text files modified:
trunk/boost/interprocess/detail/os_file_functions.hpp | 6 +++++
trunk/boost/interprocess/mapped_region.hpp | 46 ++++++++++++++++++++++++++++-----------
trunk/libs/interprocess/doc/interprocess.qbk | 1
3 files changed, 40 insertions(+), 13 deletions(-)
Modified: trunk/boost/interprocess/detail/os_file_functions.hpp
==============================================================================
--- trunk/boost/interprocess/detail/os_file_functions.hpp (original)
+++ trunk/boost/interprocess/detail/os_file_functions.hpp 2013-02-24 17:38:07 EST (Sun, 24 Feb 2013)
@@ -67,6 +67,9 @@
, file_current = winapi::file_current
} file_pos_t;
+typedef unsigned long map_options_t;
+static const map_options_t default_map_options = map_options_t(-1);
+
namespace ipcdetail{
inline mapping_handle_t mapping_handle_from_file_handle(file_handle_t hnd)
@@ -376,6 +379,9 @@
, file_current = SEEK_CUR
} file_pos_t;
+typedef int map_options_t;
+static const map_options_t default_map_options = map_options_t(-1);
+
namespace ipcdetail{
inline mapping_handle_t mapping_handle_from_file_handle(file_handle_t hnd)
Modified: trunk/boost/interprocess/mapped_region.hpp
==============================================================================
--- trunk/boost/interprocess/mapped_region.hpp (original)
+++ trunk/boost/interprocess/mapped_region.hpp 2013-02-24 17:38:07 EST (Sun, 24 Feb 2013)
@@ -95,6 +95,22 @@
//!If an address is specified, both the offset and the address must be
//!multiples of the page size.
//!
+ //!The map is created using "default_map_options". This flag is OS
+ //!dependant and it should not be changed unless the user needs to
+ //!specify special options.
+ //!
+ //!In Windows systems "map_options" is a DWORD value passed as
+ //!"dwDesiredAccess" to "MapViewOfFileEx". If "default_map_options" is passed
+ //!it's initialized to zero. "map_options" is XORed with FILE_MAP_[COPY|READ|WRITE].
+ //!
+ //!In UNIX systems and POSIX mappings "map_options" is an int value passed as "flags"
+ //!to "mmap". If "default_map_options" is specified it's initialized to MAP_NOSYNC
+ //!if that option exists and to zero otherwise. "map_options" XORed with MAP_PRIVATE or MAP_SHARED.
+ //!
+ //!In UNIX systems and XSI mappings "map_options" is an int value passed as "shmflg"
+ //!to "shmat". If "default_map_options" is specified it's initialized to zero.
+ //!"map_options" is XORed with SHM_RDONLY if needed.
+ //!
//!The OS could allocate more pages than size/page_size(), but get_address()
//!will always return the address passed in this function (if not null) and
//!get_size() will return the specified size.
@@ -103,7 +119,8 @@
,mode_t mode
,offset_t offset = 0
,std::size_t size = 0
- ,const void *address = 0);
+ ,const void *address = 0
+ ,map_options_t map_options = default_map_options);
//!Default constructor. Address will be 0 (nullptr).
//!Size will be 0.
@@ -366,7 +383,8 @@
,mode_t mode
,offset_t offset
,std::size_t size
- ,const void *address)
+ ,const void *address
+ ,map_options_t map_options)
: m_base(0), m_size(0), m_page_offset(0), m_mode(mode)
, m_file_or_mapping_hnd(ipcdetail::invalid_file())
{
@@ -378,7 +396,7 @@
//For "create_file_mapping"
unsigned long protection = 0;
//For "mapviewoffile"
- unsigned long map_access = 0;
+ unsigned long map_access = map_options == default_map_options ? 0 : map_options;
switch(mode)
{
@@ -444,7 +462,6 @@
priv_size_from_mapping_size(mapping_size, offset, page_offset, size);
}
-
//Map with new offsets and size
void *base = winapi::map_view_of_file_ex
(native_mapping_handle,
@@ -559,7 +576,8 @@
, mode_t mode
, offset_t offset
, std::size_t size
- , const void *address)
+ , const void *address
+ , map_options_t map_options)
: m_base(0), m_size(0), m_page_offset(0), m_mode(mode), m_is_xsi(false)
{
mapping_handle_t map_hnd = mapping.get_mapping_handle();
@@ -583,7 +601,7 @@
throw interprocess_exception(err);
}
//Calculate flag
- int flag = 0;
+ int flag = map_options == default_map_options ? 0 : map_options;
if(m_mode == read_only){
flag |= SHM_RDONLY;
}
@@ -620,15 +638,17 @@
priv_size_from_mapping_size(buf.st_size, offset, page_offset, size);
}
+ #ifdef MAP_NOSYNC
+ #define BOOST_INTERPROCESS_MAP_NOSYNC MAP_NOSYNC
+ #else
+ #define BOOST_INTERPROCESS_MAP_NOSYNC 0
+ #endif //MAP_NOSYNC
+
//Create new mapping
int prot = 0;
- int flags =
- #ifdef MAP_NOSYNC
- //Avoid excessive syncing in BSD systems
- MAP_NOSYNC;
- #else
- 0;
- #endif
+ int flags = map_options == default_map_options ? BOOST_INTERPROCESS_MAP_NOSYNC : map_options;
+
+ #undef BOOST_INTERPROCESS_MAP_NOSYNC
switch(mode)
{
Modified: trunk/libs/interprocess/doc/interprocess.qbk
==============================================================================
--- trunk/libs/interprocess/doc/interprocess.qbk (original)
+++ trunk/libs/interprocess/doc/interprocess.qbk 2013-02-24 17:38:07 EST (Sun, 24 Feb 2013)
@@ -6713,6 +6713,7 @@
[section:release_notes_boost_1_54_00 Boost 1.54 Release]
+* Added support for platform-specific flags to mapped_region (ticket #8030)
* Fixed bugs [@https://svn.boost.org/trac/boost/ticket/7484 #7484],
[@https://svn.boost.org/trac/boost/ticket/7598 #7598],
[@https://svn.boost.org/trac/boost/ticket/7682 #7682],
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