public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] sim: bfin: move option inits to respective modules
Date: Sun,  7 Feb 2021 23:08:33 -0500	[thread overview]
Message-ID: <20210208040833.7455-4-vapier@gentoo.org> (raw)
In-Reply-To: <20210208040833.7455-1-vapier@gentoo.org>

Now that modules can self declare their own init funcs, change the mmu
and mach logic to use it.  We don't need to export the option symbols
or specifically call this logic from the sim_open function anymore.
---
 sim/bfin/dv-bfin_mmu.c | 12 +++++++++++-
 sim/bfin/interp.c      | 11 -----------
 sim/bfin/machs.c       | 12 +++++++++++-
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/sim/bfin/dv-bfin_mmu.c b/sim/bfin/dv-bfin_mmu.c
index 5f28256fad61..cbaaaa2cae15 100644
--- a/sim/bfin/dv-bfin_mmu.c
+++ b/sim/bfin/dv-bfin_mmu.c
@@ -277,7 +277,7 @@ enum {
   OPTION_MMU_SKIP_TABLES = OPTION_START,
 };
 
-const OPTION bfin_mmu_options[] =
+static const OPTION bfin_mmu_options[] =
 {
   { {"mmu-skip-cplbs", no_argument, NULL, OPTION_MMU_SKIP_TABLES },
       '\0', NULL, "Skip parsing of CPLB tables (big speed increase)",
@@ -301,6 +301,16 @@ bfin_mmu_option_handler (SIM_DESC sd, sim_cpu *current_cpu, int opt,
       return SIM_RC_FAIL;
     }
 }
+
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern MODULE_INIT_FN sim_install_bfin_mmu;
+
+SIM_RC
+sim_install_bfin_mmu (SIM_DESC sd)
+{
+  SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
+  return sim_add_option_table (sd, NULL, bfin_mmu_options);
+}
 \f
 #define MMU_STATE(cpu) DV_STATE_CACHED (cpu, mmu)
 
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index ceb5939f4e6b..a77bcf708f45 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -739,17 +739,6 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
   if (STATE_ENVIRONMENT (sd) == ALL_ENVIRONMENT)
     STATE_ENVIRONMENT (sd) = VIRTUAL_ENVIRONMENT;
 
-  /* These options override any module options.
-     Obviously ambiguity should be avoided, however the caller may wish to
-     augment the meaning of an option.  */
-#define e_sim_add_option_table(sd, options) \
-  do { \
-    extern const OPTION options[]; \
-    sim_add_option_table (sd, NULL, options); \
-  } while (0)
-  e_sim_add_option_table (sd, bfin_mmu_options);
-  e_sim_add_option_table (sd, bfin_mach_options);
-
   /* The parser will print an error message for us, so we silently return.  */
   if (sim_parse_args (sd, argv) != SIM_RC_OK)
     {
diff --git a/sim/bfin/machs.c b/sim/bfin/machs.c
index 8b7b1060887b..a2060e8d8986 100644
--- a/sim/bfin/machs.c
+++ b/sim/bfin/machs.c
@@ -1976,7 +1976,7 @@ enum {
   OPTION_MACH_HW_BOARD_FILE,
 };
 
-const OPTION bfin_mach_options[] =
+static const OPTION bfin_mach_options[] =
 {
   { {"sirev", required_argument, NULL, OPTION_MACH_SIREV },
       '\0', "NUMBER", "Set CPU silicon revision",
@@ -2019,3 +2019,13 @@ bfin_mach_option_handler (SIM_DESC sd, sim_cpu *current_cpu, int opt,
       return SIM_RC_FAIL;
     }
 }
+
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern MODULE_INIT_FN sim_install_bfin_mach;
+
+SIM_RC
+sim_install_bfin_mach (SIM_DESC sd)
+{
+  SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
+  return sim_add_option_table (sd, NULL, bfin_mach_options);
+}
-- 
2.30.0


  parent reply	other threads:[~2021-02-08  4:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08  4:08 [PATCH 0/3] [RFC] sim: framework for self-declaring initializers Mike Frysinger
2021-02-08  4:08 ` [PATCH 1/3] sim: add framework for declaring init callbacks locally Mike Frysinger
2021-02-08  4:08 ` [PATCH 2/3] sim: dv-sockser: localize init callback Mike Frysinger
2021-02-08  4:08 ` Mike Frysinger [this message]
2021-02-08 19:45 ` [PATCH 0/3] [RFC] sim: framework for self-declaring initializers Tom Tromey
2021-04-24 17:09 ` [PATCH 1/4] sim: arm: move build logic to source files Mike Frysinger
2021-04-24 17:09   ` [PATCH 2/4] sim: add framework for declaring init callbacks locally Mike Frysinger
2021-04-24 17:09   ` [PATCH 3/4] sim: dv-sockser: localize init callback Mike Frysinger
2021-04-24 17:09   ` [PATCH 4/4] sim: bfin: move option inits to respective modules Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210208040833.7455-4-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).