ACE
6.3.3
|
C++ interface OS memory mapping system call. More...
#include <Mem_Map.h>
Public Member Functions | |
ACE_Mem_Map (void) | |
Default constructor. More... | |
ACE_Mem_Map (ACE_HANDLE handle, size_t length=static_cast< size_t >(-1), int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0) | |
ACE_Mem_Map (const ACE_TCHAR *filename, size_t length=static_cast< size_t >(-1), int flags=O_RDWR|O_CREAT, mode_t mode=ACE_DEFAULT_FILE_PERMS, int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0) | |
Map a file specified by file_name. More... | |
int | map (ACE_HANDLE handle, size_t length=static_cast< size_t >(-1), int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0) |
int | map (size_t length=static_cast< size_t >(-1), int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0) |
Remap the file associated with <handle_>. More... | |
int | map (const ACE_TCHAR *filename, size_t length=static_cast< size_t >(-1), int flags=O_RDWR|O_CREAT, mode_t mode=ACE_DEFAULT_FILE_PERMS, int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0) |
Map a file specified by filename. More... | |
~ACE_Mem_Map (void) | |
Destructor. More... | |
int | open (const ACE_TCHAR *filename, int flags=O_RDWR|O_CREAT, mode_t perms=ACE_DEFAULT_FILE_PERMS, LPSECURITY_ATTRIBUTES sa=0) |
Open the file without mapping it. More... | |
int | close (void) |
Close down the <handle_> if necessary and unmap the mapping. More... | |
int | close_handle (void) |
Close down the <handle_> if necessary. More... | |
int | close_filemapping_handle (void) |
int | operator() (void *&addr) |
void * | addr (void) const |
Return the base address. More... | |
size_t | size (void) const |
int | unmap (ssize_t len=-1) |
Unmap the region starting at base_addr_. More... | |
int | unmap (void *addr, ssize_t len) |
Unmap the region starting at addr_. More... | |
int | sync (size_t len, int flags=MS_SYNC) |
int | sync (int flags=MS_SYNC) |
int | sync (void *addr, size_t len, int flags=MS_SYNC) |
int | protect (size_t len, int prot=PROT_RDWR) |
int | protect (int prot=PROT_RDWR) |
int | protect (void *addr, size_t len, int prot=PROT_RDWR) |
int | remove (void) |
Close and remove the file from the file system. More... | |
int | advise (int behavior, int len=-1) |
Hook into the underlying VM system. More... | |
ACE_HANDLE | handle (void) const |
Return the underlying <handle_>. More... | |
const ACE_TCHAR * | filename (void) const |
Return the name of file that is mapped (if any). More... | |
void | dump (void) const |
Dump the state of an object. More... | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. More... | |
Private Member Functions | |
int | map_it (ACE_HANDLE handle, size_t len=static_cast< size_t >(-1), int prot=PROT_RDWR, int share=MAP_SHARED, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0) |
Private Member Functions inherited from ACE_Copy_Disabled | |
ACE_Copy_Disabled (void) | |
Default constructor. More... | |
Private Attributes | |
void * | base_addr_ |
Base address of the memory-mapped file. More... | |
ACE_TCHAR | filename_ [MAXPATHLEN+1] |
Name of the file that is mapped. More... | |
size_t | length_ |
Length of the mapping. More... | |
ACE_HANDLE | handle_ |
HANDLE for the open file. More... | |
ACE_HANDLE | file_mapping_ |
HANDLE for the open mapping. More... | |
bool | close_handle_ |
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.
ACE_Mem_Map::ACE_Mem_Map | ( | void | ) |
Default constructor.
ACE_Mem_Map::ACE_Mem_Map | ( | ACE_HANDLE | handle, |
size_t | length = static_cast<size_t> (-1) , |
||
int | prot = PROT_RDWR , |
||
int | share = ACE_MAP_PRIVATE , |
||
void * | addr = 0 , |
||
ACE_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.
ACE_Mem_Map::ACE_Mem_Map | ( | const ACE_TCHAR * | filename, |
size_t | length = static_cast<size_t> (-1) , |
||
int | flags = O_RDWR | O_CREAT , |
||
mode_t | mode = ACE_DEFAULT_FILE_PERMS , |
||
int | prot = PROT_RDWR , |
||
int | share = ACE_MAP_PRIVATE , |
||
void * | addr = 0 , |
||
ACE_OFF_T | offset = 0 , |
||
LPSECURITY_ATTRIBUTES | sa = 0 |
||
) |
Map a file specified by file_name.
ACE_Mem_Map::~ACE_Mem_Map | ( | void | ) |
Destructor.
|
inline |
Return the base address.
|
inline |
Hook into the underlying VM system.
int ACE_Mem_Map::close | ( | void | ) |
Close down the <handle_> if necessary and unmap the mapping.
|
inline |
Close down the internal <file_mapping_> if necessary. This is mostly necessary on Win32, which has a different handle for file-mapping kernel object.
|
inline |
Close down the <handle_> if necessary.
void ACE_Mem_Map::dump | ( | void | ) | const |
Dump the state of an object.
|
inline |
Return the name of file that is mapped (if any).
|
inline |
Return the underlying <handle_>.
|
inline |
Map a file from an open file descriptor handle. This function will lookup the length of the file if it is not given.
|
inline |
Remap the file associated with <handle_>.
int ACE_Mem_Map::map | ( | const ACE_TCHAR * | filename, |
size_t | length = static_cast<size_t> (-1) , |
||
int | flags = O_RDWR | O_CREAT , |
||
mode_t | mode = ACE_DEFAULT_FILE_PERMS , |
||
int | prot = PROT_RDWR , |
||
int | share = ACE_MAP_PRIVATE , |
||
void * | addr = 0 , |
||
ACE_OFF_T | offset = 0 , |
||
LPSECURITY_ATTRIBUTES | sa = 0 |
||
) |
Map a file specified by filename.
|
private |
This method does the dirty work of actually calling ::mmap to map the file into memory.
int ACE_Mem_Map::open | ( | const ACE_TCHAR * | filename, |
int | flags = O_RDWR | O_CREAT , |
||
mode_t | perms = ACE_DEFAULT_FILE_PERMS , |
||
LPSECURITY_ATTRIBUTES | sa = 0 |
||
) |
Open the file without mapping it.
|
inline |
This operator passes back the starting address of the mapped file.
|
inline |
Change the protection of the pages of the mapped region to prot starting at base_addr_ up to len bytes.
|
inline |
Change the protection of all the pages of the mapped region to prot starting at base_addr_.
|
inline |
Change the protection of the pages of the mapped region to prot starting at addr up to len bytes.
int ACE_Mem_Map::remove | ( | void | ) |
Close and remove the file from the file system.
|
inline |
This function returns the number of bytes currently mapped in the file.
|
inline |
Sync len bytes of the memory region to the backing store starting at base_addr_. If len == -1 then sync the whole region.
|
inline |
Sync the whole memory region to the backing store starting at base_addr_.
|
inline |
Sync len bytes of the memory region to the backing store starting at addr_.
|
inline |
Unmap the region starting at base_addr_.
|
inline |
Unmap the region starting at addr_.
ACE_Mem_Map::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
|
private |
Base address of the memory-mapped file.
|
private |
Keeps track of whether we need to close the handle. This is set if we opened the file.
|
private |
HANDLE for the open mapping.
|
private |
Name of the file that is mapped.
|
private |
HANDLE for the open file.
|
private |
Length of the mapping.