diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2001-05-01 11:50:55 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2001-05-01 11:50:55 +0000 |
commit | 402d491fe4aac4dd88fdf6bc131339e6be668fb8 (patch) | |
tree | 84d8c1b7562d5557326c45bc62554865db1418b1 /ace | |
parent | 664bf6221d1924dc44ad3a5c84c70de5ef4441a3 (diff) | |
download | ATCD-402d491fe4aac4dd88fdf6bc131339e6be668fb8.tar.gz |
ChangeLogTag:Tue May 1 06:15:26 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Hash_Map_Manager_T.h | 2 | ||||
-rw-r--r-- | ace/Local_Name_Space_T.cpp | 5 | ||||
-rw-r--r-- | ace/Mem_Map.cpp | 79 | ||||
-rw-r--r-- | ace/OS.h | 3 | ||||
-rw-r--r-- | ace/OS.i | 45 | ||||
-rw-r--r-- | ace/ace_wchar.h | 6 |
6 files changed, 114 insertions, 26 deletions
diff --git a/ace/Hash_Map_Manager_T.h b/ace/Hash_Map_Manager_T.h index a1b24bf3d77..7b721f3c365 100644 --- a/ace/Hash_Map_Manager_T.h +++ b/ace/Hash_Map_Manager_T.h @@ -144,7 +144,7 @@ public: /// Removes all the entries in <Map_Manager_Ex>. int unbind_all (void); - /// Initialize a <Hash_Map_Manager_Ex> with size <length>. + /// Cleanup the <Hash_Map_Manager_Ex>. ~ACE_Hash_Map_Manager_Ex (void); /** diff --git a/ace/Local_Name_Space_T.cpp b/ace/Local_Name_Space_T.cpp index eb049870012..a341a4b9c41 100644 --- a/ace/Local_Name_Space_T.cpp +++ b/ace/Local_Name_Space_T.cpp @@ -404,12 +404,7 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager_i (void) ACE_OS::strcat (this->context_file_, database); #if !defined (CHORUS) -# if defined(ACE_WIN32) && \ - (!defined(ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0)) - ACE_MEM_POOL_OPTIONS options (this->name_options_->base_address (), 0); -# else ACE_MEM_POOL_OPTIONS options (this->name_options_->base_address ()); -# endif /* !ACE_HAS_WINNT4 */ #else // Use base address == 0, don't use a fixed address. ACE_MEM_POOL_OPTIONS options (0, diff --git a/ace/Mem_Map.cpp b/ace/Mem_Map.cpp index 965f2f69216..7604d8a9b47 100644 --- a/ace/Mem_Map.cpp +++ b/ace/Mem_Map.cpp @@ -5,6 +5,15 @@ #include "ace/Mem_Map.h" #include "ace/Log_Msg.h" +#if defined (ACE_WIN32) \ + && (!defined(ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0)) +# define ACE_USE_MAPPING_NAME 1 +#endif /* ACE_WIN32 */ + +#if defined (ACE_USE_MAPPING_NAME) +#include "ace/SString.h" +#endif /* ACE_USE_MAPPING_NAME */ + #if !defined (__ACE_INLINE__) #include "ace/Mem_Map.i" #endif /* __ACE_INLINE__ */ @@ -13,6 +22,35 @@ ACE_RCSID(ace, Mem_Map, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Mem_Map) +#if defined (ACE_USE_MAPPING_NAME) +// Gets a mapping object name from a file name. TODO: The file name +// is used as the key to the mapping. We should try to avoid mapping +// the same object name to different files (there is a mapping object +// name length limitation). + +static void +to_mapping_name (ACE_TCHAR *mapobjname, + const ACE_TCHAR *filename, + size_t len) +{ + --len; + size_t i = 0; + + while (*filename && i < len) + { + if (*filename == ACE_LIB_TEXT ('\\')) + // Can't use backslash in mapping object name. + mapobjname[i] = ACE_LIB_TEXT ('.'); + else + mapobjname[i] = *filename; + ++filename; + ++i; + } + + mapobjname[i] = 0; +} +#endif /* ACE_USE_MAPPING_NAME */ + void ACE_Mem_Map::dump (void) const { @@ -157,14 +195,39 @@ ACE_Mem_Map::map_it (ACE_HANDLE handle, write_enabled_ = ACE_BIT_ENABLED (prot, PROT_WRITE); #endif /* __Lynx__ */ - this->base_addr_ = ACE_OS::mmap (this->base_addr_, - this->length_, - prot, - share, - this->handle_, - offset, - &this->file_mapping_, - sa); +#if defined (ACE_USE_MAPPING_NAME) + if (ACE_BIT_ENABLED (share, MAP_SHARED)) + { +# if defined(__MINGW32__) + const int max_mapping_name_length = 32; +# else + const int max_mapping_name_length = 31; +# endif /* __MINGW32__ */ + ACE_TCHAR file_mapping_name[max_mapping_name_length + 1]; + to_mapping_name (file_mapping_name, + filename_, + max_mapping_name_length + 1); + + this->base_addr_ = ACE_OS::mmap (this->base_addr_, + this->length_, + prot, + share, + this->handle_, + offset, + &this->file_mapping_, + sa, + file_mapping_name); + } + else +#endif /* ACE_USE_MAPPING_NAME */ + this->base_addr_ = ACE_OS::mmap (this->base_addr_, + this->length_, + prot, + share, + this->handle_, + offset, + &this->file_mapping_, + sa); return this->base_addr_ == MAP_FAILED ? -1 : 0; } @@ -5732,7 +5732,8 @@ public: ACE_HANDLE handle, off_t off = 0, ACE_HANDLE *file_mapping = 0, - LPSECURITY_ATTRIBUTES sa = 0); + LPSECURITY_ATTRIBUTES sa = 0, + const ACE_TCHAR *file_mapping_name = 0); static int mprotect (void *addr, size_t len, int prot); @@ -3226,9 +3226,14 @@ ACE_OS::mmap (void *addr, ACE_HANDLE file_handle, off_t off, ACE_HANDLE *file_mapping, - LPSECURITY_ATTRIBUTES sa) + LPSECURITY_ATTRIBUTES sa, + const ACE_TCHAR *file_mapping_name) { ACE_OS_TRACE ("ACE_OS::mmap"); +#if !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) + ACE_UNUSED_ARG (file_mapping_name); +#endif /* !defined (ACE_WIN32) || defined (ACE_HAS_PHARLAP) */ + #if defined (ACE_HAS_PACE) && !defined (__Lynx__) && !defined (ACE_WIN32) ACE_UNUSED_ARG (file_mapping); ACE_UNUSED_ARG (sa); @@ -3263,12 +3268,38 @@ ACE_OS::mmap (void *addr, // Only create a new handle if we didn't have a valid one passed in. if (*file_mapping == ACE_INVALID_HANDLE) - *file_mapping = ::CreateFileMapping (file_handle, - ACE_OS::default_win32_security_attributes (sa), - prot, - 0, - 0, - 0); + { +#if !defined (ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0) + int try_create = 1; + if (file_mapping_name != 0) + { + // On Win9x, we first try to OpenFileMapping to + // file_mapping_name. Only if there is no mapping object + // with that name we try CreateFileMapping. + + *file_mapping = ACE_TEXT_OpenFileMapping (nt_flags, + 0, + file_mapping_name); + if (*file_mapping != 0 + || ::GetLastError () != ERROR_INVALID_NAME) + try_create = 0; + } + + if (try_create) +#endif /* (ACE_HAS_WINNT4) || (ACE_HAS_WINNT4 == 0) */ + { + const LPSECURITY_ATTRIBUTES attr = + ACE_OS::default_win32_security_attributes (sa); + + *file_mapping = ACE_TEXT_CreateFileMapping (file_handle, + attr, + prot, + 0, + 0, + file_mapping_name); + } + } + if (*file_mapping == 0) ACE_FAIL_RETURN (MAP_FAILED); diff --git a/ace/ace_wchar.h b/ace/ace_wchar.h index 2e46e5531ca..ee4cb770be6 100644 --- a/ace/ace_wchar.h +++ b/ace/ace_wchar.h @@ -85,11 +85,7 @@ using std::size_t; // Define the unicode/wchar related macros correctly # if !defined (ACE_TEXT_WIDE) -# if defined (VXWORKS) -# define ACE_TEXT_WIDE_I(STRING) STRING -# else /* VXWORKS */ # define ACE_TEXT_WIDE_I(STRING) L##STRING -#endif /* VXWORKS */ # define ACE_TEXT_WIDE(STRING) ACE_TEXT_WIDE_I (STRING) # endif /* ACE_TEXT_WIDE */ @@ -219,6 +215,7 @@ typedef ACE_Wide_To_Ascii ACE_OS_WString; #define ACE_TEXT_GetUserName ::GetUserNameW #define ACE_TEXT_LoadLibrary ::LoadLibraryW #define ACE_TEXT_MoveFileEx ::MoveFileExW +#define ACE_TEXT_OpenFileMapping ::OpenFileMappingW #define ACE_TEXT_OpenSCManager ::OpenSCManagerW #define ACE_TEXT_OpenService ::OpenServiceW #define ACE_TEXT_RegisterEventSource ::RegisterEventSourceW @@ -263,6 +260,7 @@ typedef ACE_Wide_To_Ascii ACE_OS_WString; #define ACE_TEXT_GetUserName ::GetUserNameA #define ACE_TEXT_LoadLibrary ::LoadLibraryA #define ACE_TEXT_MoveFileEx ::MoveFileExA +#define ACE_TEXT_OpenFileMapping ::OpenFileMappingA #define ACE_TEXT_OpenSCManager ::OpenSCManagerA #define ACE_TEXT_OpenService ::OpenServiceA #define ACE_TEXT_RegisterEventSource ::RegisterEventSourceA |