summaryrefslogtreecommitdiff
path: root/ace/Mem_Map.h
diff options
context:
space:
mode:
Diffstat (limited to 'ace/Mem_Map.h')
-rw-r--r--ace/Mem_Map.h141
1 files changed, 73 insertions, 68 deletions
diff --git a/ace/Mem_Map.h b/ace/Mem_Map.h
index 7c6781c8ba6..8a0927fc418 100644
--- a/ace/Mem_Map.h
+++ b/ace/Mem_Map.h
@@ -1,18 +1,15 @@
/* -*- C++ -*- */
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// ace
-//
-// = FILENAME
-// Mem_Map.h
-//
-// = AUTHOR
-// Doug Schmidt
-//
-// ============================================================================
+
+//=============================================================================
+/**
+ * @file Mem_Map.h
+ *
+ * $Id$
+ *
+ * @author Doug Schmidt
+ */
+//=============================================================================
+
#ifndef ACE_MEM_MAP_H
#define ACE_MEM_MAP_H
@@ -24,20 +21,24 @@
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
+/**
+ * @class ACE_Mem_Map
+ *
+ * @brief C++ interface OS memory mapping system call.
+ *
+ * This class works with both the mmap(2) UNIX system and the
+ * Win32 family of memory mapping system calls.
+ */
class ACE_Export ACE_Mem_Map
{
- // = TITLE
- // C++ interface OS memory mapping system call.
- //
- // = DESCRIPTION
- // This class works with both the mmap(2) UNIX system and the
- // Win32 family of memory mapping system calls.
public:
// = Initialization and termination methods.
+ /// Default constructor.
ACE_Mem_Map (void);
- // Default constructor.
+ /// Map a file from an open file descriptor <handle>. This function
+ /// will lookup the length of the file if it is not given.
ACE_Mem_Map (ACE_HANDLE handle,
int length = -1,
int prot = PROT_RDWR,
@@ -45,9 +46,8 @@ public:
void *addr = 0,
off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
- // Map a file from an open file descriptor <handle>. This function
- // will lookup the length of the file if it is not given.
+ /// Map a file specified by <file_name>.
ACE_Mem_Map (const ACE_TCHAR *filename,
int len = -1,
int flags = O_RDWR | O_CREAT,
@@ -57,8 +57,9 @@ public:
void *addr = 0,
off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
- // Map a file specified by <file_name>.
+ /// Map a file from an open file descriptor <handle>. This function
+ /// will lookup the length of the file if it is not given.
int map (ACE_HANDLE handle,
int length = -1,
int prot = PROT_RDWR,
@@ -66,17 +67,16 @@ public:
void *addr = 0,
off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
- // Map a file from an open file descriptor <handle>. This function
- // will lookup the length of the file if it is not given.
+ /// Remap the file associated with <handle_>.
int map (int length = -1,
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
- // Remap the file associated with <handle_>.
+ /// Map a file specified by <filename>.
int map (const ACE_TCHAR *filename,
int len = -1,
int flags = O_RDWR | O_CREAT,
@@ -86,106 +86,113 @@ public:
void *addr = 0,
off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
- // Map a file specified by <filename>.
+ /// Destructor.
~ACE_Mem_Map (void);
- // Destructor.
+ /// Open the file without mapping it.
int open (const ACE_TCHAR *filename,
int flags = O_RDWR | O_CREAT,
int mode = ACE_DEFAULT_FILE_PERMS,
LPSECURITY_ATTRIBUTES sa = 0);
- // Open the file without mapping it.
+ /// Close down the <handle_> if necessary and unmap the mapping.
int close (void);
- // Close down the <handle_> if necessary and unmap the mapping.
+ /// Close down the <handle_> if necessary.
int close_handle (void);
- // Close down the <handle_> if necessary.
+ /**
+ * Close down the internal <file_mapping_> if necessary. This is
+ * mostly necessary on Win32, which has a different handle for
+ * file-mapping kernel object.
+ */
int close_filemapping_handle (void);
- // Close down the internal <file_mapping_> if necessary. This is
- // mostly necessary on Win32, which has a different handle for
- // file-mapping kernel object.
+ /// This operator passes back the starting address of the mapped
+ /// file.
int operator () (void *&addr);
- // This operator passes back the starting address of the mapped
- // file.
+ /// Return the base address.
void *addr (void) const;
- // Return the base address.
+ /// This function returns the number of bytes currently mapped in the
+ /// file.
size_t size (void) const;
- // This function returns the number of bytes currently mapped in the
- // file.
+ /// Unmap the region starting at <base_addr_>.
int unmap (int len = -1);
- // Unmap the region starting at <base_addr_>.
+ /// Unmap the region starting at <addr_>.
int unmap (void *addr, int len);
- // Unmap the region starting at <addr_>.
+ /**
+ * Sync <len> bytes of the memory region to the backing store
+ * starting at <base_addr_>. If <len> == -1 then sync the whole
+ * region.
+ */
int sync (ssize_t len = -1, int flags = MS_SYNC);
- // Sync <len> bytes of the memory region to the backing store
- // starting at <base_addr_>. If <len> == -1 then sync the whole
- // region.
+ /// Sync <len> bytes of the memory region to the backing store
+ /// starting at <addr_>.
int sync (void *addr, size_t len, int flags = MS_SYNC);
- // Sync <len> bytes of the memory region to the backing store
- // starting at <addr_>.
+ /**
+ * Change the protection of the pages of the mapped region to <prot>
+ * starting at <base_addr_> up to <len> bytes. If <len> == -1 then
+ * change protection of all pages in the mapped region.
+ */
int protect (ssize_t len = -1, int prot = PROT_RDWR);
- // Change the protection of the pages of the mapped region to <prot>
- // starting at <base_addr_> up to <len> bytes. If <len> == -1 then
- // change protection of all pages in the mapped region.
+ /// Change the protection of the pages of the mapped region to <prot>
+ /// starting at <addr> up to <len> bytes.
int protect (void *addr, size_t len, int prot = PROT_RDWR);
- // Change the protection of the pages of the mapped region to <prot>
- // starting at <addr> up to <len> bytes.
+ /// Close and remove the file from the file system.
int remove (void);
- // Close and remove the file from the file system.
+ /// Hook into the underlying VM system.
int advise (int behavior, int len = -1);
- // Hook into the underlying VM system.
+ /// Return the underlying <handle_>.
ACE_HANDLE handle (void) const;
- // Return the underlying <handle_>.
+ /// Return the name of file that is mapped (if any).
const ACE_TCHAR *filename (void) const;
- // Return the name of file that is mapped (if any).
+ /// Dump the state of an object.
void dump (void) const;
- // Dump the state of an object.
+ /// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
- // Declare the dynamic allocation hooks.
private:
+ /// Base address of the memory-mapped file.
void *base_addr_;
- // Base address of the memory-mapped file.
+ /// Name of the file that is mapped.
ACE_TCHAR filename_[MAXPATHLEN + 1];
- // Name of the file that is mapped.
+ /// Length of the mapping.
size_t length_;
- // Length of the mapping.
+ /// HANDLE for the open file.
ACE_HANDLE handle_;
- // HANDLE for the open file.
+ /// HANDLE for the open mapping.
ACE_HANDLE file_mapping_;
- // HANDLE for the open mapping.
#if defined (__Lynx__)
+ /// Flag to indicate that PROT_WRITE has been enabled.
int write_enabled_;
- // Flag to indicate that PROT_WRITE has been enabled.
#endif /* __Lynx__ */
+ /// Keeps track of whether we need to close the handle. This is set
+ /// if we opened the file.
int close_handle_;
- // Keeps track of whether we need to close the handle. This is set
- // if we opened the file.
+ /// This method does the dirty work of actually calling ::mmap to map
+ /// the file into memory.
int map_it (ACE_HANDLE handle,
int len = -1,
int prot = PROT_RDWR,
@@ -193,8 +200,6 @@ private:
void *addr = 0,
off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
- // This method does the dirty work of actually calling ::mmap to map
- // the file into memory.
// = Disallow copying and assignment.
ACE_UNIMPLEMENTED_FUNC (ACE_Mem_Map (const ACE_Mem_Map &))