From 1c636da093f335cd57e7fca0fc25ae9f9e849264 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 28 Jun 2021 21:42:56 -0400 Subject: sim: namespace sim_machs We want to do a single build with all arches in one binary which means we need to namespace sim_machs on a per-arch basis. Move it from a global variable to the sim description structure so it can be setup at runtime. Changing the SIM_MODEL->num from an enum to an int is unfortunate, but we specifically don't want to maintain a centralized list anymore, and this was never used directly in common code, just passed to per-arch callbacks. --- sim/bpf/ChangeLog | 7 +++++++ sim/bpf/arch.c | 2 +- sim/bpf/sim-if.c | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'sim/bpf') diff --git a/sim/bpf/ChangeLog b/sim/bpf/ChangeLog index 2d847bb..959c63f 100644 --- a/sim/bpf/ChangeLog +++ b/sim/bpf/ChangeLog @@ -1,3 +1,10 @@ +2021-06-30 Mike Frysinger + + * arch.c (sim_machs): Rename to ... + (bpf_sim_machs): ... this. + * sim-if.c (bpf_sim_machs): New decl. + (sim_open): Set STATE_MACH. + 2021-06-29 Mike Frysinger * arch.c (sim_machs): Mark const. diff --git a/sim/bpf/arch.c b/sim/bpf/arch.c index 8ceaa34..c9f98c5 100644 --- a/sim/bpf/arch.c +++ b/sim/bpf/arch.c @@ -25,7 +25,7 @@ This file is part of the GNU simulators. #include "sim-main.h" #include "bfd.h" -const SIM_MACH * const sim_machs[] = +const SIM_MACH * const bpf_sim_machs[] = { #ifdef HAVE_CPU_BPFBF & bpf_mach, diff --git a/sim/bpf/sim-if.c b/sim/bpf/sim-if.c index 436cc86..150f5cd 100644 --- a/sim/bpf/sim-if.c +++ b/sim/bpf/sim-if.c @@ -111,6 +111,8 @@ bpf_free_state (SIM_DESC sd) sim_state_free (sd); } +extern const SIM_MACH * const bpf_sim_machs[]; + /* Create an instance of the simulator. */ SIM_DESC @@ -125,6 +127,9 @@ sim_open (SIM_OPEN_KIND kind, SIM_DESC sd = sim_state_alloc (kind, callback); + /* Set default options before parsing user options. */ + STATE_MACHS (sd) = bpf_sim_machs; + if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) goto error; -- cgit v1.1