From ac1cab88f6e43ece947ef2e212f0a732f9c39d81 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Mon, 1 Mar 2004 09:58:44 +0000 Subject: auth/ 2003-08-17 Marcus Brinkmann * auth.c: Include . (pending_users, pending_server): Change type to struct hurd_ihash, initialize with HURD_IHASH_INITIALIZER. (struct pending): Change type of member LOCP to hurd_ihash_locp_t. (S_auth_user_authenticate): Use hurd_ihash_* functions instead ihash_*. (S_auth_server_authenticate): Likewise. (main): Do not allocate the hash tables. console-client/ 2003-08-17 Marcus Brinkmann * vga-dynafont.c: Include . (struct mapped_character): Change type of LOCP to hurd_ihash_locp_t. (struct dynafont): Change type of CHARMAP to struct hurd_ihash. (dynafont_new): Use hurd_ihash_init instead of ihash_create. Remove variable ERR. Call hurd_ihash_add instead of ihash_add. (dynafont_free): Call hurd_ihash_destroy, no ihash_free. (dynafont_lookup_internal): Use hurd_ihash_find, not ihash_find. (dynafont_lookup_internal): Call hurd_ihash_locp_remove instead ihash_locp_remove, and hurd_ihash_add instead ihash_add. (dynafont_change_font): Likewise. Clean out LOCP if character is unmapped. ftpfs/ 2003-08-17 Marcus Brinkmann * ftpfs.h: Include . (struct ftpfs): Change type of INODE_MAPPINGS to struct hurd_ihash. (struct ftpfs_dir_entry): Change type of INODE_LOCP to hurd_ihash_locp_t. * node.c (ftpfs_create_node): Call hurd_ihash_add, not ihash_add. (netfs_node_norefs): Call hurd_ihash_locp_remove, not ihash_locp_remove. * fs.c: Include . (ftpfs_create): Call hurd_ihash_init, not hurd_ihash_create. Call hurd_ihash_destroy on error. libihash/ 2003-08-17 Marcus Brinkmann * ihash.c: Rewritten. * ihash.h: Rewritten. * Makefile (SRCS): Remove sizes.c. (LCLHDRS): Remove priv.h. * primes.c, sizes.c, priv.h: Files removed. 2003-08-17 Marcus Brinkmann * 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 . (ports_create_bucket): Use hurd_ihash_init instead hurd_ihash_create. * class-iterate.c: Do not include . * 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. libps/ 2003-08-17 Marcus Brinkmann * ps.h (struct ps_context): Change type of members procs, ttys, ttys_by_cttyid and users to struct hurd_ihash. * context.c (ps_context_create): Remove variables err_procs, err_ttys, err_ttys_by_cttyid and err_users. Use hurd_ihash_init instead of ihash_create. Call hurd_ihash_set_cleanup and the hurd_ihash_cleanup_t type instead of ihash_set_cleanup. (ps_context_free): Call hurd_ihash_destroy instead of ihash_free. (lookup): Call hurd_ihash_find instead ihash_find, hurd_ihash_add instead ihash_add. (ps_context_find_proc_stat): Take pointer of hash object. (ps_context_find_tty): Likewise. (ps_context_find_tty_by_cttyid): Likewise. (ps_context_find_user): Likewise. libpthread/ 2003-08-17 Marcus Brinkmann * sysdeps/hurd/pt-key.h (PTHREAD_KEY_MEMBERS): Change type of THREAD_SPECIFICS to hurd_ihash_t. * sysdeps/hurd/pt-setspecific.c (pthread_setspecific): Call hurd_ihash_create instead ihash_create, and hurd_ihash_add instead ihash_add. * sysdeps/hurd/pt-getspecific.c (pthread_getspecific): Call hurd_ihash_find instead of ihash_find. * sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific): Call hurd_ihash_find instead of ihash_find, hurd_ihash_remove instead of ihash_remove, and hurd_ihash_free instead of ihash_free. proc/ 2003-08-17 Marcus Brinkmann * proc.h: Include . (struct proc): Change type of members p_pidhashloc and p_taskhashloc to hurd_ihash_locp_t. (struct pgrp): Likewise for pg_hashloc. (struct session): Likewise for s_hashloc. * hash.c: Change type of pghash, pidhash, taskhash and sidhash to struct hurd_ihash and initialize them with HURD_IHASH_INITIALIZER. Include stddef.h. (pid_find): Call hurd_ihash_find instead ihash_find. (pid_find_allow_zombie): Likewise. (task_find): Likewise. (task_find_nocreate): Likewise. (pgrp_find): Likewise. (session_find): Likewise. (add_proc_to_hash): Call hurd_ihash_add instead ihash_add. (add_pgrp_to_hash): Likewise. (add_session_to_hash): Likewise. (remove_pgrp_from_hash): Call hurd_ihash_locp_remove instead ihash_locp_remove, and provide hash table pointer. (remove_proc_from_hash): Likewise. (remove_session_from_hash): Likewise. (prociterate): Use HURD_IHASH_ITERATE instead ihash_iterate. trans/ 2003-08-17 Marcus Brinkmann * fakeroot.c: Include . (struct netnode): Change type of member idport_locp to hurd_ihash_locp_t. (idport_ihash): Change type to struct hurd_ihash and initialize with HURD_IHASH_INITIALIZER. (new_node): Call hurd_ihash_add instead of ihash_add. (netfs_node_norefs): Call hrd_ihash_locp_remove instead ihash_locp_remove. (netfs_S_dir_lookup): Call hurd_ihash_find instead ihash_find. utils/ 2003-08-17 Marcus Brinkmann * rpctrace.c: Include . (struct traced_info): Change type of LOCP to hurd_ihash_locp_t. (msgid_ihash): Change type to struct hurd_ihash, and initialize with HURD_IHASH_INITIALIZER, don't set cleanup here. (traced_names): Likewise. (main): Call hurd_ihash_set_cleanup for msgid_ihash. Don't create traced_names. (parse_msgid_list): Call hurd_ihash_add instead ihash_add. (new_send_wrapper): Likewise. (msgid_info): Likewise. Call hurd_ihash_find instead ihash_find. (rewrite_right): Likewise. (traced_dropweak): Call hurd_ihash_locp_remove instead ihash_locp_remove. --- libports/ChangeLog | 30 ++++++++++++++++++++++++++++++ libports/bucket-iterate.c | 9 +++------ libports/claim-right.c | 2 +- libports/class-iterate.c | 1 - libports/complete-deallocate.c | 2 +- libports/create-bucket.c | 14 +++----------- libports/create-internal.c | 2 +- libports/destroy-right.c | 2 +- libports/import-port.c | 2 +- libports/inhibit-all-rpcs.c | 31 +++++++++++++++---------------- libports/inhibit-bucket-rpcs.c | 6 ++---- libports/lookup-port.c | 4 ++-- libports/ports.h | 5 +++-- libports/reallocate-from-external.c | 6 +++--- libports/reallocate-port.c | 6 +++--- libports/transfer-right.c | 8 ++++---- 16 files changed, 73 insertions(+), 57 deletions(-) (limited to 'libports') 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 + + * 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 . + (ports_create_bucket): Use hurd_ihash_init instead hurd_ihash_create. + * class-iterate.c: Do not include . + * 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 * 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 -#include 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 #include #include #include @@ -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 #include #include +#include #include /* 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, -- cgit v1.2.3