summaryrefslogtreecommitdiff
path: root/libhurd-mm/anonymous.c
diff options
context:
space:
mode:
authorneal <neal>2007-12-12 13:51:04 +0000
committerneal <neal>2007-12-12 13:51:04 +0000
commit246a3d16754c65191a86363b951883716de7b889 (patch)
treee1760f07a4a864639db2a6f6dff91aa23716fc62 /libhurd-mm/anonymous.c
parent124d44222a82eee2b97fcc06f55df23b9a27f1f5 (diff)
2007-12-12 Neal H. Walfield <neal@gnu.org>
* mmap.c (munmap): Implement. * pager.h (pager_destroy_t): New type. (struct pager): New field, destory. (pagers): New declaration. * pager.c (pagers): Remove static qualifier. * anonymous.c (destroy): New function. (anonymous_pager_alloc): Set ANON->PAGER.DESTROY to it. (anonymous_pager_destroy): Call destroy to do the bulk of the work.
Diffstat (limited to 'libhurd-mm/anonymous.c')
-rw-r--r--libhurd-mm/anonymous.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/libhurd-mm/anonymous.c b/libhurd-mm/anonymous.c
index 4ab6973..103cdef 100644
--- a/libhurd-mm/anonymous.c
+++ b/libhurd-mm/anonymous.c
@@ -185,6 +185,30 @@ fault (struct pager *pager,
return true;
}
+static void
+destroy (struct pager *pager)
+{
+ struct anonymous_pager *anon = (struct anonymous_pager *) pager;
+
+ /* Free the allocated storage. */
+ hurd_btree_storage_desc_t *storage_descs;
+ storage_descs = (hurd_btree_storage_desc_t *) &anon->storage;
+
+ struct storage_desc *node, *next;
+ for (node = hurd_btree_storage_desc_first (storage_descs); node; node = next)
+ {
+ next = hurd_btree_storage_desc_next (node);
+
+ storage_free (node->storage, false);
+ storage_desc_free (node);
+ }
+
+ /* There is no need to unlock &anon->pager.lock: we free it. */
+
+ /* And free its storage. */
+ hurd_slab_dealloc (&anonymous_pager_slab, anon);
+}
+
struct anonymous_pager *
anonymous_pager_alloc (addr_t activity,
uintptr_t addr, size_t size,
@@ -201,6 +225,7 @@ anonymous_pager_alloc (addr_t activity,
memset (anon, 0, sizeof (*anon));
anon->pager.fault = fault;
+ anon->pager.destroy = destroy;
anon->activity = activity;
anon->flags = flags;
@@ -229,29 +254,9 @@ void
anonymous_pager_destroy (struct anonymous_pager *anon)
{
ss_mutex_lock (&pagers_lock);
-
- /* Deinstall the pager. */
pager_deinstall (&anon->pager);
-
ss_mutex_unlock (&pagers_lock);
ss_mutex_lock (&anon->pager.lock);
-
- /* Free the allocated storage. */
- hurd_btree_storage_desc_t *storage_descs;
- storage_descs = (hurd_btree_storage_desc_t *) &anon->storage;
-
- struct storage_desc *node, *next;
- for (node = hurd_btree_storage_desc_first (storage_descs); node; node = next)
- {
- next = hurd_btree_storage_desc_next (node);
-
- storage_free (node->storage, false);
- storage_desc_free (node);
- }
-
- /* There is no need to unlock &anon->pager.lock: we free it. */
-
- /* And free its storage. */
- hurd_slab_dealloc (&anonymous_pager_slab, anon);
+ destroy (&anon->pager);
}