1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-25 15:00:45 -08:00

Merging branch/2016-03-01/closure-size into master sources.

Copied from Perforce
 Change: 189880
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Brooksby 2016-03-12 08:46:57 +00:00
commit 1ffc021b51
27 changed files with 252 additions and 285 deletions

View file

@ -232,7 +232,7 @@ Count ABQDepth(ABQ abq)
/* ABQIterate -- call 'visitor' for each element in an ABQ */
void ABQIterate(ABQ abq, ABQVisitor visitor, void *closureP, Size closureS)
void ABQIterate(ABQ abq, ABQVisitor visitor, void *closure)
{
Index copy, index, in;
@ -247,7 +247,7 @@ void ABQIterate(ABQ abq, ABQVisitor visitor, void *closureP, Size closureS)
void *element = ABQElement(abq, index);
Bool delete = FALSE;
Bool cont;
cont = (*visitor)(&delete, element, closureP, closureS);
cont = (*visitor)(&delete, element, closure);
AVERT(Bool, cont);
AVERT(Bool, delete);
if (!delete) {

View file

@ -24,7 +24,7 @@
typedef struct ABQStruct *ABQ;
typedef Res (*ABQDescribeElement)(void *element, mps_lib_FILE *stream, Count depth);
typedef Bool (*ABQVisitor)(Bool *deleteReturn, void *element, void *closureP, Size closureS);
typedef Bool (*ABQVisitor)(Bool *deleteReturn, void *element, void *closure);
extern Res ABQInit(Arena arena, ABQ abq, void *owner, Count elements, Size elementSize);
extern Bool ABQCheck(ABQ abq);
@ -36,7 +36,7 @@ extern Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE
extern Bool ABQIsEmpty(ABQ abq);
extern Bool ABQIsFull(ABQ abq);
extern Count ABQDepth(ABQ abq);
extern void ABQIterate(ABQ abq, ABQVisitor visitor, void *closureP, Size closureS);
extern void ABQIterate(ABQ abq, ABQVisitor visitor, void *closure);
/* Types */

View file

@ -92,12 +92,10 @@ typedef struct TestClosureStruct {
} TestClosureStruct;
static Bool TestDeleteCallback(Bool *deleteReturn, void *element,
void *closureP, Size closureS)
void *closure)
{
TestBlock *a = (TestBlock *)element;
TestClosure cl = (TestClosure)closureP;
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
TestClosure cl = (TestClosure)closure;
if (*a == cl->b) {
*deleteReturn = TRUE;
cl->res = ResOK;
@ -145,7 +143,7 @@ static void step(void)
cdie(b != NULL, "found to delete");
cl.b = b;
cl.res = ResFAIL;
ABQIterate(&abq, TestDeleteCallback, &cl, UNUSED_SIZE);
ABQIterate(&abq, TestDeleteCallback, &cl);
cdie(cl.res == ResOK, "ABQIterate");
}
}

View file

@ -406,13 +406,11 @@ void ArenaFinish(Arena arena)
/* ArenaDestroy -- destroy the arena */
static void arenaMFSPageFreeVisitor(Pool pool, Addr base, Size size,
void *closureP, Size closureS)
void *closure)
{
AVERT(Pool, pool);
AVER(closureP == UNUSED_POINTER);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureP);
UNUSED(closureS);
AVER(closure == UNUSED_POINTER);
UNUSED(closure);
UNUSED(size);
AVER(size == ArenaGrainSize(PoolArena(pool)));
arenaFreePage(PoolArena(pool), base, pool);
@ -431,7 +429,7 @@ static void arenaFreeLandFinish(Arena arena)
/* The CBS block pool can't free its own memory via ArenaFree because
* that would use the free land. */
MFSFinishTracts(ArenaCBSBlockPool(arena), arenaMFSPageFreeVisitor,
UNUSED_POINTER, UNUSED_SIZE);
UNUSED_POINTER);
arena->hasFreeLand = FALSE;
LandFinish(ArenaFreeLand(arena));

View file

@ -182,7 +182,7 @@ static Res ClientChunkInit(Chunk chunk, BootBlock boot)
/* clientChunkDestroy -- destroy a ClientChunk */
static Bool clientChunkDestroy(Tree tree, void *closureP, Size closureS)
static Bool clientChunkDestroy(Tree tree, void *closure)
{
Arena arena;
Chunk chunk;
@ -190,10 +190,8 @@ static Bool clientChunkDestroy(Tree tree, void *closureP, Size closureS)
Size size;
AVERT(Tree, tree);
AVER(closureP == UNUSED_POINTER);
UNUSED(closureP);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
AVER(closure == UNUSED_POINTER);
UNUSED(closure);
chunk = ChunkOfTree(tree);
AVERT(Chunk, chunk);
@ -337,7 +335,7 @@ static void ClientArenaFinish(Arena arena)
* <design/arena/#chunk.delete> */
arena->primary = NULL;
TreeTraverseAndDelete(&arena->chunkTree, clientChunkDestroy,
UNUSED_POINTER, UNUSED_SIZE);
UNUSED_POINTER);
clientArena->sig = SigInvalid;

View file

@ -409,16 +409,14 @@ failSaMapped:
/* vmChunkDestroy -- destroy a VMChunk */
static Bool vmChunkDestroy(Tree tree, void *closureP, Size closureS)
static Bool vmChunkDestroy(Tree tree, void *closure)
{
Chunk chunk;
VMChunk vmChunk;
AVERT(Tree, tree);
AVER(closureP == UNUSED_POINTER);
UNUSED(closureP);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
AVER(closure == UNUSED_POINTER);
UNUSED(closure);
chunk = ChunkOfTree(tree);
AVERT(Chunk, chunk);
@ -636,7 +634,7 @@ static void VMArenaFinish(Arena arena)
* <design/arena/#chunk.delete> */
arena->primary = NULL;
TreeTraverseAndDelete(&arena->chunkTree, vmChunkDestroy,
UNUSED_POINTER, UNUSED_SIZE);
UNUSED_POINTER);
/* Destroying the chunks should have purged and removed all spare pages. */
RingFinish(&vmArena->spareRing);
@ -1094,16 +1092,14 @@ static void VMFree(Addr base, Size size, Pool pool)
/* vmChunkCompact -- delete chunk if empty and not primary */
static Bool vmChunkCompact(Tree tree, void *closureP, Size closureS)
static Bool vmChunkCompact(Tree tree, void *closure)
{
Chunk chunk;
Arena arena = closureP;
Arena arena = closure;
VMArena vmArena;
AVERT(Tree, tree);
AVERT(Arena, arena);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
vmArena = Arena2VMArena(arena);
AVERT(VMArena, vmArena);
@ -1117,7 +1113,7 @@ static Bool vmChunkCompact(Tree tree, void *closureP, Size closureS)
/* Callback before destroying the chunk, as the arena is (briefly)
invalid afterwards. See job003893. */
(*vmArena->contracted)(arena, base, size);
vmChunkDestroy(tree, UNUSED_POINTER, UNUSED_SIZE);
vmChunkDestroy(tree, UNUSED_POINTER);
return TRUE;
} else {
/* Keep this chunk. */
@ -1140,8 +1136,7 @@ static void VMCompact(Arena arena, Trace trace)
/* Destroy chunks that are completely free, but not the primary
* chunk. See <design/arena/#chunk.delete>
* TODO: add hysteresis here. See job003815. */
TreeTraverseAndDelete(&arena->chunkTree, vmChunkCompact, arena,
UNUSED_SIZE);
TreeTraverseAndDelete(&arena->chunkTree, vmChunkCompact, arena);
{
Size vmem0 = trace->preTraceArenaReserved;

View file

@ -117,36 +117,37 @@ static TreeKey cbsKey(Tree tree)
/* cbsTestNode, cbsTestTree -- test for nodes larger than the S parameter */
static Bool cbsTestNode(SplayTree splay, Tree tree,
void *closureP, Size size)
static Bool cbsTestNode(SplayTree splay, Tree tree, void *closure)
{
CBSBlock block;
Size *sizeP = closure;
AVERT(SplayTree, splay);
AVERT(Tree, tree);
AVER(closureP == NULL);
AVER(size > 0);
AVER(sizeP != NULL);
AVER(*sizeP > 0);
AVER(IsLandSubclass(CBSLand(cbsOfSplay(splay)), CBSFastLandClass));
block = cbsBlockOfTree(tree);
return CBSBlockSize(block) >= size;
return CBSBlockSize(block) >= *sizeP;
}
static Bool cbsTestTree(SplayTree splay, Tree tree,
void *closureP, Size size)
void *closure)
{
CBSFastBlock block;
Size *sizeP = closure;
AVERT(SplayTree, splay);
AVERT(Tree, tree);
AVER(closureP == NULL);
AVER(size > 0);
AVER(sizeP != NULL);
AVER(*sizeP > 0);
AVER(IsLandSubclass(CBSLand(cbsOfSplay(splay)), CBSFastLandClass));
block = cbsFastBlockOfTree(tree);
return block->maxSize >= size;
return block->maxSize >= *sizeP;
}
@ -726,25 +727,24 @@ static Res cbsZonedSplayNodeDescribe(Tree tree, mps_lib_FILE *stream)
typedef struct CBSIterateClosure {
Land land;
LandVisitor visitor;
void *closureP;
void *visitorClosure;
} CBSIterateClosure;
static Bool cbsIterateVisit(Tree tree, void *closureP, Size closureS)
static Bool cbsIterateVisit(Tree tree, void *closure)
{
CBSIterateClosure *closure = closureP;
Land land = closure->land;
CBSIterateClosure *my = closure;
Land land = my->land;
CBSBlock cbsBlock = cbsBlockOfTree(tree);
RangeStruct range;
RangeInit(&range, CBSBlockBase(cbsBlock), CBSBlockLimit(cbsBlock));
return (*closure->visitor)(land, &range, closure->closureP, closureS);
return my->visitor(land, &range, my->visitorClosure);
}
static Bool cbsIterate(Land land, LandVisitor visitor,
void *closureP, Size closureS)
static Bool cbsIterate(Land land, LandVisitor visitor, void *visitorClosure)
{
CBS cbs;
SplayTree splay;
CBSIterateClosure closure;
CBSIterateClosure iterateClosure;
AVERT(Land, land);
cbs = cbsOfLand(land);
@ -756,11 +756,11 @@ static Bool cbsIterate(Land land, LandVisitor visitor,
/* searches and meter it. */
METER_ACC(cbs->treeSearch, cbs->treeSize);
closure.land = land;
closure.visitor = visitor;
closure.closureP = closureP;
iterateClosure.land = land;
iterateClosure.visitor = visitor;
iterateClosure.visitorClosure = visitorClosure;
return TreeTraverse(SplayTreeRoot(splay), splay->compare, splay->nodeKey,
cbsIterateVisit, &closure, closureS);
cbsIterateVisit, &iterateClosure);
}
@ -773,33 +773,33 @@ typedef struct CBSIterateAndDeleteClosure {
Land land;
LandDeleteVisitor visitor;
Bool cont;
void *closureP;
void *visitorClosure;
} CBSIterateAndDeleteClosure;
static Bool cbsIterateAndDeleteVisit(Tree tree, void *closureP, Size closureS)
static Bool cbsIterateAndDeleteVisit(Tree tree, void *closure)
{
CBSIterateAndDeleteClosure *closure = closureP;
Land land = closure->land;
CBSIterateAndDeleteClosure *my = closure;
Land land = my->land;
CBS cbs = cbsOfLand(land);
CBSBlock cbsBlock = cbsBlockOfTree(tree);
Bool deleteNode = FALSE;
RangeStruct range;
RangeInit(&range, CBSBlockBase(cbsBlock), CBSBlockLimit(cbsBlock));
if (closure->cont)
closure->cont = (*closure->visitor)(&deleteNode, land, &range,
closure->closureP, closureS);
if (my->cont)
my->cont = my->visitor(&deleteNode, land, &range,
my->visitorClosure);
if (deleteNode)
cbsBlockDestroy(cbs, cbsBlock);
return deleteNode;
}
static Bool cbsIterateAndDelete(Land land, LandDeleteVisitor visitor,
void *closureP, Size closureS)
void *visitorClosure)
{
CBS cbs;
SplayTree splay;
CBSIterateAndDeleteClosure closure;
CBSIterateAndDeleteClosure iterateClosure;
AVERT(Land, land);
cbs = cbsOfLand(land);
@ -811,13 +811,13 @@ static Bool cbsIterateAndDelete(Land land, LandDeleteVisitor visitor,
/* searches and meter it. */
METER_ACC(cbs->treeSearch, cbs->treeSize);
closure.land = land;
closure.visitor = visitor;
closure.closureP = closureP;
closure.cont = TRUE;
iterateClosure.land = land;
iterateClosure.visitor = visitor;
iterateClosure.visitorClosure = visitorClosure;
iterateClosure.cont = TRUE;
TreeTraverseAndDelete(&splay->root, cbsIterateAndDeleteVisit,
&closure, closureS);
return closure.cont;
&iterateClosure);
return iterateClosure.cont;
}
@ -904,7 +904,7 @@ static Bool cbsFindFirst(Range rangeReturn, Range oldRangeReturn,
METER_ACC(cbs->treeSearch, cbs->treeSize);
found = SplayFindFirst(&tree, cbsSplay(cbs), &cbsTestNode,
&cbsTestTree, NULL, size);
&cbsTestTree, &size);
if (found) {
CBSBlock block;
RangeStruct range;
@ -934,36 +934,32 @@ typedef struct cbsTestNodeInZonesClosureStruct {
} cbsTestNodeInZonesClosureStruct, *cbsTestNodeInZonesClosure;
static Bool cbsTestNodeInZones(SplayTree splay, Tree tree,
void *closureP, Size closureS)
void *closure)
{
CBSBlock block = cbsBlockOfTree(tree);
cbsTestNodeInZonesClosure closure = closureP;
cbsTestNodeInZonesClosure my = closure;
RangeInZoneSet search;
UNUSED(splay);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
search = closure->high ? RangeInZoneSetLast : RangeInZoneSetFirst;
search = my->high ? RangeInZoneSetLast : RangeInZoneSetFirst;
return search(&closure->base, &closure->limit,
return search(&my->base, &my->limit,
CBSBlockBase(block), CBSBlockLimit(block),
closure->arena, closure->zoneSet, closure->size);
my->arena, my->zoneSet, my->size);
}
static Bool cbsTestTreeInZones(SplayTree splay, Tree tree,
void *closureP, Size closureS)
void *closure)
{
CBSFastBlock fastBlock = cbsFastBlockOfTree(tree);
CBSZonedBlock zonedBlock = cbsZonedBlockOfTree(tree);
cbsTestNodeInZonesClosure closure = closureP;
cbsTestNodeInZonesClosure my = closure;
UNUSED(splay);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
return fastBlock->maxSize >= closure->size
&& ZoneSetInter(zonedBlock->zones, closure->zoneSet) != ZoneSetEMPTY;
return fastBlock->maxSize >= my->size
&& ZoneSetInter(zonedBlock->zones, my->zoneSet) != ZoneSetEMPTY;
}
@ -989,7 +985,7 @@ static Bool cbsFindLast(Range rangeReturn, Range oldRangeReturn,
METER_ACC(cbs->treeSearch, cbs->treeSize);
found = SplayFindLast(&tree, cbsSplay(cbs), &cbsTestNode,
&cbsTestTree, NULL, size);
&cbsTestTree, &size);
if (found) {
CBSBlock block;
RangeStruct range;
@ -1033,7 +1029,7 @@ static Bool cbsFindLargest(Range rangeReturn, Range oldRangeReturn,
CBSBlock block;
METER_ACC(cbs->treeSearch, cbs->treeSize);
found = SplayFindFirst(&tree, cbsSplay(cbs), &cbsTestNode,
&cbsTestTree, NULL, maxSize);
&cbsTestTree, &maxSize);
AVER(found); /* maxSize is exact, so we will find it. */
block = cbsBlockOfTree(tree);
AVER(CBSBlockSize(block) >= maxSize);
@ -1093,7 +1089,7 @@ static Res cbsFindInZones(Bool *foundReturn, Range rangeReturn,
closure.high = high;
if (!(*splayFind)(&tree, cbsSplay(cbs),
cbsTestNodeInZones, cbsTestTreeInZones,
&closure, UNUSED_SIZE))
&closure))
goto fail;
block = cbsBlockOfTree(tree);

View file

@ -177,7 +177,7 @@ static Res failoverDelete(Range rangeReturn, Land land, Range range)
}
static Bool failoverIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
static Bool failoverIterate(Land land, LandVisitor visitor, void *closure)
{
Failover fo;
@ -186,8 +186,8 @@ static Bool failoverIterate(Land land, LandVisitor visitor, void *closureP, Size
AVERT(Failover, fo);
AVER(visitor != NULL);
return LandIterate(fo->primary, visitor, closureP, closureS)
&& LandIterate(fo->secondary, visitor, closureP, closureS);
return LandIterate(fo->primary, visitor, closure)
&& LandIterate(fo->secondary, visitor, closure);
}

View file

@ -94,13 +94,11 @@ static void describe(FBMState state) {
}
static Bool checkCallback(Range range, void *closureP, Size closureS)
static Bool checkCallback(Range range, void *closure)
{
Addr base, limit;
CheckFBMClosure cl = (CheckFBMClosure)closureP;
CheckFBMClosure cl = (CheckFBMClosure)closure;
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
Insist(cl != NULL);
base = RangeBase(range);
@ -126,18 +124,18 @@ static Bool checkCallback(Range range, void *closureP, Size closureS)
static Bool checkCBSCallback(CBS cbs, Range range,
void *closureP, Size closureS)
void *closure)
{
UNUSED(cbs);
return checkCallback(range, closureP, closureS);
return checkCallback(range, closure);
}
static Bool checkFLCallback(Bool *deleteReturn, Range range,
void *closureP, Size closureS)
void *closure)
{
*deleteReturn = FALSE;
return checkCallback(range, closureP, closureS);
return checkCallback(range, closure);
}
@ -151,10 +149,10 @@ static void check(FBMState state)
switch (state->type) {
case FBMTypeCBS:
CBSIterate(state->the.cbs, checkCBSCallback, &closure, UNUSED_SIZE);
CBSIterate(state->the.cbs, checkCBSCallback, &closure);
break;
case FBMTypeFreelist:
FreelistIterate(state->the.fl, checkFLCallback, &closure, UNUSED_SIZE);
FreelistIterate(state->the.fl, checkFLCallback, &closure);
break;
default:
cdie(0, "invalid state->type");

View file

@ -444,7 +444,7 @@ static Res freelistDelete(Range rangeReturn, Land land, Range range)
static Bool freelistIterate(Land land, LandVisitor visitor,
void *closureP, Size closureS)
void *closure)
{
Freelist fl;
FreelistBlock cur, next;
@ -453,7 +453,7 @@ static Bool freelistIterate(Land land, LandVisitor visitor,
fl = freelistOfLand(land);
AVERT(Freelist, fl);
AVER(FUNCHECK(visitor));
/* closureP and closureS are arbitrary */
/* closure arbitrary */
for (cur = fl->list; cur != freelistEND; cur = next) {
RangeStruct range;
@ -462,7 +462,7 @@ static Bool freelistIterate(Land land, LandVisitor visitor,
* visitor touches the block. */
next = freelistBlockNext(cur);
RangeInit(&range, freelistBlockBase(cur), freelistBlockLimit(fl, cur));
cont = (*visitor)(land, &range, closureP, closureS);
cont = (*visitor)(land, &range, closure);
if (!cont)
return FALSE;
}
@ -471,7 +471,7 @@ static Bool freelistIterate(Land land, LandVisitor visitor,
static Bool freelistIterateAndDelete(Land land, LandDeleteVisitor visitor,
void *closureP, Size closureS)
void *closure)
{
Freelist fl;
FreelistBlock prev, cur, next;
@ -480,7 +480,7 @@ static Bool freelistIterateAndDelete(Land land, LandDeleteVisitor visitor,
fl = freelistOfLand(land);
AVERT(Freelist, fl);
AVER(FUNCHECK(visitor));
/* closureP and closureS are arbitrary */
/* closure arbitrary */
prev = freelistEND;
cur = fl->list;
@ -492,7 +492,7 @@ static Bool freelistIterateAndDelete(Land land, LandDeleteVisitor visitor,
next = freelistBlockNext(cur); /* See .next.first. */
size = freelistBlockSize(fl, cur);
RangeInit(&range, freelistBlockBase(cur), freelistBlockLimit(fl, cur));
cont = (*visitor)(&delete, land, &range, closureP, closureS);
cont = (*visitor)(&delete, land, &range, closure);
if (delete) {
freelistBlockSetPrevNext(fl, prev, next, -1);
AVER(fl->size >= size);
@ -746,24 +746,28 @@ fail:
/* freelistDescribeVisitor -- visitor method for freelistDescribe
*
* Writes a decription of the range into the stream pointed to by
* closureP.
* closure.
*/
typedef struct FreelistDescribeClosureStruct {
mps_lib_FILE *stream;
Count depth;
} FreelistDescribeClosureStruct, *FreelistDescribeClosure;
static Bool freelistDescribeVisitor(Land land, Range range,
void *closureP, Size closureS)
void *closure)
{
Res res;
mps_lib_FILE *stream = closureP;
Count depth = closureS;
FreelistDescribeClosure my = closure;
if (!TESTT(Land, land))
return FALSE;
if (!RangeCheck(range))
return FALSE;
if (stream == NULL)
if (my->stream == NULL)
return FALSE;
res = WriteF(stream, depth,
res = WriteF(my->stream, my->depth,
"[$P,", (WriteFP)RangeBase(range),
"$P)", (WriteFP)RangeLimit(range),
" {$U}\n", (WriteFU)RangeSize(range),
@ -778,6 +782,7 @@ static Res freelistDescribe(Land land, mps_lib_FILE *stream, Count depth)
Freelist fl;
Res res;
Bool b;
FreelistDescribeClosureStruct closure;
if (!TESTT(Land, land))
return ResFAIL;
@ -793,7 +798,9 @@ static Res freelistDescribe(Land land, mps_lib_FILE *stream, Count depth)
" size = $U\n", (WriteFU)fl->size,
NULL);
b = LandIterate(land, freelistDescribeVisitor, stream, depth + 2);
closure.stream = stream;
closure.depth = depth + 2;
b = LandIterate(land, freelistDescribeVisitor, &closure);
if (!b)
return ResFAIL;

View file

@ -235,14 +235,14 @@ Res LandDelete(Range rangeReturn, Land land, Range range)
* See <design/land/#function.iterate>
*/
Bool LandIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
Bool LandIterate(Land land, LandVisitor visitor, void *closure)
{
Bool b;
AVERT(Land, land);
AVER(FUNCHECK(visitor));
landEnter(land);
b = (*land->class->iterate)(land, visitor, closureP, closureS);
b = (*land->class->iterate)(land, visitor, closure);
landLeave(land);
return b;
@ -255,14 +255,14 @@ Bool LandIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
* See <design/land/#function.iterate.and.delete>
*/
Bool LandIterateAndDelete(Land land, LandDeleteVisitor visitor, void *closureP, Size closureS)
Bool LandIterateAndDelete(Land land, LandDeleteVisitor visitor, void *closure)
{
Bool b;
AVERT(Land, land);
AVER(FUNCHECK(visitor));
landEnter(land);
b = (*land->class->iterateAndDelete)(land, visitor, closureP, closureS);
b = (*land->class->iterateAndDelete)(land, visitor, closure);
landLeave(land);
return b;
@ -403,11 +403,11 @@ Res LandDescribe(Land land, mps_lib_FILE *stream, Count depth)
/* landFlushVisitor -- visitor for LandFlush.
*
* closureP argument is the destination Land. Attempt to insert the
* closure argument is the destination Land. Attempt to insert the
* range into the destination.
*/
static Bool landFlushVisitor(Bool *deleteReturn, Land land, Range range,
void *closureP, Size closureS)
void *closure)
{
Res res;
RangeStruct newRange;
@ -416,11 +416,9 @@ static Bool landFlushVisitor(Bool *deleteReturn, Land land, Range range,
AVER(deleteReturn != NULL);
AVERT(Land, land);
AVERT(Range, range);
AVER(closureP != NULL);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
AVER(closure != NULL);
dest = closureP;
dest = closure;
res = LandInsert(&newRange, dest, range);
if (res == ResOK) {
*deleteReturn = TRUE;
@ -442,7 +440,7 @@ Bool LandFlush(Land dest, Land src)
AVERT(Land, dest);
AVERT(Land, src);
return LandIterateAndDelete(src, landFlushVisitor, dest, UNUSED_SIZE);
return LandIterateAndDelete(src, landFlushVisitor, dest);
}
@ -491,17 +489,15 @@ static Size landNoSize(Land land)
/* LandSlowSize -- generic size method but slow */
static Bool landSizeVisitor(Land land, Range range,
void *closureP, Size closureS)
void *closure)
{
Size *size;
AVERT(Land, land);
AVERT(Range, range);
AVER(closureP != NULL);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
AVER(closure != NULL);
size = closureP;
size = closure;
*size += RangeSize(range);
return TRUE;
@ -510,7 +506,7 @@ static Bool landSizeVisitor(Land land, Range range,
Size LandSlowSize(Land land)
{
Size size = 0;
Bool b = LandIterate(land, landSizeVisitor, &size, UNUSED_SIZE);
Bool b = LandIterate(land, landSizeVisitor, &size);
AVER(b);
return size;
}
@ -531,21 +527,19 @@ static Res landNoDelete(Range rangeReturn, Land land, Range range)
return ResUNIMPL;
}
static Bool landNoIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
static Bool landNoIterate(Land land, LandVisitor visitor, void *closure)
{
AVERT(Land, land);
AVER(visitor != NULL);
UNUSED(closureP);
UNUSED(closureS);
UNUSED(closure);
return FALSE;
}
static Bool landNoIterateAndDelete(Land land, LandDeleteVisitor visitor, void *closureP, Size closureS)
static Bool landNoIterateAndDelete(Land land, LandDeleteVisitor visitor, void *closure)
{
AVERT(Land, land);
AVER(visitor != NULL);
UNUSED(closureP);
UNUSED(closureS);
UNUSED(closure);
return FALSE;
}

View file

@ -67,13 +67,12 @@ static void describe(TestState state) {
}
static Bool checkVisitor(Land land, Range range, void *closureP, Size closureS)
static Bool checkVisitor(Land land, Range range, void *closure)
{
Addr base, limit;
CheckTestClosure cl = closureP;
CheckTestClosure cl = closure;
testlib_unused(land);
Insist(closureS == UNUSED_SIZE);
Insist(cl != NULL);
base = RangeBase(range);
@ -106,7 +105,7 @@ static void check(TestState state)
closure.limit = addrOfIndex(state, state->size);
closure.oldLimit = state->block;
b = LandIterate(state->land, checkVisitor, &closure, UNUSED_SIZE);
b = LandIterate(state->land, checkVisitor, &closure);
Insist(b);
if (closure.oldLimit == state->block)

View file

@ -1018,8 +1018,8 @@ extern void LandDestroy(Land land);
extern void LandFinish(Land land);
extern Res LandInsert(Range rangeReturn, Land land, Range range);
extern Res LandDelete(Range rangeReturn, Land land, Range range);
extern Bool LandIterate(Land land, LandVisitor visitor, void *closureP, Size closureS);
extern Bool LandIterateAndDelete(Land land, LandDeleteVisitor visitor, void *closureP, Size closureS);
extern Bool LandIterate(Land land, LandVisitor visitor, void *closure);
extern Bool LandIterateAndDelete(Land land, LandDeleteVisitor visitor, void *closure);
extern Bool LandFindFirst(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete);
extern Bool LandFindLast(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete);
extern Bool LandFindLargest(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete);

View file

@ -270,10 +270,10 @@ typedef void (*LandFinishMethod)(Land land);
typedef Size (*LandSizeMethod)(Land land);
typedef Res (*LandInsertMethod)(Range rangeReturn, Land land, Range range);
typedef Res (*LandDeleteMethod)(Range rangeReturn, Land land, Range range);
typedef Bool (*LandVisitor)(Land land, Range range, void *closureP, Size closureS);
typedef Bool (*LandDeleteVisitor)(Bool *deleteReturn, Land land, Range range, void *closureP, Size closureS);
typedef Bool (*LandIterateMethod)(Land land, LandVisitor visitor, void *closureP, Size closureS);
typedef Bool (*LandIterateAndDeleteMethod)(Land land, LandDeleteVisitor visitor, void *closureP, Size closureS);
typedef Bool (*LandVisitor)(Land land, Range range, void *closure);
typedef Bool (*LandDeleteVisitor)(Bool *deleteReturn, Land land, Range range, void *closure);
typedef Bool (*LandIterateMethod)(Land land, LandVisitor visitor, void *closure);
typedef Bool (*LandIterateAndDeleteMethod)(Land land, LandDeleteVisitor visitor, void *closure);
typedef Bool (*LandFindMethod)(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete);
typedef Res (*LandFindInZonesMethod)(Bool *foundReturn, Range rangeReturn, Range oldRangeReturn, Land land, Size size, ZoneSet zoneSet, Bool high);
typedef Res (*LandDescribeMethod)(Land land, mps_lib_FILE *stream, Count depth);

View file

@ -126,7 +126,7 @@ static Res MFSInit(Pool pool, ArgList args)
void MFSFinishTracts(Pool pool, MFSTractVisitor visitor,
void *closureP, Size closureS)
void *closure)
{
MFS mfs;
@ -136,19 +136,17 @@ void MFSFinishTracts(Pool pool, MFSTractVisitor visitor,
while (mfs->tractList != NULL) {
Tract nextTract = (Tract)TractP(mfs->tractList); /* .tract.chain */
visitor(pool, TractBase(mfs->tractList), mfs->extendBy, closureP, closureS);
visitor(pool, TractBase(mfs->tractList), mfs->extendBy, closure);
mfs->tractList = nextTract;
}
}
static void MFSTractFreeVisitor(Pool pool, Addr base, Size size,
void *closureP, Size closureS)
void *closure)
{
AVER(closureP == UNUSED_POINTER);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureP);
UNUSED(closureS);
AVER(closure == UNUSED_POINTER);
UNUSED(closure);
ArenaFree(base, size, pool);
}
@ -161,7 +159,7 @@ static void MFSFinish(Pool pool)
mfs = PoolPoolMFS(pool);
AVERT(MFS, mfs);
MFSFinishTracts(pool, MFSTractFreeVisitor, UNUSED_POINTER, UNUSED_SIZE);
MFSFinishTracts(pool, MFSTractFreeVisitor, UNUSED_POINTER);
mfs->sig = SigInvalid;
}

View file

@ -46,9 +46,9 @@ extern const struct mps_key_s _mps_key_MFSExtendSelf;
extern void MFSExtend(Pool pool, Addr base, Size size);
typedef void MFSTractVisitor(Pool pool, Addr base, Size size,
void *closureP, Size closureS);
void *closure);
extern void MFSFinishTracts(Pool pool, MFSTractVisitor visitor,
void *closureP, Size closureS);
void *closure);
#endif /* poolmfs_h */

View file

@ -751,23 +751,21 @@ static Res MVTBufferFill(Addr *baseReturn, Addr *limitReturn,
/* MVTDeleteOverlapping -- ABQIterate callback used by MVTInsert and
* MVTDelete. It receives a Range in its closureP argument, and sets
* MVTDelete. It receives a Range in its closure argument, and sets
* *deleteReturn to TRUE for ranges in the ABQ that overlap with it,
* and FALSE for ranges that do not.
*/
static Bool MVTDeleteOverlapping(Bool *deleteReturn, void *element,
void *closureP, Size closureS)
void *closure)
{
Range oldRange, newRange;
AVER(deleteReturn != NULL);
AVER(element != NULL);
AVER(closureP != NULL);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
AVER(closure != NULL);
oldRange = element;
newRange = closureP;
newRange = closure;
*deleteReturn = RangesOverlap(oldRange, newRange);
return TRUE;
@ -830,7 +828,7 @@ static Res MVTInsert(MVT mvt, Addr base, Addr limit)
* with ranges on the ABQ, so ensure that the corresponding ranges
* are coalesced on the ABQ.
*/
ABQIterate(MVTABQ(mvt), MVTDeleteOverlapping, &newRange, UNUSED_SIZE);
ABQIterate(MVTABQ(mvt), MVTDeleteOverlapping, &newRange);
(void)MVTReserve(mvt, &newRange);
}
@ -859,7 +857,7 @@ static Res MVTDelete(MVT mvt, Addr base, Addr limit)
* might be on the ABQ, so ensure it is removed.
*/
if (RangeSize(&rangeOld) >= mvt->reuseSize)
ABQIterate(MVTABQ(mvt), MVTDeleteOverlapping, &rangeOld, UNUSED_SIZE);
ABQIterate(MVTABQ(mvt), MVTDeleteOverlapping, &rangeOld);
/* There might be fragments at the left or the right of the deleted
* range, and either might be big enough to go back on the ABQ.
@ -1210,15 +1208,13 @@ static Bool MVTReturnSegs(MVT mvt, Range range, Arena arena)
*/
static Bool MVTRefillVisitor(Land land, Range range,
void *closureP, Size closureS)
void *closure)
{
MVT mvt;
AVERT(Land, land);
mvt = closureP;
mvt = closure;
AVERT(MVT, mvt);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
if (RangeSize(range) < mvt->reuseSize)
return TRUE;
@ -1241,7 +1237,7 @@ static void MVTRefillABQIfEmpty(MVT mvt, Size size)
mvt->abqOverflow = FALSE;
METER_ACC(mvt->refills, size);
/* The iteration stops if the ABQ overflows, so may finish or not. */
(void)LandIterate(MVTFreeLand(mvt), MVTRefillVisitor, mvt, UNUSED_SIZE);
(void)LandIterate(MVTFreeLand(mvt), MVTRefillVisitor, mvt);
}
}
@ -1260,7 +1256,7 @@ typedef struct MVTContigencyClosureStruct
} MVTContigencyClosureStruct, *MVTContigencyClosure;
static Bool MVTContingencyVisitor(Land land, Range range,
void *closureP, Size closureS)
void *closure)
{
MVT mvt;
Size size;
@ -1269,12 +1265,10 @@ static Bool MVTContingencyVisitor(Land land, Range range,
AVERT(Land, land);
AVERT(Range, range);
AVER(closureP != NULL);
cl = closureP;
AVER(closure != NULL);
cl = closure;
mvt = cl->mvt;
AVERT(MVT, mvt);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
base = RangeBase(range);
limit = RangeLimit(range);
@ -1312,7 +1306,7 @@ static Bool MVTContingencySearch(Addr *baseReturn, Addr *limitReturn,
cls.steps = 0;
cls.hardSteps = 0;
if (LandIterate(MVTFreeLand(mvt), MVTContingencyVisitor, &cls, UNUSED_SIZE))
if (LandIterate(MVTFreeLand(mvt), MVTContingencyVisitor, &cls))
return FALSE;
AVER(RangeSize(&cls.range) >= min);

View file

@ -585,18 +585,16 @@ failBlockPoolInit:
/* MVFFFinish -- finish method for MVFF */
static Bool mvffFinishVisitor(Bool *deleteReturn, Land land, Range range,
void *closureP, Size closureS)
void *closure)
{
Pool pool;
AVER(deleteReturn != NULL);
AVERT(Land, land);
AVERT(Range, range);
AVER(closureP != NULL);
pool = closureP;
AVER(closure != NULL);
pool = closure;
AVERT(Pool, pool);
AVER(closureS == UNUSED_SIZE);
UNUSED(closureS);
ArenaFree(RangeBase(range), RangeSize(range), pool);
*deleteReturn = TRUE;
@ -613,8 +611,7 @@ static void MVFFFinish(Pool pool)
AVERT(MVFF, mvff);
mvff->sig = SigInvalid;
b = LandIterateAndDelete(MVFFTotalLand(mvff), mvffFinishVisitor, pool,
UNUSED_SIZE);
b = LandIterateAndDelete(MVFFTotalLand(mvff), mvffFinishVisitor, pool);
AVER(b);
AVER(LandSize(MVFFTotalLand(mvff)) == 0);

View file

@ -1088,19 +1088,17 @@ static Res SplayNodeDescribe(Tree node, mps_lib_FILE *stream,
typedef struct SplayFindClosureStruct {
SplayTestNodeFunction testNode;
SplayTestTreeFunction testTree;
void *p;
Size s;
void *testClosure;
SplayTree splay;
Bool found;
} SplayFindClosureStruct, *SplayFindClosure;
static Compare SplayFindFirstCompare(Tree node, TreeKey key)
{
SplayFindClosure closure;
void *closureP;
Size closureS;
SplayFindClosure my;
SplayTestNodeFunction testNode;
SplayTestTreeFunction testTree;
void *testClosure;
SplayTree splay;
AVERT(Tree, node);
@ -1108,18 +1106,17 @@ static Compare SplayFindFirstCompare(Tree node, TreeKey key)
/* Lift closure values into variables so that they aren't aliased by
calls to the test functions. */
closure = (SplayFindClosure)key;
closureP = closure->p;
closureS = closure->s;
testNode = closure->testNode;
testTree = closure->testTree;
splay = closure->splay;
my = (SplayFindClosure)key;
testClosure = my->testClosure;
testNode = my->testNode;
testTree = my->testTree;
splay = my->splay;
if (TreeHasLeft(node) &&
(*testTree)(splay, TreeLeft(node), closureP, closureS)) {
(*testTree)(splay, TreeLeft(node), testClosure)) {
return CompareLESS;
} else if ((*testNode)(splay, node, closureP, closureS)) {
closure->found = TRUE;
} else if ((*testNode)(splay, node, testClosure)) {
my->found = TRUE;
return CompareEQUAL;
} else {
/* If there's a right subtree but it doesn't satisfy the tree test
@ -1127,8 +1124,8 @@ static Compare SplayFindFirstCompare(Tree node, TreeKey key)
return TRUE, so the caller must check closure->found to find out
whether the result node actually satisfies testNode. */
if (TreeHasRight(node) &&
!(*testTree)(splay, TreeRight(node), closureP, closureS)) {
closure->found = FALSE;
!(*testTree)(splay, TreeRight(node), testClosure)) {
my->found = FALSE;
return CompareEQUAL;
}
return CompareGREATER;
@ -1137,11 +1134,10 @@ static Compare SplayFindFirstCompare(Tree node, TreeKey key)
static Compare SplayFindLastCompare(Tree node, TreeKey key)
{
SplayFindClosure closure;
void *closureP;
Size closureS;
SplayFindClosure my;
SplayTestNodeFunction testNode;
SplayTestTreeFunction testTree;
void *testClosure;
SplayTree splay;
AVERT(Tree, node);
@ -1149,24 +1145,23 @@ static Compare SplayFindLastCompare(Tree node, TreeKey key)
/* Lift closure values into variables so that they aren't aliased by
calls to the test functions. */
closure = (SplayFindClosure)key;
closureP = closure->p;
closureS = closure->s;
testNode = closure->testNode;
testTree = closure->testTree;
splay = closure->splay;
my = (SplayFindClosure)key;
testClosure = my->testClosure;
testNode = my->testNode;
testTree = my->testTree;
splay = my->splay;
if (TreeHasRight(node) &&
(*testTree)(splay, TreeRight(node), closureP, closureS)) {
return CompareGREATER;
} else if ((*testNode)(splay, node, closureP, closureS)) {
closure->found = TRUE;
(*testTree)(splay, TreeRight(node), testClosure)) {
return CompareGREATER;
} else if ((*testNode)(splay, node, testClosure)) {
my->found = TRUE;
return CompareEQUAL;
} else {
/* See SplayFindFirstCompare. */
if (TreeHasLeft(node) &&
!(*testTree)(splay, TreeLeft(node), closureP, closureS)) {
closure->found = FALSE;
!(*testTree)(splay, TreeLeft(node), testClosure)) {
my->found = FALSE;
return CompareEQUAL;
}
return CompareLESS;
@ -1184,8 +1179,8 @@ static Compare SplayFindLastCompare(Tree node, TreeKey key)
* ``*nodeReturn`` is set to the node.
*
* The given callbacks testNode and testTree detect this property in
* a single node or a sub-tree rooted at a node, and both receive the
* arbitrary closures closureP and closureS.
* a single node or a sub-tree rooted at a node, and both receive an
* arbitrary closure.
*
* TODO: This repeatedly splays failed matches to the root and rotates
* them, so it could have quite an unbalancing effect if size is small.
@ -1195,7 +1190,7 @@ static Compare SplayFindLastCompare(Tree node, TreeKey key)
Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS)
void *testClosure)
{
SplayFindClosureStruct closureStruct;
Bool found;
@ -1206,11 +1201,10 @@ Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay,
AVER(FUNCHECK(testTree));
if (SplayTreeIsEmpty(splay) ||
!testTree(splay, SplayTreeRoot(splay), closureP, closureS))
!testTree(splay, SplayTreeRoot(splay), testClosure))
return FALSE; /* no suitable nodes in tree */
closureStruct.p = closureP;
closureStruct.s = closureS;
closureStruct.testClosure = testClosure;
closureStruct.testNode = testNode;
closureStruct.testTree = testTree;
closureStruct.splay = splay;
@ -1227,7 +1221,7 @@ Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay,
oldRoot = SplayTreeRoot(splay);
newRoot = TreeRight(oldRoot);
if (newRoot == TreeEMPTY || !(*testTree)(splay, newRoot, closureP, closureS))
if (newRoot == TreeEMPTY || !(*testTree)(splay, newRoot, testClosure))
return FALSE; /* no suitable nodes in the rest of the tree */
/* Temporarily chop off the left half-tree, inclusive of root,
@ -1259,7 +1253,7 @@ Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay,
Bool SplayFindLast(Tree *nodeReturn, SplayTree splay,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS)
void *testClosure)
{
SplayFindClosureStruct closureStruct;
Bool found;
@ -1270,11 +1264,10 @@ Bool SplayFindLast(Tree *nodeReturn, SplayTree splay,
AVER(FUNCHECK(testTree));
if (SplayTreeIsEmpty(splay) ||
!testTree(splay, SplayTreeRoot(splay), closureP, closureS))
!testTree(splay, SplayTreeRoot(splay), testClosure))
return FALSE; /* no suitable nodes in tree */
closureStruct.p = closureP;
closureStruct.s = closureS;
closureStruct.testClosure = testClosure;
closureStruct.testNode = testNode;
closureStruct.testTree = testTree;
closureStruct.splay = splay;
@ -1289,7 +1282,7 @@ Bool SplayFindLast(Tree *nodeReturn, SplayTree splay,
oldRoot = SplayTreeRoot(splay);
newRoot = TreeLeft(oldRoot);
if (newRoot == TreeEMPTY || !(*testTree)(splay, newRoot, closureP, closureS))
if (newRoot == TreeEMPTY || !(*testTree)(splay, newRoot, testClosure))
return FALSE; /* no suitable nodes in the rest of the tree */
/* Temporarily chop off the right half-tree, inclusive of root,

View file

@ -16,9 +16,9 @@
typedef struct SplayTreeStruct *SplayTree;
typedef Bool (*SplayTestNodeFunction)(SplayTree splay, Tree node,
void *closureP, Size closureS);
void *closure);
typedef Bool (*SplayTestTreeFunction)(SplayTree splay, Tree node,
void *closureP, Size closureS);
void *closure);
typedef void (*SplayUpdateNodeFunction)(SplayTree splay, Tree node);
extern void SplayTrivUpdate(SplayTree splay, Tree node);
@ -58,15 +58,15 @@ extern Tree SplayTreeNext(SplayTree splay, TreeKey oldKey);
typedef Bool (*SplayFindFunction)(Tree *nodeReturn, SplayTree splay,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS);
void *closure);
extern Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS);
void *closure);
extern Bool SplayFindLast(Tree *nodeReturn, SplayTree splay,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS);
void *closure);
extern void SplayNodeRefresh(SplayTree splay, Tree node);
extern void SplayNodeInit(SplayTree splay, Tree node);

View file

@ -230,20 +230,20 @@ Bool TreeInsert(Tree *treeReturn, Tree root, Tree node,
*/
Bool TreeTraverseMorris(Tree tree, TreeVisitor visit,
void *closureP, Size closureS)
void *closure)
{
Tree node;
Bool visiting = TRUE;
AVERT(Tree, tree);
AVER(FUNCHECK(visit));
/* closureP, closureS arbitrary */
/* closure arbitrary */
node = tree;
while (node != TreeEMPTY) {
if (node->left == TreeEMPTY) {
if (visiting)
visiting = visit(node, closureP, closureS);
visiting = visit(node, closure);
node = node->right;
} else {
Tree pre = node->left;
@ -256,7 +256,7 @@ Bool TreeTraverseMorris(Tree tree, TreeVisitor visit,
if (pre->right == node) {
pre->right = TreeEMPTY;
if (visiting)
visiting = visit(node, closureP, closureS);
visiting = visit(node, closure);
else if (node == tree)
return FALSE;
node = node->right;
@ -323,13 +323,13 @@ static Tree stepUpLeft(Tree node, Tree *parentIO)
Bool TreeTraverse(Tree tree,
TreeCompareFunction compare,
TreeKeyFunction key,
TreeVisitor visit, void *closureP, Size closureS)
TreeVisitor visit, void *closure)
{
Tree parent, node;
AVERT(Tree, tree);
AVER(FUNCHECK(visit));
/* closureP, closureS arbitrary */
/* closure arbitrary */
parent = TreeEMPTY;
node = tree;
@ -343,7 +343,7 @@ down:
AVER(compare(parent, key(node)) == CompareLESS);
goto down;
}
if (!visit(node, closureP, closureS))
if (!visit(node, closure))
goto abort;
if (TreeHasRight(node)) {
node = stepDownRight(node, &parent);
@ -359,7 +359,7 @@ up:
goto up;
}
node = stepUpRight(node, &parent);
if (!visit(node, closureP, closureS))
if (!visit(node, closure))
goto abort;
if (!TreeHasRight(node))
goto up;
@ -539,14 +539,14 @@ void TreeBalance(Tree *treeIO)
* See <design/arena/#chunk.delete.tricky>.
*/
void TreeTraverseAndDelete(Tree *treeIO, TreeVisitor visitor,
void *closureP, Size closureS)
void *closure)
{
Tree *treeref = treeIO;
AVER(treeIO != NULL);
AVERT(Tree, *treeIO);
AVER(FUNCHECK(visitor));
/* closureP and closureS are arbitrary */
/* closure arbitrary */
TreeToVine(treeIO);
@ -554,7 +554,7 @@ void TreeTraverseAndDelete(Tree *treeIO, TreeVisitor visitor,
Tree tree = *treeref; /* Current node. */
Tree *nextref = &tree->right; /* Location of pointer to next node. */
Tree next = *nextref; /* Next node. */
if ((*visitor)(tree, closureP, closureS)) {
if ((*visitor)(tree, closure)) {
/* Delete current node. */
*treeref = next;
} else {

View file

@ -123,13 +123,13 @@ extern Bool TreeFindNext(Tree *treeReturn, Tree root,
extern Bool TreeInsert(Tree *treeReturn, Tree root, Tree node,
TreeKey key, TreeCompareFunction compare);
typedef Bool TreeVisitor(Tree tree, void *closureP, Size closureS);
typedef Bool TreeVisitor(Tree tree, void *closure);
extern Bool TreeTraverse(Tree tree,
TreeCompareFunction compare,
TreeKeyFunction key,
TreeVisitor visit, void *closureP, Size closureS);
TreeVisitor visit, void *closure);
extern Bool TreeTraverseMorris(Tree tree, TreeVisitor visit,
void *closureP, Size closureS);
void *closure);
extern void TreeRotateLeft(Tree *nodeIO);
extern void TreeRotateRight(Tree *nodeIO);
@ -139,7 +139,7 @@ extern Count TreeToVine(Tree *treeIO);
extern void TreeBalance(Tree *treeIO);
extern void TreeTraverseAndDelete(Tree *treeIO, TreeVisitor visitor,
void *closureP, Size closureS);
void *closure);
#endif /* tree_h */

View file

@ -93,20 +93,20 @@ If the queue is full, return ``TRUE``, otherwise return ``FALSE``.
Return the number of elements in the queue.
``typedef Bool (*ABQVisitor)(Bool *deleteReturn, void *element, void *closureP, Size closureS)``
``typedef Bool (*ABQVisitor)(Bool *deleteReturn, void *element, void *closure)``
A callback function for ``ABQIterate()``. The parameter ``element`` is
an element in the queue, and ``closureP`` and ``closureS`` are the
values that were originally passed to ``ABQIterate()``. This function
must set ``*deleteReturn`` to ``FALSE`` if ``element`` must be kept in
the queue, or ``TRUE`` if ``element`` must be deleted from the queue.
It must return ``TRUE`` if the iteration must continue, or ``FALSE``
if the iteration must stop after processing ``element``.
an element in the queue, and ``closure`` is the value originally
passed to ``ABQIterate()``. This function must set ``*deleteReturn``
to ``FALSE`` if ``element`` must be kept in the queue, or ``TRUE`` if
``element`` must be deleted from the queue. It must return ``TRUE``
if the iteration must continue, or ``FALSE`` if the iteration must
stop after processing ``element``.
``void ABQIterate(ABQ abq, ABQVisitor visitor, void *closureP, Size closureS)``
``void ABQIterate(ABQ abq, ABQVisitor visitor, void *closure)``
Call ``visitor`` for each element in the queue, passing the element
and ``closureP``. See ``ABQVisitor`` for details.
and ``closure``. See ``ABQVisitor`` for details.
Document History

View file

@ -204,7 +204,7 @@ set the ``AttrGC`` attribute.
_`.method.walk`: The ``walk`` method is used by the heap walker. The
``walk`` method should apply the visitor function (along with its
closure parameters and the object format) to all *black* objects in
closure parameter and the object format) to all *black* objects in
the segment. Padding objects may or may not be included in the walk at
the classes discretion, in any case in will be the responsibility of
the client to do something sensible with padding objects. Forwarding

View file

@ -78,14 +78,14 @@ Types
_`.type.land`: The type of a generic land instance.
``typedef Bool (*LandVisitor)(Land land, Range range, void *closureP, Size closureS)``
``typedef Bool (*LandVisitor)(Land land, Range range, void *closure)``
_`.type.visitor`: Type ``LandVisitor`` is a callback function that may
be passed to ``LandIterate()``. It is called for every isolated
contiguous range in address order. The function must return a ``Bool``
indicating whether to continue with the iteration.
``typedef Bool (*LandDeleteVisitor)(Bool *deleteReturn, Land land, Range range, void *closureP, Size closureS)``
``typedef Bool (*LandDeleteVisitor)(Bool *deleteReturn, Land land, Range range, void *closure)``
_`.type.deletevisitor`: Type ``LandDeleteVisitor`` is a callback function that may
be passed to ``LandIterateAndDelete()``. It is called for every isolated
@ -172,17 +172,17 @@ strategy.
_`.function.delete.alias`: It is acceptable for ``rangeReturn`` and
``range`` to share storage.
``Bool LandIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)``
``Bool LandIterate(Land land, LandVisitor visitor, void *closure)``
_`.function.iterate`: ``LandIterate()`` is the function used to
iterate all isolated contiguous ranges in a land. It receives a
visitor function to invoke on every range, and a pointer, ``Size``
closure pair to pass on to the visitor function. If the visitor
visitor function to invoke on every range, and a closure pointer
to pass on to the visitor function. If the visitor
function returns ``FALSE``, then iteration is terminated and
``LandIterate()`` returns ``FALSE``. If all iterator method calls
return ``TRUE``, then ``LandIterate()`` returns ``TRUE``
``Bool LandIterateAndDelete(Land land, LandDeleteVisitor visitor, void *closureP, Size closureS)``
``Bool LandIterateAndDelete(Land land, LandDeleteVisitor visitor, void *closure)``
_`.function.iterate.and.delete`: As ``LandIterate()``, but the visitor
function additionally returns a Boolean indicating whether the range

View file

@ -219,16 +219,16 @@ the root of the splay tree. It is intended that the
`.usage.client-tree`_ for an example). No convenience functions are
provided for allocation or deallocation.
``typedef Bool (*SplayTestNodeFunction)(SplayTree splay, Tree tree, void *closureP, Size closureS)``
``typedef Bool (*SplayTestNodeFunction)(SplayTree splay, Tree tree, void *closure)``
_`.type.splay.test.node.function`: A function of type
``SplayTestNodeFunction`` required to determine whether the node itself
meets some client determined property (see `.prop`_ and
`.usage.test.node`_ for an example). Parameters ``closureP`` and
``closureS`` describe the environment for the function (see
`.usage.test.node`_ for an example). The ``closure``
parameter describes the environment for the function (see
`.function.splay.find.first`_ and `.function.splay.find.last`_).
``typedef Bool (*SplayTestTreeFunction)(SplayTree splay, Tree tree, void *closureP, Size closureS)``
``typedef Bool (*SplayTestTreeFunction)(SplayTree splay, Tree tree, void *closure)``
_`.type.splay.test.tree.function`: A function of type
``SplayTestTreeFunction`` is required to determine whether any of the
@ -237,7 +237,7 @@ determined property (see `.prop`_ and `.usage.test.tree`_ for an
example). In particular, it must be a precise (not conservative)
indication of whether there are any nodes in the sub-tree for which
the ``testNode`` function (see `.type.splay.test.node.function`_) would
return ``TRUE``. Parameters ``closureP`` and ``closureS`` describe the
return ``TRUE``. The ``closure`` parameter describes the
environment for the function (see `.function.splay.find.first`_ and
`.function.splay.find.last`_).
@ -348,18 +348,17 @@ splay tree, using ``nodeDescribe`` to print client-oriented
representations of the nodes (see `.req.debug`_). Provided for
debugging only.
``Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay, SplayTestNodeFunction testNode, SplayTestTreeFunction testTree, void *closureP, Size closureS)``
``Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay, SplayTestNodeFunction testNode, SplayTestTreeFunction testTree, void *closure)``
_`.function.splay.find.first`: Find the first node in the tree that
satisfies some client property, as determined by the ``testNode`` and
``testTree`` functions (see `.req.property.find`_). ``closureP`` and
``closureS`` are arbitrary values, and are passed to the ``testNode``
and ``testTree`` functions which may use the values as closure
environments. If there is no satisfactory node, return ``FALSE``;
``testTree`` functions (see `.req.property.find`_). ``closure``
is an arbitrary value, and is passed to the ``testNode``
and ``testTree`` functions. If there is no satisfactory node, return ``FALSE``;
otherwise set ``*nodeReturn`` to the node and return ``TRUE``. See
`.usage.delete`_ for an example.
``Bool SplayFindLast(Tree *nodeReturn, SplayTree splay, SplayTestNodeFunction testNode, SplayTestTreeFunction testTree, void *closureP, Size closureS)``
``Bool SplayFindLast(Tree *nodeReturn, SplayTree splay, SplayTestNodeFunction testNode, SplayTestTreeFunction testTree, void *closure)``
_`.function.splay.find.last`: As ``SplayFindFirst()``, but find the
last node in the tree that satisfies the client property.
@ -520,13 +519,13 @@ _`.usage.compare`: Comparison function (see `.type.tree.compare.function`_)::
_`.usage.test.tree`: Test tree function (see
`.type.splay.test.tree.function`_)::
Bool FreeBlockTestTree(SplayTree splay, Tree tree
void *closureP, Size closureS) {
/* Closure environment has wanted size as value of closureS. */
Bool FreeBlockTestTree(SplayTree splay, Tree tree,
void *closure) {
/* Closure environment has wanted size as value of *closure. */
/* Look at the cached value for the node to see if any */
/* blocks in the subtree are big enough. */
Size size = closureS;
Size size = *(Size *)closure;
FreeBlock freeNode = FreeBlockOfTree(tree);
return freeNode->maxSize >= size;
}
@ -534,12 +533,12 @@ _`.usage.test.tree`: Test tree function (see
_`.usage.test.node`: Test node function (see
`.type.splay.test.node.function`_)::
Bool FreeBlockTestNode(SplayTree splay, Tree tree
void *closureP, Size closureS) {
/* Closure environment has wanted size as value of closureS. */
Bool FreeBlockTestNode(SplayTree splay, Tree tree,
void *closure) {
/* Closure environment has wanted size as value of *closure. */
/* Look at the size of the node to see if is big enough. */
Size size = closureS;
Size size = *(Size *)closure;
FreeBlock freeNode = FreeBlockOfTree(tree);
return freeNode->size >= size;
}
@ -610,7 +609,7 @@ block::
Bool found;
/* look for the first node of at least the given size. */
/* closureP parameter is not used. See `.function.splay.find.first.`_ */
/* closure parameter is not used. See `.function.splay.find.first.`_ */
found = SplayFindFirst(&splayNode, splayTree,
FreeBlockTestNode, FreeBlockTestTree,
NULL, size);

View file

@ -511,8 +511,9 @@ Root interface
:c:func:`mps_scan_area`, or a similar user-defined function. See
:ref:`topic-scanning-area`.
``closure`` is an arbitrary pointer that will be passed to ``scan_area``
and intended to point to any parameters it needs.
``closure`` is an arbitrary pointer that will be passed to
``scan_area`` and is intended to point to any parameters it needs.
Ensure anything it points to exists as long as the root exists.
``cold`` is a pointer to the :term:`cold end` of stack to be
scanned. On platforms where the stack grows downwards (currently,
@ -551,6 +552,7 @@ Root interface
``closure`` is an arbitrary pointer that will be passed to
``scan_area`` and intended to point to any parameters it needs.
Ensure anything it points to exists as long as the root exists.
Returns :c:macro:`MPS_RES_OK` if the root was registered
successfully, :c:macro:`MPS_RES_MEMORY` if the new root
@ -580,8 +582,9 @@ Root interface
``scan_area`` is an tagged area scanning function that will be
used to scan the area, for example :c:func:`mps_scan_area_tagged`
or :c:func:`mps_scan_area_tagged_or_zero`. See
:ref:`topic-scanning-area`.
or :c:func:`mps_scan_area_tagged_or_zero`. The ``closure``
argument to ``scan_area`` is a :c:type:`mps_scan_tag_t` cast to
``void *`` See :ref:`topic-scanning-area`.
``mask`` is a :term:`bitmask` that is passed to ``scan_area`` to
be applied to the words in the vector to locate the :term:`tag`.