public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: model: constify sim_machs storage
@ 2021-06-28 15:19 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2021-06-28 15:19 UTC (permalink / raw)
  To: gdb-patches

The array of pointers is never modified, so mark it const so it ends
up in the read-only data section.
---
 sim/bfin/machs.c       |  2 +-
 sim/bpf/arch.c         |  2 +-
 sim/common/sim-model.c | 10 +++++-----
 sim/common/sim-model.h |  2 +-
 sim/cris/arch.c        |  2 +-
 sim/frv/arch.c         |  2 +-
 sim/iq2000/arch.c      |  2 +-
 sim/lm32/arch.c        |  2 +-
 sim/m32r/arch.c        |  2 +-
 sim/or1k/arch.c        |  2 +-
 sim/riscv/machs.c      |  2 +-
 11 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/sim/bfin/machs.c b/sim/bfin/machs.c
index e94af5d0f5b8..ff49bb7c3bb0 100644
--- a/sim/bfin/machs.c
+++ b/sim/bfin/machs.c
@@ -1962,7 +1962,7 @@ static const SIM_MACH bfin_mach =
   bfin_prepare_run
 };
 
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
   & bfin_mach,
   NULL
diff --git a/sim/bpf/arch.c b/sim/bpf/arch.c
index cb3a206f1e8a..8ceaa34cef83 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 *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
 #ifdef HAVE_CPU_BPFBF
   & bpf_mach,
diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c
index e1af9d4b1e46..bfdb3c24bc8b 100644
--- a/sim/common/sim-model.c
+++ b/sim/common/sim-model.c
@@ -74,7 +74,7 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
 
     case OPTION_MODEL_INFO :
       {
-	const SIM_MACH **machp;
+	const SIM_MACH * const *machp;
 	const SIM_MODEL *model;
 	for (machp = & sim_machs[0]; *machp != NULL; ++machp)
 	  {
@@ -140,7 +140,7 @@ sim_model_set (SIM_DESC sd, sim_cpu *cpu, const SIM_MODEL *model)
 const SIM_MODEL *
 sim_model_lookup (const char *name)
 {
-  const SIM_MACH **machp;
+  const SIM_MACH * const *machp;
   const SIM_MODEL *model;
 
   for (machp = & sim_machs[0]; *machp != NULL; ++machp)
@@ -160,7 +160,7 @@ sim_model_lookup (const char *name)
 const SIM_MACH *
 sim_mach_lookup (const char *name)
 {
-  const SIM_MACH **machp;
+  const SIM_MACH * const *machp;
 
   for (machp = & sim_machs[0]; *machp != NULL; ++machp)
     {
@@ -176,7 +176,7 @@ sim_mach_lookup (const char *name)
 const SIM_MACH *
 sim_mach_lookup_bfd_name (const char *name)
 {
-  const SIM_MACH **machp;
+  const SIM_MACH * const *machp;
 
   for (machp = & sim_machs[0]; *machp != NULL; ++machp)
     {
@@ -251,7 +251,7 @@ sim_model_init (SIM_DESC sd)
 #if !WITH_MODEL_P
 /* Set up basic model support.  This is a stub for ports that do not define
    models.  See sim-model.h for more details.  */
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
   NULL
 };
diff --git a/sim/common/sim-model.h b/sim/common/sim-model.h
index 3a028d5f32f3..d6edf649d6e2 100644
--- a/sim/common/sim-model.h
+++ b/sim/common/sim-model.h
@@ -140,7 +140,7 @@ typedef struct model {
 /* ??? In a simulator of multiple architectures, will need multiple copies of
    this.  Have an `archs' array that contains a pointer to the machs array
    for each (which in turn has a pointer to the models array for each).  */
-extern const SIM_MACH *sim_machs[];
+extern const SIM_MACH * const sim_machs[];
 
 /* Model module handlers.  */
 extern MODULE_INSTALL_FN sim_model_install;
diff --git a/sim/cris/arch.c b/sim/cris/arch.c
index 1395cc7472d1..1635ef6a9557 100644
--- a/sim/cris/arch.c
+++ b/sim/cris/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
 #ifdef HAVE_CPU_CRISV10F
   & crisv10_mach,
diff --git a/sim/frv/arch.c b/sim/frv/arch.c
index 80b620fae605..f58ed1168162 100644
--- a/sim/frv/arch.c
+++ b/sim/frv/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
 #ifdef HAVE_CPU_FRVBF
   & frv_mach,
diff --git a/sim/iq2000/arch.c b/sim/iq2000/arch.c
index 30ce2f5ca6ce..22dc565b1bca 100644
--- a/sim/iq2000/arch.c
+++ b/sim/iq2000/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
 #ifdef HAVE_CPU_IQ2000BF
   & iq2000_mach,
diff --git a/sim/lm32/arch.c b/sim/lm32/arch.c
index e8a826adc70a..72fe4b43b87b 100644
--- a/sim/lm32/arch.c
+++ b/sim/lm32/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
 #ifdef HAVE_CPU_LM32BF
   & lm32_mach,
diff --git a/sim/m32r/arch.c b/sim/m32r/arch.c
index eb4bc06baefe..4b789759eb65 100644
--- a/sim/m32r/arch.c
+++ b/sim/m32r/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
 #ifdef HAVE_CPU_M32RBF
   & m32r_mach,
diff --git a/sim/or1k/arch.c b/sim/or1k/arch.c
index 97a7a3806a69..ef3c403c9435 100644
--- a/sim/or1k/arch.c
+++ b/sim/or1k/arch.c
@@ -25,7 +25,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
 #ifdef HAVE_CPU_OR1K32BF
   & or32_mach,
diff --git a/sim/riscv/machs.c b/sim/riscv/machs.c
index 9ff230336787..eb75a1dd2002 100644
--- a/sim/riscv/machs.c
+++ b/sim/riscv/machs.c
@@ -111,7 +111,7 @@ static const SIM_MACH rv128i_mach =
 #endif
 
 /* Order matters here.  */
-const SIM_MACH *sim_machs[] =
+const SIM_MACH * const sim_machs[] =
 {
 #if WITH_TARGET_WORD_BITSIZE >= 128
   &rv128i_mach,
-- 
2.31.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-28 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 15:19 [PATCH] sim: model: constify sim_machs storage Mike Frysinger

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).