From 56fdc3d785c0cc2efea9977ed3429aa03d738bb4 Mon Sep 17 00:00:00 2001 From: Pekka Pirinen Date: Wed, 14 Mar 2001 16:10:16 +0000 Subject: [PATCH] Convert to chains Copied from Perforce Change: 21743 ServerID: perforce.ravenbrook.com --- mps/qa/function/50.c | 55 ++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/mps/qa/function/50.c b/mps/qa/function/50.c index 3174105df67..5f2c33a2b7c 100644 --- a/mps/qa/function/50.c +++ b/mps/qa/function/50.c @@ -1,6 +1,6 @@ /* TEST_HEADER - id = $HopeName: MMQA_test_function!50.c(trunk.5) $ + id = $HopeName: MMQA_test_function!50.c(trunk.6) $ summary = finalization tests with AMC, AWL and LO language = c link = testlib.o rankfmt.o @@ -19,6 +19,12 @@ END_HEADER #include "rankfmt.h" +#define genCOUNT (3) + +static mps_gen_param_s testChain[genCOUNT] = { + { 6000, 0.90 }, { 8000, 0.65 }, { 16000, 0.50 } }; + + void *stackpointer; mps_arena_t arena; @@ -40,14 +46,16 @@ int qhd = 0; int qtl = 0; -static void nq(mps_message_t mess) { +static void nq(mps_message_t mess) +{ mqueue[qhd] = mess; qhd = (qhd+1) % 10000; asserts(qhd != qtl, "No space in message queue."); } -static int qmt(void) { +static int qmt(void) +{ if (qhd == qtl) { return 1; } else { @@ -56,7 +64,8 @@ static int qmt(void) { } -static int dq(mps_message_t *mess) { +static int dq(mps_message_t *mess) +{ if (qhd == qtl) { return 0; } else { @@ -67,7 +76,8 @@ static int dq(mps_message_t *mess) { } -static void process_mess(mps_message_t message, int faction, mps_addr_t *ref) { +static void process_mess(mps_message_t message, int faction, mps_addr_t *ref) +{ mps_addr_t ffref; switch (faction) { @@ -93,7 +103,8 @@ static void process_mess(mps_message_t message, int faction, mps_addr_t *ref) { } -static void qpoll(mycell **ref, int faction) { +static void qpoll(mycell **ref, int faction) +{ mps_message_t message; if (dq(&message)) { @@ -102,7 +113,8 @@ static void qpoll(mycell **ref, int faction) { } -static void finalpoll(mycell **ref, int faction) { +static void finalpoll(mycell **ref, int faction) +{ mps_message_t message; if (mps_message_get(&message, arena, MPS_MESSAGE_TYPE_FINALIZATION)) { @@ -112,12 +124,14 @@ static void finalpoll(mycell **ref, int faction) { } -static void test(void) { +static void test(void) +{ mps_pool_t poolamc, poolawl, poollo; mps_thr_t thread; mps_root_t root0, root1; mps_fmt_t format; + mps_chain_t chain; mps_ap_t apamc, apawl, aplo; mycell *a, *b, *c, *d, *z; @@ -128,7 +142,6 @@ static void test(void) { "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); - cdie(mps_root_create_reg(&root0, arena, MPS_RANK_AMBIG, 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create root"); @@ -140,8 +153,10 @@ static void test(void) { cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format"); - cdie(mps_pool_create(&poolamc, arena, mps_class_amc(), format), - "create pool"); + cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); + + die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain), + "create pool"); cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format), "create pool"); @@ -161,7 +176,7 @@ static void test(void) { mps_message_type_enable(arena, mps_message_type_finalization()); -/* register loads of objects for finalization (1000*4) */ + /* register loads of objects for finalization (1000*4) */ a = allocone(apamc, 2, 1); b = a; @@ -181,7 +196,7 @@ static void test(void) { b = a; } -/* throw them all away and collect everything */ + /* throw them all away and collect everything */ a = NULL; b = NULL; @@ -194,13 +209,11 @@ static void test(void) { finalpoll(&z, FINAL_DISCARD); } -/* how many are left? (n.b. ideally this would be 0 but - there's no guarantee) -*/ + /* How many are left? (ideally, this would be 0 but there's no guarantee) */ report("count1", "%i", final_count); -/* now to test leaving messages open for a long time! */ + /* Now to test leaving messages open for a long time! */ for (j=0; j<10; j++) { comment("%d of 10", j); @@ -273,18 +286,16 @@ static void test(void) { mps_pool_destroy(poollo); comment("Destroyed pools."); + mps_chain_destroy(chain); mps_fmt_destroy(format); - comment("Destroyed format."); - mps_thread_dereg(thread); - comment("Deregistered thread."); - mps_arena_destroy(arena); comment("Destroyed arena."); } -int main(void) { +int main(void) +{ void *m; stackpointer=&m; /* hack to get stack pointer */