1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-30 02:33:03 -07:00

Convert to chains

Copied from Perforce
 Change: 21743
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Pekka Pirinen 2001-03-14 16:10:16 +00:00
parent 95958c5344
commit 56fdc3d785

View file

@ -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 */