forked from Imagelibrary/binutils-gdb
sim: invert sim_state storage
Currently all ports have to declare sim_state themselves in their sim-main.h and then embed the common sim_state_base & sim_cpu in it. This dynamic makes it impossible to share common object code among multiple ports because the core data structure is always different. Let's invert this relationship: common code declares sim_state, and if the port actually needs state on a per-instance basis, it can use the new arch_data field for it. Most ports don't actually use it, so they don't need to declare anything at all. This is the first in a series of changes: it adds a define to select between the old & new layouts, then converts all the ports that don't need custom state over to the new layout.
This commit is contained in:
@@ -48,8 +48,8 @@ zalloc (unsigned long size)
|
||||
/* Allocate a sim_state struct. */
|
||||
|
||||
SIM_DESC
|
||||
sim_state_alloc (SIM_OPEN_KIND kind,
|
||||
host_callback *callback)
|
||||
sim_state_alloc_extra (SIM_OPEN_KIND kind, host_callback *callback,
|
||||
size_t extra_bytes)
|
||||
{
|
||||
SIM_DESC sd = ZALLOC (struct sim_state);
|
||||
|
||||
@@ -57,6 +57,11 @@ sim_state_alloc (SIM_OPEN_KIND kind,
|
||||
STATE_CALLBACK (sd) = callback;
|
||||
STATE_OPEN_KIND (sd) = kind;
|
||||
|
||||
#ifdef SIM_HAVE_COMMON_SIM_STATE
|
||||
if (extra_bytes)
|
||||
STATE_ARCH_DATA (sd) = zalloc (extra_bytes);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
{
|
||||
int cpu_nr;
|
||||
|
||||
Reference in New Issue
Block a user