diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-01-14 11:25:37 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-01-14 11:25:37 +0000 |
commit | 008cffb6a6d93c9141589d9adc8262be8ea828c3 (patch) | |
tree | f4781d0febc0e35b587f6303f99ee83381392055 | |
parent | 38a0d55c4cb136e59c64a48e03164c7def784fa5 (diff) | |
download | ATCD-008cffb6a6d93c9141589d9adc8262be8ea828c3.tar.gz |
ChangeLogTag:Sun Jan 13 18:59:37 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu>
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-02a | 7 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-03a | 7 | ||||
-rw-r--r-- | ace/Memory_Pool.cpp | 23 | ||||
-rw-r--r-- | ace/Memory_Pool.h | 27 |
5 files changed, 62 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog index 76d622d2019..279933a504f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun Jan 13 18:59:37 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu> + + * ace/Memory_Pool.{h,cpp}: Added a new option that makes is possible + to control whether or not a fixed address will be used when + remapping a memory-mapped file. Thanks to Jonathan Reis + <reis@stentor.com> for this enhancement. + Mon Jan 14 11:02:12 2002 Johnny Willemsen <jwillemsen@remedy.nl> * include/makeinclude/ace_flags.bor: diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a index 76d622d2019..279933a504f 100644 --- a/ChangeLogs/ChangeLog-02a +++ b/ChangeLogs/ChangeLog-02a @@ -1,3 +1,10 @@ +Sun Jan 13 18:59:37 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu> + + * ace/Memory_Pool.{h,cpp}: Added a new option that makes is possible + to control whether or not a fixed address will be used when + remapping a memory-mapped file. Thanks to Jonathan Reis + <reis@stentor.com> for this enhancement. + Mon Jan 14 11:02:12 2002 Johnny Willemsen <jwillemsen@remedy.nl> * include/makeinclude/ace_flags.bor: diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index 76d622d2019..279933a504f 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,10 @@ +Sun Jan 13 18:59:37 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu> + + * ace/Memory_Pool.{h,cpp}: Added a new option that makes is possible + to control whether or not a fixed address will be used when + remapping a memory-mapped file. Thanks to Jonathan Reis + <reis@stentor.com> for this enhancement. + Mon Jan 14 11:02:12 2002 Johnny Willemsen <jwillemsen@remedy.nl> * include/makeinclude/ace_flags.bor: diff --git a/ace/Memory_Pool.cpp b/ace/Memory_Pool.cpp index 5a0fe63fabe..1cc7cee6b3a 100644 --- a/ace/Memory_Pool.cpp +++ b/ace/Memory_Pool.cpp @@ -15,7 +15,7 @@ #include "ace/Based_Pointer_Repository.h" #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ -ACE_RCSID(ace, Memory_Pool, "$Id$") +ACE_RCSID(ace, Memory_Pool, "Memory_Pool.cpp,v 4.79 2001/09/02 22:33:16 schmidt Exp") ACE_ALLOC_HOOK_DEFINE(ACE_Local_Memory_Pool) @@ -153,6 +153,7 @@ ACE_MMAP_Memory_Pool::protect (void *addr, size_t len, int prot) ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool (const ACE_TCHAR *backing_store_name, const OPTIONS *options) : base_addr_ (0), + use_fixed_addr_(0), flags_ (MAP_SHARED), write_each_page_ (0), minimum_bytes_ (0), @@ -171,17 +172,18 @@ ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool (const ACE_TCHAR *backing_store_name, else // If no options are specified, default to true. guess_on_fault_ = 1; -#endif +#endif /* (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32) */ // Only change the defaults if <options> != 0. if (options) { if (options->flags_ != 0) this->flags_ = options->flags_; - if (options->use_fixed_addr_) + use_fixed_addr_ = options->use_fixed_addr_; + + if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::ALWAYS_FIXED) { - this->base_addr_ = - ACE_const_cast (void *, options->base_addr_); + this->base_addr_ = ACE_const_cast (void *, options->base_addr_); ACE_SET_BITS (flags_, MAP_FIXED); } this->write_each_page_ = options->write_each_page_; @@ -286,6 +288,11 @@ ACE_MMAP_Memory_Pool::map_file (off_t map_size) // Unmap the existing mapping. this->mmap_.unmap (); +#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1) + if(use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::NEVER_FIXED) + this->base_addr_ = 0; +#endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */ + // Remap the file. if (this->mmap_.map (map_size, PROT_RDWR, @@ -441,7 +448,7 @@ ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options (const void *base_add int guess_on_fault, LPSECURITY_ATTRIBUTES sa) : base_addr_ (base_addr), - use_fixed_addr_ (base_addr == 0 ? 0 : use_fixed_addr), + use_fixed_addr_ (use_fixed_addr), write_each_page_ (write_each_page), minimum_bytes_ (minimum_bytes), flags_ (flags), @@ -449,6 +456,10 @@ ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options (const void *base_add sa_ (sa) { ACE_TRACE ("ACE_MMAP_Memory_Pool_Options::ACE_MMAP_Memory_Pool_Options"); + // for backwards compatability + if (base_addr_ == 0 && use_fixed_addr_ == ALWAYS_FIXED) + use_fixed_addr_ = FIRSTCALL_FIXED; + // HP-UX 11, 64-bit bug workaround. #if defined (__hpux) && defined (__LP64__) long temp = ACE_DEFAULT_BASE_ADDRL; diff --git a/ace/Memory_Pool.h b/ace/Memory_Pool.h index 896887bc886..3a824cf6f12 100644 --- a/ace/Memory_Pool.h +++ b/ace/Memory_Pool.h @@ -1,11 +1,12 @@ /* -*- C++ -*- */ + //============================================================================= /** * @file Memory_Pool.h * * $Id$ * - * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> and Prashant Jain <pjain@cs.wustl.edu> + * @author Dougls C. Schmidt <schmidt@cs.wustl.edu> and Prashant Jain <pjain@cs.wustl.edu> */ //============================================================================= @@ -382,9 +383,16 @@ protected: class ACE_Export ACE_MMAP_Memory_Pool_Options { public: + enum + { + FIRSTCALL_FIXED = 0, + ALWAYS_FIXED = 1, + NEVER_FIXED = 2 + }; + // = Initialization method. ACE_MMAP_Memory_Pool_Options (const void *base_addr = ACE_DEFAULT_BASE_ADDR, - int use_fixed_addr = 1, + int use_fixed_addr = ALWAYS_FIXED, int write_each_page = 1, off_t minimum_bytes = 0, u_int flags = 0, @@ -394,7 +402,17 @@ public: /// Base address of the memory-mapped backing store. const void *base_addr_; - /// Must we use the <base_addr_> or can we let mmap(2) select it? + /** Determines whether we set <base_addr_> or if mmap(2) selects it + * FIRSTCALL_FIXED The base address from the first call to mmap + * will be used for subsequent calls to mmap + * ALWAYS_FIXED The base address specified in base_addr will be + * used in all calls to mmap. + * NEVER_FIXED The base address will be selected by the OS for + * each call to mmap. Caution should be used with + * this mode since a call that requires the backing + * store to grow may change pointers that are + * cached by the application. + */ int use_fixed_addr_; /// Should each page be written eagerly to avoid surprises later @@ -535,6 +553,9 @@ protected: */ void *base_addr_; + /// Must we use the <base_addr_> or can we let mmap(2) select it? + int use_fixed_addr_; + /// Flags passed into <ACE_OS::mmap>. int flags_; |