mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Remove mps_arg from mps.h.
Use MPS_ARGS_BEGIN etc in the Scheme example and in the manual. Use MPS_BEGIN and MPS_END instead of BEGIN and END. The _FIELD macros don't need to be function-like macros. Restore TODO comments in mps.h. Scheme example compiles with -std=c89. Copied from Perforce Change: 181749 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
81a5ba77fa
commit
56b78ef7b9
28 changed files with 226 additions and 179 deletions
|
|
@ -123,69 +123,67 @@ extern mps_arg_s mps_args_none[];
|
|||
|
||||
extern const struct mps_key_s _mps_key_arena_size;
|
||||
#define MPS_KEY_ARENA_SIZE (&_mps_key_arena_size)
|
||||
#define MPS_KEY_ARENA_SIZE_FIELD() size
|
||||
#define MPS_KEY_ARENA_SIZE_FIELD size
|
||||
extern const struct mps_key_s _mps_key_format;
|
||||
#define MPS_KEY_FORMAT (&_mps_key_format)
|
||||
#define MPS_KEY_FORMAT_FIELD() format
|
||||
#define MPS_KEY_FORMAT_FIELD format
|
||||
extern const struct mps_key_s _mps_key_chain;
|
||||
#define MPS_KEY_CHAIN (&_mps_key_chain)
|
||||
#define MPS_KEY_CHAIN_FIELD() chain
|
||||
#define MPS_KEY_CHAIN_FIELD chain
|
||||
extern const struct mps_key_s _mps_key_rank;
|
||||
#define MPS_KEY_RANK (&_mps_key_rank)
|
||||
#define MPS_KEY_RANK_FIELD() rank
|
||||
#define MPS_KEY_RANK_FIELD rank
|
||||
|
||||
extern const struct mps_key_s _mps_key_extend_by;
|
||||
#define MPS_KEY_EXTEND_BY (&_mps_key_extend_by)
|
||||
#define MPS_KEY_EXTEND_BY_FIELD() size
|
||||
#define MPS_KEY_EXTEND_BY_FIELD size
|
||||
extern const struct mps_key_s _mps_key_min_size;
|
||||
#define MPS_KEY_MIN_SIZE (&_mps_key_min_size)
|
||||
#define MPS_KEY_MIN_SIZE_FIELD() size
|
||||
#define MPS_KEY_MIN_SIZE_FIELD size
|
||||
extern const struct mps_key_s _mps_key_mean_size;
|
||||
#define MPS_KEY_MEAN_SIZE (&_mps_key_mean_size)
|
||||
#define MPS_KEY_MEAN_SIZE_FIELD() size
|
||||
#define MPS_KEY_MEAN_SIZE_FIELD size
|
||||
extern const struct mps_key_s _mps_key_max_size;
|
||||
#define MPS_KEY_MAX_SIZE (&_mps_key_max_size)
|
||||
#define MPS_KEY_MAX_SIZE_FIELD() size
|
||||
#define MPS_KEY_MAX_SIZE_FIELD size
|
||||
extern const struct mps_key_s _mps_key_align;
|
||||
#define MPS_KEY_ALIGN (&_mps_key_align)
|
||||
#define MPS_KEY_ALIGN_FIELD() align
|
||||
#define MPS_KEY_ALIGN_FIELD align
|
||||
|
||||
extern const struct mps_key_s _mps_key_vmw3_top_down;
|
||||
#define MPS_KEY_VMW3_TOP_DOWN (&_mps_key_vmw3_top_down)
|
||||
#define MPS_KEY_VMW3_TOP_DOWN_FIELD() b
|
||||
#define MPS_KEY_VMW3_TOP_DOWN_FIELD b
|
||||
|
||||
/* Maximum length of a keyword argument list. */
|
||||
#define MPS_ARGS_MAX 32
|
||||
|
||||
#define MPS_ARGS_BEGIN(_var) \
|
||||
BEGIN \
|
||||
MPS_BEGIN \
|
||||
mps_arg_s _var[MPS_ARGS_MAX]; \
|
||||
unsigned _var##_i = 0; \
|
||||
BEGIN
|
||||
MPS_BEGIN
|
||||
|
||||
#define MPS_ARGS_ADD_FIELD(_var, _key, _field, _val) \
|
||||
BEGIN \
|
||||
AVER(_var##_i < MPS_ARGS_MAX); \
|
||||
MPS_BEGIN \
|
||||
/* TODO: AVER(_var##_i < MPS_ARGS_MAX); */ \
|
||||
_var[_var##_i].key = (_key); \
|
||||
_var[_var##_i].val._field = (_val); \
|
||||
++_var##_i; \
|
||||
END
|
||||
MPS_END
|
||||
|
||||
#define MPS_ARGS_ADD(_var, _key, _val) \
|
||||
MPS_ARGS_ADD_FIELD(_var, _key, _key##_FIELD(), _val)
|
||||
MPS_ARGS_ADD_FIELD(_var, _key, _key##_FIELD, _val)
|
||||
|
||||
#define MPS_ARGS_DONE(_var) \
|
||||
BEGIN \
|
||||
AVER(_var##_i < MPS_ARGS_MAX); \
|
||||
MPS_BEGIN \
|
||||
/* TODO: AVER(_var##_i < MPS_ARGS_MAX); */ \
|
||||
_var[_var##_i].key = MPS_KEY_ARGS_END; \
|
||||
_var##_i = MPS_ARGS_MAX; \
|
||||
END
|
||||
/* TODO: _var##_i = MPS_ARGS_MAX; */ \
|
||||
MPS_END
|
||||
|
||||
#define MPS_ARGS_END(_var) \
|
||||
END; \
|
||||
END
|
||||
|
||||
#define MPS_ARG(_key, _val) ((mps_arg_s){(_key), {._key##_FIELD() = (_val)}})
|
||||
MPS_END; \
|
||||
MPS_END
|
||||
|
||||
|
||||
/* <a id="message.types"> Keep in sync with
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
/* Client arena base address argument */
|
||||
extern const struct mps_key_s _mps_key_arena_cl_addr;
|
||||
#define MPS_KEY_ARENA_CL_BASE (&_mps_key_arena_cl_addr)
|
||||
#define MPS_KEY_ARENA_CL_BASE_FIELD() addr
|
||||
#define MPS_KEY_ARENA_CL_BASE_FIELD addr
|
||||
|
||||
extern mps_arena_class_t mps_arena_class_cl(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
extern const struct mps_key_s _mps_key_ams_support_ambiguous;
|
||||
#define MPS_KEY_AMS_SUPPORT_AMBIGUOUS (&_mps_key_ams_support_ambiguous)
|
||||
#define MPS_KEY_AMS_SUPPORT_AMBIGUOUS_FIELD() b
|
||||
#define MPS_KEY_AMS_SUPPORT_AMBIGUOUS_FIELD b
|
||||
|
||||
extern mps_class_t mps_class_ams(void);
|
||||
extern mps_class_t mps_class_ams_debug(void);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
extern const struct mps_key_s _mps_key_awl_find_dependent;
|
||||
#define MPS_KEY_AWL_FIND_DEPENDENT (&_mps_key_awl_find_dependent)
|
||||
#define MPS_KEY_AWL_FIND_DEPENDENT_FIELD() addr_method
|
||||
#define MPS_KEY_AWL_FIND_DEPENDENT_FIELD addr_method
|
||||
|
||||
extern mps_class_t mps_class_awl(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
extern const struct mps_key_s _mps_key_mfs_unit_size;
|
||||
#define MPS_KEY_MFS_UNIT_SIZE (&_mps_key_mfs_unit_size)
|
||||
#define MPS_KEY_MFS_UNIT_SIZE_FIELD() size
|
||||
#define MPS_KEY_MFS_UNIT_SIZE_FIELD size
|
||||
|
||||
extern mps_class_t mps_class_mfs(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
|
||||
extern const struct mps_key_s _mps_key_mvff_slot_high;
|
||||
#define MPS_KEY_MVFF_SLOT_HIGH (&_mps_key_mvff_slot_high)
|
||||
#define MPS_KEY_MVFF_SLOT_HIGH_FIELD() b
|
||||
#define MPS_KEY_MVFF_SLOT_HIGH_FIELD b
|
||||
extern const struct mps_key_s _mps_key_mvff_arena_high;
|
||||
#define MPS_KEY_MVFF_ARENA_HIGH (&_mps_key_mvff_arena_high)
|
||||
#define MPS_KEY_MVFF_ARENA_HIGH_FIELD() b
|
||||
#define MPS_KEY_MVFF_ARENA_HIGH_FIELD b
|
||||
extern const struct mps_key_s _mps_key_mvff_first_fit;
|
||||
#define MPS_KEY_MVFF_FIRST_FIT (&_mps_key_mvff_first_fit)
|
||||
#define MPS_KEY_MVFF_FIRST_FIT_FIELD() b
|
||||
#define MPS_KEY_MVFF_FIRST_FIT_FIELD b
|
||||
|
||||
extern size_t mps_mvff_free_size(mps_pool_t mps_pool);
|
||||
extern size_t mps_mvff_size(mps_pool_t mps_pool);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
extern const struct mps_key_s _mps_key_mvt_reserve_depth;
|
||||
#define MPS_KEY_MVT_RESERVE_DEPTH (&_mps_key_mvt_reserve_depth)
|
||||
#define MPS_KEY_MVT_RESERVE_DEPTH_FIELD() count
|
||||
#define MPS_KEY_MVT_RESERVE_DEPTH_FIELD count
|
||||
extern const struct mps_key_s _mps_key_mvt_frag_limit;
|
||||
#define MPS_KEY_MVT_FRAG_LIMIT (&_mps_key_mvt_frag_limit)
|
||||
#define MPS_KEY_MVT_FRAG_LIMIT_FIELD() count
|
||||
#define MPS_KEY_MVT_FRAG_LIMIT_FIELD count
|
||||
|
||||
/* The mvt pool class has five extra parameters to mps_pool_create:
|
||||
* mps_res_t mps_pool_create(mps_pool_t * pool, mps_arena_t arena,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# $Id$
|
||||
|
||||
# -fno-inline-functions is a temporary workaround for job003359.
|
||||
CFLAGS = @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -std=c99 -fno-inline-functions
|
||||
CFLAGS = @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -std=c89 -fno-inline-functions
|
||||
|
||||
MPS = ../../code
|
||||
|
||||
|
|
|
|||
|
|
@ -4470,9 +4470,11 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Create an MPS arena. There is usually only one of these in a process.
|
||||
It holds all the MPS "global" state and is where everything happens. */
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_vm(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_ARENA_SIZE, 32 * 1024 * 1024),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 32 * 1024 * 1024);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_vm(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create arena");
|
||||
|
||||
/* Create the object format. */
|
||||
|
|
@ -4488,10 +4490,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Create an Automatic Mostly-Copying (AMC) pool to manage the Scheme
|
||||
objects. This is a kind of copying garbage collector. */
|
||||
res = mps_pool_create_k(&obj_pool, arena, mps_class_amc(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_CHAIN, obj_chain),
|
||||
MPS_ARG(MPS_KEY_FORMAT, obj_fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, obj_chain);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, obj_fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&obj_pool, arena, mps_class_amc(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create obj pool");
|
||||
|
||||
/* Create an allocation point for fast in-line allocation of objects
|
||||
|
|
@ -4503,10 +4507,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Create an Automatic Mostly-Copying Zero-rank (AMCZ) pool to
|
||||
manage the leaf objects. */
|
||||
res = mps_pool_create_k(&leaf_pool, arena, mps_class_amcz(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_CHAIN, obj_chain),
|
||||
MPS_ARG(MPS_KEY_FORMAT, obj_fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, obj_chain);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, obj_fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&leaf_pool, arena, mps_class_amcz(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create leaf pool");
|
||||
|
||||
/* Create allocation point for leaf objects. */
|
||||
|
|
@ -4519,21 +4525,26 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Create an Automatic Weak Linked (AWL) pool to manage the hash table
|
||||
buckets. */
|
||||
res = mps_pool_create_k(&buckets_pool, arena, mps_class_awl(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_FORMAT, buckets_fmt),
|
||||
MPS_ARG(MPS_KEY_AWL_FIND_DEPENDENT,
|
||||
buckets_find_dependent),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, buckets_fmt);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_AWL_FIND_DEPENDENT, buckets_find_dependent);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&buckets_pool, arena, mps_class_awl(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create buckets pool");
|
||||
|
||||
/* Create allocation points for weak and strong buckets. */
|
||||
res = mps_ap_create_k(&strong_buckets_ap, buckets_pool,
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_RANK, mps_rank_exact()),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_RANK, mps_rank_exact());
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_ap_create_k(&strong_buckets_ap, buckets_pool, args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create strong buckets allocation point");
|
||||
res = mps_ap_create_k(&weak_buckets_ap, buckets_pool,
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_RANK, mps_rank_weak()),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_RANK, mps_rank_weak());
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_ap_create_k(&weak_buckets_ap, buckets_pool, args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create weak buckets allocation point");
|
||||
|
||||
/* Register the current thread with the MPS. The MPS must sometimes
|
||||
|
|
|
|||
|
|
@ -4391,9 +4391,11 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Create an MPS arena. There is usually only one of these in a process.
|
||||
It holds all the MPS "global" state and is where everything happens. */
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_vm(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_ARENA_SIZE, 32 * 1024 * 1024),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 32 * 1024 * 1024);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_vm(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create arena");
|
||||
|
||||
/* Create the object format. */
|
||||
|
|
@ -4409,10 +4411,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Create an Automatic Mostly-Copying (AMC) pool to manage the Scheme
|
||||
objects. This is a kind of copying garbage collector. */
|
||||
res = mps_pool_create_k(&obj_pool, arena, mps_class_amc(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_CHAIN, obj_chain),
|
||||
MPS_ARG(MPS_KEY_FORMAT, obj_fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, obj_chain);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, obj_fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&obj_pool, arena, mps_class_amc(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create obj pool");
|
||||
|
||||
/* Create an allocation point for fast in-line allocation of objects
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@ Memory Management Glossary: K
|
|||
|
||||
keyword argument
|
||||
|
||||
An optional argument to a function call, identified by an
|
||||
associated keyword.
|
||||
A argument to a function call that's identified by an
|
||||
associated keyword rather than by its position in the argument
|
||||
list.
|
||||
|
||||
.. mps:specific::
|
||||
|
||||
|
|
|
|||
|
|
@ -712,21 +712,26 @@ Finally, we can create the buckets pool and its allocation points::
|
|||
|
||||
/* Create an Automatic Weak Linked (AWL) pool to manage the hash table
|
||||
buckets. */
|
||||
res = mps_pool_create_k(&buckets_pool, arena, mps_class_awl(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_FORMAT, buckets_fmt),
|
||||
{MPS_KEY_AWL_FIND_DEPENDENT,
|
||||
.val.addr_method = buckets_find_dependent},
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, buckets_fmt);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_AWL_FIND_DEPENDENT, buckets_find_dependent);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&buckets_pool, arena, mps_class_awl(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create buckets pool");
|
||||
|
||||
/* Create allocation points for weak and strong buckets. */
|
||||
res = mps_ap_create_k(&strong_buckets_ap, buckets_pool,
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_RANK, mps_rank_exact()),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_RANK, mps_rank_exact());
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_ap_create_k(&strong_buckets_ap, buckets_pool, args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create strong buckets allocation point");
|
||||
res = mps_ap_create_k(&weak_buckets_ap, buckets_pool,
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_RANK, mps_rank_weak()),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_RANK, mps_rank_weak());
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_ap_create_k(&weak_buckets_ap, buckets_pool, args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create weak buckets allocation point");
|
||||
|
||||
By adding the line::
|
||||
|
|
@ -892,10 +897,12 @@ Second, the leaf objects must be allocated on ``leaf_ap`` instead of
|
|||
|
||||
/* Create an Automatic Mostly-Copying Zero-rank (AMCZ) pool to
|
||||
manage the leaf objects. */
|
||||
res = mps_pool_create_k(&leaf_pool, arena, mps_class_amcz(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_CHAIN, obj_chain),
|
||||
MPS_ARG(MPS_KEY_FORMAT, obj_fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, obj_chain);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, obj_fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&leaf_pool, arena, mps_class_amcz(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create leaf pool");
|
||||
|
||||
/* Create allocation point for leaf objects. */
|
||||
|
|
|
|||
|
|
@ -175,9 +175,11 @@ times larger than your peak memory usage.
|
|||
Let's reserve 32 megabytes::
|
||||
|
||||
mps_res_t res;
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_vm(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_ARENA_SIZE, 32 * 1024 * 1024),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, 32 * 1024 * 1024);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_vm(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create arena");
|
||||
|
||||
:c:func:`mps_arena_create_k` is typical of functions in the MPS
|
||||
|
|
@ -770,10 +772,12 @@ Third, the :term:`generation chain`::
|
|||
And finally the :term:`pool`::
|
||||
|
||||
mps_pool_t obj_pool;
|
||||
res = mps_pool_create_k(&obj_pool, arena, mps_class_amc(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_CHAIN, obj_chain),
|
||||
MPS_ARG(MPS_KEY_FORMAT, obj_fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, obj_chain);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, obj_fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&obj_pool, arena, mps_class_amc(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create obj pool");
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -112,12 +112,14 @@ AMC interface
|
|||
* :c:macro:`MPS_KEY_CHAIN` (type :c:type:`mps_chain_t`) specifies
|
||||
the :term:`generation chain` for the pool.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_amc(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_CHAIN, chain),
|
||||
MPS_ARG(MPS_KEY_FORMAT, fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, chain);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_amc(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -71,12 +71,14 @@ AMCZ interface
|
|||
* :c:macro:`MPS_KEY_CHAIN` (type :c:type:`mps_chain_t`) specifies
|
||||
the :term:`generation chain` for the pool.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_amcz(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_CHAIN, chain),
|
||||
MPS_ARG(MPS_KEY_FORMAT, fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, chain);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_amcz(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -115,12 +115,14 @@ AMS interface
|
|||
the :term:`generation chain` for the pool. It must have a single
|
||||
generation.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_ams(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_CHAIN, chain),
|
||||
MPS_ARG(MPS_KEY_FORMAT, fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, chain);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_ams(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -331,12 +331,14 @@ AWL interface
|
|||
how to find the :term:`dependent object` for an object in the
|
||||
pool.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_awl(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_FORMAT, fmt),
|
||||
MPS_ARG(MPS_KEY_AWL_FIND_DEPENDENT, find_dependent),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_AWL_FIND_DEPENDENT, find_dependent);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_awl(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
@ -358,11 +360,13 @@ AWL interface
|
|||
:term:`exact references`), or :c:func:`mps_rank_weak` (if the
|
||||
objects will contain :term:`weak references (1)`).
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_ap_create_k(&ap, awl_pool,
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_RANK, mps_rank_weak()),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_RANK, mps_rank_weak());
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_ap_create_k(&ap, awl_pool, args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -112,11 +112,13 @@ LO interface
|
|||
the :term:`object format` for the objects allocated in the pool.
|
||||
The format must provide a :term:`skip method`.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_lo(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_FORMAT, fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_lo(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -91,12 +91,14 @@ MFS interface
|
|||
argument. If this is not a multiple of the unit size, there will
|
||||
be wasted space in each segment.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_mfs(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_MFS_UNIT_SIZE, 1024),
|
||||
MPS_ARG(MPS_KEY_EXTEND_BY, 1024 * 1024),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MFS_UNIT_SIZE, 1024);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_EXTEND_BY, 1024 * 1024);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_mfs(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -90,13 +90,15 @@ MV interface
|
|||
The mean and maximum sizes are *hints* to the MPS: the pool will be
|
||||
less efficient if these are wrong, but nothing will break.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_mfs(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_MEAN_SIZE, 32),
|
||||
MPS_ARG(MPS_KEY_MAX_SIZE, 1024),
|
||||
MPS_ARG(MPS_KEY_EXTEND_BY, 1024 * 1024),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MEAN_SIZE, 32);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MAX_SIZE, 1024);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_EXTEND_BY, 1024 * 1024);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_mfs(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -143,16 +143,18 @@ MVFF interface
|
|||
* :c:macro:`MPS_KEY_MVFF_FIRST_FIT` (type :c:type:`mps_bool_t`) is
|
||||
undocumented and must be set to true.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_mvff(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_EXTEND_BY, 1024 * 1024),
|
||||
MPS_ARG(MPS_KEY_MEAN_SIZE, 32),
|
||||
MPS_ARG(MPS_KEY_ALIGN, 8),
|
||||
MPS_ARG(MPS_KEY_MVFF_ARENA_HIGH, 0),
|
||||
MPS_ARG(MPS_KEY_MVFF_SLOT_HIGH, 0),
|
||||
MPS_ARG(MPS_KEY_MVFF_FIRST_FIT, 1),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_EXTEND_BY, 1024 * 1024);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MEAN_SIZE, 32);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_ALIGN, 8);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MVFF_ARENA_HIGH, 0);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MVFF_SLOT_HIGH, 0);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MVFF_FIRST_FIT, 1);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_mvff(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -178,15 +178,17 @@ MVT interface
|
|||
intermediate setting can be used to limit the space-inefficiency
|
||||
of temporal fit due to varying object life expectancies.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_mvt(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_MIN_SIZE, 4),
|
||||
MPS_ARG(MPS_KEY_MEAN_SIZE, 32),
|
||||
MPS_ARG(MPS_KEY_MAX_SIZE, 1024),
|
||||
MPS_ARG(MPS_KEY_MVT_RESERVE_DEPTH, 256),
|
||||
MPS_ARG(MPS_KEY_MVT_FRAG_LIMIT, 50),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MIN_SIZE, 4);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MEAN_SIZE, 32);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MAX_SIZE, 1024);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MVT_RESERVE_DEPTH, 256);
|
||||
MPS_ARGS_ADD(ARGS, MPS_KEY_MVT_FRAG_LIMIT, 50);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_mvt(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -103,11 +103,13 @@ SNC introspection
|
|||
The format must provide a :term:`scan method`, a :term:`skip
|
||||
method`, and a :term:`padding method`.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_snc(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_FORMAT, fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_snc(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
@ -125,11 +127,13 @@ SNC introspection
|
|||
the :term:`rank` of references in objects allocated on this
|
||||
allocation point. It must be :c:func:`mps_rank_exact`.
|
||||
|
||||
For example, in :term:`C99`::
|
||||
For example::
|
||||
|
||||
res = mps_ap_create_k(&ap, awl_pool,
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_RANK, mps_rank_exact()),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_RANK, mps_rank_exact());
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_ap_create_k(&ap, awl_pool, args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -165,12 +165,14 @@ Client arenas
|
|||
* :c:macro:`MPS_KEY_ARENA_SIZE` (type :c:type:`size_t`) is its
|
||||
size.
|
||||
|
||||
For example (in :term:`C99`)::
|
||||
For example::
|
||||
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_ARENA_CL_BASE, base),
|
||||
MPS_ARG(MPS_KEY_ARENA_SIZE, size),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_ARENA_CL_BASE, base);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, size);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
If the chunk is too small to hold the internal arena structures,
|
||||
:c:func:`mps_arena_create_k` returns :c:macro:`MPS_RES_MEMORY`. In
|
||||
|
|
@ -275,11 +277,13 @@ Virtual memory arenas
|
|||
:c:macro:`MPS_RES_MEMORY`. Either ``size`` was far too small or
|
||||
the operating system refused to provide enough memory.
|
||||
|
||||
For example (in :term:`C99`)::
|
||||
For example::
|
||||
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_ARENA_SIZE, size),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, size);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
.. deprecated:: starting with version 1.112.
|
||||
|
||||
|
|
|
|||
|
|
@ -71,11 +71,13 @@ For example::
|
|||
};
|
||||
mps_pool_t pool;
|
||||
mps_res_t res;
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_ams_debug(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_POOL_DEBUG_OPTIONS, &debug_options),
|
||||
MPS_ARG(MPS_KEY_FORMAT, &fmt),
|
||||
MPS_ARG(MPS_KEY_CHAIN, &chain),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_POOL_DEBUG_OPTIONS, &debug_options);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, &fmt);
|
||||
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, &chain);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&pool, arena, mps_class_ams_debug(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("can't create debug pool");
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -92,9 +92,11 @@ For example::
|
|||
if (res != MPS_RES_OK) error("Couldn't create obj format");
|
||||
/* obj_fmt created successfully */
|
||||
|
||||
res = mps_pool_create_k(&obj_pool, arena, pool_class,
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_FORMAT, obj_fmt),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
MPS_ARGS_BEGIN(args) {
|
||||
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, obj_fmt);
|
||||
MPS_ARGS_DONE(args);
|
||||
res = mps_pool_create_k(&obj_pool, arena, pool_class, args);
|
||||
} MPS_ARGS_END(args);
|
||||
if (res != MPS_RES_OK) error("Couldn't create obj pool");
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,16 +35,6 @@ help with forming keyword argument lists::
|
|||
MPS_ARGS_DONE(args);
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(), args);
|
||||
} MPS_ARGS_END(args);
|
||||
|
||||
But if you are writing :term:`C99`, you can write this more concisely
|
||||
using the helper macro :c:func:`MPS_ARG`::
|
||||
|
||||
mps_res_t res;
|
||||
mps_arena_t arena;
|
||||
res = mps_arena_create_k(&arena, mps_arena_class_cl(),
|
||||
(mps_arg_s[]){MPS_ARG(MPS_KEY_ARENA_SIZE, 6553600),
|
||||
MPS_ARG(MPS_KEY_ARENA_CL_BASE, base_address),
|
||||
{MPS_KEY_ARGS_END}});
|
||||
|
||||
The argument array must not be ``NULL``, and must end with
|
||||
:c:macro:`MPS_KEY_ARGS_END`. If you don't want to pass any arguments, you can
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ making it available for allocation.
|
|||
:c:func:`mps_alloc` or via an :term:`allocation point`.
|
||||
|
||||
|
||||
.. c:function:: mps_res_t mps_pool_create(mps_pool_t *pool_o, mps_arena_t arena, mps_class_t class, mps_arg_s args[])
|
||||
.. c:function:: mps_res_t mps_pool_create_k(mps_pool_t *pool_o, mps_arena_t arena, mps_class_t class, mps_arg_s args[])
|
||||
|
||||
Create a :term:`pool` in an :term:`arena`.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue