summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-12 23:40:52 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-12 23:40:52 +0000
commitaeba65a2d9c65dfb0c17fb120ed162fc4f0c87cd (patch)
tree210e9ebe8ca873a27d012b8807895afd4e338667 /ace
parent896ebcb37a6f445fe0231284acacafd70959ad39 (diff)
downloadATCD-aeba65a2d9c65dfb0c17fb120ed162fc4f0c87cd.tar.gz
*** empty log message ***
Diffstat (limited to 'ace')
-rw-r--r--ace/Mem_Map.cpp65
-rw-r--r--ace/Mem_Map.h12
-rw-r--r--ace/Mem_Map.i8
3 files changed, 45 insertions, 40 deletions
diff --git a/ace/Mem_Map.cpp b/ace/Mem_Map.cpp
index 8bd49523a9c..2f15e3ec365 100644
--- a/ace/Mem_Map.cpp
+++ b/ace/Mem_Map.cpp
@@ -50,11 +50,11 @@ ACE_Mem_Map::~ACE_Mem_Map (void)
int
ACE_Mem_Map::map_it (ACE_HANDLE handle,
- int len_request,
+ int length_request,
int prot,
int share,
void *addr,
- off_t pos,
+ off_t offset,
LPSECURITY_ATTRIBUTES sa)
{
ACE_TRACE ("ACE_Mem_Map::map_it");
@@ -69,31 +69,36 @@ ACE_Mem_Map::map_it (ACE_HANDLE handle,
return -1;
// At this point we know <result> is not negative...
- size_t file_len = ACE_static_cast (size_t, result);
+ size_t current_file_length = ACE_static_cast (size_t, result);
- if (this->length_ < file_len)
- {
- // If the length of the mapped region is less than the length of
- // the file then we force a complete new remapping by setting
- // the descriptor to ACE_INVALID_HANDLE (closing down the
- // descriptor if necessary).
- this->close_filemapping_handle ();
- }
-
- // Check to see if we need to extend the backing store
+ // Flag to indicate if we need to extend the back store
int extend_backing_store = 0;
- if (len_request != -1)
- {
- if (file_len < ACE_static_cast (size_t,
- len_request))
- extend_backing_store = 1;
- // Set length to len_request
- this->length_ = len_request;
- }
- else
+ // Check <length_request>
+ if (length_request == -1)
// Set length to file_request
- this->length_ = file_len;
+ this->length_ = current_file_length;
+ else
+ {
+ // File length implicitly requested by user
+ size_t requested_file_length = length_request + offset;
+
+ // Check to see if we need to extend the backing store
+ if (requested_file_length < current_file_length)
+ {
+ // If the length of the mapped region is less than the
+ // length of the file then we force a complete new remapping
+ // by setting the descriptor to ACE_INVALID_HANDLE (closing
+ // down the descriptor if necessary).
+ this->close_filemapping_handle ();
+
+ // Remember to extend the backing store
+ extend_backing_store = 1;
+ }
+
+ // Set length to length_request
+ this->length_ = length_request;
+ }
if (extend_backing_store
// Extend the backing store.
@@ -120,7 +125,7 @@ ACE_Mem_Map::map_it (ACE_HANDLE handle,
prot,
share,
this->handle_,
- off_t (ACE::round_to_allocation_granularity (pos)),
+ offset,
&this->file_mapping_,
sa);
return this->base_addr_ == MAP_FAILED ? -1 : 0;
@@ -161,7 +166,7 @@ ACE_Mem_Map::map (LPCTSTR file_name,
int prot,
int share,
void *addr,
- off_t pos,
+ off_t offset,
LPSECURITY_ATTRIBUTES sa)
{
ACE_TRACE ("ACE_Mem_Map::map");
@@ -178,7 +183,7 @@ ACE_Mem_Map::map (LPCTSTR file_name,
prot,
share,
addr,
- pos,
+ offset,
sa);
}
@@ -202,7 +207,7 @@ ACE_Mem_Map::ACE_Mem_Map (LPCTSTR file_name,
int prot,
int share,
void *addr,
- off_t pos,
+ off_t offset,
LPSECURITY_ATTRIBUTES sa)
: base_addr_ (MAP_FAILED),
length_ (0),
@@ -218,7 +223,7 @@ ACE_Mem_Map::ACE_Mem_Map (LPCTSTR file_name,
prot,
share,
addr,
- pos,
+ offset,
sa) < 0)
ACE_ERROR ((LM_ERROR,
ASYS_TEXT ("%p\n"),
@@ -233,7 +238,7 @@ ACE_Mem_Map::ACE_Mem_Map (ACE_HANDLE handle,
int prot,
int share,
void *addr,
- off_t pos,
+ off_t offset,
LPSECURITY_ATTRIBUTES sa)
: base_addr_ (MAP_FAILED),
length_ (0),
@@ -251,7 +256,7 @@ ACE_Mem_Map::ACE_Mem_Map (ACE_HANDLE handle,
prot,
share,
addr,
- pos,
+ offset,
sa) < 0)
ACE_ERROR ((LM_ERROR,
ASYS_TEXT ("%p\n"),
diff --git a/ace/Mem_Map.h b/ace/Mem_Map.h
index f08578d8f64..2dfbfce7c15 100644
--- a/ace/Mem_Map.h
+++ b/ace/Mem_Map.h
@@ -38,7 +38,7 @@ public:
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t pos = 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.
@@ -50,7 +50,7 @@ public:
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t pos = 0,
+ off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
// Map a file specified by <file_name>.
@@ -59,7 +59,7 @@ public:
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t pos = 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.
@@ -68,7 +68,7 @@ public:
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t pos = 0,
+ off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
// Remap the file associated with <handle_>.
@@ -79,7 +79,7 @@ public:
int prot = PROT_RDWR,
int share = ACE_MAP_PRIVATE,
void *addr = 0,
- off_t pos = 0,
+ off_t offset = 0,
LPSECURITY_ATTRIBUTES sa = 0);
// Map a file specified by <filename>.
@@ -186,7 +186,7 @@ private:
int prot = PROT_RDWR,
int share = MAP_SHARED,
void *addr = 0,
- off_t pos = 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.
diff --git a/ace/Mem_Map.i b/ace/Mem_Map.i
index b2788267f04..5e07e856627 100644
--- a/ace/Mem_Map.i
+++ b/ace/Mem_Map.i
@@ -22,11 +22,11 @@ ACE_Mem_Map::map (ACE_HANDLE handle,
int prot,
int share,
void *addr,
- off_t pos,
+ off_t offset,
LPSECURITY_ATTRIBUTES sa)
{
ACE_TRACE ("ACE_Mem_Map::map");
- return this->map_it (handle, len, prot, share, addr, pos, sa);
+ return this->map_it (handle, len, prot, share, addr, offset, sa);
}
// Remap the file associated with <this->handle_>.
@@ -36,12 +36,12 @@ ACE_Mem_Map::map (int len,
int prot,
int share,
void *addr,
- off_t pos,
+ off_t offset,
LPSECURITY_ATTRIBUTES sa)
{
ACE_TRACE ("ACE_Mem_Map::map");
return this->map_it (this->handle (), len, prot,
- share, addr, pos, sa);
+ share, addr, offset, sa);
}
// This operator passes back the starting address of the mapped file.