diff options
Diffstat (limited to 'proc')
-rw-r--r-- | proc/ChangeLog | 25 | ||||
-rw-r--r-- | proc/hash.c | 43 | ||||
-rw-r--r-- | proc/proc.h | 9 |
3 files changed, 55 insertions, 22 deletions
diff --git a/proc/ChangeLog b/proc/ChangeLog index 0c872093..1a01550c 100644 --- a/proc/ChangeLog +++ b/proc/ChangeLog @@ -1,5 +1,30 @@ 2003-08-17 Marcus Brinkmann <marcus@gnu.org> + * proc.h: Include <hurd/ihash.h>. + (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. + +2003-08-17 Marcus Brinkmann <marcus@gnu.org> + * mgt.c (S_proc_dostop): Revert last change. 2003-06-16 Ognyan Kulev <ogi@fmi.uni-sofia.bg> diff --git a/proc/hash.c b/proc/hash.c index 76c2369c..ed670a16 100644 --- a/proc/hash.c +++ b/proc/hash.c @@ -20,6 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Written by Michael I. Bushnell. */ #include <mach.h> +#include <stddef.h> #include <sys/types.h> #include <hurd/hurd_types.h> #include <string.h> @@ -29,14 +30,22 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "proc.h" #include <hurd/ihash.h> -static struct ihash pghash, pidhash, taskhash, sidhash; +static struct hurd_ihash pghash + = HURD_IHASH_INITIALIZER (offsetof (struct pgrp, pg_hashloc)); +static struct hurd_ihash pidhash + = HURD_IHASH_INITIALIZER (offsetof (struct proc, p_pidhashloc)); +static struct hurd_ihash taskhash + = HURD_IHASH_INITIALIZER (offsetof (struct proc, p_taskhashloc)); +static struct hurd_ihash sidhash + = HURD_IHASH_INITIALIZER (offsetof (struct session, s_hashloc)); + /* Find the process corresponding to a given pid. */ struct proc * pid_find (pid_t pid) { struct proc *p; - p = ihash_find (&pidhash, pid); + p = hurd_ihash_find (&pidhash, pid); return (!p || p->p_dead) ? 0 : p; } @@ -45,7 +54,7 @@ pid_find (pid_t pid) struct proc * pid_find_allow_zombie (pid_t pid) { - return ihash_find (&pidhash, pid); + return hurd_ihash_find (&pidhash, pid); } /* Find the process corresponding to a given task. */ @@ -53,7 +62,7 @@ struct proc * task_find (task_t task) { struct proc *p; - p = ihash_find (&taskhash, task) ? : add_tasks (task); + p = hurd_ihash_find (&taskhash, task) ? : add_tasks (task); return (!p || p->p_dead) ? 0 : p; } @@ -63,7 +72,7 @@ struct proc * task_find_nocreate (task_t task) { struct proc *p; - p = ihash_find (&taskhash, task); + p = hurd_ihash_find (&taskhash, task); return (!p || p->p_dead) ? 0 : p; } @@ -82,58 +91,58 @@ reqport_find (mach_port_t reqport) struct pgrp * pgrp_find (pid_t pgid) { - return ihash_find (&pghash, pgid); + return hurd_ihash_find (&pghash, pgid); } /* Find the session corresponding to a given sid. */ struct session * session_find (pid_t sid) { - return ihash_find (&sidhash, sid); + return hurd_ihash_find (&sidhash, sid); } /* Add a new process to the various hash tables. */ void add_proc_to_hash (struct proc *p) { - ihash_add (&pidhash, p->p_pid, p, &p->p_pidhashloc); - ihash_add (&taskhash, p->p_task, p, &p->p_taskhashloc); + hurd_ihash_add (&pidhash, p->p_pid, p); + hurd_ihash_add (&taskhash, p->p_task, p); } /* Add a new process group to the various hash tables. */ void add_pgrp_to_hash (struct pgrp *pg) { - ihash_add (&pghash, pg->pg_pgid, pg, &pg->pg_hashloc); + hurd_ihash_add (&pghash, pg->pg_pgid, pg); } /* Add a new session to the various hash tables. */ void add_session_to_hash (struct session *s) { - ihash_add (&sidhash, s->s_sid, s, &s->s_hashloc); + hurd_ihash_add (&sidhash, s->s_sid, s); } /* Remove a process group from the various hash tables. */ void remove_pgrp_from_hash (struct pgrp *pg) { - ihash_locp_remove(0, pg->pg_hashloc); + hurd_ihash_locp_remove (&pghash, pg->pg_hashloc); } /* Remove a process from the various hash tables. */ void remove_proc_from_hash (struct proc *p) { - ihash_locp_remove(0, p->p_pidhashloc); - ihash_locp_remove(0, p->p_taskhashloc); + hurd_ihash_locp_remove (&pidhash, p->p_pidhashloc); + hurd_ihash_locp_remove (&taskhash, p->p_taskhashloc); } /* Remove a session from the various hash tables. */ void remove_session_from_hash (struct session *s) { - ihash_locp_remove(0, s->s_hashloc); + hurd_ihash_locp_remove (&sidhash, s->s_hashloc); } /* Call function FUN of two args for each process. FUN's first arg is @@ -141,14 +150,12 @@ remove_session_from_hash (struct session *s) void prociterate (void (*fun) (struct proc *, void *), void *arg) { - error_t thunk(void *value) + HURD_IHASH_ITERATE (&pidhash, value) { struct proc *p = value; if (!p->p_dead) (*fun)(p, arg); - return 0; } - ihash_iterate(&pidhash, thunk); } /* Tell if a pid is available for use */ diff --git a/proc/proc.h b/proc/proc.h index 9e79192a..7943e0be 100644 --- a/proc/proc.h +++ b/proc/proc.h @@ -25,6 +25,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/resource.h> #include <sys/mman.h> #include <hurd/ports.h> +#include <hurd/ihash.h> #include <cthreads.h> struct proc @@ -35,8 +36,8 @@ struct proc struct proc *p_gnext, **p_gprevp; /* process group */ /* Hash table pointers that point here */ - void **p_pidhashloc; /* by pid */ - void **p_taskhashloc; /* by task port */ + hurd_ihash_locp_t p_pidhashloc; /* by pid */ + hurd_ihash_locp_t p_taskhashloc; /* by task port */ /* Identification of this process */ task_t p_task; @@ -89,7 +90,7 @@ typedef struct proc *pstruct_t; struct pgrp { - void **pg_hashloc; + hurd_ihash_locp_t pg_hashloc; struct proc *pg_plist; /* member processes */ struct pgrp *pg_next, **pg_prevp; /* list of pgrps in session */ pid_t pg_pgid; @@ -99,7 +100,7 @@ struct pgrp struct session { - void **s_hashloc; + hurd_ihash_locp_t s_hashloc; pid_t s_sid; struct pgrp *s_pgrps; /* list of member pgrps */ mach_port_t s_sessionid; /* receive right */ |