#include <Mem_Map.h>
Public Methods | |
| ACE_Mem_Map (void) | |
| Default constructor. More... | |
| ACE_Mem_Map (ACE_HANDLE handle, int length=-1, int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, 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. More... | |
| ACE_Mem_Map (const ACE_TCHAR *filename, int len=-1, int flags=O_RDWR|O_CREAT, int mode=ACE_DEFAULT_FILE_PERMS, int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, off_t offset=0, LPSECURITY_ATTRIBUTES sa=0) | |
| Map a file specified by <file_name>. More... | |
| int | map (ACE_HANDLE handle, int length=-1, int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, 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. More... | |
| 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_>. More... | |
| int | map (const ACE_TCHAR *filename, int len=-1, int flags=O_RDWR|O_CREAT, int mode=ACE_DEFAULT_FILE_PERMS, int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, 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, int mode=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) |
| This operator passes back the starting address of the mapped file. More... | |
| void * | addr (void) const |
| Return the base address. More... | |
| size_t | size (void) const |
| This function returns the number of bytes currently mapped in the file. More... | |
| int | unmap (int len=-1) |
| Unmap the region starting at <base_addr_>. More... | |
| int | unmap (void *addr, int len) |
| Unmap the region starting at <addr_>. More... | |
| int | sync (ssize_t len=-1, int flags=MS_SYNC) |
| 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_>. More... | |
| int | protect (ssize_t len=-1, int prot=PROT_RDWR) |
| 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. More... | |
| 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 Methods | |
| int | map_it (ACE_HANDLE handle, int len=-1, int prot=PROT_RDWR, int share=MAP_SHARED, 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. More... | |
| ACE_Mem_Map (const ACE_Mem_Map &) | |
| void | operator= (const ACE_Mem_Map &) |
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... | |
| int | close_handle_ |
| Keeps track of whether we need to close the handle. This is set if we opened the file. More... | |
This class works with both the mmap(2) UNIX system and the Win32 family of memory mapping system calls.
Definition at line 34 of file Mem_Map.h.
|
|
Default constructor.
Definition at line 293 of file Mem_Map.cpp. References ACE_TRACE, MAP_FAILED, and ACE_OS_String::memset.
00294 : base_addr_ (MAP_FAILED), 00295 length_ (0), 00296 handle_ (ACE_INVALID_HANDLE), 00297 file_mapping_ (ACE_INVALID_HANDLE), 00298 close_handle_ (0) 00299 { 00300 ACE_TRACE ("ACE_Mem_Map::ACE_Mem_Map"); 00301 ACE_OS::memset (this->filename_, 0, sizeof this->filename_); 00302 } |
|
||||||||||||||||||||||||||||||||
|
Map a file from an open file descriptor <handle>. This function will lookup the length of the file if it is not given.
Definition at line 339 of file Mem_Map.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, addr, handle, LM_ERROR, map, MAP_FAILED, and ACE_OS_String::memset.
00346 : base_addr_ (MAP_FAILED), 00347 length_ (0), 00348 handle_ (ACE_INVALID_HANDLE), 00349 file_mapping_ (ACE_INVALID_HANDLE), 00350 close_handle_ (0) 00351 { 00352 ACE_TRACE ("ACE_Mem_Map::ACE_Mem_Map"); 00353 00354 ACE_OS::memset (this->filename_, 00355 0, 00356 sizeof this->filename_); 00357 if (this->map (handle, 00358 len, 00359 prot, 00360 share, 00361 addr, 00362 offset, 00363 sa) < 0) 00364 ACE_ERROR ((LM_ERROR, 00365 ACE_LIB_TEXT ("%p\n"), 00366 ACE_LIB_TEXT ("ACE_Mem_Map::ACE_Mem_Map"))); 00367 } |
|
||||||||||||||||||||||||||||||||||||||||
|
Map a file specified by <file_name>.
Definition at line 306 of file Mem_Map.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, addr, LM_ERROR, map, and MAP_FAILED.
00315 : base_addr_ (MAP_FAILED), 00316 length_ (0), 00317 handle_ (ACE_INVALID_HANDLE), 00318 file_mapping_ (ACE_INVALID_HANDLE), 00319 close_handle_ (0) 00320 { 00321 ACE_TRACE ("ACE_Mem_Map::ACE_Mem_Map"); 00322 if (this->map (file_name, 00323 len, 00324 flags, 00325 mode, 00326 prot, 00327 share, 00328 addr, 00329 offset, 00330 sa) < 0) 00331 ACE_ERROR ((LM_ERROR, 00332 ACE_LIB_TEXT ("%p\n"), 00333 ACE_LIB_TEXT ("ACE_Mem_Map::ACE_Mem_Map"))); 00334 } |
|
|
Destructor.
Definition at line 80 of file Mem_Map.cpp. References ACE_TRACE, and close.
|
|
|
|
|
|
Return the base address.
Definition at line 73 of file Mem_Map.i. References ACE_TRACE, and base_addr_. Referenced by ACE_Mem_Map, ACE_MMAP_Memory_Pool::acquire, ACE_Filecache_Object::address, ACE_MMAP_Memory_Pool::init_acquire, map, ACE_MMAP_Memory_Pool::map_file, map_it, operator(), protect, ACE_MMAP_Memory_Pool::remap, sync, and unmap.
00074 {
00075 ACE_TRACE ("ACE_Mem_Map::addr");
00076
00077 return this->base_addr_;
00078 }
|
|
||||||||||||
|
Hook into the underlying VM system.
Definition at line 227 of file Mem_Map.i. References ACE_TRACE, caddr_t, length_, and ACE_OS::madvise.
00228 {
00229 ACE_TRACE ("ACE_Mem_Map::advise");
00230 size_t advise_len = len < 0 ? this->length_ : ACE_static_cast (size_t, len);
00231 return ACE_OS::madvise ((caddr_t) this->base_addr_,
00232 advise_len,
00233 behavior);
00234 }
|
|
|
Close down the <handle_> if necessary and unmap the mapping.
Definition at line 71 of file Mem_Map.cpp. References ACE_TRACE, close_handle, and unmap. Referenced by ACE_MMAP_Memory_Pool::release, remove, and ~ACE_Mem_Map.
00072 {
00073 ACE_TRACE ("ACE_Mem_Map::close");
00074
00075 this->unmap ();
00076
00077 return this->close_handle ();
00078 }
|
|
|
Close down the internal <file_mapping_> if necessary. This is mostly necessary on Win32, which has a different handle for file-mapping kernel object. Definition at line 91 of file Mem_Map.i. References ACE_OS::close, file_mapping_, and handle_. Referenced by map_it, and unmap.
00092 {
00093 int result = 0;
00094
00095 if (this->file_mapping_ != this->handle_
00096 && this->file_mapping_ != ACE_INVALID_HANDLE)
00097 {
00098 // On LynxOS, this will result in unlinking of the (hidden)
00099 // shared memory file if there are no more references to it.
00100 result = ACE_OS::close (this->file_mapping_);
00101 this->file_mapping_ = ACE_INVALID_HANDLE;
00102 }
00103
00104 return result;
00105 }
|
|
|
Close down the <handle_> if necessary.
Definition at line 237 of file Mem_Map.i. References ACE_OS::close, close_handle_, and handle_. Referenced by close.
00238 {
00239 int result = 0;
00240
00241 if (this->close_handle_)
00242 {
00243 this->close_handle_ = 0;
00244 result = ACE_OS::close (this->handle_);
00245 this->handle_ = ACE_INVALID_HANDLE;
00246 }
00247
00248 return result;
00249 }
|
|
|
Dump the state of an object.
Definition at line 56 of file Mem_Map.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.
00057 {
00058 ACE_TRACE ("ACE_Mem_Map::dump");
00059
00060 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00061 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("base_addr_ = %x"), this->base_addr_));
00062 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nfilename_ = %s"), this->filename_));
00063 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nlength_ = %d"), this->length_));
00064 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nhandle_ = %d"), this->handle_));
00065 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nfile_mapping_ = %d"), this->file_mapping_));
00066 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nclose_handle_ = %d"), this->close_handle_));
00067 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00068 }
|
|
|
Return the name of file that is mapped (if any).
Definition at line 14 of file Mem_Map.i. References filename_. Referenced by ACE_Shared_Memory_MM::filename.
00015 {
00016 return this->filename_;
00017 }
|
|
|
Return the underlying <handle_>.
Definition at line 5 of file Mem_Map.i. References ACE_TRACE, and handle_. Referenced by ACE_Mem_Map, ACE_Shared_Memory_MM::get_id, map, and map_it.
|
|
||||||||||||||||||||||||||||||||||||||||
|
Map a file specified by <filename>.
Definition at line 265 of file Mem_Map.cpp. References ACE_TCHAR, ACE_TRACE, addr, length_, map_it, and open.
00274 {
00275 ACE_TRACE ("ACE_Mem_Map::map");
00276 this->length_ = 0;
00277
00278 if (this->open (file_name,
00279 flags,
00280 mode,
00281 sa) == -1)
00282 return -1;
00283 else
00284 return this->map_it (this->handle (),
00285 len,
00286 prot,
00287 share,
00288 addr,
00289 offset,
00290 sa);
00291 }
|
|
||||||||||||||||||||||||||||
|
Remap the file associated with <handle_>.
Definition at line 35 of file Mem_Map.i. References ACE_TRACE, addr, base_addr_, MAP_FAILED, MAP_FIXED, and map_it.
00041 {
00042 ACE_TRACE ("ACE_Mem_Map::map");
00043 // If we're already mapped at a particular location then try to
00044 // remap the file using the same base address.
00045 if (addr == 0 && this->base_addr_ != 0 && this->base_addr_ != MAP_FAILED)
00046 {
00047 share |= MAP_FIXED;
00048 addr = this->base_addr_;
00049 }
00050 return this->map_it (this->handle (), len, prot,
00051 share, addr, offset, sa);
00052 }
|
|
||||||||||||||||||||||||||||||||
|
Map a file from an open file descriptor <handle>. This function will lookup the length of the file if it is not given.
Definition at line 20 of file Mem_Map.i. References ACE_TRACE, addr, handle, and map_it. Referenced by ACE_Filecache_Object::ACE_Filecache_Object, ACE_Mem_Map, ACE_MMAP_Memory_Pool::init_acquire, ACE_MMAP_Memory_Pool::map_file, ACE_Shared_Memory_MM::open, and ACE_Filecache_Object::release.
|
|
||||||||||||||||||||||||||||||||
|
This method does the dirty work of actually calling mmap to map the file into memory.
Definition at line 91 of file Mem_Map.cpp. References ACE_BIT_ENABLED, ACE_TCHAR, ACE_TRACE, addr, base_addr_, close_filemapping_handle, filename_, ACE_OS::filesize, ACE_OS::ftruncate, handle, handle_, length_, MAP_FAILED, MAP_SHARED, ACE_OS::mmap, PROT_WRITE, ACE_OS::pwrite, to_mapping_name, and unmap. Referenced by map.
00098 {
00099 ACE_TRACE ("ACE_Mem_Map::map_it");
00100
00101 #if defined (ACE_LACKS_AUTO_MMAP_REPLACEMENT)
00102 // If the system does not replace any previous mappings, then
00103 // unmap() before (potentially) mapping to the same location.
00104 int unmap_result = this->unmap ();
00105 if (unmap_result != 0)
00106 return unmap_result;
00107 #endif /* ACE_LACKS_AUTO_MMAP_REPLACEMENT */
00108
00109 this->base_addr_ = addr;
00110 this->handle_ = handle;
00111
00112 #if defined (CHORUS)
00113 // Chorus does not support filesize on a shared memory handle. We
00114 // assume that <length_> = 0 when <ACE_Mem_Map> is initially
00115 // constructed (i.e., before <map_it> is called with a valid
00116 // <len_request>).
00117 long result = this->length_;
00118
00119 if (result == -1)
00120 return -1;
00121 #else
00122 long result = ACE_OS::filesize (this->handle_);
00123 #endif /* CHORUS */
00124
00125 // At this point we know <result> is not negative...
00126 size_t current_file_length = ACE_static_cast (size_t, result);
00127
00128 // Flag to indicate if we need to extend the back store
00129 int extend_backing_store = 0;
00130
00131 // File length requested by user
00132 size_t requested_file_length = 0;
00133
00134 // Check <length_request>
00135 if (length_request == -1)
00136 // Set length to file_request.
00137 this->length_ = current_file_length - offset;
00138 else
00139 {
00140 // File length implicitly requested by user
00141 requested_file_length = length_request + offset;
00142
00143 // Check to see if we need to extend the backing store
00144 if (requested_file_length > current_file_length)
00145 {
00146 // If the length of the mapped region is less than the
00147 // length of the file then we force a complete new remapping
00148 // by setting the descriptor to ACE_INVALID_HANDLE (closing
00149 // down the descriptor if necessary).
00150 this->close_filemapping_handle ();
00151
00152 // Remember to extend the backing store
00153 extend_backing_store = 1;
00154 }
00155
00156 // Set length to length_request
00157 this->length_ = length_request;
00158 }
00159
00160 // Check if we need to extend the backing store.
00161 if (extend_backing_store)
00162 {
00163 #if !defined (CHORUS)
00164 // Remember than write increases the size by one.
00165 off_t null_byte_position;
00166 if (requested_file_length > 0)
00167 // This will make the file size <requested_file_length>
00168 null_byte_position =
00169 ACE_static_cast (off_t, requested_file_length - 1);
00170 else
00171 // This will make the file size 1
00172 null_byte_position = 0;
00173
00174 if (ACE_OS::pwrite (this->handle_,
00175 "",
00176 1,
00177 null_byte_position) == -1)
00178 return -1;
00179 #else
00180 // This nonsense is to make this code similar to the above code.
00181 size_t actual_file_length;
00182 if (requested_file_length > 0)
00183 // This will make the file size <requested_file_length>
00184 actual_file_length = requested_file_length;
00185 else
00186 // This will make the file size 1
00187 actual_file_length = 1;
00188
00189 if (ACE_OS::ftruncate (this->handle_,
00190 actual_file_length) == -1)
00191 return -1;
00192 #endif /* !CHORUS */
00193 }
00194
00195 #if defined (__Lynx__)
00196 // Set flag that indicates whether PROT_WRITE has been enabled.
00197 write_enabled_ = ACE_BIT_ENABLED (prot, PROT_WRITE);
00198 #endif /* __Lynx__ */
00199
00200 #if defined (ACE_USE_MAPPING_NAME)
00201 if (ACE_BIT_ENABLED (share, MAP_SHARED))
00202 {
00203 # if defined(__MINGW32__)
00204 const int max_mapping_name_length = 32;
00205 # else
00206 const int max_mapping_name_length = 31;
00207 # endif /* __MINGW32__ */
00208 ACE_TCHAR file_mapping_name[max_mapping_name_length + 1];
00209 to_mapping_name (file_mapping_name,
00210 filename_,
00211 max_mapping_name_length + 1);
00212
00213 this->base_addr_ = ACE_OS::mmap (this->base_addr_,
00214 this->length_,
00215 prot,
00216 share,
00217 this->handle_,
00218 offset,
00219 &this->file_mapping_,
00220 sa,
00221 file_mapping_name);
00222 }
00223 else
00224 #endif /* ACE_USE_MAPPING_NAME */
00225 this->base_addr_ = ACE_OS::mmap (this->base_addr_,
00226 this->length_,
00227 prot,
00228 share,
00229 this->handle_,
00230 offset,
00231 &this->file_mapping_,
00232 sa);
00233
00234 return this->base_addr_ == MAP_FAILED ? -1 : 0;
00235 }
|
|
||||||||||||||||||||
|
Open the file without mapping it.
Definition at line 238 of file Mem_Map.cpp. References ACE_TCHAR, ACE_TRACE, close_handle_, handle_, MAXPATHLEN, ACE_OS::open, ACE_OS::shm_open, and ACE_OS_String::strsncpy. Referenced by ACE_MMAP_Memory_Pool::init_acquire, and map.
00242 {
00243 ACE_TRACE ("ACE_Mem_Map::open");
00244
00245 ACE_OS::strsncpy (this->filename_,
00246 file_name,
00247 MAXPATHLEN);
00248
00249 #if defined (CHORUS)
00250 this->handle_ = ACE_OS::shm_open (file_name, flags, mode, sa);
00251 #else
00252 this->handle_ = ACE_OS::open (file_name, flags, mode, sa);
00253 #endif /* CHORUS */
00254
00255 if (this->handle_ == ACE_INVALID_HANDLE)
00256 return -1;
00257 else
00258 {
00259 this->close_handle_ = 1;
00260 return 0;
00261 }
00262 }
|
|
|
This operator passes back the starting address of the mapped file.
Definition at line 57 of file Mem_Map.i. References ACE_TRACE, addr, base_addr_, and MAP_FAILED.
00058 {
00059 ACE_TRACE ("ACE_Mem_Map::operator");
00060
00061 if (this->base_addr_ == MAP_FAILED)
00062 return -1;
00063 else
00064 {
00065 addr = this->base_addr_;
00066 return 0;
00067 }
00068 }
|
|
|
|
|
||||||||||||||||
|
Change the protection of the pages of the mapped region to <prot> starting at <addr> up to <len> bytes.
Definition at line 218 of file Mem_Map.i. References ACE_TRACE, addr, and ACE_OS::mprotect.
00219 {
00220 ACE_TRACE ("ACE_Mem_Map::protect");
00221 return ACE_OS::mprotect (addr, len, prot);
00222 }
|
|
||||||||||||
|
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. Definition at line 206 of file Mem_Map.i. References ACE_TRACE, length_, ACE_OS::mprotect, and ssize_t. Referenced by ACE_MMAP_Memory_Pool::protect.
00207 {
00208 ACE_TRACE ("ACE_Mem_Map::protect");
00209 if (len < 0)
00210 len = this->length_;
00211 return ACE_OS::mprotect (this->base_addr_, len, prot);
00212 }
|
|
|
Close and remove the file from the file system.
Definition at line 372 of file Mem_Map.cpp. References ACE_TRACE, close, filename_, ACE_OS::ftruncate, ACE_OS::shm_unlink, and ACE_OS::unlink. Referenced by ACE_MMAP_Memory_Pool::release, and ACE_Shared_Memory_MM::remove.
00373 {
00374 ACE_TRACE ("ACE_Mem_Map::remove");
00375
00376 ACE_OS::ftruncate (this->handle_, 0);
00377 this->close ();
00378
00379 if (this->filename_[0] != '\0')
00380 #if defined (CHORUS)
00381 return ACE_OS::shm_unlink (this->filename_);
00382 #else
00383 return ACE_OS::unlink (this->filename_);
00384 #endif /* CHORUS */
00385
00386 else
00387 return 0;
00388 }
|
|
|
This function returns the number of bytes currently mapped in the file.
Definition at line 84 of file Mem_Map.i. References ACE_TRACE, and length_. Referenced by ACE_MMAP_Memory_Pool::acquire, and ACE_MMAP_Memory_Pool::handle_signal.
|
|
||||||||||||||||
|
Sync <len> bytes of the memory region to the backing store starting at <addr_>.
Definition at line 195 of file Mem_Map.i. References ACE_TRACE, addr, and ACE_OS::msync.
00196 {
00197 ACE_TRACE ("ACE_Mem_Map::sync");
00198 return ACE_OS::msync (addr, len, flags);
00199 }
|
|
||||||||||||
|
Sync <len> bytes of the memory region to the backing store starting at <base_addr_>. If <len> == -1 then sync the whole region. Definition at line 183 of file Mem_Map.i. References ACE_TRACE, length_, ACE_OS::msync, and ssize_t. Referenced by ACE_MMAP_Memory_Pool::sync.
00184 {
00185 ACE_TRACE ("ACE_Mem_Map::sync");
00186 return ACE_OS::msync (this->base_addr_,
00187 len < 0 ? this->length_ : len,
00188 flags);
00189 }
|
|
||||||||||||
|
Unmap the region starting at <addr_>.
Definition at line 148 of file Mem_Map.i. References ACE_TRACE, addr, base_addr_, close_filemapping_handle, ACE_OS::filesize, handle_, length_, ACE_OS::lseek, ACE_OS::munmap, and ACE_OS::write.
00149 {
00150 ACE_TRACE ("ACE_Mem_Map::unmap");
00151
00152 this->close_filemapping_handle ();
00153
00154 #if defined (__Lynx__)
00155 int writeback_result = 0;
00156 if (write_enabled_)
00157 {
00158 // Write back the contents of the shared memory object to the file.
00159 const off_t filesize = ACE_OS::filesize (handle_);
00160 writeback_result =
00161 ACE_OS::lseek (handle_, 0, 0) != -1
00162 && ACE_OS::write (handle_,
00163 base_addr_,
00164 (int) filesize) == filesize ? 0 : -1;
00165 }
00166 #endif /* __Lynx__ */
00167
00168 #if defined (__Lynx__)
00169 return ACE_OS::munmap (addr,
00170 len < 0 ? this->length_ : len)
00171 | writeback_result;;
00172 #else /* ! __Lynx__ */
00173 return ACE_OS::munmap (addr,
00174 len < 0 ? this->length_ : len);
00175 #endif /* ! __Lynx__ */
00176 }
|
|
|
Unmap the region starting at <base_addr_>.
Definition at line 110 of file Mem_Map.i. References ACE_TRACE, base_addr_, close_filemapping_handle, ACE_OS::filesize, handle_, length_, ACE_OS::lseek, MAP_FAILED, ACE_OS::munmap, and ACE_OS::write. Referenced by ACE_Shared_Memory_MM::close, close, ACE_MMAP_Memory_Pool::map_file, map_it, ACE_Filecache_Object::release, and ACE_Filecache_Object::~ACE_Filecache_Object.
00111 {
00112 ACE_TRACE ("ACE_Mem_Map::unmap");
00113
00114 this->close_filemapping_handle ();
00115
00116 #if defined (__Lynx__)
00117 int writeback_result = 0;
00118 if (write_enabled_)
00119 {
00120 // Write back the contents of the shared memory object to the
00121 // file.
00122 const off_t filesize = ACE_OS::filesize (handle_);
00123 writeback_result =
00124 ACE_OS::lseek (handle_, 0, 0) != -1
00125 && ACE_OS::write (handle_,
00126 base_addr_,
00127 (int) filesize) == filesize ? 0 : -1;
00128 }
00129 #endif /* __Lynx__ */
00130 if (this->base_addr_ != MAP_FAILED)
00131 {
00132 int result = ACE_OS::munmap (this->base_addr_,
00133 len < 0 ? this->length_ : len);
00134 this->base_addr_ = MAP_FAILED;
00135 return result;
00136 }
00137 else
00138 #if defined (__Lynx__)
00139 return writeback_result;
00140 #else /* ! __Lynx__ */
00141 return 0;
00142 #endif /* ! __Lynx__ */
00143 }
|
|
|
Declare the dynamic allocation hooks.
|
|
|
Base address of the memory-mapped file.
Definition at line 173 of file Mem_Map.h. Referenced by addr, map, map_it, operator(), and unmap. |
|
|
Keeps track of whether we need to close the handle. This is set if we opened the file.
Definition at line 194 of file Mem_Map.h. Referenced by close_handle, and open. |
|
|
HANDLE for the open mapping.
Definition at line 185 of file Mem_Map.h. Referenced by close_filemapping_handle. |
|
|
Name of the file that is mapped.
|
|
|
HANDLE for the open file.
Definition at line 182 of file Mem_Map.h. Referenced by close_filemapping_handle, close_handle, handle, map_it, open, and unmap. |
|
|
Length of the mapping.
Definition at line 179 of file Mem_Map.h. Referenced by advise, map, map_it, protect, size, sync, and unmap. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002