Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-02-09 00:02:36 +0300
committerCorinna Vinschen <corinna@vinschen.de>2001-02-09 00:02:36 +0300
commitdb49d0b5300479a392dee7129049b387f0a7895c (patch)
tree966f1fc5f46311f23c1ba45a1ba05d7c7c2f2ab5
parentdf7e8957fd6f1db7b9cb64960b3837909977b1b7 (diff)
* mmap.cc (class list): Add member `hash'.
(list::list): Initialize `hash'. (list::get_list_by_fd): Use filepath hash value to get the correct mapping list if it's not an anonymous mapping. (map::add_list): Initialize `hash' with filepath hash value. (mmap): Check for reusing a mapping only on MAP_SHARED.
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/mmap.cc24
2 files changed, 25 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 3c3efec77..1fa4e2ccc 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,12 @@
+Thu Feb 8 21:57:00 2001 Corinna Vinschen <corinna@vinschen.de>
+
+ * mmap.cc (class list): Add member `hash'.
+ (list::list): Initialize `hash'.
+ (list::get_list_by_fd): Use filepath hash value to get the correct
+ mapping list if it's not an anonymous mapping.
+ (map::add_list): Initialize `hash' with filepath hash value.
+ (mmap): Check for reusing a mapping only on MAP_SHARED.
+
Wed Feb 7 18:47:36 2001 Christopher Faylor <cgf@cygnus.com>
* signal.cc (killpg): Correct first argument.
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index afb348e71..e2eab3e06 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -204,6 +204,7 @@ public:
mmap_record *recs;
int nrecs, maxrecs;
int fd;
+ DWORD hash;
list ();
~list ();
mmap_record *add_record (mmap_record r);
@@ -213,11 +214,9 @@ public:
};
list::list ()
+: nrecs (0), maxrecs (10), fd (0), hash (0)
{
recs = (mmap_record *) malloc (10 * sizeof(mmap_record));
- nrecs = 0;
- maxrecs = 10;
- fd = 0;
}
list::~list ()
@@ -309,7 +308,13 @@ map::get_list_by_fd (int fd)
{
int i;
for (i=0; i<nlists; i++)
- if (lists[i]->fd == fd)
+#if 0 /* The fd isn't sufficient since it could already be another file. */
+ if (lists[i]->fd == fd
+#else /* so we use the name hash value to identify the file unless
+ it's not an anonymous mapping. */
+ if ((fd == -1 && lists[i]->fd == -1)
+ || lists[i]->hash == fdtab[fd]->get_namehash ())
+#endif
return lists[i];
return 0;
}
@@ -318,6 +323,8 @@ list *
map::add_list (list *l, int fd)
{
l->fd = fd;
+ if (fd != -1)
+ l->hash = fdtab[fd]->get_namehash ();
if (nlists == maxlists)
{
maxlists += 5;
@@ -445,14 +452,15 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
fh = &fh_paging_file;
}
- /* First check if this mapping matches into the chunk of another
- already performed mapping. */
list *l = mmapped_areas->get_list_by_fd (fd);
- if (l)
+
+ /* First check if this mapping matches into the chunk of another
+ already performed mapping. Only for MAP_SHARED mapping. */
+ if (l && (flags & MAP_SHARED))
{
mmap_record *rec;
if ((rec = l->match (off, len)) != NULL)
- {
+ {
off = rec->map_map (off, len);
caddr_t ret = rec->get_address () + off;
syscall_printf ("%x = mmap() succeeded", ret);