sim: sim_do_commandf: fix call to va_end [PR sim/19273]
[binutils-gdb.git] / sim / common / sim-base.h
index 7a28b12738da27555f413127a1293b129f7a60fd..21f61f4dc1f8a21ee85b5d424207274a983e7291 100644 (file)
@@ -1,7 +1,6 @@
 /* Simulator pseudo baseclass.
 
-   Copyright 1997, 1998, 2003, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright 1997-2015 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
 
@@ -29,12 +28,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
    information), include ``sim-base.h'':
 
      #include "sim-basics.h"
-     typedef address_word sim_cia;
      /-* If `sim_cia' is not an integral value (e.g. a struct), define
          CIA_ADDR to return the integral value.  *-/
+     /-* typedef struct {...} sim_cia; *-/
      /-* #define CIA_ADDR(cia) (...) *-/
      #include "sim-base.h"
-   
+
    finally, two data types `struct _sim_cpu' and `struct sim_state'
    are defined:
 
@@ -44,12 +43,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
      };
 
      struct sim_state {
-       sim_cpu cpu[MAX_NR_PROCESSORS];
-     #if (WITH_SMP)
-     #define STATE_CPU(sd,n) (&(sd)->cpu[n])
-     #else
-     #define STATE_CPU(sd,n) (&(sd)->cpu[0])
-     #endif
+       sim_cpu *cpu[MAX_NR_PROCESSORS];
        ... simulator specific members ...
        sim_state_base base;
      };
@@ -72,11 +66,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
    (e.g. for delay slot handling).  */
 #ifndef CIA_ADDR
 #define CIA_ADDR(cia) (cia)
+typedef address_word sim_cia;
 #endif
 #ifndef INVALID_INSTRUCTION_ADDRESS
 #define INVALID_INSTRUCTION_ADDRESS ((address_word)0 - 1)
 #endif
 
+/* TODO: Probably should just delete SIM_CPU.  */
+typedef struct _sim_cpu SIM_CPU;
 typedef struct _sim_cpu sim_cpu;
 
 #include "sim-module.h"
@@ -117,6 +114,15 @@ extern struct sim_state *current_state;
 #endif
 
 
+/* We require all sims to dynamically allocate cpus.  See comment up top about
+   struct sim_state.  */
+#if (WITH_SMP)
+# define STATE_CPU(sd, n) ((sd)->cpu[n])
+#else
+# define STATE_CPU(sd, n) ((sd)->cpu[0])
+#endif
+
+
 typedef struct {
 
   /* Simulator's argv[0].  */
@@ -245,7 +251,7 @@ typedef struct {
 } sim_state_base;
 
 /* Functions for allocating/freeing a sim_state.  */
-SIM_DESC sim_state_alloc PARAMS ((SIM_OPEN_KIND kind, host_callback *callback));
-void sim_state_free PARAMS ((SIM_DESC));
+SIM_DESC sim_state_alloc (SIM_OPEN_KIND kind, host_callback *callback);
+void sim_state_free (SIM_DESC);
 
 #endif /* SIM_BASE_H */