FreeBSD Bugzilla – Attachment 6683 Details for
Bug 14968
Convert resource_head and resource.r_link from CIRCLEQ to TAILQ
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 9.44 KB, created by
jake
on 1999-11-18 03:50:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
jake
Created:
1999-11-18 03:50:00 UTC
Size:
9.44 KB
patch
obsolete
>Index: sys/rman.h >=================================================================== >RCS file: /home/ncvs/src/sys/sys/rman.h,v >retrieving revision 1.3 >diff -c -r1.3 rman.h >*** rman.h 1999/08/28 00:51:58 1.3 >--- rman.h 1999/11/17 01:34:57 >*************** >*** 42,50 **** > * address space). That is also why the indices are defined to have type > * `unsigned long' -- that being the largest integral type in Standard C. > */ >! CIRCLEQ_HEAD(resource_head, resource); > struct resource { >! CIRCLEQ_ENTRY(resource) r_link; > LIST_ENTRY(resource) r_sharelink; > LIST_HEAD(, resource) *r_sharehead; > u_long r_start; /* index of the first entry in this resource */ >--- 42,50 ---- > * address space). That is also why the indices are defined to have type > * `unsigned long' -- that being the largest integral type in Standard C. > */ >! TAILQ_HEAD(resource_head, resource); > struct resource { >! TAILQ_ENTRY(resource) r_link; > LIST_ENTRY(resource) r_sharelink; > LIST_HEAD(, resource) *r_sharehead; > u_long r_start; /* index of the first entry in this resource */ >Index: kern/subr_rman.c >=================================================================== >RCS file: /home/ncvs/src/sys/kern/subr_rman.c,v >retrieving revision 1.10 >diff -c -r1.10 subr_rman.c >*** subr_rman.c 1999/11/16 16:28:57 1.10 >--- subr_rman.c 1999/11/17 07:36:58 >*************** >*** 77,84 **** > static int int_rman_deactivate_resource(struct resource *r); > static int int_rman_release_resource(struct rman *rm, struct resource *r); > >- #define CIRCLEQ_TERMCOND(var, head) (var == (void *)&(head)) >- > int > rman_init(struct rman *rm) > { >--- 77,82 ---- >*************** >*** 95,101 **** > if (rm->rm_type == RMAN_GAUGE) > panic("implement RMAN_GAUGE"); > >! CIRCLEQ_INIT(&rm->rm_list); > rm->rm_slock = malloc(sizeof *rm->rm_slock, M_RMAN, M_NOWAIT); > if (rm->rm_slock == 0) > return ENOMEM; >--- 93,99 ---- > if (rm->rm_type == RMAN_GAUGE) > panic("implement RMAN_GAUGE"); > >! TAILQ_INIT(&rm->rm_list); > rm->rm_slock = malloc(sizeof *rm->rm_slock, M_RMAN, M_NOWAIT); > if (rm->rm_slock == 0) > return ENOMEM; >*************** >*** 128,142 **** > r->r_rm = rm; > > simple_lock(rm->rm_slock); >! for (s = CIRCLEQ_FIRST(&rm->rm_list); >! !CIRCLEQ_TERMCOND(s, rm->rm_list) && s->r_end < r->r_start; >! s = CIRCLEQ_NEXT(s, r_link)) > ; > >! if (CIRCLEQ_TERMCOND(s, rm->rm_list)) { >! CIRCLEQ_INSERT_TAIL(&rm->rm_list, r, r_link); > } else { >! CIRCLEQ_INSERT_BEFORE(&rm->rm_list, s, r, r_link); > } > > simple_unlock(rm->rm_slock); >--- 126,140 ---- > r->r_rm = rm; > > simple_lock(rm->rm_slock); >! for (s = TAILQ_FIRST(&rm->rm_list); >! s != NULL && s->r_end < r->r_start; >! s = TAILQ_NEXT(s, r_link)) > ; > >! if (s == NULL) { >! TAILQ_INSERT_TAIL(&rm->rm_list, r, r_link); > } else { >! TAILQ_INSERT_BEFORE(s, r, r_link); > } > > simple_unlock(rm->rm_slock); >*************** >*** 149,155 **** > struct resource *r; > > simple_lock(rm->rm_slock); >! CIRCLEQ_FOREACH(r, &rm->rm_list, r_link) { > if (r->r_flags & RF_ALLOCATED) { > simple_unlock(rm->rm_slock); > return EBUSY; >--- 147,153 ---- > struct resource *r; > > simple_lock(rm->rm_slock); >! TAILQ_FOREACH(r, &rm->rm_list, r_link) { > if (r->r_flags & RF_ALLOCATED) { > simple_unlock(rm->rm_slock); > return EBUSY; >*************** >*** 160,168 **** > * There really should only be one of these if we are in this > * state and the code is working properly, but it can't hurt. > */ >! while (!CIRCLEQ_EMPTY(&rm->rm_list)) { >! r = CIRCLEQ_FIRST(&rm->rm_list); >! CIRCLEQ_REMOVE(&rm->rm_list, r, r_link); > free(r, M_RMAN); > } > simple_unlock(rm->rm_slock); >--- 158,166 ---- > * There really should only be one of these if we are in this > * state and the code is working properly, but it can't hurt. > */ >! while (!TAILQ_EMPTY(&rm->rm_list)) { >! r = TAILQ_FIRST(&rm->rm_list); >! TAILQ_REMOVE(&rm->rm_list, r, r_link); > free(r, M_RMAN); > } > simple_unlock(rm->rm_slock); >*************** >*** 194,205 **** > > simple_lock(rm->rm_slock); > >! for (r = CIRCLEQ_FIRST(&rm->rm_list); >! !CIRCLEQ_TERMCOND(r, rm->rm_list) && r->r_end < start; >! r = CIRCLEQ_NEXT(r, r_link)) > ; > >! if (CIRCLEQ_TERMCOND(r, rm->rm_list)) { > #ifdef RMAN_DEBUG > printf("could not find a region\n"); > #endif RMAN_DEBUG >--- 192,203 ---- > > simple_lock(rm->rm_slock); > >! for (r = TAILQ_FIRST(&rm->rm_list); >! r != NULL && r->r_end < start; >! r = TAILQ_NEXT(r, r_link)) > ; > >! if (r == NULL) { > #ifdef RMAN_DEBUG > printf("could not find a region\n"); > #endif RMAN_DEBUG >*************** >*** 209,216 **** > /* > * First try to find an acceptable totally-unshared region. > */ >! for (s = r; !CIRCLEQ_TERMCOND(s, rm->rm_list); >! s = CIRCLEQ_NEXT(s, r_link)) { > #ifdef RMAN_DEBUG > printf("considering [%#lx, %#lx]\n", s->r_start, s->r_end); > #endif /* RMAN_DEBUG */ >--- 207,213 ---- > /* > * First try to find an acceptable totally-unshared region. > */ >! for (s = r; s != NULL; s = TAILQ_NEXT(s, r_link)) { > #ifdef RMAN_DEBUG > printf("considering [%#lx, %#lx]\n", s->r_start, s->r_end); > #endif /* RMAN_DEBUG */ >*************** >*** 294,302 **** > r->r_sharehead = 0; > r->r_rm = rm; > s->r_end = rv->r_start - 1; >! CIRCLEQ_INSERT_AFTER(&rm->rm_list, s, rv, > r_link); >! CIRCLEQ_INSERT_AFTER(&rm->rm_list, rv, r, > r_link); > } else if (s->r_start == rv->r_start) { > #ifdef RMAN_DEBUG >--- 291,299 ---- > r->r_sharehead = 0; > r->r_rm = rm; > s->r_end = rv->r_start - 1; >! TAILQ_INSERT_AFTER(&rm->rm_list, s, rv, > r_link); >! TAILQ_INSERT_AFTER(&rm->rm_list, rv, r, > r_link); > } else if (s->r_start == rv->r_start) { > #ifdef RMAN_DEBUG >*************** >*** 306,313 **** > * We are allocating at the beginning. > */ > s->r_start = rv->r_end + 1; >! CIRCLEQ_INSERT_BEFORE(&rm->rm_list, s, rv, >! r_link); > } else { > #ifdef RMAN_DEBUG > printf("allocating at the end\n"); >--- 303,309 ---- > * We are allocating at the beginning. > */ > s->r_start = rv->r_end + 1; >! TAILQ_INSERT_BEFORE(s, rv, r_link); > } else { > #ifdef RMAN_DEBUG > printf("allocating at the end\n"); >*************** >*** 316,322 **** > * We are allocating at the end. > */ > s->r_end = rv->r_start - 1; >! CIRCLEQ_INSERT_AFTER(&rm->rm_list, s, rv, > r_link); > } > goto out; >--- 312,318 ---- > * We are allocating at the end. > */ > s->r_end = rv->r_start - 1; >! TAILQ_INSERT_AFTER(&rm->rm_list, s, rv, > r_link); > } > goto out; >*************** >*** 337,344 **** > if ((flags & (RF_SHAREABLE | RF_TIMESHARE)) == 0) > goto out; > >! for (s = r; !CIRCLEQ_TERMCOND(s, rm->rm_list); >! s = CIRCLEQ_NEXT(s, r_link)) { > if (s->r_start > end) > break; > if ((s->r_flags & flags) != flags) >--- 333,339 ---- > if ((flags & (RF_SHAREABLE | RF_TIMESHARE)) == 0) > goto out; > >! for (s = r; s != NULL; s = TAILQ_NEXT(s, r_link)) { > if (s->r_start > end) > break; > if ((s->r_flags & flags) != flags) >*************** >*** 533,540 **** > s = LIST_FIRST(r->r_sharehead); > if (r->r_flags & RF_FIRSTSHARE) { > s->r_flags |= RF_FIRSTSHARE; >! CIRCLEQ_INSERT_BEFORE(&rm->rm_list, r, s, r_link); >! CIRCLEQ_REMOVE(&rm->rm_list, r, r_link); > } > > /* >--- 528,535 ---- > s = LIST_FIRST(r->r_sharehead); > if (r->r_flags & RF_FIRSTSHARE) { > s->r_flags |= RF_FIRSTSHARE; >! TAILQ_INSERT_BEFORE(r, s, r_link); >! TAILQ_REMOVE(&rm->rm_list, r, r_link); > } > > /* >*************** >*** 553,584 **** > * Look at the adjacent resources in the list and see if our > * segment can be merged with any of them. > */ >! s = CIRCLEQ_PREV(r, r_link); >! t = CIRCLEQ_NEXT(r, r_link); > >! if (s != (void *)&rm->rm_list && (s->r_flags & RF_ALLOCATED) == 0 >! && t != (void *)&rm->rm_list && (t->r_flags & RF_ALLOCATED) == 0) { > /* > * Merge all three segments. > */ > s->r_end = t->r_end; >! CIRCLEQ_REMOVE(&rm->rm_list, r, r_link); >! CIRCLEQ_REMOVE(&rm->rm_list, t, r_link); > free(t, M_RMAN); >! } else if (s != (void *)&rm->rm_list >! && (s->r_flags & RF_ALLOCATED) == 0) { > /* > * Merge previous segment with ours. > */ > s->r_end = r->r_end; >! CIRCLEQ_REMOVE(&rm->rm_list, r, r_link); >! } else if (t != (void *)&rm->rm_list >! && (t->r_flags & RF_ALLOCATED) == 0) { > /* > * Merge next segment with ours. > */ > t->r_start = r->r_start; >! CIRCLEQ_REMOVE(&rm->rm_list, r, r_link); > } else { > /* > * At this point, we know there is nothing we >--- 548,577 ---- > * Look at the adjacent resources in the list and see if our > * segment can be merged with any of them. > */ >! s = TAILQ_PREV(r, resource_head, r_link); >! t = TAILQ_NEXT(r, r_link); > >! if (s != NULL && (s->r_flags & RF_ALLOCATED) == 0 >! && t != NULL && (t->r_flags & RF_ALLOCATED) == 0) { > /* > * Merge all three segments. > */ > s->r_end = t->r_end; >! TAILQ_REMOVE(&rm->rm_list, r, r_link); >! TAILQ_REMOVE(&rm->rm_list, t, r_link); > free(t, M_RMAN); >! } else if (s != NULL && (s->r_flags & RF_ALLOCATED) == 0) { > /* > * Merge previous segment with ours. > */ > s->r_end = r->r_end; >! TAILQ_REMOVE(&rm->rm_list, r, r_link); >! } else if (t != NULL && (t->r_flags & RF_ALLOCATED) == 0) { > /* > * Merge next segment with ours. > */ > t->r_start = r->r_start; >! TAILQ_REMOVE(&rm->rm_list, r, r_link); > } else { > /* > * At this point, we know there is nothing we
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 14968
: 6683