diff --git a/mps/code/mps.h b/mps/code/mps.h index 67d1f77738c..1eb0f230689 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h @@ -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 /* Keep in sync with diff --git a/mps/code/mpsacl.h b/mps/code/mpsacl.h index 9f8ea3f6362..b9fc2913f63 100644 --- a/mps/code/mpsacl.h +++ b/mps/code/mpsacl.h @@ -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); diff --git a/mps/code/mpscams.h b/mps/code/mpscams.h index f410c2734dd..5c1cc1b6f8f 100644 --- a/mps/code/mpscams.h +++ b/mps/code/mpscams.h @@ -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); diff --git a/mps/code/mpscawl.h b/mps/code/mpscawl.h index 5271560b11f..4c0af1fb17e 100644 --- a/mps/code/mpscawl.h +++ b/mps/code/mpscawl.h @@ -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); diff --git a/mps/code/mpscmfs.h b/mps/code/mpscmfs.h index 87f6e108424..cc0a411260b 100644 --- a/mps/code/mpscmfs.h +++ b/mps/code/mpscmfs.h @@ -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); diff --git a/mps/code/mpscmvff.h b/mps/code/mpscmvff.h index 09164872b76..f8bc97b7f3b 100644 --- a/mps/code/mpscmvff.h +++ b/mps/code/mpscmvff.h @@ -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); diff --git a/mps/code/mpscmvt.h b/mps/code/mpscmvt.h index 2237639310b..5a1e5eb6ad5 100644 --- a/mps/code/mpscmvt.h +++ b/mps/code/mpscmvt.h @@ -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, diff --git a/mps/example/scheme/Makefile.in b/mps/example/scheme/Makefile.in index aca3a682bab..73b5e8094fc 100644 --- a/mps/example/scheme/Makefile.in +++ b/mps/example/scheme/Makefile.in @@ -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 diff --git a/mps/example/scheme/scheme-advanced.c b/mps/example/scheme/scheme-advanced.c index a006f156de8..2e77ca05c51 100644 --- a/mps/example/scheme/scheme-advanced.c +++ b/mps/example/scheme/scheme-advanced.c @@ -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 diff --git a/mps/example/scheme/scheme.c b/mps/example/scheme/scheme.c index 527d946b9e8..c6f68573467 100644 --- a/mps/example/scheme/scheme.c +++ b/mps/example/scheme/scheme.c @@ -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 diff --git a/mps/manual/source/glossary/k.rst b/mps/manual/source/glossary/k.rst index b08edafb470..4033cce5fd5 100644 --- a/mps/manual/source/glossary/k.rst +++ b/mps/manual/source/glossary/k.rst @@ -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:: diff --git a/mps/manual/source/guide/advanced.rst b/mps/manual/source/guide/advanced.rst index 7ef3a7bea3d..a6604daf573 100644 --- a/mps/manual/source/guide/advanced.rst +++ b/mps/manual/source/guide/advanced.rst @@ -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. */ diff --git a/mps/manual/source/guide/lang.rst b/mps/manual/source/guide/lang.rst index d6d8943cabc..bd01c550218 100644 --- a/mps/manual/source/guide/lang.rst +++ b/mps/manual/source/guide/lang.rst @@ -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"); diff --git a/mps/manual/source/pool/amc.rst b/mps/manual/source/pool/amc.rst index 376f22752cd..51216853823 100644 --- a/mps/manual/source/pool/amc.rst +++ b/mps/manual/source/pool/amc.rst @@ -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. diff --git a/mps/manual/source/pool/amcz.rst b/mps/manual/source/pool/amcz.rst index d2cac80ca1e..45444e07404 100644 --- a/mps/manual/source/pool/amcz.rst +++ b/mps/manual/source/pool/amcz.rst @@ -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. diff --git a/mps/manual/source/pool/ams.rst b/mps/manual/source/pool/ams.rst index 523ac6d5d2e..95b718dd9e6 100644 --- a/mps/manual/source/pool/ams.rst +++ b/mps/manual/source/pool/ams.rst @@ -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. diff --git a/mps/manual/source/pool/awl.rst b/mps/manual/source/pool/awl.rst index a5379c321f1..7ee92cec48f 100644 --- a/mps/manual/source/pool/awl.rst +++ b/mps/manual/source/pool/awl.rst @@ -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. diff --git a/mps/manual/source/pool/lo.rst b/mps/manual/source/pool/lo.rst index f826d26b292..19609cc68cb 100644 --- a/mps/manual/source/pool/lo.rst +++ b/mps/manual/source/pool/lo.rst @@ -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. diff --git a/mps/manual/source/pool/mfs.rst b/mps/manual/source/pool/mfs.rst index d6aa1273907..7fe549058cf 100644 --- a/mps/manual/source/pool/mfs.rst +++ b/mps/manual/source/pool/mfs.rst @@ -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. diff --git a/mps/manual/source/pool/mv.rst b/mps/manual/source/pool/mv.rst index 815534e7934..e71153d5c75 100644 --- a/mps/manual/source/pool/mv.rst +++ b/mps/manual/source/pool/mv.rst @@ -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. diff --git a/mps/manual/source/pool/mvff.rst b/mps/manual/source/pool/mvff.rst index bca01de026f..d116cf72bc0 100644 --- a/mps/manual/source/pool/mvff.rst +++ b/mps/manual/source/pool/mvff.rst @@ -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. diff --git a/mps/manual/source/pool/mvt.rst b/mps/manual/source/pool/mvt.rst index 2fa90a802c8..31fe3044b25 100644 --- a/mps/manual/source/pool/mvt.rst +++ b/mps/manual/source/pool/mvt.rst @@ -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. diff --git a/mps/manual/source/pool/snc.rst b/mps/manual/source/pool/snc.rst index 805beb0e892..dad0020e59e 100644 --- a/mps/manual/source/pool/snc.rst +++ b/mps/manual/source/pool/snc.rst @@ -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. diff --git a/mps/manual/source/topic/arena.rst b/mps/manual/source/topic/arena.rst index 670583b9876..69e185ff4d8 100644 --- a/mps/manual/source/topic/arena.rst +++ b/mps/manual/source/topic/arena.rst @@ -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. diff --git a/mps/manual/source/topic/debugging.rst b/mps/manual/source/topic/debugging.rst index c7c372e3b2b..94b54b36b03 100644 --- a/mps/manual/source/topic/debugging.rst +++ b/mps/manual/source/topic/debugging.rst @@ -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"); diff --git a/mps/manual/source/topic/format.rst b/mps/manual/source/topic/format.rst index fd91f19e823..1d8f281318c 100644 --- a/mps/manual/source/topic/format.rst +++ b/mps/manual/source/topic/format.rst @@ -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"); diff --git a/mps/manual/source/topic/keyword.rst b/mps/manual/source/topic/keyword.rst index e809449cee9..c3971516f2e 100644 --- a/mps/manual/source/topic/keyword.rst +++ b/mps/manual/source/topic/keyword.rst @@ -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 diff --git a/mps/manual/source/topic/pool.rst b/mps/manual/source/topic/pool.rst index ad748310a22..2c7766b6356 100644 --- a/mps/manual/source/topic/pool.rst +++ b/mps/manual/source/topic/pool.rst @@ -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`.