From 4b2a6aed8413d6e7d7b25d918896ae637266d9d5 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Mon, 1 Sep 1997 03:26:31 +0000 Subject: Use sim_state_alloc to create common sim object. --- sim/common/sim-utils.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'sim/common/sim-utils.c') diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c index 9bcfffc..c72a1ab 100644 --- a/sim/common/sim-utils.c +++ b/sim/common/sim-utils.c @@ -53,7 +53,8 @@ with this program; if not, write to the Free Software Foundation, Inc., Set by sim_resume. */ struct sim_state *current_state; -/* Allocate zero filled memory with xmalloc. */ +/* Allocate zero filled memory with xmalloc - xmalloc aborts of the + allocation fails. */ void * zalloc (unsigned long size) @@ -72,10 +73,16 @@ zfree (void *data) /* Allocate a sim_state struct. */ SIM_DESC -sim_state_alloc (void) +sim_state_alloc (SIM_OPEN_KIND kind, + host_callback *callback) { - SIM_DESC sd = zalloc (sizeof (struct sim_state)); - sd->base.magic = SIM_MAGIC_NUMBER; + int cpu_nr; + SIM_DESC sd = ZALLOC (struct sim_state); + STATE_MAGIC (sd) = SIM_MAGIC_NUMBER; + STATE_CALLBACK (sd) = callback; + STATE_OPEN_KIND (sd) = kind; + for (cpu_nr = 0; cpu_nr < MAX_NR_PROCESSORS; cpu_nr++) + CPU_STATE (STATE_CPU (sd, cpu_nr)) = sd; return sd; } -- cgit v1.1