summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-11-16 10:56:05 +0000
committerphk <phk@FreeBSD.org>1999-11-16 10:56:05 +0000
commit8fca18de89986d6275d0502af100b97274c4bab5 (patch)
treed8a3cb26e484830479c8386ecba6b7d0157acc06 /sys
parent520fff788fc8f2154247a6cff986abf634fdbb51 (diff)
downloadFreeBSD-src-8fca18de89986d6275d0502af100b97274c4bab5.zip
FreeBSD-src-8fca18de89986d6275d0502af100b97274c4bab5.tar.gz
This is a partial commit of the patch from PR 14914:
Alot of the code in sys/kern directly accesses the *Q_HEAD and *Q_ENTRY structures for list operations. This patch makes all list operations in sys/kern use the queue(3) macros, rather than directly accessing the *Q_{HEAD,ENTRY} structures. This batch of changes compile to the same object files. Reviewed by: phk Submitted by: Jake Burkholder <jake@checker.org> PR: 14914
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/imgact_elf.c2
-rw-r--r--sys/kern/init_main.c2
-rw-r--r--sys/kern/kern_descrip.c4
-rw-r--r--sys/kern/kern_exit.c6
-rw-r--r--sys/kern/kern_fork.c6
-rw-r--r--sys/kern/kern_ktrace.c14
-rw-r--r--sys/kern/kern_resource.c10
-rw-r--r--sys/kern/kern_sig.c11
-rw-r--r--sys/kern/kern_synch.c6
-rw-r--r--sys/kern/subr_devstat.c4
-rw-r--r--sys/kern/tty.c4
-rw-r--r--sys/kern/uipc_socket.c11
-rw-r--r--sys/kern/uipc_syscalls.c6
-rw-r--r--sys/kern/uipc_usrreq.c16
-rw-r--r--sys/kern/vfs_bio.c4
15 files changed, 50 insertions, 56 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 8d706c5..8cb6925 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -154,7 +154,7 @@ elf_brand_inuse(Elf_Brandinfo *entry)
{
struct proc *p;
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
+ LIST_FOREACH(p, &allproc, p_list) {
if (p->p_sysent == entry->sysvec)
return TRUE;
}
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index f94c93a..ec9cf85 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -447,7 +447,7 @@ xxx_vfs_root_fdtab(dummy)
register struct filedesc0 *fdp = &filedesc0;
/* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */
- if (VFS_ROOT(mountlist.cqh_first, &rootvnode))
+ if (VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode))
panic("cannot find root vnode");
fdp->fd_fd.fd_cdir = rootvnode;
VREF(fdp->fd_fd.fd_cdir);
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 6f4ed75..e1fcf09 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -394,7 +394,7 @@ funsetownlst(sigiolst)
{
struct sigio *sigio;
- while ((sigio = sigiolst->slh_first) != NULL)
+ while ((sigio = SLIST_FIRST(sigiolst)) != NULL)
funsetown(sigio);
}
@@ -1226,7 +1226,7 @@ sysctl_kern_file SYSCTL_HANDLER_ARGS
/*
* followed by an array of file structures
*/
- for (fp = filehead.lh_first; fp != NULL; fp = fp->f_list.le_next) {
+ LIST_FOREACH(fp, &filehead, f_list) {
error = SYSCTL_OUT(req, (caddr_t)fp, sizeof (struct file));
if (error)
return (error);
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index c82eca2..6fe2171 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -269,11 +269,11 @@ exit1(p, rv)
LIST_REMOVE(p, p_hash);
- q = p->p_children.lh_first;
+ q = LIST_FIRST(&p->p_children);
if (q) /* only need this if any child is S_ZOMB */
wakeup((caddr_t) initproc);
for (; q != 0; q = nq) {
- nq = q->p_sibling.le_next;
+ nq = LIST_NEXT(q, p_sibling);
LIST_REMOVE(q, p_sibling);
LIST_INSERT_HEAD(&initproc->p_children, q, p_sibling);
q->p_pptr = initproc;
@@ -410,7 +410,7 @@ wait1(q, uap, compat)
return (EINVAL);
loop:
nfound = 0;
- for (p = q->p_children.lh_first; p != 0; p = p->p_sibling.le_next) {
+ LIST_FOREACH(p, &q->p_children, p_sibling) {
if (uap->pid != WAIT_ANY &&
p->p_pid != uap->pid && p->p_pgid != -uap->pid)
continue;
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 2fb15cf..0fbe915 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -274,9 +274,9 @@ retry:
* is in use. Remember the lowest pid that's greater
* than nextpid, so we can avoid checking for a while.
*/
- p2 = allproc.lh_first;
+ p2 = LIST_FIRST(&allproc);
again:
- for (; p2 != 0; p2 = p2->p_list.le_next) {
+ for (; p2 != 0; p2 = LIST_NEXT(p2, p_list)) {
while (p2->p_pid == nextpid ||
p2->p_pgrp->pg_id == nextpid ||
p2->p_session->s_sid == nextpid) {
@@ -295,7 +295,7 @@ again:
}
if (!doingzomb) {
doingzomb = 1;
- p2 = zombproc.lh_first;
+ p2 = LIST_FIRST(&zombproc);
goto again;
}
}
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index a72e6d8..266ea31 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -292,7 +292,7 @@ ktrace(curp, uap)
* Clear all uses of the tracefile
*/
if (ops == KTROP_CLEARFILE) {
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
+ LIST_FOREACH(p, &allproc, p_list) {
if (p->p_tracep == vp) {
if (ktrcanset(curp, p)) {
p->p_tracep = NULL;
@@ -324,7 +324,7 @@ ktrace(curp, uap)
error = ESRCH;
goto done;
}
- for (p = pg->pg_members.lh_first; p != 0; p = p->p_pglist.le_next)
+ LIST_FOREACH(p, &pg->pg_members, p_pglist)
if (descend)
ret |= ktrsetchildren(curp, p, ops, facs, vp);
else
@@ -445,13 +445,13 @@ ktrsetchildren(curp, top, ops, facs, vp)
* otherwise do any siblings, and if done with this level,
* follow back up the tree (but not past top).
*/
- if (p->p_children.lh_first)
- p = p->p_children.lh_first;
+ if (!LIST_EMPTY(&p->p_children))
+ p = LIST_FIRST(&p->p_children);
else for (;;) {
if (p == top)
return (ret);
- if (p->p_sibling.le_next) {
- p = p->p_sibling.le_next;
+ if (LIST_NEXT(p, p_sibling)) {
+ p = LIST_NEXT(p, p_sibling);
break;
}
p = p->p_pptr;
@@ -497,7 +497,7 @@ ktrwrite(vp, kth)
*/
log(LOG_NOTICE, "ktrace write failed, errno %d, tracing stopped\n",
error);
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
+ LIST_FOREACH(p, &allproc, p_list) {
if (p->p_tracep == vp) {
p->p_tracep = NULL;
p->p_traceflag = 0;
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 2fd11ab..fde934e 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -97,8 +97,7 @@ getpriority(curp, uap)
pg = curp->p_pgrp;
else if ((pg = pgfind(uap->who)) == NULL)
break;
- for (p = pg->pg_members.lh_first; p != 0;
- p = p->p_pglist.le_next) {
+ LIST_FOREACH(p, &pg->pg_members, p_pglist) {
if (p->p_nice < low)
low = p->p_nice;
}
@@ -108,7 +107,7 @@ getpriority(curp, uap)
case PRIO_USER:
if (uap->who == 0)
uap->who = curp->p_ucred->cr_uid;
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next)
+ LIST_FOREACH(p, &allproc, p_list)
if (p->p_ucred->cr_uid == uap->who &&
p->p_nice < low)
low = p->p_nice;
@@ -159,8 +158,7 @@ setpriority(curp, uap)
pg = curp->p_pgrp;
else if ((pg = pgfind(uap->who)) == NULL)
break;
- for (p = pg->pg_members.lh_first; p != 0;
- p = p->p_pglist.le_next) {
+ LIST_FOREACH(p, &pg->pg_members, p_pglist) {
error = donice(curp, p, uap->prio);
found++;
}
@@ -170,7 +168,7 @@ setpriority(curp, uap)
case PRIO_USER:
if (uap->who == 0)
uap->who = curp->p_ucred->cr_uid;
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next)
+ LIST_FOREACH(p, &allproc, p_list)
if (p->p_ucred->cr_uid == uap->who) {
error = donice(curp, p, uap->prio);
found++;
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 6bdf48e..fa065e4 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -807,7 +807,7 @@ killpg1(cp, sig, pgid, all)
/*
* broadcast
*/
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
+ LIST_FOREACH(p, &allproc, p_list) {
if (p->p_pid <= 1 || p->p_flag & P_SYSTEM ||
p == cp || !CANSIGNAL(cp, pc, p, sig))
continue;
@@ -826,8 +826,7 @@ killpg1(cp, sig, pgid, all)
if (pgrp == NULL)
return (ESRCH);
}
- for (p = pgrp->pg_members.lh_first; p != 0;
- p = p->p_pglist.le_next) {
+ LIST_FOREACH(p, &pgrp->pg_members, p_pglist) {
if (p->p_pid <= 1 || p->p_flag & P_SYSTEM ||
p->p_stat == SZOMB ||
!CANSIGNAL(cp, pc, p, sig))
@@ -923,8 +922,7 @@ pgsignal(pgrp, sig, checkctty)
register struct proc *p;
if (pgrp)
- for (p = pgrp->pg_members.lh_first; p != 0;
- p = p->p_pglist.le_next)
+ LIST_FOREACH(p, &pgrp->pg_members, p_pglist)
if (checkctty == 0 || p->p_flag & P_CONTROLT)
psignal(p, sig);
}
@@ -1677,8 +1675,7 @@ pgsigio(sigio, sig, checkctty)
} else if (sigio->sio_pgid < 0) {
struct proc *p;
- for (p = sigio->sio_pgrp->pg_members.lh_first; p != NULL;
- p = p->p_pglist.le_next)
+ LIST_FOREACH(p, &sigio->sio_pgrp->pg_members, p_pglist)
if (CANSIGIO(sigio->sio_ruid, sigio->sio_ucred, p) &&
(checkctty == 0 || (p->p_flag & P_CONTROLT)))
psignal(p, sig);
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 293a75f..4811669 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -251,7 +251,7 @@ schedcpu(arg)
register unsigned int newcpu;
realstathz = stathz ? stathz : hz;
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
+ LIST_FOREACH(p, &allproc, p_list) {
/*
* Increment time in/out of memory and sleep time
* (if sleeping). We ignore overflow; with 16-bit int's
@@ -689,7 +689,7 @@ wakeup(ident)
s = splhigh();
qp = &slpque[LOOKUP(ident)];
restart:
- for (p = qp->tqh_first; p != NULL; p = p->p_procq.tqe_next) {
+ TAILQ_FOREACH(p, qp, p_procq) {
if (p->p_wchan == ident) {
TAILQ_REMOVE(qp, p, p_procq);
p->p_wchan = 0;
@@ -730,7 +730,7 @@ wakeup_one(ident)
s = splhigh();
qp = &slpque[LOOKUP(ident)];
- for (p = qp->tqh_first; p != NULL; p = p->p_procq.tqe_next) {
+ TAILQ_FOREACH(p, qp, p_procq) {
if (p->p_wchan == ident) {
TAILQ_REMOVE(qp, p, p_procq);
p->p_wchan = 0;
diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c
index 23b397a..b04662b 100644
--- a/sys/kern/subr_devstat.c
+++ b/sys/kern/subr_devstat.c
@@ -281,9 +281,9 @@ sysctl_devstat SYSCTL_HANDLER_ARGS
/*
* Now push out all the devices.
*/
- for (i = 0, nds = devstat_head->stqh_first;
+ for (i = 0, nds = STAILQ_FIRST(devstat_head);
(nds != NULL) && (i < devstat_num_devs) && (error == 0);
- nds = nds->dev_links.stqe_next, i++)
+ nds = STAILQ_NEXT(nds, dev_links), i++)
error = SYSCTL_OUT(req, nds, sizeof(struct devstat));
return(error);
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 7f4cd43..b8eff2c 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -2228,11 +2228,11 @@ ttyinfo(tp)
ttyprintf(tp, "not a controlling terminal\n");
else if (tp->t_pgrp == NULL)
ttyprintf(tp, "no foreground process group\n");
- else if ((p = tp->t_pgrp->pg_members.lh_first) == 0)
+ else if ((p = LIST_FIRST(&tp->t_pgrp->pg_members)) == 0)
ttyprintf(tp, "empty foreground process group\n");
else {
/* Pick interesting process. */
- for (pick = NULL; p != 0; p = p->p_pglist.le_next)
+ for (pick = NULL; p != 0; p = LIST_NEXT(p, p_pglist))
if (proc_compare(pick, p))
pick = p;
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 3d15c27..c650a36 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -182,7 +182,7 @@ solisten(so, backlog, p)
splx(s);
return (error);
}
- if (so->so_comp.tqh_first == NULL)
+ if (TAILQ_EMPTY(&so->so_comp))
so->so_options |= SO_ACCEPTCONN;
if (backlog < 0 || backlog > somaxconn)
backlog = somaxconn;
@@ -239,12 +239,13 @@ soclose(so)
if (so->so_options & SO_ACCEPTCONN) {
struct socket *sp, *sonext;
- for (sp = so->so_incomp.tqh_first; sp != NULL; sp = sonext) {
- sonext = sp->so_list.tqe_next;
+ sp = TAILQ_FIRST(&so->so_incomp);
+ for (; sp != NULL; sp = sonext) {
+ sonext = TAILQ_NEXT(sp, so_list);
(void) soabort(sp);
}
- for (sp = so->so_comp.tqh_first; sp != NULL; sp = sonext) {
- sonext = sp->so_list.tqe_next;
+ for (sp = TAILQ_FIRST(&so->so_comp); sp != NULL; sp = sonext) {
+ sonext = TAILQ_NEXT(sp, so_list);
/* Dequeue from so_comp since sofree() won't do it */
TAILQ_REMOVE(&so->so_comp, sp, so_list);
so->so_qlen--;
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index ade2c4d..cb21ac6f 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -205,11 +205,11 @@ accept1(p, uap, compat)
splx(s);
return (EINVAL);
}
- if ((head->so_state & SS_NBIO) && head->so_comp.tqh_first == NULL) {
+ if ((head->so_state & SS_NBIO) && TAILQ_EMPTY(&head->so_comp)) {
splx(s);
return (EWOULDBLOCK);
}
- while (head->so_comp.tqh_first == NULL && head->so_error == 0) {
+ while (TAILQ_EMPTY(&head->so_comp) && head->so_error == 0) {
if (head->so_state & SS_CANTRCVMORE) {
head->so_error = ECONNABORTED;
break;
@@ -235,7 +235,7 @@ accept1(p, uap, compat)
* block allowing another process to accept the connection
* instead.
*/
- so = head->so_comp.tqh_first;
+ so = TAILQ_FIRST(&head->so_comp);
TAILQ_REMOVE(&head->so_comp, so, so_list);
head->so_qlen--;
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 5aea71a..34222b2 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -510,8 +510,8 @@ unp_detach(unp)
}
if (unp->unp_conn)
unp_disconnect(unp);
- while (unp->unp_refs.lh_first)
- unp_drop(unp->unp_refs.lh_first, ECONNRESET);
+ while (!LIST_EMPTY(&unp->unp_refs))
+ unp_drop(LIST_FIRST(&unp->unp_refs), ECONNRESET);
soisdisconnected(unp->unp_socket);
unp->unp_socket->so_pcb = 0;
if (unp_rights) {
@@ -762,8 +762,8 @@ unp_pcblist SYSCTL_HANDLER_ARGS
if (unp_list == 0)
return ENOMEM;
- for (unp = head->lh_first, i = 0; unp && i < n;
- unp = unp->unp_link.le_next) {
+ for (unp = LIST_FIRST(head), i = 0; unp && i < n;
+ unp = LIST_NEXT(unp, unp_link)) {
if (unp->unp_gencnt <= gencnt && !prison_unpcb(req->p, unp))
unp_list[i++] = unp;
}
@@ -990,10 +990,10 @@ unp_gc()
* before going through all this, set all FDs to
* be NOT defered and NOT externally accessible
*/
- for (fp = filehead.lh_first; fp != 0; fp = fp->f_list.le_next)
+ LIST_FOREACH(fp, &filehead, f_list)
fp->f_flag &= ~(FMARK|FDEFER);
do {
- for (fp = filehead.lh_first; fp != 0; fp = fp->f_list.le_next) {
+ LIST_FOREACH(fp, &filehead, f_list) {
/*
* If the file is not open, skip it
*/
@@ -1104,9 +1104,9 @@ unp_gc()
* 91/09/19, bsy@cs.cmu.edu
*/
extra_ref = malloc(nfiles * sizeof(struct file *), M_FILE, M_WAITOK);
- for (nunref = 0, fp = filehead.lh_first, fpp = extra_ref; fp != 0;
+ for (nunref = 0, fp = LIST_FIRST(&filehead), fpp = extra_ref; fp != 0;
fp = nextfp) {
- nextfp = fp->f_list.le_next;
+ nextfp = LIST_NEXT(fp, f_list);
/*
* If it's not open, skip it
*/
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 8563bf0..af1d835 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1225,16 +1225,14 @@ gbincore(struct vnode * vp, daddr_t blkno)
struct bufhashhdr *bh;
bh = bufhash(vp, blkno);
- bp = bh->lh_first;
/* Search hash chain */
- while (bp != NULL) {
+ LIST_FOREACH(bp, bh, b_hash) {
/* hit */
if (bp->b_vp == vp && bp->b_lblkno == blkno &&
(bp->b_flags & B_INVAL) == 0) {
break;
}
- bp = bp->b_hash.le_next;
}
return (bp);
}
OpenPOWER on IntegriCloud