summaryrefslogtreecommitdiff
path: root/ipc/ipc_space.h
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-08-16 02:18:47 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-09-14 14:45:06 +0200
commitb51f047c28142cdfb7b24641006d0afdcf399292 (patch)
tree7387a8a62833e78eb232005121b0a7d786c86c6b /ipc/ipc_space.h
parent537188a07d5ee6548555260acdd616034c73c7c4 (diff)
codify locking contracts
Conflicts: vm/vm_page.h
Diffstat (limited to 'ipc/ipc_space.h')
-rw-r--r--ipc/ipc_space.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h
index a2aac40..fcc36b0 100644
--- a/ipc/ipc_space.h
+++ b/ipc/ipc_space.h
@@ -118,6 +118,10 @@ MACRO_END
#define is_write_to_read_lock(is) lock_write_to_read(&(is)->is_lock_data)
+#define have_is_lock(is) have_lock(&(is)->is_lock_data)
+#define have_is_read_lock(is) have_read_lock(&(is)->is_lock_data)
+#define have_is_write_lock(is) have_write_lock(&(is)->is_lock_data)
+
extern void ipc_space_reference(struct ipc_space *space);
extern void ipc_space_release(struct ipc_space *space);
@@ -147,6 +151,8 @@ ipc_entry_lookup(
ipc_entry_t entry;
assert(space->is_active);
+ assert(have_is_lock(space));
+
entry = rdxtree_lookup(&space->is_map, (rdxtree_key_t) name);
if (entry != IE_NULL
&& IE_BITS_TYPE(entry->ie_bits) == MACH_PORT_TYPE_NONE)
@@ -177,6 +183,7 @@ ipc_entry_get(
ipc_entry_t free_entry;
assert(space->is_active);
+ assert(have_is_write_lock(space));
/* Get entry from the free list. */
free_entry = space->is_free_list;
@@ -233,6 +240,7 @@ ipc_entry_dealloc(
ipc_entry_t entry)
{
assert(space->is_active);
+ assert(have_is_write_lock(space));
assert(entry->ie_object == IO_NULL);
assert(entry->ie_request == 0);
@@ -267,6 +275,7 @@ ipc_reverse_insert(ipc_space_t space,
{
assert(space != IS_NULL);
assert(obj != IO_NULL);
+ assert(have_is_write_lock(space));
return (kern_return_t) rdxtree_insert(&space->is_reverse_map,
KEY(obj), entry);
}
@@ -279,6 +288,7 @@ ipc_reverse_remove(ipc_space_t space,
{
assert(space != IS_NULL);
assert(obj != IO_NULL);
+ assert(have_is_write_lock(space));
return rdxtree_remove(&space->is_reverse_map, KEY(obj));
}
@@ -288,6 +298,7 @@ static inline void
ipc_reverse_remove_all(ipc_space_t space)
{
assert(space != IS_NULL);
+ assert(have_is_write_lock(space));
rdxtree_remove_all(&space->is_reverse_map);
assert(space->is_reverse_map.height == 0);
assert(space->is_reverse_map.root == NULL);
@@ -302,6 +313,7 @@ ipc_reverse_lookup(ipc_space_t space,
{
assert(space != IS_NULL);
assert(obj != IO_NULL);
+ assert(have_is_lock(space));
return rdxtree_lookup(&space->is_reverse_map, KEY(obj));
}