Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amiga/amiga convert to TAILQ, remove open-coded CIR...
details: https://anonhg.NetBSD.org/src/rev/e54bc59a2133
branches: trunk
changeset: 791576:e54bc59a2133
user: christos <christos%NetBSD.org@localhost>
date: Sat Nov 23 22:48:00 2013 +0000
description:
convert to TAILQ, remove open-coded CIRCLEQ
diffstat:
sys/arch/amiga/amiga/cc.c | 116 +++++++++++++++++++++++-----------------------
sys/arch/amiga/amiga/cc.h | 6 +-
2 files changed, 61 insertions(+), 61 deletions(-)
diffs (268 lines):
diff -r d162faf10ddb -r e54bc59a2133 sys/arch/amiga/amiga/cc.c
--- a/sys/arch/amiga/amiga/cc.c Sat Nov 23 22:31:53 2013 +0000
+++ b/sys/arch/amiga/amiga/cc.c Sat Nov 23 22:48:00 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cc.c,v 1.22 2010/12/20 00:25:25 matt Exp $ */
+/* $NetBSD: cc.c,v 1.23 2013/11/23 22:48:00 christos Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cc.c,v 1.22 2010/12/20 00:25:25 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cc.c,v 1.23 2013/11/23 22:48:00 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -90,22 +90,22 @@
struct vbl_node *n, *prev;
s = spl3();
- prev = NULL;
- for (n = vbl_list.lh_first; n != NULL; n = n->link.le_next) {
+ prev = LIST_END(&vbl_list);
+ LIST_FOREACH(n, &vbl_list, link) {
if (add->priority > n->priority) {
/* insert add_node before. */
- if (prev == NULL) {
+ if (prev == LIST_END(&vbl_list)) {
LIST_INSERT_HEAD(&vbl_list, add, link);
} else {
LIST_INSERT_AFTER(prev, add, link);
}
- add = NULL;
+ add = LIST_END(&vbl_list);
break;
}
prev = n;
}
- if (add) {
- if (prev == NULL) {
+ if (add != LIST_END(&vbl_list)) {
+ if (prev == LIST_END(&vbl_list)) {
LIST_INSERT_HEAD(&vbl_list, add, link);
} else {
LIST_INSERT_AFTER(prev, add, link);
@@ -131,12 +131,12 @@
struct vbl_node *n;
/* handle all vbl functions */
- for (n = vbl_list.lh_first; n != NULL; n = n->link.le_next) {
+ LIST_FOREACH(n, &vbl_list, link) {
if (n->flags & VBLNF_TURNOFF) {
n->flags |= VBLNF_OFF;
n->flags &= ~(VBLNF_TURNOFF);
} else {
- if (n != NULL)
+ if (n != LIST_END(&vbl_list))
n->function(n->data);
}
}
@@ -334,10 +334,10 @@
/*
* initialize audio channels to off.
*/
- for (i=0; i < 4; i++) {
+ for (i = 0; i < 4; i++) {
channel[i].play_count = 0;
- channel[i].isaudio=0;
- channel[i].handler=NULL;
+ channel[i].isaudio = 0;
+ channel[i].handler = NULL;
}
}
@@ -458,8 +458,8 @@
* Chipmem allocator.
*/
-static CIRCLEQ_HEAD(chiplist, mem_node) chip_list;
-static CIRCLEQ_HEAD(freelist, mem_node) free_list;
+static TAILQ_HEAD(chiplist, mem_node) chip_list;
+static TAILQ_HEAD(freelist, mem_node) free_list;
static u_long chip_total; /* total free. */
static u_long chip_size; /* size of it all. */
@@ -475,11 +475,11 @@
mem = (struct mem_node *)chipmem_steal(chip_size);
mem->size = chip_total;
- CIRCLEQ_INIT(&chip_list);
- CIRCLEQ_INIT(&free_list);
+ TAILQ_INIT(&chip_list);
+ TAILQ_INIT(&free_list);
- CIRCLEQ_INSERT_HEAD(&chip_list, mem, link);
- CIRCLEQ_INSERT_HEAD(&free_list, mem, free_link);
+ TAILQ_INSERT_HEAD(&chip_list, mem, link);
+ TAILQ_INSERT_HEAD(&free_list, mem, free_link);
splx(s);
}
@@ -500,20 +500,20 @@
/*
* walk list of available nodes.
*/
- mn = free_list.cqh_first;
- while (size > mn->size && mn != (void *)&free_list)
- mn = mn->free_link.cqe_next;
+ TAILQ_FOREACH(mn, &free_list, free_link)
+ if (size <= mn->size)
+ break;
- if (mn == (void *)&free_list)
- return(NULL);
+ if (mn == TAILQ_END(&free_list))
+ return NULL;
if ((mn->size - size) <= sizeof (*mn)) {
/*
* our allocation would not leave room
* for a new node in between.
*/
- CIRCLEQ_REMOVE(&free_list, mn, free_link);
- mn->free_link.cqe_next = NULL;
+ TAILQ_REMOVE(&free_list, mn, free_link);
+ TAILQ_NEXT(mn, free_link) = TAILQ_END(&free_list);
size = mn->size; /* increase size. (or same) */
chip_total -= mn->size;
splx(s);
@@ -532,8 +532,8 @@
* add split node to node list
* and mark as not on free list
*/
- CIRCLEQ_INSERT_AFTER(&chip_list, new, mn, link);
- mn->free_link.cqe_next = NULL;
+ TAILQ_INSERT_AFTER(&chip_list, new, mn, link);
+ TAILQ_NEXT(mn, free_link) = TAILQ_END(&free_list);
chip_total -= size + sizeof(struct mem_node);
splx(s);
@@ -551,66 +551,67 @@
s = splhigh();
mn = (struct mem_node *)mem - 1;
- next = mn->link.cqe_next;
- prev = mn->link.cqe_prev;
+ next = TAILQ_NEXT(mn, link);
+ prev = TAILQ_PREV(mn, chiplist, link);
/*
* check ahead of us.
*/
- if (next->link.cqe_next != (void *)&chip_list &&
- next->free_link.cqe_next) {
+ if (TAILQ_NEXT(next, link) != TAILQ_END(&chip_list) &&
+ TAILQ_NEXT(next, free_link) != TAILQ_END(&free_list)) {
/*
* if next is: a valid node and a free node. ==> merge
*/
- CIRCLEQ_INSERT_BEFORE(&free_list, next, mn, free_link);
- CIRCLEQ_REMOVE(&chip_list, next, link);
- CIRCLEQ_REMOVE(&chip_list, next, free_link);
+ TAILQ_INSERT_BEFORE(next, mn, free_link);
+ TAILQ_REMOVE(&chip_list, next, link);
+ TAILQ_REMOVE(&chip_list, next, free_link);
chip_total += mn->size + sizeof(struct mem_node);
mn->size += next->size + sizeof(struct mem_node);
}
- if (prev->link.cqe_prev != (void *)&chip_list &&
- prev->free_link.cqe_prev) {
+ if (TAILQ_PREV(prev, chiplist, link) != TAILQ_END(&chip_list) &&
+ TAILQ_PREV(prev, freelist, free_link) != TAILQ_END(&free_list)) {
/*
* if prev is: a valid node and a free node. ==> merge
*/
- if (mn->free_link.cqe_next == NULL)
+ if (TAILQ_NEXT(mn, free_link) == TAILQ_END(&free_list))
chip_total += mn->size + sizeof(struct mem_node);
else {
/* already on free list */
- CIRCLEQ_REMOVE(&free_list, mn, free_link);
+ TAILQ_REMOVE(&free_list, mn, free_link);
chip_total += sizeof(struct mem_node);
}
- CIRCLEQ_REMOVE(&chip_list, mn, link);
+ TAILQ_REMOVE(&chip_list, mn, link);
prev->size += mn->size + sizeof(struct mem_node);
- } else if (mn->free_link.cqe_next == NULL) {
+ } else if (TAILQ_NEXT(mn, free_link) == TAILQ_END(&free_list)) {
/*
* we still are not on free list and we need to be.
* <-- | -->
*/
- while (next->link.cqe_next != (void *)&chip_list &&
- prev->link.cqe_prev != (void *)&chip_list) {
- if (next->free_link.cqe_next) {
- CIRCLEQ_INSERT_BEFORE(&free_list, next, mn,
+ while (TAILQ_NEXT(next, link) != TAILQ_END(&chip_list) &&
+ TAILQ_PREV(prev, chiplist, link) != TAILQ_END(&chip_list)) {
+ if (TAILQ_NEXT(next, free_link) !=
+ TAILQ_END(&free_list)) {
+ TAILQ_INSERT_BEFORE(next, mn, free_link);
+ break;
+ }
+ if (TAILQ_NEXT(prev, free_link) !=
+ TAILQ_END(&free_list)) {
+ TAILQ_INSERT_AFTER(&free_list, prev, mn,
free_link);
break;
}
- if (prev->free_link.cqe_next) {
- CIRCLEQ_INSERT_AFTER(&free_list, prev, mn,
- free_link);
- break;
- }
- prev = prev->link.cqe_prev;
- next = next->link.cqe_next;
+ prev = TAILQ_PREV(prev, chiplist, link);
+ next = TAILQ_NEXT(next, link);
}
- if (mn->free_link.cqe_next == NULL) {
- if (next->link.cqe_next == (void *)&chip_list) {
+ if (TAILQ_NEXT(mn, free_link) == TAILQ_END(&free_list)) {
+ if (TAILQ_NEXT(next, link) == TAILQ_END(&chip_list)) {
/*
* we are not on list so we can add
* ourselves to the tail. (we walked to it.)
*/
- CIRCLEQ_INSERT_TAIL(&free_list,mn,free_link);
+ TAILQ_INSERT_TAIL(&free_list,mn,free_link);
} else {
- CIRCLEQ_INSERT_HEAD(&free_list,mn,free_link);
+ TAILQ_INSERT_HEAD(&free_list,mn,free_link);
}
}
chip_total += mn->size; /* add our helpings to the pool. */
@@ -642,8 +643,7 @@
val = chip_total;
else {
s = splhigh();
- for (mn = free_list.cqh_first; mn != (void *)&free_list;
- mn = mn->free_link.cqe_next) {
+ TAILQ_FOREACH(mn, &free_list, free_link) {
if (mn->size > val)
val = mn->size;
}
diff -r d162faf10ddb -r e54bc59a2133 sys/arch/amiga/amiga/cc.h
--- a/sys/arch/amiga/amiga/cc.h Sat Nov 23 22:31:53 2013 +0000
+++ b/sys/arch/amiga/amiga/cc.h Sat Nov 23 22:48:00 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cc.h,v 1.16 2007/03/05 18:33:34 he Exp $ */
+/* $NetBSD: cc.h,v 1.17 2013/11/23 22:48:00 christos Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@@ -157,8 +157,8 @@
*/
struct mem_node {
- CIRCLEQ_ENTRY(mem_node) link;
- CIRCLEQ_ENTRY(mem_node) free_link;
+ TAILQ_ENTRY(mem_node) link;
+ TAILQ_ENTRY(mem_node) free_link;
u_long size; /* size of memory following node. */
};
Home |
Main Index |
Thread Index |
Old Index