1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 08:43:40 -07:00

Review.impl.c.poolams.2 edits

Copied from Perforce
 Change: 18706
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Nick Barnes 1997-09-02 15:23:06 +01:00
parent 64430af6c8
commit f6612c8347
2 changed files with 80 additions and 3 deletions

View file

@ -1,6 +1,6 @@
/* impl.c.bt: BIT TABLES
*
* $HopeName: MMsrc!bt.c(trunk.7) $
* $HopeName: MMsrc!bt.c(trunk.8) $
* Copyright (C) 1997 Harlequin Group, all rights reserved
*
* READERSHIP
@ -19,9 +19,47 @@
#include "mpm.h"
SRCID(bt, "$HopeName: MMsrc!bt.c(trunk.7) $");
SRCID(bt, "$HopeName: MMsrc!bt.c(trunk.8) $");
/* AMSBTCreate -- allocate a BT from the control pool
*
* See design.mps.bt.if.create
*/
Res BTCreate(BT *btReturn, Arena arena, Count length)
{
Res res;
BT bt;
void *p;
AVER(btReturn != NULL);
AVERT(Arena, arena);
AVER(length > 0);
res = ArenaAlloc(&p, arena, BTSize(length));
if(res != ResOK)
return res;
bt = (BT)p;
*btReturn = bt;
return ResOK;
}
/* BTDestroy -- free a BT to the control pool.
*
* See design.mps.bt.if.destroy
*/
void BTDestroy(BT bt, Arena arena, Count length)
{
AVER(bt != NULL);
AVERT(Arena, arena);
AVER(length > 0);
ArenaFree(arena, bt, BTSize(length));
}
/* BTCheck -- check the validity of a bit table
*
* There's not much that can be checked at present. This is
@ -247,3 +285,38 @@ Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn,
searchBase, searchLimit,
length, length);
}
/* BTRangesSame -- check that a range of bits in two BTs are the same.
*
* See design.mps.bt.if.ranges-same
*/
Bool BTRangesSame(BT BTx, BT BTy, Index base, Index limit)
{
Index i = base;
while(i < limit) {
if (BTGet(BTx, i) != BTGet(BTy, i))
return FALSE;
++ i;
}
return TRUE;
}
/* BTCopyInvertRange -- copy a range of bits from one BT to another,
* inverting them as you go.
*
* See design.mps.bt.if.copy-invert-range
*/
void BTCopyInvertRange(BT fromBT, BT toBT, Index base, Index limit)
{
Index i = base;
while(i < limit) {
if (BTGet(fromBT, i))
BTRes(toBT,i);
else
BTSet(toBT,i);
++ i;
}
}

View file

@ -1,6 +1,6 @@
/* impl.h.mpm: MEMORY POOL MANAGER DEFINITIONS
*
* $HopeName: MMsrc!mpm.h(trunk.42) $
* $HopeName: MMsrc!mpm.h(trunk.43) $
* Copyright (C) 1997 The Harlequin Group Limited. All rights reserved.
*/
@ -220,6 +220,8 @@ extern void (BTRes)(BT bt, Index index);
~((Word)1<<((i)&~((Word)-1<<MPS_WORD_SHIFT))); \
END
extern Res BTCreate(BT *btReturn, Arena arena, Count length);
extern void BTDestroy(BT bt, Arena arena, Count length);
extern void BTSetRange(BT bt, Index base, Index limit);
extern Bool BTIsSetRange(BT bt, Index base, Index limit);
extern void BTResRange(BT bt, Index base, Index limit);
@ -232,6 +234,8 @@ extern Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn,
BT bt,
Index searchBase, Index searchLimit,
unsigned long length);
extern Bool BTRangesSame(BT BTx, BT BTy, Index base, Index limit);
extern void BTCopyInvertRange(BT fromBT, BT toBT, Index base, Index limit);
/* Pool Interface -- see impl.c.pool */