summaryrefslogtreecommitdiff
path: root/boost/interprocess/windows_shared_memory.hpp
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2013-08-26 12:15:55 (GMT)
committerAnas Nashif <anas.nashif@intel.com>2013-08-26 12:15:55 (GMT)
commitbb4dd8289b351fae6b55e303f189127a394a1edd (patch)
tree77c9c35a31b1459dd7988c2448e797d142530c41 /boost/interprocess/windows_shared_memory.hpp
parent1a78a62555be32868418fe52f8e330c9d0f95d5a (diff)
downloadboost-bb4dd8289b351fae6b55e303f189127a394a1edd.zip
boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.gz
boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.bz2
Imported Upstream version 1.51.0upstream/1.51.0refs/changes/75/8775/1
Diffstat (limited to 'boost/interprocess/windows_shared_memory.hpp')
-rw-r--r--boost/interprocess/windows_shared_memory.hpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/boost/interprocess/windows_shared_memory.hpp b/boost/interprocess/windows_shared_memory.hpp
index 9a8b3f4..76601bb 100644
--- a/boost/interprocess/windows_shared_memory.hpp
+++ b/boost/interprocess/windows_shared_memory.hpp
@@ -72,26 +72,26 @@ class windows_shared_memory
windows_shared_memory(open_or_create_t, const char *name, mode_t mode, std::size_t size, const permissions& perm = permissions())
{ this->priv_open_or_create(ipcdetail::DoOpenOrCreate, name, mode, size, perm); }
- //!Tries to open a shared memory object with name "name", with the access mode "mode".
+ //!Tries to open a shared memory object with name "name", with the access mode "mode".
//!If the file does not previously exist, it throws an error.
windows_shared_memory(open_only_t, const char *name, mode_t mode)
{ this->priv_open_or_create(ipcdetail::DoOpen, name, mode, 0, permissions()); }
- //!Moves the ownership of "moved"'s shared memory object to *this.
- //!After the call, "moved" does not represent any shared memory object.
+ //!Moves the ownership of "moved"'s shared memory object to *this.
+ //!After the call, "moved" does not represent any shared memory object.
//!Does not throw
windows_shared_memory(BOOST_RV_REF(windows_shared_memory) moved)
: m_handle(0)
{ this->swap(moved); }
//!Moves the ownership of "moved"'s shared memory to *this.
- //!After the call, "moved" does not represent any shared memory.
+ //!After the call, "moved" does not represent any shared memory.
//!Does not throw
windows_shared_memory &operator=(BOOST_RV_REF(windows_shared_memory) moved)
- {
+ {
windows_shared_memory tmp(boost::move(moved));
this->swap(tmp);
- return *this;
+ return *this;
}
//!Swaps to shared_memory_objects. Does not throw
@@ -129,21 +129,21 @@ class windows_shared_memory
/// @cond
-inline windows_shared_memory::windows_shared_memory()
+inline windows_shared_memory::windows_shared_memory()
: m_handle(0)
{}
-inline windows_shared_memory::~windows_shared_memory()
+inline windows_shared_memory::~windows_shared_memory()
{ this->priv_close(); }
inline const char *windows_shared_memory::get_name() const
{ return m_name.c_str(); }
inline void windows_shared_memory::swap(windows_shared_memory &other)
-{
+{
std::swap(m_handle, other.m_handle);
std::swap(m_mode, other.m_mode);
- m_name.swap(other.m_name);
+ m_name.swap(other.m_name);
}
inline mapping_handle_t windows_shared_memory::get_mapping_handle() const
@@ -157,22 +157,26 @@ inline bool windows_shared_memory::priv_open_or_create
{
m_name = filename ? filename : "";
- unsigned long file_map_access = 0;
+ unsigned long protection = 0;
unsigned long map_access = 0;
switch(mode)
{
+ //"protection" is for "create_file_mapping"
+ //"map_access" is for "open_file_mapping"
+ //Add section query (strange that read or access does not grant it...)
+ //to obtain the size of the mapping. copy_on_write is equal to section_query.
case read_only:
- file_map_access |= winapi::page_readonly;
- map_access |= winapi::file_map_read;
+ protection |= winapi::page_readonly;
+ map_access |= winapi::file_map_read | winapi::section_query;
break;
case read_write:
- file_map_access |= winapi::page_readwrite;
- map_access |= winapi::file_map_write;
+ protection |= winapi::page_readwrite;
+ map_access |= winapi::file_map_write | winapi::section_query;
break;
case copy_on_write:
- file_map_access |= winapi::page_writecopy;
- map_access |= winapi::file_map_copy;
+ protection |= winapi::page_writecopy;
+ map_access |= winapi::file_map_copy;
break;
default:
{
@@ -184,16 +188,13 @@ inline bool windows_shared_memory::priv_open_or_create
switch(type){
case ipcdetail::DoOpen:
- m_handle = winapi::open_file_mapping
- (map_access, filename);
+ m_handle = winapi::open_file_mapping(map_access, filename);
break;
case ipcdetail::DoCreate:
case ipcdetail::DoOpenOrCreate:
{
- __int64 s = size;
- unsigned long high_size(s >> 32), low_size((boost::uint32_t)s);
m_handle = winapi::create_file_mapping
- ( winapi::invalid_handle_value, file_map_access, high_size, low_size, filename
+ ( winapi::invalid_handle_value, protection, size, filename
, (winapi::interprocess_security_attributes*)perm.get_permissions());
}
break;