summaryrefslogtreecommitdiff
path: root/ACE/ace/Mem_Map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/Mem_Map.cpp')
-rw-r--r--ACE/ace/Mem_Map.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/ACE/ace/Mem_Map.cpp b/ACE/ace/Mem_Map.cpp
index 0f8775018c4..d2bc4102ce6 100644
--- a/ACE/ace/Mem_Map.cpp
+++ b/ACE/ace/Mem_Map.cpp
@@ -13,12 +13,49 @@
#include "ace/Log_Msg.h"
#include "ace/Truncate.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 */
+
ACE_RCSID(ace, Mem_Map, "Mem_Map.cpp,v 4.39 2003/11/01 11:15:13 dhinton Exp")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
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
@@ -141,6 +178,31 @@ ACE_Mem_Map::map_it (ACE_HANDLE handle,
return -1;
}
+#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,