Update of /cvsroot/ggi/ggi-core/libgalloc/galloc
In directory usw-pr-cvs1:/tmp/cvs-serv7878/galloc
Modified Files:
templates.c
Log Message:
More galloc brains to mystify and confuse the coding public.
Index: templates.c
===================================================================
RCS file: /cvsroot/ggi/ggi-core/libgalloc/galloc/templates.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** templates.c 2001/10/26 01:27:43 1.24
--- templates.c 2001/10/27 05:02:23 1.25
***************
*** 284,287 ****
--- 284,314 ----
+ /* Finds the taghead of res, (but only if it occurs before res
+ * in the list). Returns NULL when nothing found.
+ */
+ static inline ggiGA_taghead_t find_taghead(ggiGA_resource_list list,
+ ggiGA_resource_handle this) {
+ ggiGA_resource_handle tmp2;
+ ggiGA_taghead_t taghead;
+
+ if (!ggiGA_TAG(this)) return NULL;
+
+ tmp2 = list;
+ taghead = NULL;
+
+ while (tmp2 != this) {
+ if (ggiGA_FULLTYPE(tmp2) != GA_RT_RESLIST_TAGHEAD)
+ goto skip;
+ taghead = (ggiGA_taghead_t)tmp2;
+ if (ggiGA_TAG(this) == taghead->tag2) break;
+ taghead = NULL;
+ skip:
+ tmp2 = tmp2->next;
+ }
+ return taghead;
+ }
+
+ #define find_compound(list,res) ggiGAFindCompoundHead(list, res)
+
/* This function checks to see if has in haslist, which is a proposed
* master resource for res in reslist, would place res in the "correct"
***************
*** 293,297 ****
ggiGA_resource_list haslist,
ggiGA_resource_handle has) {
! return 0;
}
--- 320,427 ----
ggiGA_resource_list haslist,
ggiGA_resource_handle has) {
! ggiGA_resource_handle has_tmp, req_tmp;
!
! /* All resources before req (e.g. resources which
! * have already been checked) in req's compound
! * must have masters in the same compound that
! * has belongs to in the haslist.
! *
! * Since resources prior to this have succeeded
! * this test already, it is only necessary to
! * do the following check:
! */
! req_tmp = find_compound(reqlist, req);
! has_tmp = find_compound(haslist, has);
! if ((req_tmp != req) &&
! (find_compound(haslist, req_tmp->master) != has_tmp)) return -1;
!
! /* All resources before and including req which are in
! * req's ring must have masters in the same ring that
! * has belongs to in the haslist.
! *
! * Since resources prior to this have succeeded
! * this test already, it is only necessary to
! * check one such resource. But first we must find
! * one (one which is not the tag group head of the ring.)
! */
! req_tmp = req;
! do {
! /* Simply traverse through the tag group head of the ring. */
! if (ggiGA_TAG(req_tmp) != ggiGA_TAG(req)) {
! LIB_ASSERT(ggiGA_FULLTYPE(req_tmp) == GA_RT_RESLIST_TAGHEAD);
! req_tmp = ((ggiGA_taghead_t)req_tmp)->right2;
! continue;
! } /* if */
! req_tmp = req_tmp->right;
! if (!ggiGAIsFailed(req_tmp)) break;
! } while (req_tmp != req);
! if (req_tmp == req) goto alone;
! has_tmp = has;
! do {
! if (req_tmp->master == has_tmp) break;
! /* Simply traverse through the tag group heads of the ring. */
! if (ggiGA_TAG(has_tmp) != ggiGA_TAG(has)) {
! LIB_ASSERT(ggiGA_FULLTYPE(has_tmp) == GA_RT_RESLIST_TAGHEAD);
! has_tmp = ((ggiGA_taghead_t)has_tmp)->right2;
! continue;
! } /* if */
! has_tmp = has_tmp->right;
! } while (has_tmp != has);
! if (req_tmp->master != has_tmp) return -1;
!
! /* If the req's left pointer is pointing out if its ring,
! * we check to make sure that the ring it is hooked to
! * contains resources which have masters which are in the
! * same ring that has's left pointer is hooked to.
! */
! alone:
! req_tmp = req->left;
! do {
! if (req_tmp == req) return GALLOC_OK; /* ring is 2-way */
! /* Simply traverse through tag group head of the ring. */
! if (ggiGA_TAG(req_tmp) != ggiGA_TAG(req)) {
! LIB_ASSERT(ggiGA_FULLTYPE(req_tmp) == GA_RT_RESLIST_TAGHEAD);
! req_tmp = ((ggiGA_taghead_t)req_tmp)->right2;
! continue;
! } /* if */
! req_tmp = req_tmp->right;
! } while (req_tmp != req->left);
! /* Find a pointer in the ring that has already been checked */
! if (!ggiGAIsFailed(req->left)) goto skip;
! req_tmp = req->left;
! do {
! if (!ggiGAIsFailed(req_tmp)) break;
! /* Simply traverse through tag group head of the ring. */
! if (ggiGA_TAG(req_tmp) != ggiGA_TAG(req)) {
! LIB_ASSERT(ggiGA_FULLTYPE(req_tmp) == GA_RT_RESLIST_TAGHEAD);
! req_tmp = ((ggiGA_taghead_t)req_tmp)->right2;
! continue;
! } /* if */
! req_tmp = req_tmp->right;
! } while (req_tmp != req->left);
! /* If there are no successful resources in that ring, we will
! * give the resource the benefit of the doubt.
! *
! * Right now this case is not handled elsewhere in the code,
! * so we complain.
! */
! LIB_ASSERT(req_tmp != req->left);
! if (req_tmp == req->left) return GALLOC_OK;
! skip:
! /* Finally, we look for its master in the haslist */
! has_tmp = has;
! do {
! if (req_tmp->master == has_tmp) break;
! /* Simply traverse through the tag group heads of the ring. */
! if (ggiGA_TAG(has_tmp) != ggiGA_TAG(has)) {
! LIB_ASSERT(ggiGA_FULLTYPE(has_tmp) == GA_RT_RESLIST_TAGHEAD);
! has_tmp = ((ggiGA_taghead_t)has_tmp)->right2;
! continue;
! } /* if */
! has_tmp = has_tmp->right;
! } while (has_tmp != has);
! if (req_tmp->master != has_tmp) return -1;
!
! return GALLOC_OK;
}
***************
*** 301,305 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 431,435 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 390,393 ****
--- 520,525 ----
reset_haslist(vis, haslist);
while (tmp1 != NULL) {
+ ggiGA_taghead_t taghead = NULL;
+ ggiGA_resource_handle compound = NULL;
if (need_reset > 1) {
reset_reqlist(request, reqlist);
***************
*** 396,410 ****
tmp2 = reqlist;
while (tmp2 != tmp1) {
rc = do_callback(vis, reqlist, GA_CB_PRECHECK,
! tmp1, NULL, NULL,
! tmp2, &state, &privstate);
LIB_ASSERT(rc == GALLOC_OK);
rc = do_callback(vis, reqlist, GA_CB_CHECK,
! tmp1, NULL, NULL,
! tmp2, &state, &privstate);
LIB_ASSERT(rc == GALLOC_OK);
rc = do_callback(vis, reqlist, GA_CB_POSTCHECK,
! tmp1, NULL, NULL,
! tmp2, &state, &privstate);
LIB_ASSERT(rc == GALLOC_OK);
}
--- 528,547 ----
tmp2 = reqlist;
while (tmp2 != tmp1) {
+ taghead = find_taghead(reqlist, tmp2);
+ compound = find_compound(reqlist, tmp2);
rc = do_callback(vis, reqlist, GA_CB_PRECHECK,
! tmp2, compound, taghead,
! tmp2->master,
! &state, &privstate);
LIB_ASSERT(rc == GALLOC_OK);
rc = do_callback(vis, reqlist, GA_CB_CHECK,
! tmp2, compound, taghead,
! tmp2->master,
! &state, &privstate);
LIB_ASSERT(rc == GALLOC_OK);
rc = do_callback(vis, reqlist, GA_CB_POSTCHECK,
! tmp2, compound, taghead,
! tmp2->master,
! &state, &privstate);
LIB_ASSERT(rc == GALLOC_OK);
}
***************
*** 414,433 ****
tmp2 = reqlist;
while (tmp2 != tmp1) {
rc = do_callback(vis, reqlist, GA_CB_RECHECK,
! tmp1, NULL, NULL,
! tmp2, &state, &privstate);
LIB_ASSERT(rc == GALLOC_OK);
}
need_reset = 0;
}
tmp2 = (tmp1->master == NULL) ? haslist : tmp1->master->next;
while (tmp2 != NULL) {
fprintf(stderr, "matching %p to %p\n", tmp1, tmp2);
if (do_callback(vis, reqlist, GA_CB_MATCH,
! tmp1, NULL, NULL,
tmp2, &state, &privstate))
goto nexthas;
if (do_callback(vis, reqlist, GA_CB_PRECHECK,
! tmp1, NULL, NULL,
tmp2, &state, &privstate))
goto nexthas;
--- 551,575 ----
tmp2 = reqlist;
while (tmp2 != tmp1) {
+ taghead = find_taghead(reqlist, tmp2);
+ compound = find_compound(reqlist, tmp2);
rc = do_callback(vis, reqlist, GA_CB_RECHECK,
! tmp2, compound, taghead,
! tmp2->master,
! &state, &privstate);
LIB_ASSERT(rc == GALLOC_OK);
}
need_reset = 0;
}
+ taghead = find_taghead(reqlist, tmp1);
+ compound = find_compound(reqlist, tmp1);
tmp2 = (tmp1->master == NULL) ? haslist : tmp1->master->next;
while (tmp2 != NULL) {
fprintf(stderr, "matching %p to %p\n", tmp1, tmp2);
if (do_callback(vis, reqlist, GA_CB_MATCH,
! tmp1, compound, taghead,
tmp2, &state, &privstate))
goto nexthas;
if (do_callback(vis, reqlist, GA_CB_PRECHECK,
! tmp1, compound, taghead,
tmp2, &state, &privstate))
goto nexthas;
***************
*** 435,443 ****
goto nexthas;
if (do_callback(vis, reqlist, GA_CB_CHECK,
! tmp1, NULL, NULL,
tmp2, &state, &privstate))
goto nexthas;
if (do_callback(vis, reqlist, GA_CB_POSTCHECK,
! tmp1, NULL, NULL,
tmp2, &state, &privstate))
goto nexthas;
--- 577,585 ----
goto nexthas;
if (do_callback(vis, reqlist, GA_CB_CHECK,
! tmp1, compound, taghead,
tmp2, &state, &privstate))
goto nexthas;
if (do_callback(vis, reqlist, GA_CB_POSTCHECK,
! tmp1, compound, taghead,
tmp2, &state, &privstate))
goto nexthas;
***************
*** 456,459 ****
--- 598,603 ----
tmp1 = tmp2;
if (tmp2 != NULL) {
+ taghead = find_taghead(reqlist, tmp1);
+ compound = find_compound(reqlist, tmp1);
tmp2 = tmp2->next;
while (tmp2 != NULL) {
***************
*** 463,467 ****
need_reset = do_callback(vis, reqlist,
GA_CB_UNCHECK,
! tmp1, NULL, NULL,
tmp1->master,
&state, &privstate);
--- 607,612 ----
need_reset = do_callback(vis, reqlist,
GA_CB_UNCHECK,
! tmp1, compound,
! taghead,
tmp1->master,
&state, &privstate);
***************
*** 487,491 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 632,636 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 522,526 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 667,671 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 558,562 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 703,707 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 570,574 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 715,719 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 582,586 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 727,731 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 594,598 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 739,743 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 649,653 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 794,798 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 674,678 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 819,823 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 699,703 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 844,848 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 732,736 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 877,881 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 763,767 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 908,912 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 775,779 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 920,924 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 787,791 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 932,936 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 799,803 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 944,948 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 838,842 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 983,987 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 854,858 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 999,1003 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
***************
*** 870,874 ****
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_resource_handle taghead,
ggiGA_resource_handle has,
void **state,
--- 1015,1019 ----
ggiGA_resource_handle res,
ggiGA_resource_handle head,
! ggiGA_taghead_t taghead,
ggiGA_resource_handle has,
void **state,
|