summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-12-02 02:28:22 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-12-02 02:28:22 +0000
commitf96af347e71a0cbd53221ab1477cf183c0b4b254 (patch)
tree70e9885a4ed2ccde1ff07e2060ffb06e39cbdb31 /lib
parent50db31580519f08061cbcb183acf50dc9d571f55 (diff)
CIRCLEQ begone.
ok miller@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/db/mpool/mpool.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c
index 65008de3d2d..263c93b5ebc 100644
--- a/lib/libc/db/mpool/mpool.c
+++ b/lib/libc/db/mpool/mpool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpool.c,v 1.18 2006/01/25 14:40:03 millert Exp $ */
+/* $OpenBSD: mpool.c,v 1.19 2013/12/02 02:28:21 krw Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -76,9 +76,9 @@ mpool_open(void *key, int fd, pgno_t pagesize, pgno_t maxcache)
/* Allocate and initialize the MPOOL cookie. */
if ((mp = (MPOOL *)calloc(1, sizeof(MPOOL))) == NULL)
return (NULL);
- CIRCLEQ_INIT(&mp->lqh);
+ TAILQ_INIT(&mp->lqh);
for (entry = 0; entry < HASHSIZE; ++entry)
- CIRCLEQ_INIT(&mp->hqh[entry]);
+ TAILQ_INIT(&mp->hqh[entry]);
mp->maxcache = maxcache;
mp->npages = sb.st_size / pagesize;
mp->pagesize = pagesize;
@@ -132,8 +132,8 @@ mpool_new(MPOOL *mp, pgno_t *pgnoaddr, u_int flags)
bp->flags = MPOOL_PINNED | MPOOL_INUSE;
head = &mp->hqh[HASHKEY(bp->pgno)];
- CIRCLEQ_INSERT_HEAD(head, bp, hq);
- CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q);
+ TAILQ_INSERT_HEAD(head, bp, hq);
+ TAILQ_INSERT_TAIL(&mp->lqh, bp, q);
return (bp->page);
}
@@ -155,8 +155,8 @@ mpool_delete(MPOOL *mp, void *page)
/* Remove from the hash and lru queues. */
head = &mp->hqh[HASHKEY(bp->pgno)];
- CIRCLEQ_REMOVE(head, bp, hq);
- CIRCLEQ_REMOVE(&mp->lqh, bp, q);
+ TAILQ_REMOVE(head, bp, hq);
+ TAILQ_REMOVE(&mp->lqh, bp, q);
free(bp);
mp->curcache--;
@@ -195,10 +195,10 @@ mpool_get(MPOOL *mp, pgno_t pgno,
* of the lru chain.
*/
head = &mp->hqh[HASHKEY(bp->pgno)];
- CIRCLEQ_REMOVE(head, bp, hq);
- CIRCLEQ_INSERT_HEAD(head, bp, hq);
- CIRCLEQ_REMOVE(&mp->lqh, bp, q);
- CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q);
+ TAILQ_REMOVE(head, bp, hq);
+ TAILQ_INSERT_HEAD(head, bp, hq);
+ TAILQ_REMOVE(&mp->lqh, bp, q);
+ TAILQ_INSERT_TAIL(&mp->lqh, bp, q);
/* Return a pinned page. */
bp->flags |= MPOOL_PINNED;
@@ -248,8 +248,8 @@ mpool_get(MPOOL *mp, pgno_t pgno,
* of the lru chain.
*/
head = &mp->hqh[HASHKEY(bp->pgno)];
- CIRCLEQ_INSERT_HEAD(head, bp, hq);
- CIRCLEQ_INSERT_TAIL(&mp->lqh, bp, q);
+ TAILQ_INSERT_HEAD(head, bp, hq);
+ TAILQ_INSERT_TAIL(&mp->lqh, bp, q);
/* Run through the user's filter. */
if (mp->pgin != NULL)
@@ -295,9 +295,8 @@ mpool_close(MPOOL *mp)
BKT *bp;
/* Free up any space allocated to the lru pages. */
- while (!CIRCLEQ_EMPTY(&mp->lqh)) {
- bp = CIRCLEQ_FIRST(&mp->lqh);
- CIRCLEQ_REMOVE(&mp->lqh, bp, q);
+ while ((bp = TAILQ_FIRST(&mp->lqh))) {
+ TAILQ_REMOVE(&mp->lqh, bp, q);
free(bp);
}
@@ -316,7 +315,7 @@ mpool_sync(MPOOL *mp)
BKT *bp;
/* Walk the lru chain, flushing any dirty pages to disk. */
- CIRCLEQ_FOREACH(bp, &mp->lqh, q)
+ TAILQ_FOREACH(bp, &mp->lqh, q)
if (bp->flags & MPOOL_DIRTY &&
mpool_write(mp, bp) == RET_ERROR)
return (RET_ERROR);
@@ -345,7 +344,7 @@ mpool_bkt(MPOOL *mp)
* off any lists. If we don't find anything we grow the cache anyway.
* The cache never shrinks.
*/
- CIRCLEQ_FOREACH(bp, &mp->lqh, q)
+ TAILQ_FOREACH(bp, &mp->lqh, q)
if (!(bp->flags & MPOOL_PINNED)) {
/* Flush if dirty. */
if (bp->flags & MPOOL_DIRTY &&
@@ -356,8 +355,8 @@ mpool_bkt(MPOOL *mp)
#endif
/* Remove from the hash and lru queues. */
head = &mp->hqh[HASHKEY(bp->pgno)];
- CIRCLEQ_REMOVE(head, bp, hq);
- CIRCLEQ_REMOVE(&mp->lqh, bp, q);
+ TAILQ_REMOVE(head, bp, hq);
+ TAILQ_REMOVE(&mp->lqh, bp, q);
#ifdef DEBUG
{ void *spage;
spage = bp->page;
@@ -426,7 +425,7 @@ mpool_look(MPOOL *mp, pgno_t pgno)
BKT *bp;
head = &mp->hqh[HASHKEY(pgno)];
- CIRCLEQ_FOREACH(bp, head, hq)
+ TAILQ_FOREACH(bp, head, hq)
if ((bp->pgno == pgno) &&
((bp->flags & MPOOL_INUSE) == MPOOL_INUSE)) {
#ifdef STATISTICS
@@ -470,7 +469,7 @@ mpool_stat(MPOOL *mp)
sep = "";
cnt = 0;
- CIRCLEQ_FOREACH(bp, &mp->lqh, q) {
+ TAILQ_FOREACH(bp, &mp->lqh, q) {
(void)fprintf(stderr, "%s%d", sep, bp->pgno);
if (bp->flags & MPOOL_DIRTY)
(void)fprintf(stderr, "d");