Use sim_state_alloc to create common sim object.
[deliverable/binutils-gdb.git] / sim / common / sim-utils.c
index 9bcfffce87ce5a2ca50e9681ec3b676f0684675f..c72a1ab34d96a5e1207fbf7f2500a12444bae69d 100644 (file)
@@ -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;
 }
 
This page took 0.023035 seconds and 4 git commands to generate.