mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-18 08:51:45 -08:00
New mps i/f
Copied from Perforce Change: 15055 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
2649caacaf
commit
f9ddc8d1ef
10 changed files with 162 additions and 126 deletions
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* OBJECT FORMATS
|
||||
*
|
||||
* $HopeName: MMsrc/!format.c(trunk.1)$
|
||||
* $HopeName: MMsrc/!format.c(trunk.2)$
|
||||
*
|
||||
* Copyright (C) 1995 Harlequin Group, all rights reserved
|
||||
*/
|
||||
|
|
@ -25,6 +25,7 @@ Bool FormatIsValid(Format format, ValidationType validParam)
|
|||
AVER(ISVALIDNESTED(Sig, &FormatSigStruct));
|
||||
AVER(format->sig == &FormatSigStruct);
|
||||
#endif
|
||||
AVER(ISVALIDNESTED(Space, format->space));
|
||||
AVER(IsPoT(format->alignment));
|
||||
/* **** alignment should be less than maximum allowed */
|
||||
AVER(format->scan != NULL);
|
||||
|
|
@ -40,17 +41,27 @@ Bool FormatIsValid(Format format, ValidationType validParam)
|
|||
#endif /* DEBUG_ASSERT */
|
||||
|
||||
|
||||
Error FormatInit(Format format, Addr alignment,
|
||||
FormatScanMethod scan,
|
||||
FormatSkipMethod skip,
|
||||
FormatLengthMethod length,
|
||||
FormatProbeMethod probe,
|
||||
FormatMoveMethod move,
|
||||
FormatIsMovedMethod isMoved,
|
||||
FormatCopyMethod copy)
|
||||
Error FormatCreate(Format *formatReturn, Space space,
|
||||
Addr alignment,
|
||||
FormatScanMethod scan,
|
||||
FormatSkipMethod skip,
|
||||
FormatLengthMethod length,
|
||||
FormatProbeMethod probe,
|
||||
FormatMoveMethod move,
|
||||
FormatIsMovedMethod isMoved,
|
||||
FormatCopyMethod copy)
|
||||
{
|
||||
AVER(format != NULL);
|
||||
Format format;
|
||||
Error e;
|
||||
|
||||
AVER(formatReturn != NULL);
|
||||
|
||||
e = PoolAlloc((Addr *)&format, SpaceControlPool(space),
|
||||
sizeof(FormatStruct));
|
||||
if(e != ErrSUCCESS)
|
||||
return e;
|
||||
|
||||
format->space = space;
|
||||
format->alignment = alignment;
|
||||
format->scan = scan;
|
||||
format->skip = skip;
|
||||
|
|
@ -67,17 +78,18 @@ Error FormatInit(Format format, Addr alignment,
|
|||
|
||||
AVER(ISVALID(Format, format));
|
||||
|
||||
return(ErrSUCCESS);
|
||||
*formatReturn = format;
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void FormatFinish(Format format)
|
||||
void FormatDestroy(Format format)
|
||||
{
|
||||
#if !defined(DEBUG_ASSERT) && !defined(DEBUG_SIGN)
|
||||
UNUSED(format);
|
||||
#endif
|
||||
AVER(ISVALID(Format, format));
|
||||
#ifdef DEBUG_SIGN
|
||||
format->sig = SigInvalid;
|
||||
#endif
|
||||
|
||||
PoolFree(SpaceControlPool(format->space),
|
||||
(Addr)format, sizeof(FormatStruct));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ==== POOLS ====
|
||||
*
|
||||
* $HopeName: MMsrc/!pool.c(trunk.1)$
|
||||
* $HopeName: MMsrc/!pool.c(trunk.3)$
|
||||
*
|
||||
* Copyright (C) 1994,1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -110,7 +110,7 @@ void PoolDestroy(Pool pool)
|
|||
}
|
||||
|
||||
|
||||
Error (PoolAllocP)(void **pReturn, Pool pool, size_t size)
|
||||
Error (PoolAlloc)(Addr *pReturn, Pool pool, Size size)
|
||||
{
|
||||
Error e;
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ Error (PoolAllocP)(void **pReturn, Pool pool, size_t size)
|
|||
AVER(ISVALID(Pool, pool));
|
||||
AVER(size > 0);
|
||||
|
||||
e = (*pool->class->allocP)(pReturn, pool, size);
|
||||
e = (*pool->class->alloc)(pReturn, pool, size);
|
||||
if(e != ErrSUCCESS) return e;
|
||||
|
||||
/* Make sure that the allocated address was in the pool's memory. */
|
||||
|
|
@ -128,14 +128,14 @@ Error (PoolAllocP)(void **pReturn, Pool pool, size_t size)
|
|||
}
|
||||
|
||||
|
||||
void PoolFreeP(Pool pool, void *old, size_t size)
|
||||
void PoolFree(Pool pool, Addr old, Size size)
|
||||
{
|
||||
AVER(ISVALID(Pool, pool));
|
||||
AVER(old != NULL);
|
||||
AVER(PoolHasAddr(pool, (Addr)old));
|
||||
AVER(old != (Addr)0);
|
||||
AVER(PoolHasAddr(pool, old));
|
||||
|
||||
if(pool->class->freeP != NULL)
|
||||
(*pool->class->freeP)(pool, old, size);
|
||||
if(pool->class->free != NULL)
|
||||
(*pool->class->free)(pool, old, size);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -237,14 +237,14 @@ Error PoolSegAlloc(Addr *segReturn, Pool pool, Addr size)
|
|||
AVER(IsAligned(ArenaGrain(arena), size));
|
||||
|
||||
arpool = PoolArenaPool(arena);
|
||||
e = PoolAllocP((void **)&seg, arpool, size);
|
||||
e = PoolAlloc(&seg, arpool, size);
|
||||
if(e != ErrSUCCESS)
|
||||
return(e);
|
||||
return e;
|
||||
|
||||
ArenaPut(arena, seg, ARENA_POOL, (void *)pool);
|
||||
|
||||
*segReturn = seg;
|
||||
return(ErrSUCCESS);
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -260,7 +260,7 @@ void PoolSegFree(Pool pool, Addr seg, Addr size)
|
|||
|
||||
ArenaPut(arena, seg, ARENA_POOL, (void *)arpool);
|
||||
|
||||
PoolFreeP(arpool, (void *)seg, (size_t)size);
|
||||
PoolFree(arpool, (Addr)seg, (Size)size);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ==== MANUAL FIXED SMALL UNIT POOL ====
|
||||
*
|
||||
* $HopeName: MMsrc/!poolmfs.c(trunk.1)$
|
||||
* $HopeName: MMsrc/!poolmfs.c(trunk.3)$
|
||||
*
|
||||
* Copyright (C) 1994,1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -20,12 +20,12 @@
|
|||
* Notes
|
||||
* 1. The simple freelist policy might lead to poor locality of allocation
|
||||
* if the list gets fragmented. richard 1994-11-03
|
||||
* 2. freeP should check that the pointer it is asked to free is in a
|
||||
* 2. free should check that the pointer it is asked to free is in a
|
||||
* segment owned by the pool. This required more support from the
|
||||
* arena manager than is currently available. richard 1994-11-03
|
||||
* 3. A describe method is needed. richard 1994-11-03
|
||||
* 4. By not using the rounded extent of a segment some space may be
|
||||
* wasted at the end in allocP. richard 1994-11-03
|
||||
* wasted at the end in alloc. richard 1994-11-03
|
||||
* 5. isValid should check that free list points into the pool.
|
||||
* richard 1994-11-03
|
||||
* 6. This pool doesn't support fast cache allocation, which is a shame.
|
||||
|
|
@ -57,8 +57,8 @@
|
|||
|
||||
static Error create(Pool *poolReturn, Space space, va_list arg);
|
||||
static void destroy(Pool pool);
|
||||
static Error allocP(void **pReturn, Pool pool, size_t size);
|
||||
static void freeP(Pool pool, void *old, size_t size);
|
||||
static Error alloc(Addr *pReturn, Pool pool, Size size);
|
||||
static void free_(Pool pool, Addr old, Size size);
|
||||
static Error describe(Pool pool, LibStream stream);
|
||||
|
||||
static PoolClassStruct PoolClassMFSStruct;
|
||||
|
|
@ -69,7 +69,7 @@ PoolClass PoolClassMFS(void)
|
|||
"MFS",
|
||||
sizeof(PoolMFSStruct), offsetof(PoolMFSStruct, poolStruct),
|
||||
create, destroy,
|
||||
allocP, freeP,
|
||||
alloc, free_,
|
||||
NULL, NULL, /* bufferCreate, bufferDestroy */
|
||||
NULL, NULL, NULL, /* comdemn, mark, scan */
|
||||
NULL, NULL, /* fix, relcaim */
|
||||
|
|
@ -138,14 +138,15 @@ Error PoolMFSCreate(PoolMFS *poolMFSReturn, Space space,
|
|||
AVER(poolMFSReturn != NULL);
|
||||
AVER(ISVALID(Space, space));
|
||||
|
||||
e = PoolAllocP((void **)&poolMFS, SpaceControlPool(space),
|
||||
e = PoolAlloc((Addr *)&poolMFS, SpaceControlPool(space),
|
||||
sizeof(PoolMFSStruct));
|
||||
if(e != ErrSUCCESS) return(e);
|
||||
if(e != ErrSUCCESS)
|
||||
return e;
|
||||
|
||||
e = PoolMFSInit(poolMFS, space, extendBy, unitSize);
|
||||
if(e != ErrSUCCESS) {
|
||||
PoolFreeP(SpaceControlPool(space), poolMFS, sizeof(PoolMFSStruct));
|
||||
return(e);
|
||||
PoolFree(SpaceControlPool(space), (Addr)poolMFS, sizeof(PoolMFSStruct));
|
||||
return e;
|
||||
}
|
||||
|
||||
*poolMFSReturn = poolMFS;
|
||||
|
|
@ -178,7 +179,7 @@ void PoolMFSDestroy(PoolMFS poolMFS)
|
|||
AVER(ISVALID(PoolMFS, poolMFS));
|
||||
control = SpaceControlPool(PoolSpace(PoolMFSPool(poolMFS)));
|
||||
PoolMFSFinish(poolMFS);
|
||||
PoolFreeP(control, poolMFS, sizeof(PoolMFSStruct));
|
||||
PoolFree(control, (Addr)poolMFS, sizeof(PoolMFSStruct));
|
||||
}
|
||||
|
||||
static void destroy(Pool pool)
|
||||
|
|
@ -243,7 +244,7 @@ void PoolMFSFinish(PoolMFS poolMFS)
|
|||
* and returning it. If there are none, a new segment is allocated.
|
||||
*/
|
||||
|
||||
static Error allocP(void **pReturn, Pool pool, size_t size)
|
||||
static Error alloc(Addr *pReturn, Pool pool, Size size)
|
||||
{
|
||||
Header f;
|
||||
Error e;
|
||||
|
|
@ -255,7 +256,7 @@ static Error allocP(void **pReturn, Pool pool, size_t size)
|
|||
|
||||
AVER(ISVALID(Pool, pool));
|
||||
AVER(pool->class == &PoolClassMFSStruct);
|
||||
AVER(pReturn != NULL);
|
||||
AVER(pReturn != (Addr)0);
|
||||
|
||||
MFS = PARENT(PoolMFSStruct, poolStruct, pool);
|
||||
|
||||
|
|
@ -275,7 +276,7 @@ static Error allocP(void **pReturn, Pool pool, size_t size)
|
|||
/* Create a new segment and attach it to the pool. */
|
||||
e = PoolSegAlloc(&seg, pool, MFS->extendBy);
|
||||
if(e != ErrSUCCESS)
|
||||
return(e);
|
||||
return e;
|
||||
|
||||
/* chain segs through Key1; can find them when finishing */
|
||||
arena = SpaceArena(PoolSpace(pool));
|
||||
|
|
@ -314,8 +315,8 @@ static Error allocP(void **pReturn, Pool pool, size_t size)
|
|||
|
||||
MFS->freeList = f->next;
|
||||
|
||||
*pReturn = (void *)f;
|
||||
return(ErrSUCCESS);
|
||||
*pReturn = (Addr)f;
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -326,7 +327,7 @@ static Error allocP(void **pReturn, Pool pool, size_t size)
|
|||
* locations throughout the pool.
|
||||
*/
|
||||
|
||||
static void freeP(Pool pool, void *old, size_t size)
|
||||
static void free_(Pool pool, Addr old, Size size)
|
||||
{
|
||||
Header h;
|
||||
PoolMFS MFS;
|
||||
|
|
@ -337,7 +338,7 @@ static void freeP(Pool pool, void *old, size_t size)
|
|||
|
||||
AVER(ISVALID(Pool, pool));
|
||||
AVER(pool->class == &PoolClassMFSStruct);
|
||||
AVER(old != NULL);
|
||||
AVER(old != (Addr)0);
|
||||
|
||||
MFS = PARENT(PoolMFSStruct, poolStruct, pool);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* MANUAL FIXED SMALL UNIT POOL
|
||||
*
|
||||
* $HopeName$
|
||||
* $HopeName: MMsrc/!poolmfs.h(trunk.1)$
|
||||
*
|
||||
* Copyright (C) 1994,1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
*
|
||||
* Create and Init take the following arguments:
|
||||
*
|
||||
* size_t extendBy
|
||||
* Size extendBy
|
||||
*
|
||||
* extendBy is the default number of bytes reserved by the pool at a time.
|
||||
* A large size will make allocation cheaper but have a higher resource
|
||||
* overhead. A typical value might be 65536. See note 2.
|
||||
*
|
||||
* size_t unitSize
|
||||
* Size unitSize
|
||||
*
|
||||
* unitSize is the size in bytes of the objects you with to allocate. It
|
||||
* must be larger than the minimum unit size returned by GetInfo, and not
|
||||
|
|
@ -42,9 +42,11 @@ typedef struct PoolMFSStruct *PoolMFS;
|
|||
|
||||
extern PoolClass PoolClassMFS(void);
|
||||
|
||||
extern Error PoolMFSCreate(PoolMFS *poolMFSReturn, Space space, size_t extendBy, size_t unitSize);
|
||||
extern Error PoolMFSCreate(PoolMFS *poolMFSReturn, Space space,
|
||||
Size extendBy, Size unitSize);
|
||||
extern void PoolMFSDestroy(PoolMFS poolMFS);
|
||||
extern Error PoolMFSInit(PoolMFS poolMFS, Space space, size_t extendBy, size_t unitSize);
|
||||
extern Error PoolMFSInit(PoolMFS poolMFS, Space space,
|
||||
Size extendBy, Size unitSize);
|
||||
extern void PoolMFSFinish(PoolMFS poolMFS);
|
||||
extern Bool PoolMFSIsValid(PoolMFS poolMFS, ValidationType validParam);
|
||||
extern Pool (PoolMFSPool)(PoolMFS poolMFS);
|
||||
|
|
@ -54,7 +56,7 @@ typedef const struct PoolMFSInfoStruct *PoolMFSInfo;
|
|||
|
||||
struct PoolMFSInfoStruct
|
||||
{
|
||||
size_t unitSizeMin; /* minimum unit size */
|
||||
Size unitSizeMin; /* minimum unit size */
|
||||
};
|
||||
|
||||
extern PoolMFSInfo PoolMFSGetInfo(void);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ==== MANUAL VARIABLE POOL ====
|
||||
*
|
||||
* $HopeName: MMsrc/!poolmv.c(trunk.1)$
|
||||
* $HopeName: MMsrc/!poolmv.c(trunk.3)$
|
||||
*
|
||||
* Copyright (C) 1994, 1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Notes
|
||||
* 1. Need to measure typical fragmentation levels and adjust the
|
||||
* blockExtendBy parameter appropriately. richard 1994-11-08
|
||||
* 2. freeP can lose memory if it can't allocate a block descriptor. The
|
||||
* 2. free can lose memory if it can't allocate a block descriptor. The
|
||||
* memory could be pushed onto a special chain to be reclaimed later.
|
||||
* richard 1994-11-09
|
||||
* 3. The span chain could be adaptive. richard 1994-11-09
|
||||
|
|
@ -52,8 +52,8 @@
|
|||
|
||||
static Error create(Pool *poolReturn, Space space, va_list arg);
|
||||
static void destroy(Pool pool);
|
||||
static Error allocP(void **pReturn, Pool pool, size_t size);
|
||||
static void freeP(Pool pool, void *old, size_t size);
|
||||
static Error alloc(Addr *pReturn, Pool pool, Size size);
|
||||
static void free_(Pool pool, Addr old, Size size);
|
||||
static Error describe(Pool pool, LibStream stream);
|
||||
|
||||
static PoolClassStruct PoolClassMVStruct;
|
||||
|
|
@ -64,7 +64,7 @@ PoolClass PoolClassMV(void)
|
|||
"MV",
|
||||
sizeof(PoolMVStruct), offsetof(PoolMVStruct, poolStruct),
|
||||
create, destroy,
|
||||
allocP, freeP,
|
||||
alloc, free_,
|
||||
NULL, NULL, /* bufferCreate, bufferDestroy */
|
||||
NULL, NULL, NULL, /* condemn, mark, scan */
|
||||
NULL, NULL, /* fix, relcaim */
|
||||
|
|
@ -190,7 +190,7 @@ Pool PoolMVPool(PoolMV poolMV)
|
|||
|
||||
|
||||
Error PoolMVCreate(PoolMV *poolMVReturn, Space space,
|
||||
size_t extendBy, size_t avgSize, size_t maxSize)
|
||||
Size extendBy, Size avgSize, Size maxSize)
|
||||
{
|
||||
Error e;
|
||||
PoolMV poolMV;
|
||||
|
|
@ -198,13 +198,15 @@ Error PoolMVCreate(PoolMV *poolMVReturn, Space space,
|
|||
AVER(poolMVReturn != NULL);
|
||||
AVER(ISVALID(Space, space));
|
||||
|
||||
e = PoolAllocP((void **)&poolMV, SpaceControlPool(space), sizeof(PoolMVStruct));
|
||||
if(e != ErrSUCCESS) return(e);
|
||||
e = PoolAlloc((Addr *)&poolMV, SpaceControlPool(space),
|
||||
sizeof(PoolMVStruct));
|
||||
if(e != ErrSUCCESS)
|
||||
return(e);
|
||||
|
||||
e = PoolMVInit(poolMV, space, extendBy, avgSize, maxSize);
|
||||
if(e != ErrSUCCESS) {
|
||||
PoolFreeP(SpaceControlPool(space), poolMV, sizeof(PoolMVStruct));
|
||||
return(e);
|
||||
PoolFree(SpaceControlPool(space), (Addr)poolMV, sizeof(PoolMVStruct));
|
||||
return e;
|
||||
}
|
||||
|
||||
*poolMVReturn = poolMV;
|
||||
|
|
@ -213,22 +215,23 @@ Error PoolMVCreate(PoolMV *poolMVReturn, Space space,
|
|||
|
||||
static Error create(Pool *poolReturn, Space space, va_list arg)
|
||||
{
|
||||
size_t extendBy, avgSize, maxSize;
|
||||
Size extendBy, avgSize, maxSize;
|
||||
PoolMV poolMV;
|
||||
Error e;
|
||||
|
||||
AVER(poolReturn != NULL);
|
||||
AVER(ISVALID(Space, space));
|
||||
|
||||
extendBy = va_arg(arg, size_t);
|
||||
avgSize = va_arg(arg, size_t);
|
||||
maxSize = va_arg(arg, size_t);
|
||||
extendBy = va_arg(arg, Size);
|
||||
avgSize = va_arg(arg, Size);
|
||||
maxSize = va_arg(arg, Size);
|
||||
|
||||
e = PoolMVCreate(&poolMV, space, extendBy, avgSize, maxSize);
|
||||
if(e != ErrSUCCESS) return(e);
|
||||
if(e != ErrSUCCESS)
|
||||
return e;
|
||||
|
||||
*poolReturn = PoolMVPool(poolMV);
|
||||
return(ErrSUCCESS);
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -238,7 +241,7 @@ void PoolMVDestroy(PoolMV poolMV)
|
|||
AVER(ISVALID(PoolMV, poolMV));
|
||||
control = SpaceControlPool(PoolSpace(PoolMVPool(poolMV)));
|
||||
PoolMVFinish(poolMV);
|
||||
PoolFreeP(control, poolMV, sizeof(PoolMVStruct));
|
||||
PoolFree(control, (Addr)poolMV, sizeof(PoolMVStruct));
|
||||
}
|
||||
|
||||
static void destroy(Pool pool)
|
||||
|
|
@ -249,11 +252,11 @@ static void destroy(Pool pool)
|
|||
}
|
||||
|
||||
|
||||
Error PoolMVInit(PoolMV poolMV, Space space, size_t extendBy,
|
||||
size_t avgSize, size_t maxSize)
|
||||
Error PoolMVInit(PoolMV poolMV, Space space, Size extendBy,
|
||||
Size avgSize, Size maxSize)
|
||||
{
|
||||
Error e;
|
||||
size_t blockExtendBy, spanExtendBy;
|
||||
Size blockExtendBy, spanExtendBy;
|
||||
|
||||
AVER(poolMV != NULL);
|
||||
AVER(ISVALID(Space, space));
|
||||
|
|
@ -270,13 +273,17 @@ Error PoolMVInit(PoolMV poolMV, Space space, size_t extendBy,
|
|||
|
||||
blockExtendBy = sizeof(BlockStruct) * (extendBy/avgSize)/2;
|
||||
|
||||
e = PoolMFSInit(&poolMV->blockPoolStruct, space, blockExtendBy, sizeof(BlockStruct));
|
||||
if(e != ErrSUCCESS) return(e);
|
||||
e = PoolMFSInit(&poolMV->blockPoolStruct, space,
|
||||
blockExtendBy, sizeof(BlockStruct));
|
||||
if(e != ErrSUCCESS)
|
||||
return e;
|
||||
|
||||
spanExtendBy = sizeof(SpanStruct) * (maxSize/extendBy);
|
||||
|
||||
e = PoolMFSInit(&poolMV->spanPoolStruct, space, spanExtendBy, sizeof(SpanStruct));
|
||||
if(e != ErrSUCCESS) return(e);
|
||||
e = PoolMFSInit(&poolMV->spanPoolStruct, space,
|
||||
spanExtendBy, sizeof(SpanStruct));
|
||||
if(e != ErrSUCCESS)
|
||||
return e;
|
||||
|
||||
poolMV->extendBy = extendBy;
|
||||
poolMV->avgSize = avgSize;
|
||||
|
|
@ -287,7 +294,7 @@ Error PoolMVInit(PoolMV poolMV, Space space, size_t extendBy,
|
|||
|
||||
AVER(ISVALID(PoolMV, poolMV));
|
||||
|
||||
return(ErrSUCCESS);
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -356,7 +363,7 @@ static Bool SpanAlloc(Addr *addrReturn, Span span, Addr size,
|
|||
Block old = block->next;
|
||||
block->limit = old->limit;
|
||||
block->next = old->next;
|
||||
PoolFreeP(blockPool, old, sizeof(BlockStruct));
|
||||
PoolFree(blockPool, (Addr)old, sizeof(BlockStruct));
|
||||
--span->blockCount;
|
||||
}
|
||||
else
|
||||
|
|
@ -410,7 +417,7 @@ static Error SpanFree(Span span, Addr base, Addr limit, Pool blockPool)
|
|||
{
|
||||
AVER(block->next != NULL); /* should at least be a sentinel */
|
||||
*prev = block->next;
|
||||
PoolFreeP(blockPool, block, sizeof(BlockStruct));
|
||||
PoolFree(blockPool, (Addr)block, sizeof(BlockStruct));
|
||||
--span->blockCount;
|
||||
}
|
||||
else if(!isBase && block->base == base)
|
||||
|
|
@ -425,7 +432,7 @@ static Error SpanFree(Span span, Addr base, Addr limit, Pool blockPool)
|
|||
/* The freed area is buried in the middle of the block, so the */
|
||||
/* block must be split into two parts. */
|
||||
|
||||
e = PoolAllocP((void **)&new, blockPool, sizeof(BlockStruct));
|
||||
e = PoolAlloc((Addr *)&new, blockPool, sizeof(BlockStruct));
|
||||
if(e != ErrSUCCESS) return(e);
|
||||
|
||||
/* If the freed area is in the base sentinel then insert the new */
|
||||
|
|
@ -465,23 +472,23 @@ static Error SpanFree(Span span, Addr base, Addr limit, Pool blockPool)
|
|||
while(block != NULL);
|
||||
|
||||
/* The freed area is in the span, but not within a block. */
|
||||
ASSERT2(PoolFreeP(poolMV), FALSE,
|
||||
ASSERT2(PoolFree(poolMV), FALSE,
|
||||
"Block %p size %lu is already partially free in pool.",
|
||||
(void *)base, (unsigned long)(limit-base));
|
||||
|
||||
return(ErrSUCCESS);
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* == Allocate == */
|
||||
|
||||
static Error allocP(void **pReturn, Pool pool, size_t size)
|
||||
static Error alloc(Addr *pReturn, Pool pool, Size size)
|
||||
{
|
||||
Error e;
|
||||
Arena arena;
|
||||
Span span;
|
||||
PoolMV poolMV;
|
||||
size_t segSize;
|
||||
Size segSize;
|
||||
|
||||
AVER(pReturn != NULL);
|
||||
AVER(ISVALID(Pool, pool));
|
||||
|
|
@ -506,8 +513,8 @@ static Error allocP(void **pReturn, Pool pool, size_t size)
|
|||
{
|
||||
poolMV->space -= size;
|
||||
AVER(IsAligned(pool->alignment, new));
|
||||
*pReturn = (void *)new;
|
||||
return(ErrSUCCESS);
|
||||
*pReturn = new;
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -521,9 +528,9 @@ static Error allocP(void **pReturn, Pool pool, size_t size)
|
|||
* segment.
|
||||
*/
|
||||
|
||||
e = PoolAllocP((void **)&span, SPANPOOL(poolMV), sizeof(SpanStruct));
|
||||
e = PoolAlloc((Addr *)&span, SPANPOOL(poolMV), sizeof(SpanStruct));
|
||||
if(e != ErrSUCCESS)
|
||||
return(e);
|
||||
return e;
|
||||
|
||||
if(size <= poolMV->extendBy)
|
||||
segSize = poolMV->extendBy;
|
||||
|
|
@ -536,8 +543,8 @@ static Error allocP(void **pReturn, Pool pool, size_t size)
|
|||
e = PoolSegAlloc(&span->seg, pool, segSize);
|
||||
if(e != ErrSUCCESS)
|
||||
{
|
||||
PoolFreeP(SPANPOOL(poolMV), span, sizeof(SpanStruct));
|
||||
return(e);
|
||||
PoolFree(SPANPOOL(poolMV), (Addr)span, sizeof(SpanStruct));
|
||||
return e;
|
||||
}
|
||||
ArenaPut(arena, span->seg, ARENA_CLASS, (void *)span);
|
||||
|
||||
|
|
@ -560,12 +567,12 @@ static Error allocP(void **pReturn, Pool pool, size_t size)
|
|||
poolMV->space += span->space;
|
||||
poolMV->spans = span;
|
||||
|
||||
*pReturn = (void *)span->base.base;
|
||||
return(ErrSUCCESS);
|
||||
*pReturn = span->base.base;
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void freeP(Pool pool, void *old, size_t size)
|
||||
static void free_(Pool pool, Addr old, Size size)
|
||||
{
|
||||
Addr base, limit;
|
||||
Arena arena;
|
||||
|
|
@ -582,7 +589,7 @@ static void freeP(Pool pool, void *old, size_t size)
|
|||
|
||||
poolMV = PARENT(PoolMVStruct, poolStruct, pool);
|
||||
size = AlignUp(pool->alignment, size);
|
||||
base = (Addr)old;
|
||||
base = old;
|
||||
limit = base + size;
|
||||
|
||||
/* Map the pointer onto the segment which contains it, and thence */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ==== MANUAL VARIABLE POOLS ====
|
||||
*
|
||||
* $HopeName$
|
||||
* $HopeName: MMsrc/!poolmv.h(trunk.1)$
|
||||
*
|
||||
* Copyright (C) 1994,1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -10,13 +10,13 @@
|
|||
*
|
||||
* This class adds the following arguments to PoolCreate:
|
||||
*
|
||||
* size_t extendBy
|
||||
* Size extendBy
|
||||
*
|
||||
* extendBy is the default number of bytes reserved by the pool at a time.
|
||||
* A large size will make allocation cheaper but have a higher resource
|
||||
* overhead. A typical value might be 65536. See note 2.
|
||||
*
|
||||
* size_t avgSize
|
||||
* Size avgSize
|
||||
*
|
||||
* avgSize is an estimate of the average size of an allocation, and is used
|
||||
* to choose the size of internal tables. An accurate estimate will
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* efficient. A typical value might be 32. avgSize must not be less than
|
||||
* extendBy.
|
||||
*
|
||||
* size_t maxSize
|
||||
* Size maxSize
|
||||
*
|
||||
* maxSize is an estimate of the maximum total size that the pool will
|
||||
* reach. Setting this parameter does not actually contrain the pool, but
|
||||
|
|
@ -57,10 +57,10 @@ typedef struct PoolMVStruct *PoolMV;
|
|||
extern PoolClass PoolClassMV(void);
|
||||
|
||||
extern Error PoolMVCreate(PoolMV *poolMVReturn, Space space,
|
||||
size_t extendBy, size_t avgSize, size_t maxSize);
|
||||
Size extendBy, Size avgSize, Size maxSize);
|
||||
extern void PoolMVDestroy(PoolMV poolMV);
|
||||
extern Error PoolMVInit(PoolMV poolMV, Space space,
|
||||
size_t extendBy, size_t avgSize, size_t maxSize);
|
||||
Size extendBy, Size avgSize, Size maxSize);
|
||||
extern void PoolMVFinish(PoolMV poolMV);
|
||||
extern Bool PoolMVIsValid(PoolMV poolMV, ValidationType validParam);
|
||||
extern Pool (PoolMVPool)(PoolMV poolMV);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* ROOT IMPLEMENTATION
|
||||
*
|
||||
* $HopeName: MMsrc/!root.c(trunk.2)$
|
||||
* $HopeName: MMsrc/!root.c(trunk.3)$
|
||||
*
|
||||
* Copyright (C) 1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
#include "mpmconf.h"
|
||||
#include "ref.h"
|
||||
#include "trace.h"
|
||||
#include "spacest.h"
|
||||
|
||||
|
||||
#ifdef DEBUG_SIGN
|
||||
|
|
@ -67,7 +68,7 @@ Bool RootIsValid(Root root, ValidationType validParam)
|
|||
}
|
||||
|
||||
|
||||
static Error create(Root *rootReturn, Pool pool,
|
||||
static Error create(Root *rootReturn, Space space,
|
||||
RefRank rank, RootMode mode,
|
||||
RootType type, RootUnion theUnion)
|
||||
{
|
||||
|
|
@ -75,14 +76,15 @@ static Error create(Root *rootReturn, Pool pool,
|
|||
Error e;
|
||||
|
||||
AVER(rootReturn != NULL);
|
||||
AVER(ISVALID(Pool, pool));
|
||||
AVER(ISVALID(Space, space));
|
||||
AVER(modeIsValid(mode));
|
||||
AVER(ISVALID(RefRank, rank));
|
||||
|
||||
e = PoolAllocP((void **)&root, pool, sizeof(RootStruct));
|
||||
if(e != ErrSUCCESS) return e;
|
||||
e = PoolAlloc((Addr *)&root, SpaceControlPool(space),
|
||||
sizeof(RootStruct));
|
||||
if(e != ErrSUCCESS)
|
||||
return e;
|
||||
|
||||
root->pool = pool;
|
||||
root->rank = rank;
|
||||
root->mode = mode;
|
||||
root->type = type;
|
||||
|
|
@ -98,12 +100,14 @@ static Error create(Root *rootReturn, Pool pool,
|
|||
|
||||
AVER(ISVALID(Root, root));
|
||||
|
||||
DequeAppend(SpaceRootDeque(space), &root->spaceDeque);
|
||||
|
||||
*rootReturn = root;
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Error RootCreateTable(Root *rootReturn, Pool pool,
|
||||
Error RootCreateTable(Root *rootReturn, Space space,
|
||||
RefRank rank, RootMode mode,
|
||||
Addr *base, Addr *limit)
|
||||
{
|
||||
|
|
@ -115,14 +119,14 @@ Error RootCreateTable(Root *rootReturn, Pool pool,
|
|||
theUnion.table.base = base;
|
||||
theUnion.table.limit = limit;
|
||||
|
||||
return create(rootReturn, pool, rank, mode, RootTABLE, theUnion);
|
||||
return create(rootReturn, space, rank, mode, RootTABLE, theUnion);
|
||||
}
|
||||
|
||||
|
||||
Error RootCreateFun(Root *rootReturn, Pool pool,
|
||||
RefRank rank, RootMode mode,
|
||||
Error (*scan)(void *p, int i, Trace trace),
|
||||
void *p, int i)
|
||||
Error RootCreate(Root *rootReturn, Space space,
|
||||
RefRank rank, RootMode mode,
|
||||
Error (*scan)(void *p, int i, Trace trace),
|
||||
void *p, int i)
|
||||
{
|
||||
RootUnion theUnion;
|
||||
|
||||
|
|
@ -132,22 +136,31 @@ Error RootCreateFun(Root *rootReturn, Pool pool,
|
|||
theUnion.fun.p = p;
|
||||
theUnion.fun.i = i;
|
||||
|
||||
return create(rootReturn, pool, rank, mode, RootFUN, theUnion);
|
||||
return create(rootReturn, space, rank, mode, RootFUN, theUnion);
|
||||
}
|
||||
|
||||
|
||||
void RootDestroy(Root root)
|
||||
{
|
||||
Space space;
|
||||
|
||||
AVER(ISVALID(Root, root));
|
||||
|
||||
space = PARENT(SpaceStruct, rootDeque,
|
||||
DequeNodeParent(&root->spaceDeque));
|
||||
|
||||
AVER(ISVALID(Space, space));
|
||||
|
||||
DequeNodeRemove(&root->spaceDeque);
|
||||
DequeNodeFinish(&root->spaceDeque);
|
||||
|
||||
TraceSetFinish(&root->marked);
|
||||
DequeNodeFinish(&root->spaceDeque);
|
||||
|
||||
#ifdef DEBUG_SIGN
|
||||
root->sig = SigInvalid;
|
||||
#endif
|
||||
|
||||
PoolFreeP(root->pool, root, sizeof(RootStruct));
|
||||
PoolFree(SpaceControlPool(space), (Addr)root, sizeof(RootStruct));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* ANSI THREADS MANAGER
|
||||
*
|
||||
* $HopeName: MMsrc/!than.c(trunk.1)$
|
||||
* $HopeName: MMsrc/!than.c(trunk.2)$
|
||||
*
|
||||
* Copyright (C) 1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -61,8 +61,8 @@ Error ThreadRegister(Thread *threadReturn, Space space, Addr *stackBot)
|
|||
AVER(threadReturn != NULL);
|
||||
AVER(stackBot != NULL);
|
||||
|
||||
e = PoolAllocP((void *)&thread, SpaceControlPool(space),
|
||||
sizeof(ThreadStruct));
|
||||
e = PoolAlloc((Addr *)&thread, SpaceControlPool(space),
|
||||
sizeof(ThreadStruct));
|
||||
if(e != ErrSUCCESS)
|
||||
goto return_e;
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ void ThreadDeregister(Thread thread, Space space)
|
|||
|
||||
DequeNodeFinish(&thread->spaceDeque);
|
||||
|
||||
PoolFreeP(SpaceControlPool(space), thread, sizeof(ThreadStruct));
|
||||
PoolFree(SpaceControlPool(space), (Addr)thread, sizeof(ThreadStruct));
|
||||
}
|
||||
|
||||
void ThreadDequeSuspend(Deque threadDeque)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* WIN32 THREAD MANAGER
|
||||
*
|
||||
* $HopeName: MMsrc/!thntmv.c(MMdevel_dsm_0.1)$
|
||||
* $HopeName: MMsrc/!thnti3.c(trunk.1)$
|
||||
*
|
||||
* Copyright (C) 1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -119,7 +119,8 @@ Error ThreadRegister(Thread *threadReturn, Space space, Addr *stackBot)
|
|||
AVER(stackBot != NULL);
|
||||
AVER(ISVALID(Space, space));
|
||||
|
||||
e = PoolAllocP(&thread, SpaceControlPool(space), sizeof(ThreadStruct));
|
||||
e = PoolAlloc((Addr *)&thread, SpaceControlPool(space),
|
||||
sizeof(ThreadStruct));
|
||||
if(e != ErrSUCCESS)
|
||||
goto return_e;
|
||||
|
||||
|
|
@ -176,7 +177,7 @@ void ThreadDeregister(Thread thread, Space space)
|
|||
b = CloseHandle(thread->handle);
|
||||
AVER(b); /* .error.close-handle */
|
||||
|
||||
PoolFreeP(SpaceControlPool(space), thread, sizeof(ThreadStruct));
|
||||
PoolFree(SpaceControlPool(space), (Addr)thread, sizeof(ThreadStruct));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* GENERIC TRACER IMPLEMENTATION
|
||||
*
|
||||
* $HopeName: MMsrc/!trace.c(trunk.2)$
|
||||
* $HopeName: MMsrc/!trace.c(trunk.3)$
|
||||
*
|
||||
* Copyright (C) 1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -31,7 +31,7 @@ static SigStruct TraceSetSigStruct;
|
|||
#endif
|
||||
|
||||
|
||||
#define TRACEBIT(id) ((Addr)(1uL << (id)))
|
||||
#define TRACEBIT(id) ((Addr)((Addr)1 << (id)))
|
||||
|
||||
|
||||
#ifdef DEBUG_ASSERT
|
||||
|
|
@ -211,12 +211,12 @@ Error TraceCreate(Trace *traceReturn, Space space)
|
|||
|
||||
controlPool = SpaceControlPool(space);
|
||||
|
||||
e = PoolAllocP((void **)&trace, controlPool, sizeof(TraceStruct));
|
||||
e = PoolAlloc((Addr *)&trace, controlPool, sizeof(TraceStruct));
|
||||
if(e != ErrSUCCESS) return e;
|
||||
|
||||
e = TraceInit(trace, space);
|
||||
if(e != ErrSUCCESS) {
|
||||
PoolFreeP(controlPool, (void *)trace, sizeof(TraceStruct));
|
||||
PoolFree(controlPool, (Addr)trace, sizeof(TraceStruct));
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ void TraceDestroy(Trace trace)
|
|||
AVER(ISVALID(Trace, trace));
|
||||
controlPool = SpaceControlPool(trace->space);;
|
||||
TraceFinish(trace);
|
||||
PoolFreeP(controlPool, (void *)trace, sizeof(TraceStruct));
|
||||
PoolFree(controlPool, (Addr)trace, sizeof(TraceStruct));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue