summaryrefslogtreecommitdiff
path: root/libhurd-mm/map.c
diff options
context:
space:
mode:
authorneal <neal>2008-06-18 13:52:29 +0000
committerneal <neal>2008-06-18 13:52:29 +0000
commitf4be7013d5e0113f73d756a4b35b657f4cec9383 (patch)
tree8284daa8f9debd9f8323b068748998f46340dd2c /libhurd-mm/map.c
parent5cd77a92a8d3b4661c35735ff8a34642a45fcb94 (diff)
2008-06-18 Neal H. Walfield <neal@gnu.org>
* mmap.c (mmap): If MAP_FIXED is specified, first unmap the region. (mmap): Don't panic if we fail to create a pager, just return MAP_FAILED. * map.h (map_destroy_t): New define. (struct map): Add field destroy. (map_create): Take additional argument destroy. * map.c (map_create): Take additional argument destroy. Set MAP->DESTROY to it. (map_destroy): Call MAP->DESTROY. If MAP->PAGER->NO_REFS is NULL, unlock MAP->PAGER->LOCK. * anonymous.c (offset_compare): Support comparing ranges. (mdestroy): New function. (destroy): Don't free ANON->MAP_AREA. (anonymous_pager_alloc): Pass mdestroy to map_create. * mprotect.c: New file. * Makefile.am (libhurd_mm_a_SOURCES): Add mprotect.c.
Diffstat (limited to 'libhurd-mm/map.c')
-rw-r--r--libhurd-mm/map.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libhurd-mm/map.c b/libhurd-mm/map.c
index 08d55ae..6ae951a 100644
--- a/libhurd-mm/map.c
+++ b/libhurd-mm/map.c
@@ -154,7 +154,8 @@ map_install (struct map *map)
struct map *
map_create (struct region region, enum map_access access,
- struct pager *pager, uintptr_t offset)
+ struct pager *pager, uintptr_t offset,
+ map_destroy_t destroy)
{
maps_lock_lock ();
ss_mutex_lock (&pager->lock);
@@ -165,6 +166,7 @@ map_create (struct region region, enum map_access access,
map->pager = pager;
map->offset = offset;
map->access = access;
+ map->destroy = destroy;
if (! map_install (map))
{
@@ -199,16 +201,23 @@ map_destroy (struct map *map)
/* Drop our reference. */
assert (map->pager->maps);
+ if (map->destroy)
+ map->destroy (map);
+
if (map->pager->maps == map && ! map->map_list_next)
/* This is the last reference. */
{
map->pager->maps = NULL;
+
if (map->pager->no_refs)
map->pager->no_refs (map->pager);
+ else
+ ss_mutex_unlock (&map->pager->lock);
}
else
{
list_unlink (map);
+
ss_mutex_unlock (&map->pager->lock);
}