mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-16 10:50:49 -08:00
Converting pools to use keyword arguments, mostly, and so far inconsistently, but at least it compiles.
Copied from Perforce Change: 181635 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
f774413584
commit
07f446a450
40 changed files with 601 additions and 150 deletions
|
|
@ -301,10 +301,8 @@ Res ControlInit(Arena arena)
|
|||
Res res;
|
||||
|
||||
AVERT(Arena, arena);
|
||||
res = PoolInit(&arena->controlPoolStruct.poolStruct,
|
||||
arena, PoolClassMV(),
|
||||
ARENA_CONTROL_EXTENDBY, ARENA_CONTROL_AVGSIZE,
|
||||
ARENA_CONTROL_MAXSIZE);
|
||||
res = PoolInit(&arena->controlPoolStruct.poolStruct, arena,
|
||||
PoolClassMV(), argsNone);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
arena->poolReady = TRUE; /* <design/arena/#pool.ready> */
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ static void testPageTable(ArenaClass class, Size size, Addr addr)
|
|||
Arena arena; Pool pool;
|
||||
Size pageSize;
|
||||
Count tractsPerPage;
|
||||
ArgStruct args[3];
|
||||
ArgStruct args[4];
|
||||
|
||||
args[0].key = MPS_KEY_ARENA_SIZE;
|
||||
args[0].val.size = size;
|
||||
|
|
@ -346,9 +346,7 @@ static void testPageTable(ArenaClass class, Size size, Addr addr)
|
|||
args[2].key = MPS_KEY_ARGS_END;
|
||||
die(ArenaCreate(&arena, class, args), "ArenaCreate");
|
||||
|
||||
die(PoolCreate(&pool, arena, PoolClassMV(),
|
||||
(Size)65536, (Size)32, (Size)65536),
|
||||
"PoolCreate");
|
||||
die(PoolCreate(&pool, arena, PoolClassMV(), argsNone), "PoolCreate");
|
||||
|
||||
pageSize = ArenaAlign(arena);
|
||||
tractsPerPage = pageSize / sizeof(TractStruct);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ Bool ArgCheckCant(Arg arg) {
|
|||
|
||||
const KeyStruct _mps_key_varargs = {KeySig, "VARARGS", ArgCheckCant};
|
||||
|
||||
ArgStruct mps_args_none[] = {{MPS_KEY_ARGS_END}};
|
||||
|
||||
|
||||
/* KeyCheck -- check the validity of an argument key */
|
||||
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@ Res CBSInit(Arena arena, CBS cbs, void *owner,
|
|||
Bool mayUseInline, Bool fastFind)
|
||||
{
|
||||
Res res;
|
||||
ArgStruct args[3];
|
||||
|
||||
AVERT(Arena, arena);
|
||||
AVER(new == NULL || FUNCHECK(new));
|
||||
|
|
@ -286,8 +287,12 @@ Res CBSInit(Arena arena, CBS cbs, void *owner,
|
|||
|
||||
SplayTreeInit(splayTreeOfCBS(cbs), &cbsSplayCompare,
|
||||
fastFind ? &cbsUpdateNode : NULL);
|
||||
res = PoolCreate(&(cbs->blockPool), arena, PoolClassMFS(),
|
||||
sizeof(CBSBlockStruct) * 64, sizeof(CBSBlockStruct));
|
||||
args[0].key = MPS_KEY_MFS_UNIT_SIZE;
|
||||
args[0].val.size = sizeof(CBSBlockStruct);
|
||||
args[1].key = MPS_KEY_MFS_EXTEND_BY;
|
||||
args[1].val.size = sizeof(CBSBlockStruct) * 64;
|
||||
args[2].key = MPS_KEY_ARGS_END;
|
||||
res = PoolCreate(&(cbs->blockPool), arena, PoolClassMFS(), args);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
cbs->splayTreeSize = 0;
|
||||
|
|
|
|||
|
|
@ -238,6 +238,18 @@
|
|||
#define EPVMDefaultSubsequentSegSIZE ((Size)64 * 1024)
|
||||
|
||||
|
||||
/* Pool MV Configuration -- see <code/poolmv.c> */
|
||||
|
||||
#define MV_EXTEND_BY_DEFAULT ((Size)4096)
|
||||
#define MV_AVG_SIZE_DEFAULT ((Size)32)
|
||||
#define MV_MAX_SIZE_DEFAULT ((Size)65536)
|
||||
|
||||
|
||||
/* Pool MFS Configuration -- see <code/poolmfs.c> */
|
||||
|
||||
#define MFS_EXTEND_BY_DEFAULT ((Size)65536)
|
||||
|
||||
|
||||
/* Arena Configuration -- see <code/arena.c>
|
||||
*
|
||||
* .client.seg-size: ARENA_CLIENT_PAGE_SIZE is the size in bytes of a
|
||||
|
|
@ -245,10 +257,6 @@
|
|||
* with no particular justification.
|
||||
*/
|
||||
|
||||
#define ARENA_CONTROL_EXTENDBY ((Size)4096)
|
||||
#define ARENA_CONTROL_AVGSIZE ((Size)32)
|
||||
#define ARENA_CONTROL_MAXSIZE ((Size)65536)
|
||||
|
||||
#define ArenaPollALLOCTIME (65536.0)
|
||||
|
||||
#define ARENA_ZONESHIFT ((Shift)20)
|
||||
|
|
|
|||
|
|
@ -117,17 +117,32 @@ static Bool PoolDebugOptionsCheck(PoolDebugOptions opt)
|
|||
* Someday, this could be split into fence and tag init methods.
|
||||
*/
|
||||
|
||||
static Res DebugPoolInit(Pool pool, va_list args)
|
||||
const KeyStruct _mps_key_pool_debug_option = {
|
||||
KeySig, "POOL_DEBUG_OPTION", ArgCheckCant /* FIXME: ArgCheckPoolDebugOption */
|
||||
};
|
||||
|
||||
static Res DebugPoolInit(Pool pool, ArgList args)
|
||||
{
|
||||
Res res;
|
||||
PoolDebugOptions options;
|
||||
PoolDebugMixin debug;
|
||||
TagInitMethod tagInit;
|
||||
Size tagSize;
|
||||
ArgStruct arg;
|
||||
|
||||
AVERT(Pool, pool);
|
||||
options = va_arg(args, PoolDebugOptions);
|
||||
|
||||
/* FIXME: Split this structure into separate keys */
|
||||
/* FIXME: Can't use varargs -- update docs. */
|
||||
if (ArgPick(&arg, args, MPS_KEY_POOL_DEBUG_OPTION))
|
||||
options = (PoolDebugOptions)arg.val.pool_debug_option;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
|
||||
AVERT(PoolDebugOptions, options);
|
||||
|
||||
/* @@@@ Tag parameters should be taken from options, but tags have */
|
||||
/* not been published yet. */
|
||||
tagInit = NULL; tagSize = 0;
|
||||
|
|
@ -173,11 +188,16 @@ static Res DebugPoolInit(Pool pool, va_list args)
|
|||
/* tag init */
|
||||
debug->tagInit = tagInit;
|
||||
if (debug->tagInit != NULL) {
|
||||
ArgStruct pcArgs[3];
|
||||
debug->tagSize = tagSize + sizeof(tagStruct) - 1;
|
||||
/* This pool has to be like the arena control pool: the blocks */
|
||||
/* allocated must be accessible using void*. */
|
||||
res = PoolCreate(&debug->tagPool, PoolArena(pool), PoolClassMFS(),
|
||||
debug->tagSize, debug->tagSize);
|
||||
pcArgs[0].key = MPS_KEY_MFS_EXTEND_BY;
|
||||
pcArgs[0].val.size = debug->tagSize; /* FIXME: Really? */
|
||||
pcArgs[1].key = MPS_KEY_MFS_UNIT_SIZE;
|
||||
pcArgs[1].val.size = debug->tagSize;
|
||||
pcArgs[2].key = MPS_KEY_ARGS_END;
|
||||
res = PoolCreate(&debug->tagPool, PoolArena(pool), PoolClassMFS(), pcArgs);
|
||||
if (res != ResOK)
|
||||
goto tagFail;
|
||||
debug->missingTags = 0;
|
||||
|
|
@ -191,6 +211,7 @@ static Res DebugPoolInit(Pool pool, va_list args)
|
|||
tagFail:
|
||||
alignFail:
|
||||
SuperclassOfPool(pool)->finish(pool);
|
||||
failParam:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -834,7 +834,7 @@ Res ArenaFinalize(Arena arena, Ref obj)
|
|||
if (!arena->isFinalPool) {
|
||||
Pool pool;
|
||||
|
||||
res = PoolCreate(&pool, arena, PoolClassMRG());
|
||||
res = PoolCreate(&pool, arena, PoolClassMRG(), argsNone);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
arena->finalPool = pool;
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ extern Bool ResIsAllocFailure(Res res);
|
|||
|
||||
/* Argument Lists */
|
||||
|
||||
#define argsNone mps_args_none
|
||||
extern Bool KeyCheck(Key key);
|
||||
extern Bool ArgCheck(Arg arg);
|
||||
extern Bool ArgListCheck(ArgList args);
|
||||
|
|
@ -187,8 +188,7 @@ extern char *MPSVersion(void);
|
|||
|
||||
/* Pool Interface -- see impl.c.pool */
|
||||
|
||||
extern Res PoolInit(Pool pool, Arena arena, PoolClass class, ...);
|
||||
extern Res PoolInitV(Pool pool, Arena arena, PoolClass class, va_list args);
|
||||
extern Res PoolInit(Pool pool, Arena arena, PoolClass class, ArgList args);
|
||||
extern void PoolFinish(Pool pool);
|
||||
extern Bool PoolClassCheck(PoolClass class);
|
||||
extern Bool PoolCheck(Pool pool);
|
||||
|
|
@ -205,9 +205,8 @@ extern double PoolMutatorAllocSize(Pool pool);
|
|||
extern Bool PoolOfAddr(Pool *poolReturn, Arena arena, Addr addr);
|
||||
extern Bool PoolHasAddr(Pool pool, Addr addr);
|
||||
|
||||
extern Res PoolCreate(Pool *poolReturn, Arena arena, PoolClass class, ...);
|
||||
extern Res PoolCreateV(Pool *poolReturn, Arena arena, PoolClass class,
|
||||
va_list arg);
|
||||
extern Res PoolCreate(Pool *poolReturn, Arena arena, PoolClass class,
|
||||
ArgList args);
|
||||
extern void PoolDestroy(Pool pool);
|
||||
extern BufferClass PoolDefaultBufferClass(Pool pool);
|
||||
extern Res PoolAlloc(Addr *pReturn, Pool pool, Size size,
|
||||
|
|
@ -229,7 +228,7 @@ extern void PoolTraceEnd(Pool pool, Trace trace);
|
|||
extern void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
|
||||
void *v, size_t s);
|
||||
extern void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p);
|
||||
extern Res PoolTrivInit(Pool pool, va_list arg);
|
||||
extern Res PoolTrivInit(Pool pool, ArgList arg);
|
||||
extern void PoolTrivFinish(Pool pool);
|
||||
extern Res PoolNoAlloc(Addr *pReturn, Pool pool, Size size,
|
||||
Bool withReservoirPermit);
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ typedef Res (*BufferDescribeMethod)(Buffer buffer, mps_lib_FILE *stream);
|
|||
|
||||
/* Order of types corresponds to PoolClassStruct in <code/mpmst.h> */
|
||||
|
||||
typedef Res (*PoolInitMethod)(Pool pool, va_list args);
|
||||
typedef Res (*PoolInitMethod)(Pool pool, ArgList args);
|
||||
typedef void (*PoolFinishMethod)(Pool pool);
|
||||
typedef Res (*PoolAllocMethod)(Addr *pReturn, Pool pool, Size size,
|
||||
Bool withReservoirPermit);
|
||||
|
|
|
|||
|
|
@ -107,6 +107,10 @@ typedef struct mps_arg_s {
|
|||
size_t size;
|
||||
va_list varargs;
|
||||
mps_addr_t addr;
|
||||
mps_fmt_t format;
|
||||
mps_chain_t chain;
|
||||
struct mps_pool_debug_option_s *pool_debug_option;
|
||||
mps_addr_t (*addr_method)(mps_addr_t);
|
||||
} val;
|
||||
} mps_arg_s;
|
||||
|
||||
|
|
@ -120,6 +124,12 @@ extern const struct mps_key_s _mps_key_varargs;
|
|||
#define MPS_KEY_VARARGS (&_mps_key_varargs)
|
||||
extern const struct mps_key_s _mps_key_arena_size;
|
||||
#define MPS_KEY_ARENA_SIZE (&_mps_key_arena_size)
|
||||
extern const struct mps_key_s _mps_key_format;
|
||||
#define MPS_KEY_FORMAT (&_mps_key_format)
|
||||
extern const struct mps_key_s _mps_key_chain;
|
||||
#define MPS_KEY_CHAIN (&_mps_key_chain)
|
||||
|
||||
extern mps_arg_s mps_args_none[];
|
||||
|
||||
|
||||
/* <a id="message.types"> Keep in sync with
|
||||
|
|
@ -347,6 +357,8 @@ extern mps_res_t mps_pool_create(mps_pool_t *, mps_arena_t,
|
|||
mps_class_t, ...);
|
||||
extern mps_res_t mps_pool_create_v(mps_pool_t *, mps_arena_t,
|
||||
mps_class_t, va_list);
|
||||
extern mps_res_t mps_pool_create_k(mps_pool_t *, mps_arena_t,
|
||||
mps_class_t, mps_arg_s []);
|
||||
extern void mps_pool_destroy(mps_pool_t);
|
||||
|
||||
/* .gen-param: This structure must match <code/chain.h#gen-param>. */
|
||||
|
|
@ -634,6 +646,9 @@ typedef struct mps_pool_debug_option_s {
|
|||
size_t free_size;
|
||||
} mps_pool_debug_option_s;
|
||||
|
||||
extern const struct mps_key_s _mps_key_pool_debug_option;
|
||||
#define MPS_KEY_POOL_DEBUG_OPTION (&_mps_key_pool_debug_option)
|
||||
|
||||
extern void mps_pool_check_fenceposts(mps_pool_t);
|
||||
extern void mps_pool_check_free_space(mps_pool_t);
|
||||
|
||||
|
|
|
|||
|
|
@ -1038,6 +1038,51 @@
|
|||
3114A6C6156E9815001E0AA3 /* mpseventcnv */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mpseventcnv; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3114A6D0156E9829001E0AA3 /* eventcnv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = eventcnv.c; sourceTree = "<group>"; };
|
||||
3114A6D9156E9950001E0AA3 /* eventpro.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = eventpro.c; sourceTree = "<group>"; };
|
||||
311F2F5017398AD500C15B6A /* boot.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = boot.h; sourceTree = "<group>"; };
|
||||
311F2F5117398AE900C15B6A /* bt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bt.h; sourceTree = "<group>"; };
|
||||
311F2F5217398AE900C15B6A /* cbs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cbs.h; sourceTree = "<group>"; };
|
||||
311F2F5317398AE900C15B6A /* chain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = chain.h; sourceTree = "<group>"; };
|
||||
311F2F5417398AE900C15B6A /* check.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = check.h; sourceTree = "<group>"; };
|
||||
311F2F5517398AE900C15B6A /* clock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = clock.h; sourceTree = "<group>"; };
|
||||
311F2F5617398AE900C15B6A /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
|
||||
311F2F5717398AE900C15B6A /* dbgpool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = dbgpool.h; sourceTree = "<group>"; };
|
||||
311F2F5817398AE900C15B6A /* event.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = event.h; sourceTree = "<group>"; };
|
||||
311F2F5917398AE900C15B6A /* eventcom.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = eventcom.h; sourceTree = "<group>"; };
|
||||
311F2F5A17398AE900C15B6A /* eventdef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = eventdef.h; sourceTree = "<group>"; };
|
||||
311F2F5B17398AE900C15B6A /* eventpro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = eventpro.h; sourceTree = "<group>"; };
|
||||
311F2F5C17398AE900C15B6A /* eventrep.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = eventrep.h; sourceTree = "<group>"; };
|
||||
311F2F5D17398B0400C15B6A /* lo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lo.h; sourceTree = "<group>"; };
|
||||
311F2F5E17398B0E00C15B6A /* lock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lock.h; sourceTree = "<group>"; };
|
||||
311F2F5F17398B0E00C15B6A /* meter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = meter.h; sourceTree = "<group>"; };
|
||||
311F2F6017398B0E00C15B6A /* misc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = misc.h; sourceTree = "<group>"; };
|
||||
311F2F6117398B0E00C15B6A /* mpm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpm.h; sourceTree = "<group>"; };
|
||||
311F2F6217398B1A00C15B6A /* mpmst.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpmst.h; sourceTree = "<group>"; };
|
||||
311F2F6317398B1A00C15B6A /* mpmtypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpmtypes.h; sourceTree = "<group>"; };
|
||||
311F2F6417398B1A00C15B6A /* mps.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mps.h; sourceTree = "<group>"; };
|
||||
311F2F6517398B3B00C15B6A /* mpsacl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpsacl.h; sourceTree = "<group>"; };
|
||||
311F2F6617398B3B00C15B6A /* mpsavm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpsavm.h; sourceTree = "<group>"; };
|
||||
311F2F6717398B3B00C15B6A /* mpsio.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpsio.h; sourceTree = "<group>"; };
|
||||
311F2F6817398B3B00C15B6A /* mpslib.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpslib.h; sourceTree = "<group>"; };
|
||||
311F2F6917398B3B00C15B6A /* mpstd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpstd.h; sourceTree = "<group>"; };
|
||||
311F2F6A17398B4C00C15B6A /* mpsw3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpsw3.h; sourceTree = "<group>"; };
|
||||
311F2F6B17398B4C00C15B6A /* mpswin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpswin.h; sourceTree = "<group>"; };
|
||||
311F2F6C17398B5800C15B6A /* osxc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = osxc.h; sourceTree = "<group>"; };
|
||||
311F2F6D17398B6300C15B6A /* prmci3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = prmci3.h; sourceTree = "<group>"; };
|
||||
311F2F6E17398B6300C15B6A /* prmci6.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = prmci6.h; sourceTree = "<group>"; };
|
||||
311F2F6F17398B6300C15B6A /* prmcix.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = prmcix.h; sourceTree = "<group>"; };
|
||||
311F2F7017398B6300C15B6A /* prmcw3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = prmcw3.h; sourceTree = "<group>"; };
|
||||
311F2F7117398B7100C15B6A /* protocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = protocol.h; sourceTree = "<group>"; };
|
||||
311F2F7217398B7100C15B6A /* pthrdext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = pthrdext.h; sourceTree = "<group>"; };
|
||||
311F2F7317398B7100C15B6A /* ring.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ring.h; sourceTree = "<group>"; };
|
||||
311F2F7417398B7100C15B6A /* sac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sac.h; sourceTree = "<group>"; };
|
||||
311F2F7517398B8E00C15B6A /* sc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sc.h; sourceTree = "<group>"; };
|
||||
311F2F7617398B8E00C15B6A /* splay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = splay.h; sourceTree = "<group>"; };
|
||||
311F2F7717398B8E00C15B6A /* ss.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ss.h; sourceTree = "<group>"; };
|
||||
311F2F7817398B8E00C15B6A /* th.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = th.h; sourceTree = "<group>"; };
|
||||
311F2F7917398B8E00C15B6A /* thw3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = thw3.h; sourceTree = "<group>"; };
|
||||
311F2F7A17398B8E00C15B6A /* tract.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tract.h; sourceTree = "<group>"; };
|
||||
311F2F7B17398E7600C15B6A /* poolmv.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = poolmv.h; sourceTree = "<group>"; };
|
||||
311F2F7C17398E9A00C15B6A /* mpscmv.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpscmv.h; sourceTree = "<group>"; };
|
||||
3124CAB8156BE3EC00753214 /* awlut */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = awlut; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3124CAC2156BE40100753214 /* awlut.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = awlut.c; sourceTree = "<group>"; };
|
||||
3124CAC6156BE48D00753214 /* fmtdy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fmtdy.c; sourceTree = "<group>"; };
|
||||
|
|
@ -1053,6 +1098,9 @@
|
|||
317B3C2A1731830100F9A469 /* arg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = arg.c; sourceTree = "<group>"; };
|
||||
31A47BA3156C1E130039B1C2 /* mps.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mps.c; sourceTree = "<group>"; };
|
||||
31A47BA5156C1E5E0039B1C2 /* ssixi3.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ssixi3.c; sourceTree = "<group>"; };
|
||||
31CD33BB173A9F1500524741 /* mpscams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpscams.h; sourceTree = "<group>"; };
|
||||
31CD33BC173A9F1500524741 /* poolams.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = poolams.c; sourceTree = "<group>"; };
|
||||
31CD33BD173A9F1500524741 /* poolams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = poolams.h; sourceTree = "<group>"; };
|
||||
31D60006156D3C5F00337B26 /* segsmss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = segsmss.c; sourceTree = "<group>"; };
|
||||
31D6000D156D3CB200337B26 /* awluthe */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = awluthe; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
31D60017156D3CC300337B26 /* awluthe.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = awluthe.c; sourceTree = "<group>"; };
|
||||
|
|
@ -1120,6 +1168,11 @@
|
|||
31EEAC74156AB58E00714D05 /* mpmss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mpmss.c; sourceTree = SOURCE_ROOT; };
|
||||
31EEAC9E156AB73400714D05 /* testlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testlib.c; sourceTree = "<group>"; };
|
||||
31EEACA7156AB79800714D05 /* span.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = span.c; sourceTree = "<group>"; };
|
||||
31F6CCA91739B0CF00C48748 /* mpscamc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpscamc.h; sourceTree = "<group>"; };
|
||||
31F6CCAA1739B0CF00C48748 /* mpscawl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpscawl.h; sourceTree = "<group>"; };
|
||||
31F6CCAB1739B0CF00C48748 /* mpsclo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpsclo.h; sourceTree = "<group>"; };
|
||||
31F6CCAC1739B0CF00C48748 /* mpscmvff.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpscmvff.h; sourceTree = "<group>"; };
|
||||
31F6CCAD1739B0CF00C48748 /* mpscsnc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpscsnc.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
|
@ -1572,38 +1625,82 @@
|
|||
31EEAC03156AB23A00714D05 /* arenavm.c */,
|
||||
317B3C2A1731830100F9A469 /* arg.c */,
|
||||
31EEAC3F156AB32500714D05 /* boot.c */,
|
||||
311F2F5017398AD500C15B6A /* boot.h */,
|
||||
31EEAC27156AB2F200714D05 /* bt.c */,
|
||||
311F2F5117398AE900C15B6A /* bt.h */,
|
||||
31EEAC19156AB2B200714D05 /* buffer.c */,
|
||||
31EEAC40156AB32500714D05 /* cbs.c */,
|
||||
311F2F5217398AE900C15B6A /* cbs.h */,
|
||||
311F2F5317398AE900C15B6A /* chain.h */,
|
||||
311F2F5417398AE900C15B6A /* check.h */,
|
||||
311F2F5517398AE900C15B6A /* clock.h */,
|
||||
311F2F5617398AE900C15B6A /* config.h */,
|
||||
31EEAC28156AB2F200714D05 /* dbgpool.c */,
|
||||
311F2F5717398AE900C15B6A /* dbgpool.h */,
|
||||
31EEAC29156AB2F200714D05 /* dbgpooli.c */,
|
||||
31EEAC41156AB32500714D05 /* diag.c */,
|
||||
31EEAC2A156AB2F200714D05 /* event.c */,
|
||||
311F2F5817398AE900C15B6A /* event.h */,
|
||||
311F2F5917398AE900C15B6A /* eventcom.h */,
|
||||
311F2F5A17398AE900C15B6A /* eventdef.h */,
|
||||
311F2F5B17398AE900C15B6A /* eventpro.h */,
|
||||
311F2F5C17398AE900C15B6A /* eventrep.h */,
|
||||
31EEAC1A156AB2B200714D05 /* format.c */,
|
||||
31EEAC07156AB27B00714D05 /* global.c */,
|
||||
31EEAC2B156AB2F200714D05 /* ld.c */,
|
||||
311F2F5E17398B0E00C15B6A /* lock.h */,
|
||||
31EEAC08156AB27B00714D05 /* locus.c */,
|
||||
31EEAC2C156AB2F200714D05 /* message.c */,
|
||||
31EEAC42156AB32500714D05 /* meter.c */,
|
||||
311F2F5F17398B0E00C15B6A /* meter.h */,
|
||||
311F2F6017398B0E00C15B6A /* misc.h */,
|
||||
31EEAC01156AB21B00714D05 /* mpm.c */,
|
||||
311F2F6117398B0E00C15B6A /* mpm.h */,
|
||||
311F2F6217398B1A00C15B6A /* mpmst.h */,
|
||||
311F2F6317398B1A00C15B6A /* mpmtypes.h */,
|
||||
311F2F6417398B1A00C15B6A /* mps.h */,
|
||||
311F2F6517398B3B00C15B6A /* mpsacl.h */,
|
||||
311F2F6617398B3B00C15B6A /* mpsavm.h */,
|
||||
31EEABF5156AAF7C00714D05 /* mpsi.c */,
|
||||
311F2F6717398B3B00C15B6A /* mpsio.h */,
|
||||
311F2F6817398B3B00C15B6A /* mpslib.h */,
|
||||
311F2F6917398B3B00C15B6A /* mpstd.h */,
|
||||
311F2F6A17398B4C00C15B6A /* mpsw3.h */,
|
||||
311F2F6B17398B4C00C15B6A /* mpswin.h */,
|
||||
311F2F6C17398B5800C15B6A /* osxc.h */,
|
||||
31EEAC09156AB27B00714D05 /* pool.c */,
|
||||
31EEAC0A156AB27B00714D05 /* poolabs.c */,
|
||||
31EEAC2D156AB2F200714D05 /* poolmfs.c */,
|
||||
31EEAC2E156AB2F200714D05 /* poolmrg.c */,
|
||||
31EEAC2F156AB2F200714D05 /* poolmv.c */,
|
||||
311F2F7B17398E7600C15B6A /* poolmv.h */,
|
||||
311F2F7C17398E9A00C15B6A /* mpscmv.h */,
|
||||
311F2F6D17398B6300C15B6A /* prmci3.h */,
|
||||
311F2F6E17398B6300C15B6A /* prmci6.h */,
|
||||
311F2F6F17398B6300C15B6A /* prmcix.h */,
|
||||
311F2F7017398B6300C15B6A /* prmcw3.h */,
|
||||
31EEAC0B156AB27B00714D05 /* protocol.c */,
|
||||
311F2F7117398B7100C15B6A /* protocol.h */,
|
||||
311F2F7217398B7100C15B6A /* pthrdext.h */,
|
||||
31EEAC1B156AB2B200714D05 /* ref.c */,
|
||||
31EEAC0C156AB27B00714D05 /* reserv.c */,
|
||||
31EEAC30156AB2F200714D05 /* ring.c */,
|
||||
311F2F7317398B7100C15B6A /* ring.h */,
|
||||
31EEAC1C156AB2B200714D05 /* root.c */,
|
||||
31EEAC31156AB2F200714D05 /* sac.c */,
|
||||
311F2F7417398B7100C15B6A /* sac.h */,
|
||||
311F2F7517398B8E00C15B6A /* sc.h */,
|
||||
31EEAC1D156AB2B200714D05 /* seg.c */,
|
||||
31EEAC32156AB2F200714D05 /* shield.c */,
|
||||
31EEAC43156AB32500714D05 /* splay.c */,
|
||||
311F2F7617398B8E00C15B6A /* splay.h */,
|
||||
311F2F7717398B8E00C15B6A /* ss.h */,
|
||||
311F2F7817398B8E00C15B6A /* th.h */,
|
||||
311F2F7917398B8E00C15B6A /* thw3.h */,
|
||||
31EEAC1E156AB2B200714D05 /* trace.c */,
|
||||
31EEAC1F156AB2B200714D05 /* traceanc.c */,
|
||||
31EEAC0D156AB27B00714D05 /* tract.c */,
|
||||
311F2F7A17398B8E00C15B6A /* tract.h */,
|
||||
31EEAC44156AB32500714D05 /* version.c */,
|
||||
31EEAC0E156AB27B00714D05 /* walk.c */,
|
||||
);
|
||||
|
|
@ -1629,7 +1726,16 @@
|
|||
31EEAC5A156AB40800714D05 /* Extra pools */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
311F2F5D17398B0400C15B6A /* lo.h */,
|
||||
31F6CCA91739B0CF00C48748 /* mpscamc.h */,
|
||||
31CD33BB173A9F1500524741 /* mpscams.h */,
|
||||
31F6CCAA1739B0CF00C48748 /* mpscawl.h */,
|
||||
31F6CCAB1739B0CF00C48748 /* mpsclo.h */,
|
||||
31F6CCAC1739B0CF00C48748 /* mpscmvff.h */,
|
||||
31F6CCAD1739B0CF00C48748 /* mpscsnc.h */,
|
||||
31EEAC5B156AB41900714D05 /* poolamc.c */,
|
||||
31CD33BC173A9F1500524741 /* poolams.c */,
|
||||
31CD33BD173A9F1500524741 /* poolams.h */,
|
||||
3124CACE156BE4CF00753214 /* poolawl.c */,
|
||||
3124CACA156BE4A300753214 /* poollo.c */,
|
||||
31EEAC5F156AB44D00714D05 /* poolmvff.c */,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
#include "mps.h"
|
||||
|
||||
extern const struct mps_key_s _mps_key_ams_support_ambiguous;
|
||||
#define MPS_KEY_AMS_SUPPORT_AMBIGUOUS (&_mps_key_ams_support_ambiguous)
|
||||
|
||||
extern mps_class_t mps_class_ams(void);
|
||||
extern mps_class_t mps_class_ams_debug(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,13 @@
|
|||
|
||||
#include "mps.h"
|
||||
|
||||
extern const struct mps_key_s _mps_key_awl_find_dependent;
|
||||
#define MPS_KEY_AWL_FIND_DEPENDENT (&_mps_key_awl_find_dependent)
|
||||
|
||||
extern mps_class_t mps_class_awl(void);
|
||||
|
||||
typedef mps_addr_t (*mps_awl_find_dependent_t)(mps_addr_t addr);
|
||||
|
||||
#endif /* mpscawl_h */
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@
|
|||
|
||||
#include "mps.h"
|
||||
|
||||
extern const struct mps_key_s _mps_mfs_extend_by;
|
||||
#define MPS_KEY_MFS_EXTEND_BY (&_mps_mfs_extend_by)
|
||||
extern const struct mps_key_s _mps_mfs_unit_size;
|
||||
#define MPS_KEY_MFS_UNIT_SIZE (&_mps_mfs_unit_size)
|
||||
|
||||
extern mps_class_t mps_class_mfs(void);
|
||||
|
||||
#endif /* mpscmfs_h */
|
||||
|
|
|
|||
|
|
@ -9,6 +9,13 @@
|
|||
|
||||
#include "mps.h"
|
||||
|
||||
extern const struct mps_key_s _mps_key_mv_extend_by;
|
||||
#define MPS_KEY_MV_EXTEND_BY (&_mps_key_mv_extend_by)
|
||||
extern const struct mps_key_s _mps_key_mv_avg_size;
|
||||
#define MPS_KEY_MV_AVG_SIZE (&_mps_key_mv_avg_size)
|
||||
extern const struct mps_key_s _mps_key_mv_max_size;
|
||||
#define MPS_KEY_MV_MAX_SIZE (&_mps_key_mv_max_size)
|
||||
|
||||
extern size_t mps_mv_free_size(mps_pool_t mps_pool);
|
||||
extern size_t mps_mv_size(mps_pool_t mps_pool);
|
||||
extern mps_class_t mps_class_mv(void);
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ mps_res_t mps_arena_create(mps_arena_t *mps_arena_o,
|
|||
va_start(args[0].val.varargs, mps_arena_class);
|
||||
args[1].key = MPS_KEY_ARGS_END;
|
||||
res = mps_arena_create_args(mps_arena_o, mps_arena_class, args);
|
||||
va_end(args[0].val.varargs);
|
||||
/* FIXME: Can't va_end? */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -633,15 +633,31 @@ mps_res_t mps_pool_create(mps_pool_t *mps_pool_o, mps_arena_t arena,
|
|||
mps_class_t mps_class, ...)
|
||||
{
|
||||
mps_res_t res;
|
||||
va_list args;
|
||||
va_start(args, mps_class);
|
||||
res = mps_pool_create_v(mps_pool_o, arena, mps_class, args);
|
||||
va_end(args);
|
||||
mps_arg_s args[2];
|
||||
args[0].key = MPS_KEY_VARARGS;
|
||||
va_start(args[0].val.varargs, mps_class);
|
||||
args[1].key = MPS_KEY_ARGS_END;
|
||||
res = mps_pool_create_k(mps_pool_o, arena, mps_class, args);
|
||||
/* FIXME: Can't va_end? */
|
||||
return res;
|
||||
}
|
||||
|
||||
mps_res_t mps_pool_create_v(mps_pool_t *mps_pool_o, mps_arena_t arena,
|
||||
mps_class_t class, va_list args)
|
||||
mps_class_t class, va_list varargs)
|
||||
{
|
||||
mps_arg_s args[2];
|
||||
|
||||
args[0].key = MPS_KEY_VARARGS;
|
||||
/* FIXME: va_copy not available in C89 */
|
||||
memcpy(&args[0].val.varargs, &varargs, sizeof(va_list));
|
||||
args[1].key = MPS_KEY_ARGS_END;
|
||||
|
||||
return mps_pool_create_k(mps_pool_o, arena, class, args);
|
||||
}
|
||||
|
||||
|
||||
mps_res_t mps_pool_create_k(mps_pool_t *mps_pool_o, mps_arena_t arena,
|
||||
mps_class_t class, mps_arg_s args[])
|
||||
{
|
||||
Pool pool;
|
||||
Res res;
|
||||
|
|
@ -651,8 +667,9 @@ mps_res_t mps_pool_create_v(mps_pool_t *mps_pool_o, mps_arena_t arena,
|
|||
AVER(mps_pool_o != NULL);
|
||||
AVERT(Arena, arena);
|
||||
AVERT(PoolClass, class);
|
||||
AVER(ArgListCheck(args));
|
||||
|
||||
res = PoolCreateV(&pool, arena, class, args);
|
||||
res = PoolCreate(&pool, arena, class, args);
|
||||
|
||||
ArenaLeave(arena);
|
||||
|
||||
|
|
|
|||
|
|
@ -105,22 +105,18 @@ Bool PoolCheck(Pool pool)
|
|||
}
|
||||
|
||||
|
||||
/* PoolInit, PoolInitV -- initialize a pool
|
||||
/* Common keywords to PoolInit */
|
||||
|
||||
const KeyStruct _mps_key_format = {KeySig, "AMS_FORMAT", ArgCheckCant}; /* FIXME: ArgCheckFormat */
|
||||
const KeyStruct _mps_key_chain = {KeySig, "AMS_CHAIN", ArgCheckCant}; /* FIXME: ArgCheckChain */
|
||||
|
||||
|
||||
/* PoolInit -- initialize a pool
|
||||
*
|
||||
* Initialize the generic fields of the pool and calls class-specific
|
||||
* init. See <design/pool/#align>. */
|
||||
|
||||
Res PoolInit(Pool pool, Arena arena, PoolClass class, ...)
|
||||
{
|
||||
Res res;
|
||||
va_list args;
|
||||
va_start(args, class);
|
||||
res = PoolInitV(pool, arena, class, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
Res PoolInitV(Pool pool, Arena arena, PoolClass class, va_list args)
|
||||
Res PoolInit(Pool pool, Arena arena, PoolClass class, ArgList args)
|
||||
{
|
||||
Res res;
|
||||
Word classId;
|
||||
|
|
@ -185,18 +181,7 @@ failInit:
|
|||
/* PoolCreate, PoolCreateV: Allocate and initialise pool */
|
||||
|
||||
Res PoolCreate(Pool *poolReturn, Arena arena,
|
||||
PoolClass class, ...)
|
||||
{
|
||||
Res res;
|
||||
va_list args;
|
||||
va_start(args, class);
|
||||
res = PoolCreateV(poolReturn, arena, class, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
Res PoolCreateV(Pool *poolReturn, Arena arena,
|
||||
PoolClass class, va_list args)
|
||||
PoolClass class, ArgList args)
|
||||
{
|
||||
Res res;
|
||||
Pool pool;
|
||||
|
|
@ -219,7 +204,7 @@ Res PoolCreateV(Pool *poolReturn, Arena arena,
|
|||
pool = (Pool)PointerAdd(base, class->offset);
|
||||
|
||||
/* Initialize the pool. */
|
||||
res = PoolInitV(pool, arena, class, args);
|
||||
res = PoolInit(pool, arena, class, args);
|
||||
if (res != ResOK)
|
||||
goto failPoolInit;
|
||||
|
||||
|
|
|
|||
|
|
@ -194,9 +194,10 @@ void PoolTrivFinish(Pool pool)
|
|||
NOOP;
|
||||
}
|
||||
|
||||
Res PoolTrivInit(Pool pool, va_list args)
|
||||
Res PoolTrivInit(Pool pool, ArgList args)
|
||||
{
|
||||
AVERT(Pool, pool);
|
||||
AVER(ArgListCheck(args));
|
||||
UNUSED(args);
|
||||
return ResOK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -933,7 +933,7 @@ static Bool amcNailRangeIsMarked(Seg seg, Addr base, Addr limit)
|
|||
* See <design/poolamc/#init>.
|
||||
* Shared by AMCInit and AMCZinit.
|
||||
*/
|
||||
static Res amcInitComm(Pool pool, RankSet rankSet, va_list arg)
|
||||
static Res amcInitComm(Pool pool, RankSet rankSet, ArgList args)
|
||||
{
|
||||
AMC amc;
|
||||
Res res;
|
||||
|
|
@ -943,6 +943,7 @@ static Res amcInitComm(Pool pool, RankSet rankSet, va_list arg)
|
|||
Index i;
|
||||
size_t genArraySize;
|
||||
size_t genCount;
|
||||
ArgStruct arg;
|
||||
|
||||
/* Suppress a warning about this structure not being used when there
|
||||
are no statistics. Note that simply making the declaration conditional
|
||||
|
|
@ -959,11 +960,27 @@ static Res amcInitComm(Pool pool, RankSet rankSet, va_list arg)
|
|||
amc = Pool2AMC(pool);
|
||||
arena = PoolArena(pool);
|
||||
|
||||
pool->format = va_arg(arg, Format);
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS)) {
|
||||
pool->format = va_arg(arg.val.varargs, Format);
|
||||
amc->chain = va_arg(arg.val.varargs, Chain);
|
||||
} else {
|
||||
if (ArgPick(&arg, args, MPS_KEY_FORMAT))
|
||||
pool->format = arg.val.format;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
if (ArgPick(&arg, args, MPS_KEY_CHAIN))
|
||||
amc->chain = arg.val.chain;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
}
|
||||
|
||||
AVERT(Format, pool->format);
|
||||
pool->alignment = pool->format->alignment;
|
||||
amc->chain = va_arg(arg, Chain);
|
||||
AVERT(Chain, amc->chain);
|
||||
pool->alignment = pool->format->alignment;
|
||||
amc->rankSet = rankSet;
|
||||
|
||||
RingInit(&amc->genRing);
|
||||
|
|
@ -1035,17 +1052,18 @@ failGenAlloc:
|
|||
}
|
||||
ControlFree(arena, amc->gen, genArraySize);
|
||||
failGensAlloc:
|
||||
failParam:
|
||||
return res;
|
||||
}
|
||||
|
||||
static Res AMCInit(Pool pool, va_list arg)
|
||||
static Res AMCInit(Pool pool, ArgList args)
|
||||
{
|
||||
return amcInitComm(pool, RankSetSingle(RankEXACT), arg);
|
||||
return amcInitComm(pool, RankSetSingle(RankEXACT), args);
|
||||
}
|
||||
|
||||
static Res AMCZInit(Pool pool, va_list arg)
|
||||
static Res AMCZInit(Pool pool, ArgList args)
|
||||
{
|
||||
return amcInitComm(pool, RankSetEMPTY, arg);
|
||||
return amcInitComm(pool, RankSetEMPTY, args);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -733,18 +733,47 @@ static void AMSSegsDestroy(AMS ams)
|
|||
* Takes one additional argument: the format of the objects
|
||||
* allocated in the pool. See <design/poolams/#init>.
|
||||
*/
|
||||
static Res AMSInit(Pool pool, va_list args)
|
||||
|
||||
const KeyStruct _mps_key_ams_support_ambiguous = {
|
||||
KeySig, "AMS_SUPPORT_AMBIGUOUS", ArgCheckCant /* FIXME: ArgCheckBool */
|
||||
};
|
||||
|
||||
static Res AMSInit(Pool pool, ArgList args)
|
||||
{
|
||||
Res res;
|
||||
Format format;
|
||||
Chain chain;
|
||||
Bool supportAmbiguous;
|
||||
ArgStruct arg;
|
||||
|
||||
AVERT(Pool, pool);
|
||||
AVER(ArgListCheck(args));
|
||||
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS)) {
|
||||
format = va_arg(arg.val.varargs, Format);
|
||||
chain = va_arg(arg.val.varargs, Chain);
|
||||
supportAmbiguous = va_arg(arg.val.varargs, Bool);
|
||||
} else {
|
||||
if (ArgPick(&arg, args, MPS_KEY_CHAIN))
|
||||
chain = arg.val.chain;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
if (ArgPick(&arg, args, MPS_KEY_FORMAT))
|
||||
format = arg.val.format;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
if (ArgPick(&arg, args, MPS_KEY_AMS_SUPPORT_AMBIGUOUS))
|
||||
supportAmbiguous = arg.val.b;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
}
|
||||
|
||||
format = va_arg(args, Format);
|
||||
chain = va_arg(args, Chain);
|
||||
supportAmbiguous = va_arg(args, Bool);
|
||||
/* .ambiguous.noshare: If the pool is required to support ambiguous */
|
||||
/* references, the alloc and white tables cannot be shared. */
|
||||
res = AMSInitInternal(Pool2AMS(pool), format, chain, !supportAmbiguous);
|
||||
|
|
@ -752,6 +781,9 @@ static Res AMSInit(Pool pool, va_list args)
|
|||
EVENT3(PoolInitAMS, pool, PoolArena(pool), format);
|
||||
}
|
||||
return res;
|
||||
|
||||
failParam:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include "mpmst.h"
|
||||
#include "ring.h"
|
||||
#include "bt.h"
|
||||
#include "mpscams.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -511,7 +511,11 @@ static Bool AWLSegAlloc(Addr *baseReturn, Addr *limitReturn,
|
|||
|
||||
/* AWLInit -- initialize an AWL pool */
|
||||
|
||||
static Res AWLInit(Pool pool, va_list arg)
|
||||
const KeyStruct _mps_key_awl_find_dependent = {
|
||||
KeySig, "AWL_FIND_DEPENDENT", ArgCheckCant /* FIXME: ArgCheckFun */
|
||||
};
|
||||
|
||||
static Res AWLInit(Pool pool, ArgList args)
|
||||
{
|
||||
AWL awl;
|
||||
Format format;
|
||||
|
|
@ -519,17 +523,34 @@ static Res AWLInit(Pool pool, va_list arg)
|
|||
Chain chain;
|
||||
Res res;
|
||||
static GenParamStruct genParam = { SizeMAX, 0.5 /* dummy */ };
|
||||
ArgStruct arg;
|
||||
|
||||
/* Weak check, as half-way through initialization. */
|
||||
AVER(pool != NULL);
|
||||
|
||||
awl = Pool2AWL(pool);
|
||||
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS)) {
|
||||
format = va_arg(arg.val.varargs, Format);
|
||||
findDependent = va_arg(arg.val.varargs, FindDependentMethod);
|
||||
} else {
|
||||
if (ArgPick(&arg, args, MPS_KEY_FORMAT))
|
||||
format = arg.val.format;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
if (ArgPick(&arg, args, MPS_KEY_AWL_FIND_DEPENDENT))
|
||||
findDependent = (FindDependentMethod)arg.val.addr_method;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
}
|
||||
|
||||
format = va_arg(arg, Format);
|
||||
AVERT(Format, format);
|
||||
pool->format = format;
|
||||
|
||||
findDependent = va_arg(arg, FindDependentMethod);
|
||||
AVER(FUNCHECK(findDependent));
|
||||
awl->findDependent = findDependent;
|
||||
|
||||
|
|
@ -557,6 +578,7 @@ static Res AWLInit(Pool pool, va_list arg)
|
|||
|
||||
failGenInit:
|
||||
ChainDestroy(chain);
|
||||
failParam:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -469,19 +469,30 @@ static void LOWalk(Pool pool, Seg seg,
|
|||
|
||||
/* LOInit -- initialize an LO pool */
|
||||
|
||||
static Res LOInit(Pool pool, va_list arg)
|
||||
static Res LOInit(Pool pool, ArgList args)
|
||||
{
|
||||
Format format;
|
||||
LO lo;
|
||||
Arena arena;
|
||||
Res res;
|
||||
static GenParamStruct loGenParam = { 1024, 0.2 };
|
||||
ArgStruct arg;
|
||||
|
||||
AVERT(Pool, pool);
|
||||
|
||||
arena = PoolArena(pool);
|
||||
|
||||
format = va_arg(arg, Format);
|
||||
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS)) {
|
||||
format = va_arg(arg.val.varargs, Format);
|
||||
} else {
|
||||
if (ArgPick(&arg, args, MPS_KEY_FORMAT))
|
||||
format = arg.val.format;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
}
|
||||
|
||||
AVERT(Format, format);
|
||||
|
||||
lo = PoolPoolLO(pool);
|
||||
|
|
@ -507,6 +518,7 @@ static Res LOInit(Pool pool, va_list arg)
|
|||
|
||||
failGenInit:
|
||||
ChainDestroy(lo->chain);
|
||||
failParam:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,16 +77,38 @@ Pool (MFSPool)(MFS mfs)
|
|||
}
|
||||
|
||||
|
||||
static Res MFSInit(Pool pool, va_list arg)
|
||||
const KeyStruct _mps_mfs_extend_by = {KeySig, "MFS_EXTEND_BY", ArgCheckCant};
|
||||
const KeyStruct _mps_mfs_unit_size = {KeySig, "MFS_UNIT_SIZE", ArgCheckCant};
|
||||
|
||||
static Res MFSInit(Pool pool, ArgList args)
|
||||
{
|
||||
Res res;
|
||||
Size extendBy, unitSize;
|
||||
MFS mfs;
|
||||
Arena arena;
|
||||
ArgStruct arg;
|
||||
|
||||
AVER(pool != NULL);
|
||||
|
||||
extendBy = va_arg(arg, Size);
|
||||
unitSize = va_arg(arg, Size);
|
||||
AVER(ArgListCheck(args));
|
||||
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS)) {
|
||||
extendBy = va_arg(arg.val.varargs, Size);
|
||||
unitSize = va_arg(arg.val.varargs, Size);
|
||||
} else {
|
||||
if (ArgPick(&arg, args, MPS_KEY_MFS_UNIT_SIZE))
|
||||
unitSize = arg.val.size;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
if (ArgPick(&arg, args, MPS_KEY_MFS_EXTEND_BY))
|
||||
extendBy = arg.val.size;
|
||||
else {
|
||||
extendBy = MFS_EXTEND_BY_DEFAULT;
|
||||
if (extendBy < unitSize)
|
||||
extendBy = unitSize;
|
||||
}
|
||||
}
|
||||
|
||||
AVER(unitSize >= UNIT_MIN);
|
||||
AVER(extendBy >= unitSize);
|
||||
|
|
@ -109,6 +131,9 @@ static Res MFSInit(Pool pool, va_list arg)
|
|||
AVERT(MFS, mfs);
|
||||
EVENT4(PoolInitMFS, pool, arena, extendBy, unitSize);
|
||||
return ResOK;
|
||||
|
||||
failParam:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#define poolmfs_h
|
||||
|
||||
#include "mpm.h"
|
||||
#include "mpscmfs.h"
|
||||
|
||||
typedef struct MFSStruct *MFS;
|
||||
|
||||
|
|
|
|||
|
|
@ -616,11 +616,12 @@ static Res MRGRefSegScan(ScanState ss, MRGRefSeg refseg, MRG mrg)
|
|||
|
||||
/* MRGInit -- init method for MRG */
|
||||
|
||||
static Res MRGInit(Pool pool, va_list args)
|
||||
static Res MRGInit(Pool pool, ArgList args)
|
||||
{
|
||||
MRG mrg;
|
||||
|
||||
AVER(pool != NULL); /* Can't check more; see pool contract @@@@ */
|
||||
AVER(ArgListCheck(args));
|
||||
UNUSED(args);
|
||||
|
||||
mrg = Pool2MRG(pool);
|
||||
|
|
|
|||
|
|
@ -184,16 +184,33 @@ static Bool MVSpanCheck(MVSpan span)
|
|||
|
||||
/* MVInit -- init method for class MV */
|
||||
|
||||
static Res MVInit(Pool pool, va_list arg)
|
||||
const KeyStruct _mps_key_mv_extend_by = {KeySig, "MV_EXTEND_BY", ArgCheckCant};
|
||||
const KeyStruct _mps_key_mv_avg_size = {KeySig, "MV_AVG_SIZE", ArgCheckCant};
|
||||
const KeyStruct _mps_key_mv_max_size = {KeySig, "MV_MAX_SIZE", ArgCheckCant};
|
||||
|
||||
static Res MVInit(Pool pool, ArgList args)
|
||||
{
|
||||
Size extendBy, avgSize, maxSize, blockExtendBy, spanExtendBy;
|
||||
Size extendBy = MV_EXTEND_BY_DEFAULT;
|
||||
Size avgSize = MV_AVG_SIZE_DEFAULT;
|
||||
Size maxSize = MV_MAX_SIZE_DEFAULT;
|
||||
Size blockExtendBy, spanExtendBy;
|
||||
MV mv;
|
||||
Arena arena;
|
||||
Res res;
|
||||
|
||||
extendBy = va_arg(arg, Size);
|
||||
avgSize = va_arg(arg, Size);
|
||||
maxSize = va_arg(arg, Size);
|
||||
ArgStruct arg;
|
||||
ArgStruct piArgs[3];
|
||||
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS)) {
|
||||
extendBy = va_arg(arg.val.varargs, Size);
|
||||
avgSize = va_arg(arg.val.varargs, Size);
|
||||
maxSize = va_arg(arg.val.varargs, Size);
|
||||
}
|
||||
if (ArgPick(&arg, args, MPS_KEY_MV_EXTEND_BY))
|
||||
extendBy = arg.val.size;
|
||||
if (ArgPick(&arg, args, MPS_KEY_MV_AVG_SIZE))
|
||||
avgSize = arg.val.size;
|
||||
if (ArgPick(&arg, args, MPS_KEY_MV_MAX_SIZE))
|
||||
maxSize = arg.val.size;
|
||||
|
||||
AVER(extendBy > 0);
|
||||
AVER(avgSize > 0);
|
||||
|
|
@ -211,17 +228,23 @@ static Res MVInit(Pool pool, va_list arg)
|
|||
blockExtendBy = sizeof(MVBlockStruct);
|
||||
}
|
||||
|
||||
res = PoolInit(&mv->blockPoolStruct.poolStruct,
|
||||
arena, PoolClassMFS(),
|
||||
blockExtendBy, sizeof(MVBlockStruct));
|
||||
piArgs[0].key = MPS_KEY_MFS_EXTEND_BY;
|
||||
piArgs[0].val.size = blockExtendBy;
|
||||
piArgs[1].key = MPS_KEY_MFS_UNIT_SIZE;
|
||||
piArgs[1].val.size = sizeof(MVBlockStruct);
|
||||
piArgs[2].key = MPS_KEY_ARGS_END;
|
||||
res = PoolInit(&mv->blockPoolStruct.poolStruct, arena, PoolClassMFS(), piArgs);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
spanExtendBy = sizeof(MVSpanStruct) * (maxSize/extendBy);
|
||||
|
||||
res = PoolInit(&mv->spanPoolStruct.poolStruct,
|
||||
arena, PoolClassMFS(),
|
||||
spanExtendBy, sizeof(MVSpanStruct));
|
||||
piArgs[0].key = MPS_KEY_MFS_EXTEND_BY;
|
||||
piArgs[0].val.size = spanExtendBy;
|
||||
piArgs[1].key = MPS_KEY_MFS_UNIT_SIZE;
|
||||
piArgs[1].val.size = sizeof(MVSpanStruct);
|
||||
piArgs[2].key = MPS_KEY_ARGS_END;
|
||||
res = PoolInit(&mv->spanPoolStruct.poolStruct, arena, PoolClassMFS(), piArgs);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
|
||||
#include "mpmtypes.h"
|
||||
#include "mpscmv.h"
|
||||
|
||||
typedef struct MVStruct *MV;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ SRCID(poolmv2, "$Id$");
|
|||
/* Private prototypes */
|
||||
|
||||
typedef struct MVTStruct *MVT;
|
||||
static Res MVTInit(Pool pool, va_list arg);
|
||||
static Res MVTInit(Pool pool, ArgList arg);
|
||||
static Bool MVTCheck(MVT mvt);
|
||||
static void MVTFinish(Pool pool);
|
||||
static Res MVTBufferFill(Addr *baseReturn, Addr *limitReturn,
|
||||
|
|
@ -194,38 +194,46 @@ static SegPref MVTSegPref(MVT mvt)
|
|||
* Parameters are:
|
||||
* minSize, meanSize, maxSize, reserveDepth, fragLimit
|
||||
*/
|
||||
static Res MVTInit(Pool pool, va_list arg)
|
||||
static Res MVTInit(Pool pool, ArgList args)
|
||||
{
|
||||
Arena arena;
|
||||
Size minSize, meanSize, maxSize, reuseSize, fillSize;
|
||||
Count reserveDepth, abqDepth, fragLimit;
|
||||
MVT mvt;
|
||||
Res res;
|
||||
ArgStruct arg;
|
||||
|
||||
AVERT(Pool, pool);
|
||||
mvt = Pool2MVT(pool);
|
||||
/* can't AVERT mvt, yet */
|
||||
arena = PoolArena(pool);
|
||||
AVERT(Arena, arena);
|
||||
|
||||
/* --- Should there be a ResBADARG ? */
|
||||
minSize = va_arg(arg, Size);
|
||||
unless (minSize > 0)
|
||||
return ResLIMIT;
|
||||
meanSize = va_arg(arg, Size);
|
||||
unless (meanSize >= minSize)
|
||||
return ResLIMIT;
|
||||
maxSize = va_arg(arg, Size);
|
||||
unless (maxSize >= meanSize)
|
||||
return ResLIMIT;
|
||||
/* --- check that maxSize is not too large */
|
||||
reserveDepth = va_arg(arg, Count);
|
||||
unless (reserveDepth > 0)
|
||||
return ResLIMIT;
|
||||
/* --- check that reserveDepth is not too large or small */
|
||||
fragLimit = va_arg(arg, Count);
|
||||
unless (fragLimit <= 100)
|
||||
return ResLIMIT;
|
||||
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS)) {
|
||||
/* FIXME: Inconsistent reporting of bad arguments. Elsewhere we assert or return ResPARAM. */
|
||||
/* --- Should there be a ResBADARG ? */
|
||||
minSize = va_arg(arg.val.varargs, Size);
|
||||
unless (minSize > 0)
|
||||
return ResLIMIT;
|
||||
meanSize = va_arg(arg.val.varargs, Size);
|
||||
unless (meanSize >= minSize)
|
||||
return ResLIMIT;
|
||||
maxSize = va_arg(arg.val.varargs, Size);
|
||||
unless (maxSize >= meanSize)
|
||||
return ResLIMIT;
|
||||
/* --- check that maxSize is not too large */
|
||||
reserveDepth = va_arg(arg.val.varargs, Count);
|
||||
unless (reserveDepth > 0)
|
||||
return ResLIMIT;
|
||||
/* --- check that reserveDepth is not too large or small */
|
||||
fragLimit = va_arg(arg.val.varargs, Count);
|
||||
unless (fragLimit <= 100)
|
||||
return ResLIMIT;
|
||||
} else {
|
||||
/* FIXME: Keywords not yet supported. */
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
|
||||
/* see <design/poolmvt/#arch.parameters> */
|
||||
fillSize = SizeAlignUp(maxSize, ArenaAlign(arena));
|
||||
|
|
@ -319,6 +327,7 @@ static Res MVTInit(Pool pool, va_list arg)
|
|||
failABQ:
|
||||
CBSFinish(MVTCBS(mvt));
|
||||
failCBS:
|
||||
failParam:
|
||||
AVER(res != ResOK);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ static void MVFFBufferEmpty(Pool pool, Buffer buffer,
|
|||
|
||||
/* MVFFInit -- initialize method for MVFF */
|
||||
|
||||
static Res MVFFInit(Pool pool, va_list arg)
|
||||
static Res MVFFInit(Pool pool, ArgList args)
|
||||
{
|
||||
Size extendBy, avgSize, align;
|
||||
Bool slotHigh, arenaHigh, firstFit;
|
||||
|
|
@ -418,6 +418,7 @@ static Res MVFFInit(Pool pool, va_list arg)
|
|||
Res res;
|
||||
void *p;
|
||||
ZoneSet zones;
|
||||
ArgStruct arg;
|
||||
|
||||
AVERT(Pool, pool);
|
||||
|
||||
|
|
@ -425,12 +426,20 @@ static Res MVFFInit(Pool pool, va_list arg)
|
|||
/* <design/poolmvff/#method.init> */
|
||||
/* .arg.check: we do the same checks here and in MVFFCheck */
|
||||
/* except for arenaHigh, which is stored only in the segPref. */
|
||||
extendBy = va_arg(arg, Size);
|
||||
avgSize = va_arg(arg, Size);
|
||||
align = va_arg(arg, Size);
|
||||
slotHigh = va_arg(arg, Bool);
|
||||
arenaHigh = va_arg(arg, Bool);
|
||||
firstFit = va_arg(arg, Bool);
|
||||
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS)) {
|
||||
extendBy = va_arg(arg.val.varargs, Size);
|
||||
avgSize = va_arg(arg.val.varargs, Size);
|
||||
align = va_arg(arg.val.varargs, Size);
|
||||
slotHigh = va_arg(arg.val.varargs, Bool);
|
||||
arenaHigh = va_arg(arg.val.varargs, Bool);
|
||||
firstFit = va_arg(arg.val.varargs, Bool);
|
||||
} else {
|
||||
/* FIXME: Accept keywords! */
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
|
||||
AVER(extendBy > 0); /* .arg.check */
|
||||
AVER(avgSize > 0); /* .arg.check */
|
||||
AVER(avgSize <= extendBy); /* .arg.check */
|
||||
|
|
@ -479,6 +488,7 @@ static Res MVFFInit(Pool pool, va_list arg)
|
|||
|
||||
failInit:
|
||||
ControlFree(arena, p, sizeof(SegPrefStruct));
|
||||
failParam:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ typedef struct PoolNStruct {
|
|||
|
||||
/* NInit -- init method for class N */
|
||||
|
||||
static Res NInit(Pool pool, va_list args)
|
||||
static Res NInit(Pool pool, ArgList args)
|
||||
{
|
||||
PoolN poolN = PoolPoolN(pool);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ static void testit(ArenaClass class, ArgList args)
|
|||
|
||||
die(ArenaCreate(&arena, class, args), "ArenaCreate");
|
||||
|
||||
die(PoolCreate(&pool, arena, PoolClassN()), "PoolNCreate");
|
||||
die(PoolCreate(&pool, arena, PoolClassN(), argsNone), "PoolNCreate");
|
||||
res = PoolAlloc(&p, pool, 1, /* withReservoirPermit */ FALSE);
|
||||
if (res == ResOK) {
|
||||
error("Error: Unexpectedly succeeded in"
|
||||
|
|
|
|||
|
|
@ -361,17 +361,28 @@ static Bool sncFindFreeSeg(Seg *segReturn, SNC snc, Size size)
|
|||
|
||||
/* SNCInit -- initialize an SNC pool */
|
||||
|
||||
static Res SNCInit(Pool pool, va_list arg)
|
||||
static Res SNCInit(Pool pool, ArgList args)
|
||||
{
|
||||
Res res;
|
||||
SNC snc;
|
||||
Format format;
|
||||
ArgStruct arg;
|
||||
|
||||
/* weak check, as half-way through initialization */
|
||||
AVER(pool != NULL);
|
||||
|
||||
snc = Pool2SNC(pool);
|
||||
|
||||
format = va_arg(arg, Format);
|
||||
if (ArgPick(&arg, args, MPS_KEY_VARARGS))
|
||||
format = va_arg(arg.val.varargs, Format);
|
||||
else {
|
||||
if (ArgPick(&arg, args, MPS_KEY_FORMAT))
|
||||
format = arg.val.format;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
}
|
||||
|
||||
AVERT(Format, format);
|
||||
pool->format = format;
|
||||
|
|
@ -384,6 +395,9 @@ static Res SNCInit(Pool pool, va_list arg)
|
|||
AVERT(SNC, snc);
|
||||
EVENT2(PoolInitSNC, pool, format);
|
||||
return ResOK;
|
||||
|
||||
failParam:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ SRCID(reserv, "$Id$");
|
|||
|
||||
/* ResPoolInit -- Reservoir pool init method */
|
||||
|
||||
static Res ResPoolInit(Pool pool, va_list arg)
|
||||
static Res ResPoolInit(Pool pool, ArgList arg)
|
||||
{
|
||||
AVER(pool != NULL);
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ Res ReservoirInit(Reservoir reservoir, Arena arena)
|
|||
reservoir->sig = ReservoirSig;
|
||||
/* initialize the reservoir pool, <design/reservoir/> */
|
||||
res = PoolInit(&reservoir->poolStruct,
|
||||
arena, EnsureReservoirPoolClass());
|
||||
arena, EnsureReservoirPoolClass(), argsNone);
|
||||
if (res == ResOK) {
|
||||
AVERT(Reservoir, reservoir);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -330,17 +330,24 @@ static Res AMSTSegSizePolicy(Size *sizeReturn,
|
|||
|
||||
/* AMSTInit -- the pool class initialization method */
|
||||
|
||||
static Res AMSTInit(Pool pool, va_list args)
|
||||
static Res AMSTInit(Pool pool, ArgList args)
|
||||
{
|
||||
AMST amst; AMS ams;
|
||||
Format format;
|
||||
Chain chain;
|
||||
Res res;
|
||||
static GenParamStruct genParam = { 1024, 0.2 };
|
||||
ArgStruct arg;
|
||||
|
||||
AVERT(Pool, pool);
|
||||
|
||||
format = va_arg(args, Format);
|
||||
|
||||
if (ArgPick(&arg, args, MPS_KEY_FORMAT))
|
||||
format = arg.val.format;
|
||||
else {
|
||||
res = ResPARAM;
|
||||
goto failParam;
|
||||
}
|
||||
|
||||
res = ChainCreate(&chain, pool->arena, 1, &genParam);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
|
@ -362,6 +369,10 @@ static Res AMSTInit(Pool pool, va_list args)
|
|||
amst->sig = AMSTSig;
|
||||
AVERT(AMST, amst);
|
||||
return ResOK;
|
||||
|
||||
failParam:
|
||||
AVER(res != ResOK);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -755,13 +766,17 @@ static void *test(void *arg, size_t s)
|
|||
mps_ap_t busy_ap;
|
||||
mps_addr_t busy_init;
|
||||
char *indent = " ";
|
||||
mps_arg_s args[2];
|
||||
|
||||
arena = (mps_arena_t)arg;
|
||||
(void)s; /* unused */
|
||||
|
||||
die(mps_fmt_create_A(&format, arena, dylan_fmt_A()), "fmt_create");
|
||||
|
||||
die(mps_pool_create(&pool, arena, mps_class_amst(), format),
|
||||
args[0].key = MPS_KEY_FORMAT;
|
||||
args[0].val.format = format;
|
||||
args[1].key = MPS_KEY_ARGS_END;
|
||||
die(mps_pool_create_k(&pool, arena, mps_class_amst(), args),
|
||||
"pool_create(amst)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
|
||||
|
|
|
|||
|
|
@ -73,6 +73,19 @@ the way that they acquire the memory to be managed.
|
|||
The type of :term:`arena classes`.
|
||||
|
||||
|
||||
.. c:function:: mps_res_t mps_arena_create_k(mps_arena_t *arena_o, mps_arena_class_t arena_class, mps_arg_s args[])
|
||||
|
||||
Create an :term:`arena`.
|
||||
|
||||
``arena_o`` points to a location that will hold a pointer to the new
|
||||
arena.
|
||||
|
||||
``arena_class`` is the :term:`arena class`.
|
||||
|
||||
``args`` are :ref:`topic-interface-keywords` specific to the arena
|
||||
class. See the documentation for the arena class.
|
||||
|
||||
|
||||
.. c:function:: mps_res_t mps_arena_create(mps_arena_t *arena_o, mps_arena_class_t arena_class, ...)
|
||||
|
||||
Create an :term:`arena`.
|
||||
|
|
@ -142,18 +155,29 @@ Client arenas
|
|||
A client arena gets its managed memory from the :term:`client
|
||||
program`. This memory chunk is passed when the arena is created.
|
||||
|
||||
When creating a client arena, :c:func:`mps_arena_create` takes two
|
||||
extra arguments::
|
||||
When creating a client arena, :c:func:`mps_arena_create_k` requires two
|
||||
:ref:`topic-interface-keywords`:
|
||||
|
||||
* ``MPS_KEY_ARENA_CL_BASE`` (type ``mps_addr_t``) is the
|
||||
:term:`address` of the chunk of memory that will be managed by the
|
||||
arena.
|
||||
|
||||
* ``MPS_KEY_ARENA_SIZE`` (type ``size_t``) is its size.
|
||||
|
||||
For example (in C99)::
|
||||
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(),
|
||||
(mps_arg_s[]){{MPS_KEY_ARENA_CL_BASE, .val.addr = base},
|
||||
{MPS_KEY_ARENA_SIZE, .val.size = size},
|
||||
{MPS_KEY_ARGS_END}});
|
||||
|
||||
When creating a client arena, :c:func:`mps_arena_create` takes the
|
||||
these arguments like this::
|
||||
|
||||
mps_res_t mps_arena_create(mps_arena_t *arena_o,
|
||||
mps_arena_class_t mps_arena_class_cl,
|
||||
size_t size, mps_addr_t base)
|
||||
|
||||
``base`` is the :term:`address` of the chunk of memory that will
|
||||
be managed by the arena.
|
||||
|
||||
``size`` is its :term:`size`.
|
||||
|
||||
If the chunk is too small to hold the internal arena structures,
|
||||
:c:func:`mps_arena_create` returns :c:macro:`MPS_RES_MEMORY`. In
|
||||
this case, you need to use a (much) larger chunk.
|
||||
|
|
@ -204,12 +228,17 @@ Virtual memory arenas
|
|||
:term:`fragmentation` and helps make :term:`garbage collection`
|
||||
more efficient.
|
||||
|
||||
When creating a virtual memory arena, :c:func:`mps_arena_create`
|
||||
takes one extra argument::
|
||||
|
||||
mps_res_t mps_arena_create(mps_arena_t *arena_o,
|
||||
mps_arena_class_t arena_class_vm(),
|
||||
size_t size)
|
||||
When creating a virtual memory arena, :c:func:`mps_arena_create_k`
|
||||
requires one
|
||||
:ref:`topic-interface-keywords`:
|
||||
|
||||
* ``MPS_KEY_ARENA_SIZE`` (type ``size_t``)
|
||||
|
||||
For example (in C99)::
|
||||
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(),
|
||||
(mps_arg_s[]){{MPS_KEY_ARENA_SIZE, .val.size = size},
|
||||
{MPS_KEY_ARGS_END}});
|
||||
|
||||
``size`` is the initial amount of virtual address space, in
|
||||
:term:`bytes (1)`, that the arena will reserve (this space is
|
||||
|
|
@ -227,6 +256,28 @@ Virtual memory arenas
|
|||
more times it has to extend its address space, the less
|
||||
efficient garbage collection will become.
|
||||
|
||||
An optional :ref:`topic-interface-keywords` may be passed, but is
|
||||
only used on the Windows operating system:
|
||||
|
||||
* ``MPS_KEY_VM_W3_TOP_DOWN`` (type ``mps_bool_t``)
|
||||
|
||||
If true, the arena will allocate address space starting at the
|
||||
highest possible address and working downwards through memory.
|
||||
|
||||
.. note::
|
||||
|
||||
This causes the arena to pass the ``MEM_TOP_DOWN`` flag to
|
||||
`VirtualAlloc`_.
|
||||
|
||||
.. _VirtualAlloc: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366887%28v=vs.85%29.aspx
|
||||
|
||||
When creating a virtual memory arena, :c:func:`mps_arena_create`
|
||||
takes one extra argument::
|
||||
|
||||
mps_res_t mps_arena_create(mps_arena_t *arena_o,
|
||||
mps_arena_class_t arena_class_vm(),
|
||||
size_t size)
|
||||
|
||||
If the MPS fails to reserve adequate address space to place the
|
||||
arena in, :c:func:`mps_arena_create` returns
|
||||
:c:macro:`MPS_RES_RESOURCE`. Possibly this means that other parts
|
||||
|
|
|
|||
|
|
@ -258,6 +258,45 @@ Macros
|
|||
separately.
|
||||
|
||||
|
||||
.. _topic-interface-keywords:
|
||||
|
||||
Keyword arguments
|
||||
-----------------
|
||||
|
||||
Some functions take :term:`keyword arguments` in order to pass values
|
||||
that might be optional, or are only required in some circumstances. For
|
||||
example, :ref:`client arenas <topic-arena-client>` require a base address. These
|
||||
arguments are passed in a keyword argument array, like this::
|
||||
|
||||
mps_res_t res;
|
||||
mps_arena_t arena;
|
||||
mps_arg_s args[3];
|
||||
args[0].key = MPS_KEY_ARENA_SIZE;
|
||||
args[0].val.size = 6553600;
|
||||
args[1].key = MPS_KEY_ARENA_CL_BASE;
|
||||
args[1].val.addr = base_address;
|
||||
args[2].key = MPS_KEY_ARGS_END;
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(), args);
|
||||
|
||||
If you are writing C99, you can write this more concisely as::
|
||||
|
||||
mps_res_t res;
|
||||
mps_arena_t arena;
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(),
|
||||
(mps_arg_s[]){{MPS_KEY_ARENA_SIZE, .val.size = 6553600},
|
||||
{MPS_KEY_ARENA_CL_BASE, .val.addr = base_address},
|
||||
{MPS_KEY_ARGS_END}});
|
||||
|
||||
The argument array must not be ``NULL``, and must end with
|
||||
``MPS_KEY_ARGS_END``.
|
||||
|
||||
On return, the keyword argument array will be *modified* to remove any
|
||||
arguments that have been used. If all arguments have been used the
|
||||
first element key will be MPS_KEY_ARGS_END.
|
||||
|
||||
If you don't want to pass any arguments, you can either call the equivalent function that does not take
|
||||
|
||||
|
||||
.. _topic-interface-general:
|
||||
|
||||
General types
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -265,7 +265,7 @@ Keyword arguments
|
|||
|
||||
Some functions take :term:`keyword arguments` in order to pass values
|
||||
that might be optional, or are only required in some circumstances. For
|
||||
example, :ref:`topic-arena-client` require a base address. These
|
||||
example, :term:`client arenas` require a base address. These
|
||||
arguments are passed in a keyword argument array, like this::
|
||||
|
||||
mps_res_t res;
|
||||
|
|
@ -288,12 +288,14 @@ If you are writing C99, you can write this more concisely as::
|
|||
{MPS_KEY_ARGS_END}});
|
||||
|
||||
The argument array must not be ``NULL``, and must end with
|
||||
``MPS_KEY_ARGS_END``.
|
||||
``MPS_KEY_ARGS_END``. If you don't want to pass any arguments, you can
|
||||
either call the equivalent function that does not take keyword arguments
|
||||
(named without the ``_k``) or pass ``mps_args_none``.
|
||||
|
||||
On return, the keyword argument array will be *modified* to remove any
|
||||
arguments that have been used. If all arguments have been used the
|
||||
first element key will be MPS_KEY_ARGS_END.
|
||||
|
||||
first element key will be ``MPS_KEY_ARGS_END``.
|
||||
|
||||
|
||||
.. _topic-interface-general:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue