Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: sim/ppc PAGE_SIZE redefinition
       [not found]   ` <PA4PR02MB66860C617F013F3B3CC8F07AEA0E9@PA4PR02MB6686.eurprd02.prod.outlook.com>
@ 2021-06-17 23:06     ` Mike Frysinger via Gdb-patches
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger via Gdb-patches @ 2021-06-17 23:06 UTC (permalink / raw)
  To: CHIGOT, CLEMENT; +Cc: Nick Clifton, gdb-patches, binutils

On 17 Jun 2021 12:00, CHIGOT, CLEMENT via Binutils wrote:
> > > I'm not able to build "sim/ppc" anymore on AIX.
> > 
> > The sim sources are part of gdb, not the binutils ...
> 
> Oh, I wasn't aware of that. 
> Note that it's still being built even when --disable-gdb is provided 
> to the configure.  
> 
> >> or is it safe to
> >> rename it PAGE_SIZE_1k or something like that ?
> >
> > It really depends upon how the simulator sources are going to use the constant.
> > But it would probably be best if the value used inside the simulator matched
> > the system value.  That way you are unlikely to run into host-vs-sim emulation
> > issues.  All of which is a fancy to way to say that the best solutions is
> > probably to patch semantics.h to only define PAGE_SIZE if it is not already
> > defined.
> 
> That's what I've done locally. But I don't know anything about sim. The tests 
> on AIX aren't even building. On linux/ppc64le, it seems ok though. I can 
> submit the patch, but I want to be sure that this is the correct way to fix that.

the PAGE_SIZE here has no relationship to the host system.  it's just used for
a single cpu hardware quirk.  so we can safely rename it to anything else.
-mike

From a49dd19e81deb6d6c4af0fcadd94be1574f0b7dc Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Thu, 17 Jun 2021 19:03:32 -0400
Subject: [PATCH] sim: ppc: avoid "PAGE_SIZE" name

This define is used for a particular target and depends on the
simulated CPU hardware.  It has no relation to the host CPU that
the sim is running on.  So rename the common "PAGE_SIZE" here to
better reflect its usage and avoid conflicts with system headers.
---
 sim/ppc/ChangeLog        | 5 +++++
 sim/ppc/igen.c           | 2 +-
 sim/ppc/ppc-instructions | 6 +++---
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog
index 05178aa427b5..280234af869e 100644
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+	* igen.c (gen_semantics_h): Rename PAGE_SIZE to MPC860C0_PAGE_SIZE.
+	* ppc-instructions: Likewise.
+
 2021-06-16  Mike Frysinger  <vapier@gentoo.org>
 
 	* configure.ac: Delete AC_EXEEXT call.
diff --git a/sim/ppc/igen.c b/sim/ppc/igen.c
index 0bf3b58ca26d..f0ff06b31c41 100644
--- a/sim/ppc/igen.c
+++ b/sim/ppc/igen.c
@@ -182,7 +182,7 @@ gen_semantics_h(insn_table *table,
   lf_printf(file, "\n");
   if ((code & generate_calls)) {
     lf_printf(file, "extern int option_mpc860c0;\n");
-    lf_printf(file, "#define PAGE_SIZE 0x1000\n");
+    lf_printf(file, "#define MPC860C0_PAGE_SIZE 0x1000\n");
     lf_printf(file, "\n");
     lf_printf(file, "PSIM_EXTERN_SEMANTICS(void)\n");
     lf_printf(file, "semantic_init(device* root);\n");
diff --git a/sim/ppc/ppc-instructions b/sim/ppc/ppc-instructions
index 70aa04e2210e..2278b6263765 100644
--- a/sim/ppc/ppc-instructions
+++ b/sim/ppc/ppc-instructions
@@ -1537,7 +1537,7 @@ void::function::invalid_zero_divide_operation:cpu *processor, unsigned_word cia,
 	  If this is a forward branch and it is near the end of a page,
 	  we've detected a problematic branch. */
 	  if (succeed && NIA > CIA) {
-	    if (PAGE_SIZE - (CIA & (PAGE_SIZE-1)) <= option_mpc860c0)
+	    if (MPC860C0_PAGE_SIZE - (CIA & (MPC860C0_PAGE_SIZE-1)) <= option_mpc860c0)
 	      program_interrupt(processor, cia, mpc860c0_instruction_program_interrupt);
 	  }
 	}
@@ -1579,7 +1579,7 @@ void::function::invalid_zero_divide_operation:cpu *processor, unsigned_word cia,
 	  If this is a forward branch and it is near the end of a page,
 	  we've detected a problematic branch. */
 	  if (succeed && NIA > CIA) {
-	    if (PAGE_SIZE - (CIA & (PAGE_SIZE-1)) <= option_mpc860c0)
+	    if (MPC860C0_PAGE_SIZE - (CIA & (MPC860C0_PAGE_SIZE-1)) <= option_mpc860c0)
 	      program_interrupt(processor, cia, mpc860c0_instruction_program_interrupt);
 	  }
 	}
@@ -1610,7 +1610,7 @@ void::function::invalid_zero_divide_operation:cpu *processor, unsigned_word cia,
 	  If this is a forward branch and it is near the end of a page,
 	  we've detected a problematic branch. */
 	  if (succeed && NIA > CIA) {
-	    if (PAGE_SIZE - (CIA & (PAGE_SIZE-1)) <= option_mpc860c0)
+	    if (MPC860C0_PAGE_SIZE - (CIA & (MPC860C0_PAGE_SIZE-1)) <= option_mpc860c0)
 	      program_interrupt(processor, cia, mpc860c0_instruction_program_interrupt);
 	  }
 	}
-- 
2.31.1

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

only message in thread, other threads:[~2021-06-17 23:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <PA4PR02MB66864BED0D7DE4F013788E87EA0E9@PA4PR02MB6686.eurprd02.prod.outlook.com>
     [not found] ` <f272a69f-5d20-4c87-3990-4dba81f0ad7a@redhat.com>
     [not found]   ` <PA4PR02MB66860C617F013F3B3CC8F07AEA0E9@PA4PR02MB6686.eurprd02.prod.outlook.com>
2021-06-17 23:06     ` sim/ppc PAGE_SIZE redefinition Mike Frysinger via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox