summaryrefslogtreecommitdiff
path: root/libports
diff options
context:
space:
mode:
Diffstat (limited to 'libports')
-rw-r--r--libports/ChangeLog30
-rw-r--r--libports/bucket-iterate.c9
-rw-r--r--libports/claim-right.c2
-rw-r--r--libports/class-iterate.c1
-rw-r--r--libports/complete-deallocate.c2
-rw-r--r--libports/create-bucket.c14
-rw-r--r--libports/create-internal.c2
-rw-r--r--libports/destroy-right.c2
-rw-r--r--libports/import-port.c2
-rw-r--r--libports/inhibit-all-rpcs.c31
-rw-r--r--libports/inhibit-bucket-rpcs.c6
-rw-r--r--libports/lookup-port.c4
-rw-r--r--libports/ports.h5
-rw-r--r--libports/reallocate-from-external.c6
-rw-r--r--libports/reallocate-port.c6
-rw-r--r--libports/transfer-right.c8
16 files changed, 73 insertions, 57 deletions
diff --git a/libports/ChangeLog b/libports/ChangeLog
index b6d1d054..e650d158 100644
--- a/libports/ChangeLog
+++ b/libports/ChangeLog
@@ -1,3 +1,33 @@
+2003-08-17 Marcus Brinkmann <marcus@gnu.org>
+
+ * ports.h (struct port_bucket): Change type of HTABLE to struct
+ hurd_ihash.
+ (struct port_info): Change type of HENTRY to hurd_ihash_locp_t.
+ * lookup-port.c (ports_lookup_port): Use hurd_ihash_find instead
+ ihash_find.
+ * bucket-iterate.c (_ports_bucket_class_iterate): Use
+ HURD_IHASH_ITERATE instead ihash_iterate.
+ * inhibit-all-rpcs.c (ports_inhibit_all_rpcs): Likewise.
+ * inhibit-bucket-rpcs.c (ports_inhibit_bucket_rpcs): Likewise.
+ * create-internal.c (_ports_create_port_internal): Use
+ hurd_ihash_add instead ihash_add.
+ * import-port.c (ports_import_port): Likewise.
+ * reallocate-from-external.c (ports_reallocate_from_external):
+ Likewise.
+ * reallocate-port.c (ports_reallocate_port): Likewise.
+ * transfer-right.c (ports_transfer_right): Likewise.
+ * create-bucket.c: Include <stddef.h>.
+ (ports_create_bucket): Use hurd_ihash_init instead hurd_ihash_create.
+ * class-iterate.c: Do not include <hurd/ihash.h>.
+ * claim-right.c (ports_claim_right): Call hurd_ihash_locp_remove
+ instead ihash_locp_remove.
+ * complete-deallocate.c (_ports_complete_deallocate): Likewise.
+ * destroy-right.c (ports_destroy_right): Likewise.
+ * reallocate-from-external.c (ports_reallocate_from_external):
+ Likewise.
+ * reallocate-port.c (ports_reallocate_port): Likewise.
+ * transfer-right.c (ports_transfer_right): Likewise.
+
2001-03-29 Neal H Walfield <neal@cs.uml.edu>
* claim-right.c (ports_claim_right): Include errno.h and
diff --git a/libports/bucket-iterate.c b/libports/bucket-iterate.c
index 1bfd73e3..d376e6f8 100644
--- a/libports/bucket-iterate.c
+++ b/libports/bucket-iterate.c
@@ -30,7 +30,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket,
struct port_class *class,
error_t (*fun)(void *))
{
- /* This is obsecenely ineffecient. ihash and ports need to cooperate
+ /* This is obscenely ineffecient. ihash and ports need to cooperate
more closely to do it effeciently. */
struct item
{
@@ -40,7 +40,8 @@ _ports_bucket_class_iterate (struct port_bucket *bucket,
struct item *i, *nxt;
error_t err;
- error_t enqueue (void *arg)
+ mutex_lock (&_ports_lock);
+ HURD_IHASH_ITERATE (&bucket->htable, arg)
{
struct port_info *const pi = arg;
struct item *j;
@@ -53,11 +54,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket,
list = j;
pi->refcnt++;
}
- return 0;
}
-
- mutex_lock (&_ports_lock);
- ihash_iterate (bucket->htable, enqueue);
mutex_unlock (&_ports_lock);
err = 0;
diff --git a/libports/claim-right.c b/libports/claim-right.c
index 9986ba2e..aef53bb7 100644
--- a/libports/claim-right.c
+++ b/libports/claim-right.c
@@ -35,7 +35,7 @@ ports_claim_right (void *portstruct)
return ret;
mutex_lock (&_ports_lock);
- ihash_locp_remove (pi->bucket->htable, pi->hentry);
+ hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry);
err = mach_port_move_member (mach_task_self (), ret, MACH_PORT_NULL);
assert_perror (err);
pi->port_right = MACH_PORT_NULL;
diff --git a/libports/class-iterate.c b/libports/class-iterate.c
index 1e349497..e2a15173 100644
--- a/libports/class-iterate.c
+++ b/libports/class-iterate.c
@@ -19,7 +19,6 @@
#include "ports.h"
#include <cthreads.h>
-#include <hurd/ihash.h>
error_t
ports_class_iterate (struct port_class *class,
diff --git a/libports/complete-deallocate.c b/libports/complete-deallocate.c
index a94ab171..52e8f17b 100644
--- a/libports/complete-deallocate.c
+++ b/libports/complete-deallocate.c
@@ -30,7 +30,7 @@ _ports_complete_deallocate (struct port_info *pi)
if (pi->port_right)
{
- ihash_locp_remove (pi->bucket->htable, pi->hentry);
+ hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry);
mach_port_mod_refs (mach_task_self (), pi->port_right,
MACH_PORT_RIGHT_RECEIVE, -1);
pi->port_right = MACH_PORT_NULL;
diff --git a/libports/create-bucket.c b/libports/create-bucket.c
index 9e25ab60..6be4bcad 100644
--- a/libports/create-bucket.c
+++ b/libports/create-bucket.c
@@ -1,5 +1,5 @@
/* Create a port bucket
- Copyright (C) 1995, 1997, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1997, 2001, 2003 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ports.h"
+#include <stddef.h>
#include <errno.h>
#include <stdlib.h>
#include <hurd/ihash.h>
@@ -46,16 +47,7 @@ ports_create_bucket ()
return NULL;
}
- err = ihash_create (&ret->htable);
- if (err)
- {
- errno = err;
- mach_port_mod_refs (mach_task_self (), ret->portset,
- MACH_PORT_RIGHT_PORT_SET, -1);
- free (ret);
- return NULL;
- }
-
+ hurd_ihash_init (&ret->htable, offsetof (struct port_info, hentry));
ret->rpcs = ret->flags = ret->count = 0;
mutex_lock (&_ports_lock);
diff --git a/libports/create-internal.c b/libports/create-internal.c
index b50212ea..5db71129 100644
--- a/libports/create-internal.c
+++ b/libports/create-internal.c
@@ -82,7 +82,7 @@ _ports_create_port_internal (struct port_class *class,
goto loop;
}
- err = ihash_add (bucket->htable, port, pi, &pi->hentry);
+ err = hurd_ihash_add (&bucket->htable, port, pi);
if (err)
goto lose;
diff --git a/libports/destroy-right.c b/libports/destroy-right.c
index 32085c80..327029a8 100644
--- a/libports/destroy-right.c
+++ b/libports/destroy-right.c
@@ -32,7 +32,7 @@ ports_destroy_right (void *portstruct)
if (pi->port_right != MACH_PORT_NULL)
{
mutex_lock (&_ports_lock);
- ihash_locp_remove (pi->bucket->htable, pi->hentry);
+ hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry);
err = mach_port_mod_refs (mach_task_self (), pi->port_right,
MACH_PORT_RIGHT_RECEIVE, -1);
assert_perror (err);
diff --git a/libports/import-port.c b/libports/import-port.c
index b958245f..d7a62960 100644
--- a/libports/import-port.c
+++ b/libports/import-port.c
@@ -76,7 +76,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket,
goto loop;
}
- err = ihash_add (bucket->htable, port, pi, &pi->hentry);
+ err = hurd_ihash_add (&bucket->htable, port, pi);
if (err)
goto lose;
diff --git a/libports/inhibit-all-rpcs.c b/libports/inhibit-all-rpcs.c
index 9efb3c2f..9a72f83e 100644
--- a/libports/inhibit-all-rpcs.c
+++ b/libports/inhibit-all-rpcs.c
@@ -36,27 +36,26 @@ ports_inhibit_all_rpcs ()
{
struct port_bucket *bucket;
int this_one = 0;
- error_t interruptor (void *portstruct)
- {
- struct rpc_info *rpc;
- struct port_info *pi = portstruct;
- for (rpc = pi->current_rpcs; rpc; rpc = rpc->next)
+ for (bucket = _ports_all_buckets; bucket; bucket = bucket->next)
+ {
+ HURD_IHASH_ITERATE (&bucket->htable, portstruct)
{
- /* Avoid cancelling the calling thread if it's currently
- handling a RPC. */
- if (rpc->thread == hurd_thread_self ())
- this_one = 1;
- else
- hurd_thread_cancel (rpc->thread);
+ struct rpc_info *rpc;
+ struct port_info *pi = portstruct;
+
+ for (rpc = pi->current_rpcs; rpc; rpc = rpc->next)
+ {
+ /* Avoid cancelling the calling thread if it's currently
+ handling a RPC. */
+ if (rpc->thread == hurd_thread_self ())
+ this_one = 1;
+ else
+ hurd_thread_cancel (rpc->thread);
+ }
}
-
- return 0;
}
- for (bucket = _ports_all_buckets; bucket; bucket = bucket->next)
- ihash_iterate (bucket->htable, interruptor);
-
while (_ports_total_rpcs > this_one)
{
_ports_flags |= _PORTS_INHIBIT_WAIT;
diff --git a/libports/inhibit-bucket-rpcs.c b/libports/inhibit-bucket-rpcs.c
index 06af9c60..7fc55d31 100644
--- a/libports/inhibit-bucket-rpcs.c
+++ b/libports/inhibit-bucket-rpcs.c
@@ -35,7 +35,8 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket)
else
{
int this_one = 0;
- error_t interruptor (void *portstruct)
+
+ HURD_IHASH_ITERATE (&bucket->htable, portstruct)
{
struct rpc_info *rpc;
struct port_info *pi = portstruct;
@@ -48,11 +49,8 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket)
else
hurd_thread_cancel (rpc->thread);
}
-
- return 0;
}
- ihash_iterate (bucket->htable, interruptor);
while (bucket->rpcs > this_one)
{
diff --git a/libports/lookup-port.c b/libports/lookup-port.c
index d0ee8d00..8eb98a12 100644
--- a/libports/lookup-port.c
+++ b/libports/lookup-port.c
@@ -32,11 +32,11 @@ ports_lookup_port (struct port_bucket *bucket,
mutex_lock (&_ports_lock);
if (bucket)
- pi = ihash_find (bucket->htable, port);
+ pi = hurd_ihash_find (&bucket->htable, port);
else
for (bucket = _ports_all_buckets; bucket; bucket = bucket->next)
{
- pi = ihash_find (bucket->htable, port);
+ pi = hurd_ihash_find (&bucket->htable, port);
if (pi)
break;
}
diff --git a/libports/ports.h b/libports/ports.h
index 6a406ed0..9a5ccbc2 100644
--- a/libports/ports.h
+++ b/libports/ports.h
@@ -24,6 +24,7 @@
#include <mach.h>
#include <stdlib.h>
#include <hurd.h>
+#include <hurd/ihash.h>
#include <mach/notify.h>
/* These are global values for common flags used in the various structures.
@@ -45,7 +46,7 @@ struct port_info
mach_port_t port_right;
struct rpc_info *current_rpcs;
struct port_bucket *bucket;
- void **hentry;
+ hurd_ihash_locp_t hentry;
struct port_info *next, **prevp; /* links on port_class list */
};
/* FLAGS above are the following: */
@@ -57,7 +58,7 @@ struct port_info
struct port_bucket
{
mach_port_t portset;
- struct ihash *htable;
+ struct hurd_ihash htable;
int rpcs;
int flags;
int count;
diff --git a/libports/reallocate-from-external.c b/libports/reallocate-from-external.c
index 80b2905e..ebddd9f7 100644
--- a/libports/reallocate-from-external.c
+++ b/libports/reallocate-from-external.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 2003 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -44,7 +44,7 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive)
MACH_PORT_RIGHT_RECEIVE, -1);
assert_perror (err);
- ihash_locp_remove (pi->bucket->htable, pi->hentry);
+ hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry);
if ((pi->flags & PORT_HAS_SENDRIGHTS) && !stat.mps_srights)
{
@@ -61,7 +61,7 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive)
pi->cancel_threshold = 0;
pi->mscount = stat.mps_mscount;
- ihash_add (pi->bucket->htable, receive, pi, &pi->hentry);
+ hurd_ihash_add (&pi->bucket->htable, receive, pi);
mutex_unlock (&_ports_lock);
mach_port_move_member (mach_task_self (), receive, pi->bucket->portset);
diff --git a/libports/reallocate-port.c b/libports/reallocate-port.c
index bd1b1893..23898e88 100644
--- a/libports/reallocate-port.c
+++ b/libports/reallocate-port.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 2001, 2003 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -37,7 +37,7 @@ ports_reallocate_port (void *portstruct)
MACH_PORT_RIGHT_RECEIVE, -1);
assert_perror (err);
- ihash_locp_remove (pi->bucket->htable, pi->hentry);
+ hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry);
err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE,
&pi->port_right);
@@ -49,7 +49,7 @@ ports_reallocate_port (void *portstruct)
}
pi->cancel_threshold = 0;
pi->mscount = 0;
- ihash_add (pi->bucket->htable, pi->port_right, pi, &pi->hentry);
+ hurd_ihash_add (&pi->bucket->htable, pi->port_right, pi);
mutex_unlock (&_ports_lock);
err = mach_port_move_member (mach_task_self (), pi->port_right,
diff --git a/libports/transfer-right.c b/libports/transfer-right.c
index 45a6cc52..e7b0ff55 100644
--- a/libports/transfer-right.c
+++ b/libports/transfer-right.c
@@ -1,5 +1,5 @@
/* Transfer the receive right from one port structure to another
- Copyright (C) 1996 Free Software Foundation, Inc.
+ Copyright (C) 1996, 2003 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -41,7 +41,7 @@ ports_transfer_right (void *tostruct,
port = frompi->port_right;
if (port != MACH_PORT_NULL)
{
- ihash_locp_remove (frompi->bucket->htable, frompi->hentry);
+ hurd_ihash_locp_remove (&frompi->bucket->htable, frompi->hentry);
frompi->port_right = MACH_PORT_NULL;
if (frompi->flags & PORT_HAS_SENDRIGHTS)
{
@@ -54,7 +54,7 @@ ports_transfer_right (void *tostruct,
/* Destroy the existing right in TOPI. */
if (topi->port_right != MACH_PORT_NULL)
{
- ihash_locp_remove (topi->bucket->htable, topi->hentry);
+ hurd_ihash_locp_remove (&topi->bucket->htable, topi->hentry);
err = mach_port_mod_refs (mach_task_self (), topi->port_right,
MACH_PORT_RIGHT_RECEIVE, -1);
assert_perror (err);
@@ -77,7 +77,7 @@ ports_transfer_right (void *tostruct,
if (port)
{
- ihash_add (topi->bucket->htable, port, topi, &topi->hentry);
+ hurd_ihash_add (&topi->bucket->htable, port, topi);
if (topi->bucket != frompi->bucket)
{
err = mach_port_move_member (mach_task_self (), port,